Class OID

java.lang.Object
com.unboundid.util.OID
All Implemented Interfaces:
Serializable, 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:
  • Constructor Summary

    Constructors
    Constructor
    Description
    OID(int... 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(String oidString)
    Creates a new OID object from the provided string representation.
    OID(List<Integer> components)
    Creates a new OID object from the provided set of numeric components.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Indicates the position of the provided object relative to this OID in a sorted list.
    boolean
    Indicates whether the provided object is equal to this OID.
    Retrieves the numeric components that comprise this OID.
    Retrieves the OID that is the parent for this OID.
    int
    Retrieves a hash code for this OID.
    boolean
    Indicates whether this OID is an ancestor of the provided OID.
    boolean
    Indicates whether this OID is a descendant of the provided OID.
    boolean
    Indicates whether this object represents a strictly valid numeric OID.
    static boolean
    Indicates whether this object represents a strictly valid numeric OID.
    boolean
    Indicates whether the provided string represents a valid numeric OID.
    static boolean
    Indicates whether the provided string represents a valid numeric OID.
    static List<Integer>
    Parses the provided string as a numeric OID and extracts the numeric components from it.
    static OID
    parseNumericOID(String oidString, boolean strict)
    Parses the provided string as a numeric OID, optionally using additional strict validation.
    Retrieves a string representation of this OID.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • OID

      public OID(@Nullable 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(@Nullable 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(@Nullable List<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.
    • OID

      public OID(@NotNull OID parentOID, int childComponent) throws ParseException
      Creates a new OID that is a child of the provided parent OID.
      Parameters:
      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.
      Throws:
      ParseException - If the provided parent OID is not a valid numeric OID.
  • Method Details

    • parseComponents

      @Nullable public static List<Integer> parseComponents(@Nullable 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.
    • parseNumericOID

      @NotNull public static OID parseNumericOID(@Nullable String oidString, boolean strict) throws ParseException
      Parses the provided string as a numeric OID, optionally using additional strict validation.
      Parameters:
      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.
      Returns:
      The OID that was parsed from the provided string.
      Throws:
      ParseException - If the provided string cannot be parsed as a valid numeric OID.
    • isValidNumericOID

      public static boolean isValidNumericOID(@Nullable 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. The 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.
      Parameters:
      s - The string for which to make the determination.
      Returns:
      true if the provided string represents a valid numeric OID, or false 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. The 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.
      Returns:
      true if this object represents a valid numeric OID, or false if not.
    • isStrictlyValidNumericOID

      public static boolean isStrictlyValidNumericOID(@Nullable 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, or false 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, or false if not.
    • getComponents

      Retrieves the numeric components that comprise this OID. This will only return a non-null value if isValidNumericOID(java.lang.String) returns true.
      Returns:
      The numeric components that comprise this OID, or null if this object does not represent a valid numeric OID.
    • getParent

      Retrieves the OID that is the parent for this OID. This OID must represent a valid numeric OID.
      Returns:
      The OID that is the parent for this OID, or 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).
      Throws:
      ParseException - If this OID does not represent a valid numeric OID.
    • isAncestorOf

      public boolean isAncestorOf(@NotNull OID oid) throws ParseException
      Indicates whether this OID is an ancestor of the provided OID. This OID will be considered an ancestor of the provided OID if the provided OID has more components than this OID, and if the components that comprise this OID make up the initial set of components for the provided OID.
      Parameters:
      oid - The OID for which to make the determination. It must not be null, and it must represent a valid numeric OID.
      Returns:
      true if this OID is an ancestor of the provided OID, or false if not.
      Throws:
      ParseException - If either this OID or the provided OID does not represent a valid numeric OID.
    • isDescendantOf

      public boolean isDescendantOf(@NotNull OID oid) throws ParseException
      Indicates whether this OID is a descendant of the provided OID. This OID will be considered a descendant of the provided OID if this OID has more components than the provided OID, and if the components that comprise the provided OID make up the initial set of components for this OID.
      Parameters:
      oid - The OID for which to make the determination. It must not be null, and it must represent a valid numeric OID.
      Returns:
      true if this OID is a descendant of the provided OID, or false if not.
      Throws:
      ParseException - If either this OID or the provided OID does not represent a valid numeric OID.
    • hashCode

      public int hashCode()
      Retrieves a hash code for this OID.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code for this OID.
    • equals

      public boolean equals(@Nullable Object o)
      Indicates whether the provided object is equal to this OID.
      Overrides:
      equals in class Object
      Parameters:
      o - The object for which to make the determination.
      Returns:
      true if the provided object is equal to this OID, or false if not.
    • compareTo

      public int compareTo(@NotNull OID oid)
      Indicates the position of the provided object relative to this OID in a sorted list.
      Specified by:
      compareTo in interface 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

      Retrieves a string representation of this OID.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this OID.