Package com.unboundid.util
Class OID
- java.lang.Object
-
- com.unboundid.util.OID
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<OID>
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class OID extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<OID>
This class provides a data structure that may be used for representing object identifiers. Since some directory servers support using strings that aren't valid object identifiers where OIDs are required, this implementation supports arbitrary strings, but some methods may only be available for valid OIDs.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description OID(int... components)
Creates a new OID object from the provided set of numeric components.OID(java.lang.String oidString)
Creates a new OID object from the provided string representation.OID(java.util.List<java.lang.Integer> components)
Creates a new OID object from the provided set of numeric components.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(OID oid)
Indicates the position of the provided object relative to this OID in a sorted list.boolean
equals(java.lang.Object o)
Indicates whether the provided object is equal to this OID.java.util.List<java.lang.Integer>
getComponents()
Retrieves the numeric components that comprise this OID.int
hashCode()
Retrieves a hash code for this OID.boolean
isStrictlyValidNumericOID()
Indicates whether this object represents a strictly valid numeric OID.static boolean
isStrictlyValidNumericOID(java.lang.String s)
Indicates whether this object represents a strictly valid numeric OID.boolean
isValidNumericOID()
Indicates whether the provided string represents a valid numeric OID.static boolean
isValidNumericOID(java.lang.String s)
Indicates whether the provided string represents a valid numeric OID.static java.util.List<java.lang.Integer>
parseComponents(java.lang.String oidString)
Parses the provided string as a numeric OID and extracts the numeric components from it.java.lang.String
toString()
Retrieves a string representation of this OID.
-
-
-
Constructor Detail
-
OID
public OID(java.lang.String oidString)
Creates a new OID object from the provided string representation.- Parameters:
oidString
- The string to use to create this OID.
-
OID
public OID(int... components)
Creates a new OID object from the provided set of numeric components. At least one component must be provided for a valid OID.- Parameters:
components
- The numeric components to include in the OID.
-
OID
public OID(java.util.List<java.lang.Integer> components)
Creates a new OID object from the provided set of numeric components. At least one component must be provided for a valid OID.- Parameters:
components
- The numeric components to include in the OID.
-
-
Method Detail
-
parseComponents
public static java.util.List<java.lang.Integer> parseComponents(java.lang.String oidString)
Parses the provided string as a numeric OID and extracts the numeric components from it.- Parameters:
oidString
- The string to parse as a numeric OID.- Returns:
- The numeric components extracted from the provided string, or
null
if the provided string does not represent a valid numeric OID.
-
isValidNumericOID
public static boolean isValidNumericOID(java.lang.String s)
Indicates whether the provided string represents a valid numeric OID. Note this this method only ensures that the value is made up of a dotted list of numbers that does not start or end with a period and does not contain two consecutive periods. TheisStrictlyValidNumericOID(String)
method performs additional validation, including ensuring that the OID contains at least two components, that the value of the first component is not greater than two, and that the value of the second component is not greater than 39 if the value of the first component is zero or one.- Parameters:
s
- The string for which to make the determination.- Returns:
true
if the provided string represents a valid numeric OID, orfalse
if not.
-
isValidNumericOID
public boolean isValidNumericOID()
Indicates whether the provided string represents a valid numeric OID. Note this this method only ensures that the value is made up of a dotted list of numbers that does not start or end with a period and does not contain two consecutive periods. TheisStrictlyValidNumericOID()
method performs additional validation, including ensuring that the OID contains at least two components, that the value of the first component is not greater than two, and that the value of the second component is not greater than 39 if the value of the first component is zero or one.- Returns:
true
if this object represents a valid numeric OID, orfalse
if not.
-
isStrictlyValidNumericOID
public static boolean isStrictlyValidNumericOID(java.lang.String s)
Indicates whether this object represents a strictly valid numeric OID. In addition to ensuring that the value is made up of a dotted list of numbers that does not start or end with a period or contain two consecutive periods, this method also ensures that the OID contains at least two components, that the value of the first component is not greater than two, and that the value of the second component is not greater than 39 if the value of the first component is zero or one.- Parameters:
s
- The string for which to make the determination.- Returns:
true
if this object represents a strictly valid numeric OID, orfalse
if not.
-
isStrictlyValidNumericOID
public boolean isStrictlyValidNumericOID()
Indicates whether this object represents a strictly valid numeric OID. In addition to ensuring that the value is made up of a dotted list of numbers that does not start or end with a period or contain two consecutive periods, this method also ensures that the OID contains at least two components, that the value of the first component is not greater than two, and that the value of the second component is not greater than 39 if the value of the first component is zero or one.- Returns:
true
if this object represents a strictly valid numeric OID, orfalse
if not.
-
getComponents
public java.util.List<java.lang.Integer> getComponents()
Retrieves the numeric components that comprise this OID. This will only return a non-null
value ifisValidNumericOID(java.lang.String)
returnstrue
.- Returns:
- The numeric components that comprise this OID, or
null
if this object does not represent a valid numeric OID.
-
hashCode
public int hashCode()
Retrieves a hash code for this OID.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hash code for this OID.
-
equals
public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this OID.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- The object for which to make the determination.- Returns:
true
if the provided object is equal to this OID, orfalse
if not.
-
compareTo
public int compareTo(OID oid)
Indicates the position of the provided object relative to this OID in a sorted list.- Specified by:
compareTo
in interfacejava.lang.Comparable<OID>
- Parameters:
oid
- The OID to compare against this OID.- Returns:
- A negative value if this OID should come before the provided OID in a sorted list, a positive value if this OID should come after the provided OID in a sorted list, or zero if the two OIDs represent equivalent values.
-
toString
public java.lang.String toString()
Retrieves a string representation of this OID.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this OID.
-
-