Class MTAInfo


public class MTAInfo extends IsodeSyntax<MHSR.MTAInfo>
Class representation of an MTAInfo value. Users may create values from Strings, BER, or AttributeValue objects.

This class works by holding an MHSR.MTAInfo object, and providing a slightly more user-friendly set of methods which access and manipulate fields inside that object. See RFC 1801 for description of MTAInfo, which says it looks like this:

 MTAInfo ::= SEQUENCE {
              name DistinguishedName,
              weight [1] RouteWeight DEFAULT preferred-access,
              mta-attributes [2] SET OF Attribute OPTIONAL,
              ae-info  SEQUENCE OF SEQUENCE {
                  aEQualifier PrintableString,
                  ae-weight RouteWeight DEFAULT preferred-access,
                  ae-attributes SET OF Attribute OPTIONAL} OPTIONAL
  }
 
This class (along with its inner class MTAInfo.AEInfo) supports access (via set and get methods) to all of the above fields.

Note that the Isode syntax handler, syn_mtai.c, does not handle mta-attributes nor ae-attributes ("values are neither parsed nor printed"). This means that while you can set/get the values using this class, they will not appear in any String representation of an AttributeValue, and will be ignored if an attempt is made to parse a String representation that does contain them.

Author:
nh
  • Constructor Details

    • MTAInfo

      public MTAInfo(MHSR.MTAInfo val)
      Create a new MTAInfo object from an existing ASN representation.
      Parameters:
      val - an ASN value, which must not be null. The contents of this object will be copied.
      Since:
      14.4
    • MTAInfo

      public MTAInfo(String str) throws BadValueException, BadSyntaxException
      Create a new MTAInfo object from a string representation.

      Note that the Isode syntax handler (syn_mtai.c) currently ignores the mta-attributes and ae-attributes fields ("values are neither parsed nor printed"), which means that any values for these field in the input string will be lost.

      Parameters:
      str - String representation. Must not be null.
      Throws:
      BadValueException - if str is not a valid MTAInfo
      BadSyntaxException - it is not possible to parse MTAInfo values
    • MTAInfo

      Create a new MTAInfo object from a suitable AttributeValue.
      Parameters:
      av - AttributeValue. Must not be null.
      Throws:
      BadValueException - if av is not a valid MTAInfo
      BadSyntaxException - it is not possible to parse MTAInfo values
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • MTAInfo

      public MTAInfo(byte[] ber) throws BadValueException
      Construct a new object based on a byte array containing the BER representation of an MTAInfo.
      Parameters:
      ber - BER representation of an MTAInfo value
      Throws:
      BadValueException - if ber doesn't hold a valid MTAInfo value
      Since:
      14.4
    • MTAInfo

      public MTAInfo(DN dn, int weight, String aeQualifier, int aeWeight) throws BadValueException, NativeLibraryException
      Construct a new object based on a set of fields.
      Parameters:
      dn - MTA's distinguished name (must not be null).
      weight - routing weight of the MTA
      aeQualifier - the ae-qualifier for the first ae-info of the MTA. A null value means that no ae-info is present, in which case aeWeight will be ignored.
      aeWeight - the ae-weight of the first ae-info of this MTA. Ignored if aeQualifier is null.
      Throws:
      BadValueException - if the supplied values cannot be converted into an MTAInfo
      NullPointerException - if dn is null.
      NativeLibraryException
  • Method Details

    • getSyntaxInfo

      protected IsodeSyntax.SyntaxInfo getSyntaxInfo() throws BadSyntaxException
      Description copied from class: IsodeSyntax
      Subclasses must implement a method which returns a SyntaxInfo object that can be used by the IsodeSyntax class.
      Specified by:
      getSyntaxInfo in class IsodeSyntax<MHSR.MTAInfo>
      Returns:
      a SyntaxInfo describing the syntax represented by the subclass.
      Throws:
      BadSyntaxException - if no SyntaxInfo is available for this syntax.
    • parse

      protected void parse(byte[] berRepresentation) throws BadValueException
      Parse the specified byte array into asn representation
      Specified by:
      parse in class IsodeSyntax<MHSR.MTAInfo>
      Parameters:
      berRepresentation - putative value in BER
      Throws:
      BadValueException
    • set

      public void set(String str) throws BadValueException, BadSyntaxException
      Set value from string.

      If an error is detected with the specified value, an exception will be thrown, and the object retains its original value.

      Note that the Isode syntax handler (syn_mtai.c) currently ignores the mta-attributes and ae-attributes fields ("values are neither parsed nor printed"), which means that any values for these field in the input string will be lost.

      Overrides:
      set in class IsodeSyntax<MHSR.MTAInfo>
      Parameters:
      str - String representation. Must not be null.
      Throws:
      BadValueException - if str is not a valid MTAInfo.
      BadSyntaxException - if there is no library routine available to parse str
    • getMhsrMTAInfo

      public MHSR.MTAInfo getMhsrMTAInfo()
      Return a reference to the underlying asn representation of this object
      Returns:
      the MHSR.MTAInfo object.
      Since:
      14.4
    • toString

      public String toString()
      Determine the string representation of this object. This will be either the syntax handler's representation, or if that cannot be obtained, the ASN object's string representation.

      This may not the same as the String used to initialize the object.

      Due to limitations in the syntax handler, values for mta-attributes and ae-attributes will not appear in the returned String.

      Overrides:
      toString in class IsodeSyntax<MHSR.MTAInfo>
      Returns:
      String representation of value.
      See Also:
    • getDN

      public DN getDN()
      Determine the distinguished name of the MTA represented by this object.
      Returns:
      a DN containing the MTA's name. This will be the root DN if the object contains no DN.
    • getWeight

      public int getWeight()
      Determine the routing weight of the MTA represented by this object.
      Returns:
      an integer representing the routing weight. Lower values are "better".
    • getAEInfo

      public MTAInfo.AEInfo getAEInfo(int index)
      Return a copy of a specific AEInfo
      Parameters:
      index - which AEInfo to get
      Returns:
      the AEInfo value. Note this is a copy of the value that can be used to gain read access to the contained fields; any changes made to it will not be reflected in the MTAInfo object.
      Throws:
      IndexOutOfBoundsException - if index is out of range.
      Since:
      14.4
      See Also:
    • getAEInfoCount

      public int getAEInfoCount()
      Return a count of AEInfo structures in this object
      Returns:
      how many AEInfo structures there are.
      Since:
      14.4
    • addAEInfo

      public void addAEInfo(MTAInfo.AEInfo ae)
      Add an ae-info to the MTAInfo. The new value will be placed at the end of the list.
      Parameters:
      ae - the AEInfo to add
      Since:
      14.4
    • removeAEInfo

      public boolean removeAEInfo(int index)
      Remove a specific ae-info from the MTAInfo. Other ae-infos will be "shuffled back" to fill the gap - i.e. the sequence numbers will change.

      To empty the list altogether, call this method repeatedly using an index of 0 until it returns false.

      Parameters:
      index - the ae-info to remove. If this is out of range, no change will be made.
      Returns:
      true if the value was removed, false otherwise (e.g. if index was out of range).
      Since:
      14.4
    • setDN

      public void setDN(DN newDN) throws BadValueException
      Set the DN component of an MTAInfo. Other fields remain unchanged.

      If an error is detected with the specified value, an exception will be thrown, and the object retains its original value.

      Parameters:
      newDN - the new DN to be used (must not be null).
      Throws:
      BadValueException - if dn could not be used to generate a valid MTAInfo
      NullPointerException - if newDN is null.
    • setWeight

      public void setWeight(int newWeight)
      Set the weight component of an MTAInfo. Other fields remain unchanged.
      Parameters:
      newWeight - the new weight to be used.
    • getMtaAttributes

      public Set<Attribute> getMtaAttributes()
      Return a set containing the values of the mta attributes.

      Note that the Isode syntax handler (syn_mtai.c) currently ignores this field ("values are neither parsed nor printed"), which means that values generated via the syntax handler will always report no values.

      Returns:
      a set of Attributes. If no mta-attributes are present, this will be an empty set.
      Since:
      14.4
    • setMtaAttributes

      public void setMtaAttributes(Set<Attribute> atts)
      Set the values for mta attributes.

      Note that the Isode syntax handler (syn_mtai.c) currently ignores this field ("values are neither parsed nor printed"), which means that values generated via the syntax handler will always report no values.

      Parameters:
      atts - a set of Attributes. Use null to indicate that no attributes should be used.
      Since:
      14.4
    • reset

      public void reset()
      Clear all fields in the object. The object may not be a valid MTAInfo, but may become one if fields inside it are set appropriately.
      Specified by:
      reset in class IsodeSyntax<MHSR.MTAInfo>
      Since:
      14.6