Class MTAInfo
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents the AEInfo structure inside an MTAInfoNested classes/interfaces inherited from class com.isode.dsapi.syntax.IsodeSyntax
IsodeSyntax.SyntaxInfo
-
Field Summary
Fields inherited from class com.isode.dsapi.syntax.IsodeSyntax
asnVal, logger
-
Constructor Summary
ConstructorsConstructorDescriptionMTAInfo
(byte[] ber) Construct a new object based on a byte array containing the BER representation of an MTAInfo.MTAInfo
(MHSR.MTAInfo val) Create a new MTAInfo object from an existing ASN representation.Create a new MTAInfo object from a suitable AttributeValue.Construct a new object based on a set of fields.Create a new MTAInfo object from a string representation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an ae-info to the MTAInfo.getAEInfo
(int index) Return a copy of a specific AEInfoint
Return a count of AEInfo structures in this objectgetDN()
Determine the distinguished name of the MTA represented by this object.Return a reference to the underlying asn representation of this objectReturn a set containing the values of the mta attributes.protected IsodeSyntax.SyntaxInfo
Subclasses must implement a method which returns a SyntaxInfo object that can be used by the IsodeSyntax class.int
Determine the routing weight of the MTA represented by this object.protected void
parse
(byte[] berRepresentation) Parse the specified byte array into asn representationboolean
removeAEInfo
(int index) Remove a specific ae-info from the MTAInfo.void
reset()
Clear all fields in the object.void
Set value from string.void
Set the DN component of an MTAInfo.void
setMtaAttributes
(Set<Attribute> atts) Set the values for mta attributes.void
setWeight
(int newWeight) Set the weight component of an MTAInfo.toString()
Determine the string representation of this object.Methods inherited from class com.isode.dsapi.syntax.IsodeSyntax
equals, getAsnVal, getAttributeValue, getAttributeValue, getStringRepresentation, hashCode, isNumeric, isValid, isValidStringValue
-
Constructor Details
-
MTAInfo
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
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 MTAInfoBadSyntaxException
- 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 MTAInfoBadSyntaxException
- it is not possible to parse MTAInfo valuesNativeLibraryException
- if an unrecoverable error was detected by the native library
-
MTAInfo
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 MTAaeQualifier
- 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 MTAInfoNullPointerException
- if dn is null.NativeLibraryException
-
-
Method Details
-
getSyntaxInfo
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 classIsodeSyntax<MHSR.MTAInfo>
- Returns:
- a SyntaxInfo describing the syntax represented by the subclass.
- Throws:
BadSyntaxException
- if no SyntaxInfo is available for this syntax.
-
parse
Parse the specified byte array into asn representation- Specified by:
parse
in classIsodeSyntax<MHSR.MTAInfo>
- Parameters:
berRepresentation
- putative value in BER- Throws:
BadValueException
-
set
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 classIsodeSyntax<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
Return a reference to the underlying asn representation of this object- Returns:
- the MHSR.MTAInfo object.
- Since:
- 14.4
-
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 classIsodeSyntax<MHSR.MTAInfo>
- Returns:
- String representation of value.
- See Also:
-
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
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
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
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 MTAInfoNullPointerException
- 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
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
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 classIsodeSyntax<MHSR.MTAInfo>
- Since:
- 14.6
-