Package com.isode.dsapi.syntax
Class NetworkAddress
java.lang.Object
com.isode.dsapi.syntax.NetworkAddress
- All Implemented Interfaces:
Comparable<NetworkAddress>
This class stores information about a network address in the following
formats: TELEX, URI and OTHER. The following address types are supported:
ITOT, ITOTS, LDAP, LDAPS, IDM (in the future) and OTHER.
This is an immutable class.
Examples:
TELEX+00728722+IP-APP+11+127.0.0.1
TELEX+00728722+RFC-1006+03+localhost+19000
URI+0000+URL+itot://localhost:19000
URI+0000+URL+itots://localhost:19000
URI+0001+URL+ldaps://mv@127.0.0.1/
Future enhancements:
- Support IDM addresses.
- Since:
- 15.0
- Author:
- mv
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enumeration defining the different address formats that can be used to create a network address.static enum
An enumeration defining the different address types that can be used to create a network address. -
Constructor Summary
ConstructorsConstructorDescriptionNetworkAddress
(NetworkAddress.Type type, TelexData telexData) Constructor to create an object with the given data.NetworkAddress
(NetworkAddress.Type type, URIData uriData) Constructor to create an object with the given data.NetworkAddress
(NetworkAddress.Type type, String otherStr) Constructor to create an object with the given data.NetworkAddress
(NetworkAddress naToCopy, 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.NetworkAddress
(NetworkAddress naToCopy, String hostName, int portNo) Creates a copy of a NetworkAddress, but with the hostName and portNo replaced with given values.NetworkAddress
(String str) Constructor to create an object with the given data. -
Method Summary
Modifier and TypeMethodDescriptionint
static String
If the network address is stored using the "Internet=" MACRO but with the hostname (as in the old bind profile), then the presentation address syntax handler would convert the hostname into an IP address.static NetworkAddress
createNetworkAddress
(NetworkAddress.Type type, String hostStr, int port) The network address for a given host name and port is returned.boolean
The telex DATA and URI data are converted to their canonical forms.Returns string form to display.Returns the format of the network address.getHost()
Returns the host name of the network address if the network address is not in the OTHER format.Returns the OTHER data of the network address.int
getPort()
Returns the port of the network address if the network address is not in the OTHER format.Returns the TELEX data of the network address.getType()
Returns the type of the network address.Returns the URI data of the network address.int
hashCode()
toString()
-
Constructor Details
-
NetworkAddress
Constructor to create an object with the given data.- Parameters:
str
- String representation of the network address.- Throws:
BadValueException
- if the input is invalid.
-
NetworkAddress
Constructor to create an object with the given data.- Parameters:
type
- Type of the network address.telexData
- TELEX data format of the network address.- Throws:
BadValueException
- if the input is invalid. Note that ITOTS does not support TelextData.
-
NetworkAddress
Constructor to create an object with the given data.- Parameters:
type
- Type of the network address.uriData
- URI data format of the network address.- Throws:
BadValueException
- if the input is invalid.
-
NetworkAddress
Constructor to create an object with the given data.- Parameters:
type
- Type of the network address.otherStr
- OTHER format of the network address.- Throws:
BadValueException
- if the input is invalid.
-
NetworkAddress
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:
naToCopy
- object to copy, must not be nullhostName
- Host name, must not be null- Throws:
BadValueException
- if any of the input is invalid.
-
NetworkAddress
public NetworkAddress(NetworkAddress naToCopy, String hostName, int portNo) throws BadValueException Creates a copy of a NetworkAddress, but with the hostName and portNo replaced with given values.- Parameters:
naToCopy
- The NetworkAddress to copy. This can not benull
.hostName
- The new value for hostName. This can not benull
.portNo
- The new value for port no.- Throws:
BadValueException
- Thrown if any of the input is invalid.- Since:
- 16.0
-
-
Method Details
-
toString
-
getType
Returns the type of the network address.- Returns:
- Type of the network address.
-
getFormat
Returns the format of the network address.- Returns:
- Format of the network address.
-
getTelexData
Returns the TELEX data of the network address.- Returns:
- TELEX data of the network address; NULL if the network address is not in the TELEX format.
-
getURIData
Returns the URI data of the network address.- Returns:
- URI data of the network address; NULL if the network address is not in the URI format.
-
getHost
Returns the host name of the network address if the network address is not in the OTHER format.- Returns:
- Host name of the network address; NULL if the network address is in the OTHER format.
-
getPort
public int getPort()Returns the port of the network address if the network address is not in the OTHER format.- Returns:
- Port of the network address; -1 if the network address is in the OTHER format.
-
getOtherStr
Returns the OTHER data of the network address.- Returns:
- OTHER data of the network address; NULL if the network address is not in the OTHER format.
-
convertInternetToItot
If the network address is stored using the "Internet=" MACRO but with the hostname (as in the old bind profile), then the presentation address syntax handler would convert the hostname into an IP address. If the caller wants to avoid that, they may convert the network address into an ITOT format that preserves the hostname. This function does just that.- Parameters:
str
- String representation of a network address.- Returns:
- ITOT form of the network address if the given address is in the "Internet=" form and the host name is not IPv4; the given string is returned as it is in all other circumstances.
-
getDisplayString
Returns string form to display.- Returns:
- String form to display.
-
getCanonicalForm
The telex DATA and URI data are converted to their canonical forms. Other string is converted to lower case.- Returns:
- canonical form of object.
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<NetworkAddress>
-
createNetworkAddress
public static NetworkAddress createNetworkAddress(NetworkAddress.Type type, String hostStr, int port) throws BadValueException The network address for a given host name and port is returned. If the host is in IPv4 format, the network address is in telex format, otherwise in URI format - except forNetworkAddress.Type.ITOTS
which is always in URI format.- Parameters:
type
- any type exceptNetworkAddress.Type.OTHER
hostStr
- Host nameport
- port- Returns:
- created network address, will never be null
- Throws:
BadValueException
- if the input is invalid
-