com.filenet.api.util

Class Id

  • java.lang.Object
    • com.filenet.api.util.Id
  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable
    Direct Known Subclasses:
    SystemAddOnId, VersionStatusId


    public class Id
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable
    Immutable class that represents GUID values. This class can be constructed from either a String or a byte array.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static Id ZERO_ID
      Convenience constant for the all-zero GUID.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Id(byte[] bytes)
      Constructs an ID with an array of bytes representing its GUID value.
      Id(java.lang.String id)
      Constructs an ID from a string representing its GUID value.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static Id asIdOrNull(java.lang.String id)
      Returns an Id if the passed String is in GUID format.
      int compareTo(java.lang.Object arg)
      Compares two IDs.
      int compareTo(java.lang.Object arg, DatabaseType dbType)
      Compares two IDs as is done in a database search.
      static Id createId()
      Generates an ID with an IETF Version 4 UUID value.
      boolean equals(java.lang.Object otherId)
      Compares two IDs for logical equality.
      byte[] getBytes()
      Returns a copy of this ID as an array of bytes.
      int hashCode()
      Returns the hashcode for this ID.
      static boolean isId(java.lang.String value)
      Determines if a String is an ID or not.
      java.lang.String toString()
      Returns the string representation of this ID.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ZERO_ID

        public static final Id ZERO_ID
        Convenience constant for the all-zero GUID.
    • Constructor Detail

      • Id

        public Id(java.lang.String id)
        Constructs an ID from a string representing its GUID value. A valid string consists of optional whitespace, an optional left brace({), followed by required 8 hexadecimal characters, a dash, 4 hexadecimal characters, a dash, 4 hexadecimal characters, a dash, 4 hexadecimal characters, a dash, and 12 hexadecimal characters, then finally an optional right brace(}) followed by whitespace. The braces must either both be present or both be omitted.
        Example: {1234abcd-56ef-7a89-9fe8-7d65cd43ba21} An exception is thrown if the input string does not conform to this format.
        Parameters:
        id - GUID value in string format from which to construct an ID.
      • Id

        public Id(byte[] bytes)
        Constructs an ID with an array of bytes representing its GUID value.
        Parameters:
        bytes - GUID value in byte array format from which to construct an ID.
    • Method Detail

      • createId

        public static Id createId()
        Generates an ID with an IETF Version 4 UUID value. This value is based on the Internet Engineering Task Force (IETF) UUID specification using java.security.SecureRandom.
        Returns:
        An Id object.
      • asIdOrNull

        public static Id asIdOrNull(java.lang.String id)
        Returns an Id if the passed String is in GUID format. A valid string consists of optional whitespace, an optional left brace({), followed by required 8 hexadecimal characters, a dash, 4 hexadecimal characters, a dash, 4 hexadecimal characters, a dash, 4 hexadecimal characters, a dash, and 12 hexadecimal characters, then finally an optional right brace(}) followed by whitespace. The braces must either both be present or both be omitted.
        Example: {1234abcd-56ef-7a89-9fe8-7d65cd43ba21} If the input String does not conform to this format, the method returns null. This method provides a more efficient alternative to calling isId(String) followed conditionally by new Id(String).
        Parameters:
        id - GUID value in string format from which to construct an ID.
        Returns:
        An Id object or null.
      • compareTo

        public int compareTo(java.lang.Object arg)
        Compares two IDs. This method returns -1 if this is less than arg, 1 if this is greater than arg, and 0 if the IDs are equal.

        This comparison is consistent with how IDs are compared in the DB2 and Oracle databases, but does not match how MSSQL Server compares IDs. For MSSQL Server databases, use compareTo(arg, dbType).

        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        arg - A Java Object representing the ID against which to compare this ID.
        Returns:
        An integer (-1, 1, or 0).
      • compareTo

        public int compareTo(java.lang.Object arg,
                    DatabaseType dbType)
        Compares two IDs as is done in a database search. This method returns -1 if this is less than arg, 1 if this is greater than arg, and 0 if the IDs are equal.

        This comparison matches the way that the databases compare IDs if done in a database search. dbType may be null if the comparison algorithm does not need to match that of any particular database. Specifying null for dbType is the same as calling the single-parameter form of this method (compareTo(arg)).

        Parameters:
        arg - The GUID against which to compare this GUID.
        dbType - An instance of DatabaseType; can be null.
        Returns:
        An integer (-1, 1, or 0).
      • equals

        public boolean equals(java.lang.Object otherId)
        Compares two IDs for logical equality.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        otherId - The ID against which to compare this ID.
        Returns:
        true if otherId is an Id object and their GUIDs are logically equal; otherwise, returns false.
      • getBytes

        public byte[] getBytes()
        Returns a copy of this ID as an array of bytes.
        Returns:
        A copy of this ID as an array of bytes.
      • hashCode

        public int hashCode()
        Returns the hashcode for this ID.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        An integer representing the hashcode for the ID.
      • isId

        public static boolean isId(java.lang.String value)
        Determines if a String is an ID or not.
        Parameters:
        value - The String to verify.
        Returns:
        true if the provided String is in GUID format; otherwise, returns false.
      • toString

        public java.lang.String toString()
        Returns the string representation of this ID.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The ID as a String.

© Copyright IBM Corporation 2006, 2013. All rights reserved.