Class AttributeType

java.lang.Object
com.isode.dsapi.AttributeType

public class AttributeType extends Object
Representation of an attribute type.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Used by the native library when creating a new empty object.
     
    Construct a new AttributeType using the specified attribute name or OID string, allowing only types that are recognised by the local schema.
     
    AttributeType(String attrName, boolean allow_unknown)
    Construct a new AttributeType using the specified attribute name or OID string, optionally permitting unknown attribute-types.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compare attribute types for equality.
    boolean
    Compares this AttributeType with another one for equality.
    protected void
    Releases any native structures associated with this object.
    static String
    Fetch the alternative name of an attribute, if it has one.
    Return attribute type alias, if the attribute-type has one.
    Return attribute type name (for example, the String "cn").
    static String[]
    getCompletions(String partial_name)
    Return an array containing all the attribute names and aliases that start with the given string (matching case-insensitively).
    static String
    getOID(String name)
    Fetch the OID of the named attribute type.
    int
    Return the integer identifier of this type's syntax.
    Return a String representation of this object's syntax.
    int
    Overrides Object.hashCode in order to be consistent with the equals(Object) method.
    boolean
    Determine whether the local schema regards this AttributeType as a 'collective' type.
    boolean
    Test whether this is a file-based attribute according to the local schema.
    boolean
    Determine whether the local schema regards this AttributeType as being marked 'no user modification'.
    boolean
    Determine whether the local schema regards this AttributeType as being marked 'obsolete'.
    boolean
    Determine whether the local schema regards this AttributeType as being marked 'operational'.
    boolean
    Determine whether values of this AttributeType have a printable string representation.
    boolean
    Determine whether this AttributeType is one which has a String representation that is likely to be a DN.
    boolean
    Determine whether the local schema regards this AttributeType as single-valued.
    boolean
    Check to see if the attribute-type is unknown to the loaded schema.
    protected void
    setAttributeType(String attrName, boolean allow_unknown)
    Used by the native library to set an attribute type from the attribute name or OID string.
    Returns a string representation of this AttributeType.

    Methods inherited from class java.lang.Object

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

    • AttributeType

      protected AttributeType()
      Used by the native library when creating a new empty object.
    • AttributeType

      public AttributeType(String attrName) throws BadAttributeTypeException, NativeLibraryException
      Construct a new AttributeType using the specified attribute name or OID string, allowing only types that are recognised by the local schema. Note that either the short or long attribute-type name may be used to construct the object (e.g. "cn" and "commonname" would be equivalent).
      Parameters:
      attrName - Attribute type name or OID
      Throws:
      BadAttributeTypeException - if name is null or not recognised.
      NativeLibraryException - if an unrecoverable error was detected by the native library
      See Also:
    • AttributeType

      public AttributeType(String attrName, boolean allow_unknown) throws BadAttributeTypeException, NativeLibraryException
      Construct a new AttributeType using the specified attribute name or OID string, optionally permitting unknown attribute-types. Note that either the short or long attribute-type name may be used to construct the object (e.g. "cn" and "commonname" would be equivalent). Unknown attribute-types always have 'octetstring' syntax and can be written to LDIF or sent over LDAP, but not sent over DAP.
      Parameters:
      attrName - Attribute type name or OID
      allow_unknown - true to allow unknown attribute types, false to disallow them (which may result in BadAttributeTypeException being thrown).
      Throws:
      BadAttributeTypeException - if name is null or not recognised.
      NativeLibraryException - if an unrecoverable error was detected by the native library
      See Also:
  • Method Details

    • setAttributeType

      protected void setAttributeType(String attrName, boolean allow_unknown) throws BadAttributeTypeException, NativeLibraryException
      Used by the native library to set an attribute type from the attribute name or OID string.
      Parameters:
      attrName - Attribute type name or OID.
      allow_unknown - Allow unknown attribute-types?
      Throws:
      BadAttributeTypeException - if attribute name is null or not recognised.
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • finalize

      protected void finalize() throws Throwable
      Releases any native structures associated with this object.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • isUnknown

      public boolean isUnknown()
      Check to see if the attribute-type is unknown to the loaded schema. Unknown attribute-types can be created with the 'allow-unknown' flag set on the LDAP session, the LDIF stream, or on the AttributeType constructor.
    • equals

      public boolean equals(AttributeType type)
      Compare attribute types for equality.
      Parameters:
      type - Attribute type to compare.
      Returns:
      true if the same, false otherwise.
    • equals

      public boolean equals(Object o)
      Compares this AttributeType with another one for equality.
      Overrides:
      equals in class Object
      Returns:
      true if o is an AttributeType representing the same value as this object.
    • hashCode

      public int hashCode()
      Overrides Object.hashCode in order to be consistent with the equals(Object) method.
      Overrides:
      hashCode in class Object
    • getAttributeTypeName

      public String getAttributeTypeName() throws NativeLibraryException
      Return attribute type name (for example, the String "cn"). This is the LDAP representation of the type name. See also getAttributeTypeAlias() to fetch the alternative name for the attribute type, if it has one.
      Returns:
      Attribute type name. Returns a string representation of the underlying OID of no name present.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      See Also:
    • getAttributeTypeAlias

      public String getAttributeTypeAlias() throws NativeLibraryException
      Return attribute type alias, if the attribute-type has one. This is an alternative name for the attribute-type.
      Returns:
      Attribute type alias, or null if not present.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      See Also:
    • toString

      public String toString() throws NativeLibraryException
      Returns a string representation of this AttributeType. The string representation is equivalent to that returned by getAttributeTypeName.
      Overrides:
      toString in class Object
      Returns:
      Attribute type name. Returns a string representation of the underlying OID of no name present.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • getSyntaxID

      public int getSyntaxID() throws NativeLibraryException
      Return the integer identifier of this type's syntax. This is the pure syntax-ID integer, without any file-based offset.
      Returns:
      Syntax identifier.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      See Also:
    • isFileBased

      public boolean isFileBased() throws NativeLibraryException
      Test whether this is a file-based attribute according to the local schema.
      Returns:
      'true' if this is a file-based attribute, else 'false'
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      Since:
      R15.0
      See Also:
    • getSyntaxName

      public String getSyntaxName() throws NativeLibraryException
      Return a String representation of this object's syntax. For example, "caseignorestring" or "GeneralizedTime".
      Returns:
      the syntax of the AttributeType
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      See Also:
    • isPrintable

      public boolean isPrintable() throws NativeLibraryException
      Determine whether values of this AttributeType have a printable string representation.
      Returns:
      true if values of this AttributeType have a printable string representation, false otherwise.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      Since:
      14.6
      See Also:
    • isSingleValue

      public boolean isSingleValue()
      Determine whether the local schema regards this AttributeType as single-valued.
      Returns:
      true if the Attribute is single-valued, false otherwise.
    • isCollective

      public boolean isCollective()
      Determine whether the local schema regards this AttributeType as a 'collective' type.
      Returns:
      true if the Attribute is collective, false otherwise.
    • isNoUserModification

      public boolean isNoUserModification()
      Determine whether the local schema regards this AttributeType as being marked 'no user modification'.
      Returns:
      true if the Attribute is no user modification, false otherwise.
    • isObsolete

      public boolean isObsolete()
      Determine whether the local schema regards this AttributeType as being marked 'obsolete'.
      Returns:
      true if the Attribute is obsolete, false otherwise.
    • isOperational

      public boolean isOperational()
      Determine whether the local schema regards this AttributeType as being marked 'operational'.
      Returns:
      true if the Attribute is operational, false otherwise.
    • getAlias

      public static String getAlias(String name)
      Fetch the alternative name of an attribute, if it has one. This converts the short name to the long name, or vice versa. It also converts the OID to the default name.
      Returns:
      alternative attribute-type name, or 'null' if there isn't an alias, or for any other problem
    • getOID

      public static String getOID(String name)
      Fetch the OID of the named attribute type.
      Returns:
      OID of the attribute-type, or 'null' if there isn't one or if the type isn't known
      Since:
      14.4
    • getCompletions

      public static String[] getCompletions(String partial_name)
      Return an array containing all the attribute names and aliases that start with the given string (matching case-insensitively). This is intended for getting a list of all possible attribute-types (passing ""), or doing attribute-type auto-completion (passing user's current input).
      Parameters:
      partial_name - Initial part of name to match
      Returns:
      Array of names, maybe zero-length
    • isPseudoDN

      public boolean isPseudoDN()
      Determine whether this AttributeType is one which has a String representation that is likely to be a DN. This method was specifically added to cope with atnAmhsmdNamingcontext, which had previously been defined as DN, until a change in schema for ATN compatibility meant that it became a PrintableString.
      Returns:
      true if this kind of Attribute holds values that may well be treatable as DNs, false otherwise.