Class ObjectEncoder

    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectEncoder()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      AttributeTypeDefinition constructAttributeType​(java.lang.reflect.Field f)
      Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value of the specified field.
      abstract AttributeTypeDefinition constructAttributeType​(java.lang.reflect.Field f, OIDAllocator a)
      Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value of the specified field.
      AttributeTypeDefinition constructAttributeType​(java.lang.reflect.Method m)
      Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value returned by the specified method.
      abstract AttributeTypeDefinition constructAttributeType​(java.lang.reflect.Method m, OIDAllocator a)
      Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value returned by the specified method.
      abstract void decodeField​(java.lang.reflect.Field field, java.lang.Object object, Attribute attribute)
      Updates the provided object to assign a value for the specified field from the contents of the given attribute.
      abstract Attribute encodeFieldValue​(java.lang.reflect.Field field, java.lang.Object value, java.lang.String name)
      Encodes the provided field to an LDAP attribute.
      abstract Attribute encodeMethodValue​(java.lang.reflect.Method method, java.lang.Object value, java.lang.String name)
      Encodes the provided method to an LDAP attribute.
      abstract void invokeSetter​(java.lang.reflect.Method method, java.lang.Object object, Attribute attribute)
      Updates the provided object to invoke the specified method to set a value from the contents of the given attribute.
      void setNull​(java.lang.reflect.Field f, java.lang.Object o)
      Assigns a null value to the provided field, if possible.
      void setNull​(java.lang.reflect.Method m, java.lang.Object o)
      Invokes the provided setter method with a single argument that will set a null value for that method, if possible.
      abstract boolean supportsMultipleValues​(java.lang.reflect.Field field)
      Indicates whether the provided field can hold multiple values.
      abstract boolean supportsMultipleValues​(java.lang.reflect.Method method)
      Indicates whether the provided setter method takes an argument that can hold multiple values.
      abstract boolean supportsType​(java.lang.reflect.Type t)
      Indicates whether this object encoder may be used to encode or decode objects of the specified type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • supportsType

        public abstract boolean supportsType​(@NotNull
                                             java.lang.reflect.Type t)
        Indicates whether this object encoder may be used to encode or decode objects of the specified type.
        Parameters:
        t - The type of object for which to make the determination.
        Returns:
        true if this object encoder may be used for objects of the specified type, or false if not.
      • constructAttributeType

        @NotNull
        public final AttributeTypeDefinition constructAttributeType​(@NotNull
                                                                    java.lang.reflect.Field f)
                                                             throws LDAPPersistException
        Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value of the specified field. Note that the object identifier used for the constructed attribute type definition is not required to be valid or unique.
        Parameters:
        f - The field for which to construct an LDAP attribute type definition. It will include the LDAPField annotation type.
        Returns:
        The constructed attribute type definition.
        Throws:
        LDAPPersistException - If this object encoder does not support encoding values for the associated field type.
      • constructAttributeType

        @NotNull
        public abstract AttributeTypeDefinition constructAttributeType​(@NotNull
                                                                       java.lang.reflect.Field f,
                                                                       @NotNull
                                                                       OIDAllocator a)
                                                                throws LDAPPersistException
        Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value of the specified field.
        Parameters:
        f - The field for which to construct an LDAP attribute type definition. It will include the LDAPField annotation type.
        a - The OID allocator to use to generate the object identifier. It must not be null.
        Returns:
        The constructed attribute type definition.
        Throws:
        LDAPPersistException - If this object encoder does not support encoding values for the associated field type.
      • constructAttributeType

        @NotNull
        public final AttributeTypeDefinition constructAttributeType​(@NotNull
                                                                    java.lang.reflect.Method m)
                                                             throws LDAPPersistException
        Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value returned by the specified method. Note that the object identifier used for the constructed attribute type definition is not required to be valid or unique.
        Parameters:
        m - The method for which to construct an LDAP attribute type definition. It will include the LDAPGetter annotation type.
        Returns:
        The constructed attribute type definition.
        Throws:
        LDAPPersistException - If this object encoder does not support encoding values for the associated method type.
      • constructAttributeType

        @NotNull
        public abstract AttributeTypeDefinition constructAttributeType​(@NotNull
                                                                       java.lang.reflect.Method m,
                                                                       @NotNull
                                                                       OIDAllocator a)
                                                                throws LDAPPersistException
        Constructs a definition for an LDAP attribute type which may be added to the directory server schema to allow it to hold the value returned by the specified method. Note that the object identifier used for the constructed attribute type definition is not required to be valid or unique.
        Parameters:
        m - The method for which to construct an LDAP attribute type definition. It will include the LDAPGetter annotation type.
        a - The OID allocator to use to generate the object identifier. It must not be null.
        Returns:
        The constructed attribute type definition.
        Throws:
        LDAPPersistException - If this object encoder does not support encoding values for the associated method type.
      • supportsMultipleValues

        public abstract boolean supportsMultipleValues​(@NotNull
                                                       java.lang.reflect.Field field)
        Indicates whether the provided field can hold multiple values.
        Parameters:
        field - The field for which to make the determination. It must be marked with the LDAPField annotation.
        Returns:
        true if the provided field can hold multiple values, or false if not.
      • supportsMultipleValues

        public abstract boolean supportsMultipleValues​(@NotNull
                                                       java.lang.reflect.Method method)
        Indicates whether the provided setter method takes an argument that can hold multiple values.
        Parameters:
        method - The setter method for which to make the determination. It must be marked with the LDAPSetter annotation type and conform to the constraints associated with that annotation.
        Returns:
        true if the provided method takes an argument that can hold multiple values, or false if not.
      • encodeFieldValue

        @NotNull
        public abstract Attribute encodeFieldValue​(@NotNull
                                                   java.lang.reflect.Field field,
                                                   @NotNull
                                                   java.lang.Object value,
                                                   @NotNull
                                                   java.lang.String name)
                                            throws LDAPPersistException
        Encodes the provided field to an LDAP attribute.
        Parameters:
        field - The field to be encoded.
        value - The value for the field in the object to be encoded.
        name - The name to use for the constructed attribute.
        Returns:
        The attribute containing the encoded representation of the provided field.
        Throws:
        LDAPPersistException - If a problem occurs while attempting to construct an attribute for the field.
      • encodeMethodValue

        @NotNull
        public abstract Attribute encodeMethodValue​(@NotNull
                                                    java.lang.reflect.Method method,
                                                    @NotNull
                                                    java.lang.Object value,
                                                    @NotNull
                                                    java.lang.String name)
                                             throws LDAPPersistException
        Encodes the provided method to an LDAP attribute.
        Parameters:
        method - The method to be encoded.
        value - The value returned by the method in the object to be encoded.
        name - The name to use for the constructed attribute.
        Returns:
        The attribute containing the encoded representation of the provided method value.
        Throws:
        LDAPPersistException - If a problem occurs while attempting to construct an attribute for the method.
      • decodeField

        public abstract void decodeField​(@NotNull
                                         java.lang.reflect.Field field,
                                         @NotNull
                                         java.lang.Object object,
                                         @NotNull
                                         Attribute attribute)
                                  throws LDAPPersistException
        Updates the provided object to assign a value for the specified field from the contents of the given attribute.
        Parameters:
        field - The field to update in the provided object.
        object - The object to be updated.
        attribute - The attribute whose value(s) should be used to update the specified field in the given object.
        Throws:
        LDAPPersistException - If a problem occurs while attempting to assign a value to the specified field.
      • setNull

        public void setNull​(@NotNull
                            java.lang.reflect.Field f,
                            @NotNull
                            java.lang.Object o)
                     throws LDAPPersistException
        Assigns a null value to the provided field, if possible. If the field type is primitive and cannot be assigned a null value, then a default primitive value will be assigned instead (0 for numeric values, false for boolean values, and the null character for char values).
        Parameters:
        f - The field to which the null value should be assigned. It must not be null and must be marked with the LDAPField annotation.
        o - The object to be updated. It must not be null, and the class must be marked with the annotation.
        Throws:
        LDAPPersistException - If a problem occurs while attempting to assign a null value to the specified field.
      • setNull

        public void setNull​(@NotNull
                            java.lang.reflect.Method m,
                            @NotNull
                            java.lang.Object o)
                     throws LDAPPersistException
        Invokes the provided setter method with a single argument that will set a null value for that method, if possible. If the argument type is and cannot be assigned a null value, then a default primitive value will be assigned instead (0 for numeric values, false for boolean values, and the null character for char values).
        Parameters:
        m - The setter method that should be used to set the null value. It must not be null, and must have the LDAPSetter annotation.
        o - The object to be updated. It must not be null, and the class must be marked with the annotation.
        Throws:
        LDAPPersistException - If a problem occurs while attempting to assign a null value to the specified field.
      • invokeSetter

        public abstract void invokeSetter​(@NotNull
                                          java.lang.reflect.Method method,
                                          @NotNull
                                          java.lang.Object object,
                                          @NotNull
                                          Attribute attribute)
                                   throws LDAPPersistException
        Updates the provided object to invoke the specified method to set a value from the contents of the given attribute.
        Parameters:
        method - The method to invoke in the provided object.
        object - The object to be updated.
        attribute - The attribute whose value(s) should be used to update the specified method in the given object.
        Throws:
        LDAPPersistException - If a problem occurs while attempting to determine the value or invoke the specified method.