@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class OID extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<OID>
Constructor and Description |
---|
OID(int... components)
Creates a new OID object from the provided set of numeric components.
|
OID(java.util.List<java.lang.Integer> components)
Creates a new OID object from the provided set of numeric components.
|
OID(OID parentOID,
int childComponent)
Creates a new OID that is a child of the provided parent OID.
|
OID(java.lang.String oidString)
Creates a new OID object from the provided string representation.
|
Modifier and Type | Method and 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.
|
OID |
getParent()
Retrieves the OID that is the parent for this OID.
|
int |
hashCode()
Retrieves a hash code for this OID.
|
boolean |
isAncestorOf(OID oid)
Indicates whether this OID is an ancestor of the provided OID.
|
boolean |
isDescendantOf(OID oid)
Indicates whether this OID is a descendant of the provided 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.
|
static OID |
parseNumericOID(java.lang.String oidString,
boolean strict)
Parses the provided string as a numeric OID, optionally using additional
strict validation.
|
java.lang.String |
toString()
Retrieves a string representation of this OID.
|
public OID(@Nullable java.lang.String oidString)
oidString
- The string to use to create this OID.public OID(@Nullable int... components)
components
- The numeric components to include in the OID.public OID(@Nullable java.util.List<java.lang.Integer> components)
components
- The numeric components to include in the OID.public OID(@NotNull OID parentOID, int childComponent) throws java.text.ParseException
parentOID
- The parent OID below which the child should be
created. It must not be null
, and it must
be a valid numeric OID.childComponent
- The integer value for the child component.java.text.ParseException
- If the provided parent OID is not a valid numeric
OID.@Nullable public static java.util.List<java.lang.Integer> parseComponents(@Nullable java.lang.String oidString)
oidString
- The string to parse as a numeric OID.null
if the provided string does not represent a valid
numeric OID.@NotNull public static OID parseNumericOID(@Nullable java.lang.String oidString, boolean strict) throws java.text.ParseException
oidString
- The string to be parsed as a numeric OID. It must not
be null
.strict
- Indicates whether to use strict validation. If this is
false
, then the method will verify that the
provided string is made up of a dotted list of numbers
that does not start or end with a period and does not
contain consecutive periods. If this is true
,
then it will additional verify 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.java.text.ParseException
- If the provided string cannot be parsed as a valid
numeric OID.public static boolean isValidNumericOID(@Nullable java.lang.String s)
isStrictlyValidNumericOID(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.s
- The string for which to make the determination.true
if the provided string represents a valid numeric
OID, or false
if not.public boolean isValidNumericOID()
isStrictlyValidNumericOID()
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.true
if this object represents a valid numeric OID, or
false
if not.public static boolean isStrictlyValidNumericOID(@Nullable java.lang.String s)
s
- The string for which to make the determination.true
if this object represents a strictly valid numeric
OID, or false
if not.public boolean isStrictlyValidNumericOID()
true
if this object represents a strictly valid numeric
OID, or false
if not.@Nullable public java.util.List<java.lang.Integer> getComponents()
null
value if isValidNumericOID(java.lang.String)
returns
true
.null
if
this object does not represent a valid numeric OID.@Nullable public OID getParent() throws java.text.ParseException
null
if this
OID doesn't have a parent. Note that the returned OID may not
necessarily be strictly valid in some cases (for example, if this
OID only contains two components, as all strictly valid OIDs must
contain at least two components).java.text.ParseException
- If this OID does not represent a valid numeric
OID.public boolean isAncestorOf(@NotNull OID oid) throws java.text.ParseException
oid
- The OID for which to make the determination. It must not be
null
, and it must represent a valid numeric OID.true
if this OID is an ancestor of the provided OID, or
false
if not.java.text.ParseException
- If either this OID or the provided OID does not
represent a valid numeric OID.public boolean isDescendantOf(@NotNull OID oid) throws java.text.ParseException
oid
- The OID for which to make the determination. It must not be
null
, and it must represent a valid numeric OID.true
if this OID is a descendant of the provided OID, or
false
if not.java.text.ParseException
- If either this OID or the provided OID does not
represent a valid numeric OID.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
o
- The object for which to make the determination.true
if the provided object is equal to this OID, or
false
if not.public int compareTo(@NotNull OID oid)
compareTo
in interface java.lang.Comparable<OID>
oid
- The OID to compare against this OID.