Class PresentationAddress
- All Implemented Interfaces:
Comparable<PresentationAddress>
This is an immutable class.
This class works by holding an DSE.PSAPaddr
object, and providing a slightly more user-friendly set of methods which
access and manipulate fields inside that object.
The ASN for a PresentationAddress is:
PresentationAddress ::= SEQUENCE { pSelector [0] OCTET STRING OPTIONAL, sSelector [1] OCTET STRING OPTIONAL, tSelector [2] OCTET STRING OPTIONAL, nAddresses [3] SET SIZE (1..MAX) OF OCTET STRING
Examples:
"0aZ-."/'0aff'H/'00'H/TELEX+00728722+IP-APP+11+127.0.0.1
"0aZ-."//TELEX+00728722+RFC-1006+03+127.0.0.1|URI+0000+URL+itot://[FFEF::1]| TELEX+00728722+RFC-1006+03+localhost+19000/
- Since:
- 15.0
- Author:
- mv
-
Nested Class Summary
Nested 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
ConstructorsConstructorDescriptionPresentationAddress
(byte[] ber) Create a new presentation address object from a byte array containing the BER representation of the object.Create a new presentation address object from the given input.PresentationAddress
(PresentationAddress paToCopy, String hostName) Constructor to create an object which is a copy of the given object but replaces the host name with the given host name.PresentationAddress
(PresentationAddress paToCopy, String hostName, int portNo) Creates a copy of a PresentationAddress.PresentationAddress
(Selector presentationSelector, Selector sessionSelector, Selector transportSelector, NetworkAddress na) Create a new presentation address object from the given input.PresentationAddress
(Selector presentationSelector, Selector sessionSelector, Selector transportSelector, List<NetworkAddress> naList) Create a new presentation address object from the given input.PresentationAddress
(String paStr) Create a new presentation address object from a string representation.PresentationAddress
(List<NetworkAddress> naList) Create a new presentation address object from the given input. -
Method Summary
Modifier and TypeMethodDescriptionint
static PresentationAddress
createDefaultServerAddress
(String hostStr) The default server address for a given host name consists of an ITOT and an LDAP network address.static PresentationAddress
createDefaultServerAddress
(String hostStr, boolean withMesh) The default server address for a given host name consists of an ITOT and an LDAP network address.boolean
Performs equality testing using the syntax handler for the relevant attribute type.getAllAddresses
(boolean hostname, boolean ipv4, boolean ipv6, boolean removeLoopback) Returns the set of host names derived from the network address(es) of the presentation address.The selectors and network addresses are converted to their canonical forms.Returns string form to display.Return a String containing a short "user-friendly" version of the PresentationAddress.Returns a String containing the names of any hosts that are contained in this object.static int
Static function returning the maximum number of network addresses allowed in a presentation address.Returns the vector containing the network addresses.Returns the Presentation selector.static String
getSelectorDisplay
(Selector pSel, Selector sSel, Selector tSel) Returns the session selector.protected IsodeSyntax.SyntaxInfo
Subclasses must implement a method which returns a SyntaxInfo object that can be used by the IsodeSyntax class.Returns the transport selector.int
hashCode()
Returns a hashcode suitable for use by the Collection classesprotected void
parse
(byte[] berRepresentation) Set the object to contain a value based on the specified BER representation.void
reset()
Clear all fields in the object.Methods inherited from class com.isode.dsapi.syntax.IsodeSyntax
getAsnVal, getAttributeValue, getAttributeValue, getStringRepresentation, isNumeric, isValid, isValidStringValue, set, toString
-
Constructor Details
-
PresentationAddress
public PresentationAddress(Selector presentationSelector, Selector sessionSelector, Selector transportSelector, List<NetworkAddress> naList) throws BadValueException, BadSyntaxException Create a new presentation address object from the given input.- Parameters:
presentationSelector
- Presentation selector.sessionSelector
- Session selector.transportSelector
- Transport selector.naList
- List containing network addresses.- Throws:
BadValueException
- if any of the input is not a valid or the resulting presentation address is not valid.BadSyntaxException
- if it is not possible to parse the presentation address.
-
PresentationAddress
public PresentationAddress(Selector presentationSelector, Selector sessionSelector, Selector transportSelector, NetworkAddress na) throws BadValueException, BadSyntaxException Create a new presentation address object from the given input. This can be used when there is a single network address in the presentation address.- Parameters:
presentationSelector
- Presentation selector.sessionSelector
- Session selector.transportSelector
- Transport selector.na
- A single network address.- Throws:
BadValueException
- if any of the input is not a valid or the resulting presentation address is not valid.BadSyntaxException
- if it is not possible to parse the presentation address.
-
PresentationAddress
public PresentationAddress(List<NetworkAddress> naList) throws BadValueException, BadSyntaxException Create a new presentation address object from the given input. This can be used when there is no selector in the presentation address.- Parameters:
naList
- List containing network addresses.- Throws:
BadValueException
- if the input is not a valid or the resulting presentation address is not valid.BadSyntaxException
- if it is not possible to parse the presentation address.
-
PresentationAddress
Create a new presentation address object from the given input. This can be used when there is a single network address and no selectors in the presentation address.- Parameters:
na
- A single network address.- Throws:
BadValueException
- if the input is not a valid or the resulting presentation address is not valid.BadSyntaxException
- if it is not possible to parse the presentation address.
-
PresentationAddress
Create a new presentation address object from a string representation.- Parameters:
paStr
- String representation. Must not be null.- Throws:
BadValueException
- if the input is not a valid.BadSyntaxException
- if it is not possible to parse the presentation address.
-
PresentationAddress
public PresentationAddress(PresentationAddress paToCopy, String hostName) throws BadSyntaxException, BadValueException Constructor to create an object which is a copy of the given object but replaces the host name with the given host name. If the object to copy does not contain a host name, the constructed object contains the same information as the object to copy.- Parameters:
paToCopy
- object to copy, must not be nullhostName
- Host name, must not be null- Throws:
BadValueException
- if any of the input is not a valid or the resulting presentation address is not valid.BadSyntaxException
- if it is not possible to parse the presentation address.
-
PresentationAddress
public PresentationAddress(PresentationAddress paToCopy, String hostName, int portNo) throws BadValueException, BadSyntaxException Creates a copy of a PresentationAddress. But with the host names and port no replaced by the given value.- Parameters:
paToCopy
- The Presentation Address to copy. This can not benull
.hostName
- The new value for host name. This can not benull
.portNo
- The new port no.- Throws:
BadValueException
- If any of the input is invalidBadSyntaxException
- If it was not possible to parse the PresentationAddress- Since:
- 16.0
-
PresentationAddress
Create a new presentation address object from a byte array containing the BER representation of the object.- Parameters:
ber
- BER representation of value. Must not be null.- Throws:
BadValueException
- if ber doesn't hold a valid value for this attribute typeBadSyntaxException
- if it is not possible to parse the presentation address.
-
-
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<DSE.PSAPaddr>
- Returns:
- a SyntaxInfo describing the syntax represented by the subclass.
- Throws:
BadSyntaxException
- if no SyntaxInfo is available for this syntax.
-
parse
Description copied from class:IsodeSyntax
Set the object to contain a value based on the specified BER representation. If the BER is not valid, and exception will be thrown and the object will retain its previous value.Subclasses must implement a suitable syntax-specific method, which will contain code like this:
protected void parse(byte[] berRepresentation) throws BadValueException { com.isode.asn.modules.MHSR.GlobalDomainIdentifie savedVal = asnVal; try { asnVal = ASNConv.decode( berRepresentation, com.isode.asn.modules.MHSR.GlobalDomainIdentifier.class); } catch (BadValueException e) { asnVal = savedVal; throw e; } }
(Replace the second parameter to the decode() method with a reference to the appropriate class).- Specified by:
parse
in classIsodeSyntax<DSE.PSAPaddr>
- Parameters:
berRepresentation
- putative value in BER- Throws:
BadValueException
-
reset
public void reset()Description copied from class:IsodeSyntax
Clear all fields in the object. Following this operation, the object may not be a valid value, so may need to have fields set in it to become one.Subclasses should implement a method which clears all the asn fields, e.g.
asnVal = new MHSR.GlobalDomainIdentifier(); asnVal.setAdministration_domain_name(new AdministrationDomainName()); asnVal.setCountry_name(new CountryName());
Note that this method is called by theIsodeSyntax()
constructor.- Specified by:
reset
in classIsodeSyntax<DSE.PSAPaddr>
-
getMaxAddresses
public static int getMaxAddresses()Static function returning the maximum number of network addresses allowed in a presentation address.- Returns:
- Maximum number of network addresses in a presentation address.
-
getNetworkAddresses
Returns the vector containing the network addresses.- Returns:
- List containing the network addresses.
-
getTransportSelector
Returns the transport selector.- Returns:
- Transport selector; NULL if absent.
-
getSessionSelector
Returns the session selector.- Returns:
- Session selector; NULL if absent.
-
getPresentationSelector
Returns the Presentation selector.- Returns:
- presentation selector; NULL if absent.
-
getSelectorDisplay
- Parameters:
pSel
- Presentation selector, can be nullsSel
- Session selector, can be nulltSel
- Transport selector, can be null- Returns:
- String form of selectors to display.
-
getSelectorDisplay
- Returns:
- String form of selectors to display.
-
getDisplayString
Returns string form to display.- Returns:
- String form to display.
-
getHostnames
Returns a String containing the names of any hosts that are contained in this object. Any hostname will only appear once in the returned String, regardless of how many separate network addresses refer to it. Multiple hostnames will be separated by a vertical bar ("|"), and will be ordered alphabeticallySo, for example
-
"psel"//"tsel"/URI+0000+URL+itot://william.isode.net:19999
-->"william.isode.net"
-
URI+0000+URL+itot://william:19999|URI+0000+URL+itot://funky:1999|URI+0000+URL+itot://william:1999
-->"funky|william"
- Returns:
- a String containing all the distinct hostnames that are contained in this object.
-
-
getFriendlyString
Return a String containing a short "user-friendly" version of the PresentationAddress. The intention is that this String be used in situations where we want to enough information that's likely to allow the user to identify the address without having to overload the user with a full-blown String representation.The current implementation simply calls
getHostnames()
. A future implementation may do something more elaborate.- Returns:
- a String representation of the PresentationAddress which contains enough information to be useful in most cases. If it's not possible to make a short name, then this method returns the empty String "".
-
getCanonicalForm
The selectors and network addresses are converted to their canonical forms. The network address list is sorted and duplicates are removed.- Returns:
- canonical form of object.
- Throws:
BadSyntaxException
- if it is not possible to parse the presentation address.
-
equals
Description copied from class:IsodeSyntax
Performs equality testing using the syntax handler for the relevant attribute type.Note that this method uses JNI to constructs AttributeValues and then call the syntax handler's comparison function, so it may not be ideal for use in resource-constrained situations (e.g. calling it loads of times in a loop)
- Overrides:
equals
in classIsodeSyntax<DSE.PSAPaddr>
- Parameters:
other
- another object of the same attribute type- Returns:
- true if other is the same object, or one which has a valid value that matches this object's value so far as the syntax handler is concerned. A value of false means that object contains a different value, or that it is not possible to compare the values because no suitable syntax handler is available.
-
hashCode
public int hashCode()Description copied from class:IsodeSyntax
Returns a hashcode suitable for use by the Collection classes- Overrides:
hashCode
in classIsodeSyntax<DSE.PSAPaddr>
- Returns:
- a hash code value for this object.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<PresentationAddress>
-
getAllAddresses
public Set<String> getAllAddresses(boolean hostname, boolean ipv4, boolean ipv6, boolean removeLoopback) Returns the set of host names derived from the network address(es) of the presentation address. Also resolves the host names to IPv4 and IPv6 addresses and adds to returned set.Any item will only appear once in the returned set, regardless of how many separate network addresses refer to it or how many host names resolve to it.
If no items are available as per request, the method returns an empty set.
- Parameters:
hostname
- TRUE if non-IPv4 and non-IPv6 host names need to be included in the setipv4
- TRUE if IPv4 addresses need to be included in the setipv6
- TRUE if IPv6 addresses need to be included in the setremoveLoopback
- TRUE if loopback addresses need to be removed- Returns:
- set containing requested items
-
createDefaultServerAddress
public static PresentationAddress createDefaultServerAddress(String hostStr) throws BadValueException, BadSyntaxException The default server address for a given host name consists of an ITOT and an LDAP network address. This method creates such a presentation address.- Parameters:
hostStr
- Host name, must not be null- Throws:
BadValueException
- if the host name is invalid or emptyBadSyntaxException
- if it is not possible to parse the presentation address.
-
createDefaultServerAddress
public static PresentationAddress createDefaultServerAddress(String hostStr, boolean withMesh) throws BadValueException, BadSyntaxException The default server address for a given host name consists of an ITOT and an LDAP network address. This method creates such a presentation address.- Parameters:
hostStr
- Host name, must not be nullwithMesh
- Whether address should contain a multimaster address.- Returns:
- Presentation address representing the default server address
- Throws:
BadValueException
- if the host name is invalid or emptyBadSyntaxException
- if it is not possible to parse the presentation address.
-