Class AttributeType


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

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

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

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

      • AttributeType

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

        public AttributeType​(java.lang.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:
        isUnknown()
    • Method Detail

      • setAttributeType

        protected void setAttributeType​(java.lang.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 java.lang.Throwable
        Releases any native structures associated with this object.
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.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​(java.lang.Object o)
        Compares this AttributeType with another one for equality.
        Overrides:
        equals in class java.lang.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 java.lang.Object
      • getAttributeTypeName

        public java.lang.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()
      • getAttributeTypeAlias

        public java.lang.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:
        getAttributeTypeName()
      • toString

        public java.lang.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 java.lang.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
      • 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:
        getSyntaxID()
      • getSyntaxName

        public java.lang.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:
        DSapi.nameToSyntaxID(String)
      • 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:
        DSapi.isPrintableSyntax(int)
      • 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 java.lang.String getAlias​(java.lang.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 java.lang.String getOID​(java.lang.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 java.lang.String[] getCompletions​(java.lang.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.