Class TypeConverterMapping


  • public class TypeConverterMapping
    extends SingleFieldMapping
    Mapping where the member has its value converted to/from some storable datastore type using a TypeConverter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getBoolean​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      byte getByte​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      char getChar​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      int getDefaultLength​(int index)
      Accessor for the default length for this type in the datastore (if applicable).
      double getDouble​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      float getFloat​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      int getInt​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      java.lang.Class getJavaType()
      Accessor for the java type being mapped.
      java.lang.String getJavaTypeForColumnMapping​(int index)
      Accessor for the name of the java-type actually used when mapping the particular datastore field.
      long getLong​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      protected java.lang.Object getMemberValueFromDatastore​(java.sql.ResultSet resultSet, int[] exprIndex)
      Method that retrieves the datastore value and converts it back to the member value.
      java.lang.Object getObject​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      short getShort​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      java.lang.String getString​(org.datanucleus.ExecutionContext ec, java.sql.ResultSet resultSet, int[] exprIndex)
      Obtains a value from datastoreResults at position specified by exprIndex.
      org.datanucleus.store.types.converters.TypeConverter getTypeConverter()  
      void initialize​(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)
      Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.
      void initialize​(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.types.converters.TypeConverter conv)  
      void initialize​(RDBMSStoreManager storeMgr, java.lang.String type)
      Initialise this JavaTypeMapping with the given StoreManager for the given type.
      void setBoolean​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, boolean value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setByte​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, byte value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setChar​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, char value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      protected void setDatastoreFromMemberValue​(java.sql.PreparedStatement ps, int[] exprIndex, java.lang.Object memberValue)
      Method that takes the member value and sets the datastore value in the PreparedStatement at the specified position.
      void setDouble​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, double value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setFloat​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, float value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setInt​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, int value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setLong​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, long value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setObject​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, java.lang.Object value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setShort​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, short value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      void setString​(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] exprIndex, java.lang.String value)
      Sets a value into datastoreStatement at position specified by exprIndex.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • converter

        org.datanucleus.store.types.converters.TypeConverter converter
    • Constructor Detail

      • TypeConverterMapping

        public TypeConverterMapping()
    • Method Detail

      • initialize

        public void initialize​(RDBMSStoreManager storeMgr,
                               java.lang.String type)
        Description copied from class: JavaTypeMapping
        Initialise this JavaTypeMapping with the given StoreManager for the given type. Used when the mapping is for a parameter in a query. This will not set the "mmd" and "datastoreContainer" parameters. If these are required for usage of the mapping then you should call setFieldInformation(AbstractMemberMetaData, DatastoreContainerObject) below. Subclasses should override this method to perform any datastore initialization operations.
        Overrides:
        initialize in class JavaTypeMapping
        Parameters:
        storeMgr - The Datastore Adapter that this Mapping should use.
        type - The Class that this mapping maps to the database.
      • initialize

        public void initialize​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                               Table table,
                               org.datanucleus.ClassLoaderResolver clr)
        Description copied from class: SingleFieldMapping
        Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.
        Overrides:
        initialize in class SingleFieldMapping
        Parameters:
        mmd - FieldMetaData for the field to be mapped (if any)
        table - The datastore container storing this mapping (if any)
        clr - the ClassLoaderResolver
      • initialize

        public void initialize​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                               Table table,
                               org.datanucleus.ClassLoaderResolver clr,
                               org.datanucleus.store.types.converters.TypeConverter conv)
      • getTypeConverter

        public org.datanucleus.store.types.converters.TypeConverter getTypeConverter()
      • getDefaultLength

        public int getDefaultLength​(int index)
        Description copied from class: SingleFieldMapping
        Accessor for the default length for this type in the datastore (if applicable).
        Overrides:
        getDefaultLength in class SingleFieldMapping
        Parameters:
        index - requested column index.
        Returns:
        Default length
      • getJavaTypeForColumnMapping

        public java.lang.String getJavaTypeForColumnMapping​(int index)
        Description copied from class: SingleFieldMapping
        Accessor for the name of the java-type actually used when mapping the particular datastore field. This java-type must have an entry in the datastore mappings.
        Overrides:
        getJavaTypeForColumnMapping in class SingleFieldMapping
        Parameters:
        index - requested column index.
        Returns:
        the name of java-type for the requested column.
      • getJavaType

        public java.lang.Class getJavaType()
        Description copied from class: JavaTypeMapping
        Accessor for the java type being mapped. This is the java type that the mapping represents. Some examples :
        • if the field is of type "MyClass" then the mapping will be OIDMapping (or subclass) the javaType will be OID, and the type will be MyClass.
        • if the field is of type "int" then the mapping will be IntegerMapping, the javaType will be Integer, and the type will be int.
        The "java type" is the java-type name used in the plugin.xml mapping file
        Specified by:
        getJavaType in class JavaTypeMapping
        Returns:
        The java type
      • setDatastoreFromMemberValue

        protected void setDatastoreFromMemberValue​(java.sql.PreparedStatement ps,
                                                   int[] exprIndex,
                                                   java.lang.Object memberValue)
        Method that takes the member value and sets the datastore value in the PreparedStatement at the specified position.
        Parameters:
        ps - The PreparedStatement
        exprIndex - The position in the statement
        memberValue - The member value for this field
      • getMemberValueFromDatastore

        protected java.lang.Object getMemberValueFromDatastore​(java.sql.ResultSet resultSet,
                                                               int[] exprIndex)
        Method that retrieves the datastore value and converts it back to the member value.
        Parameters:
        resultSet - The result set
        exprIndex - The position in the result set
        Returns:
        The member value
      • setBoolean

        public void setBoolean​(org.datanucleus.ExecutionContext ec,
                               java.sql.PreparedStatement ps,
                               int[] exprIndex,
                               boolean value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setBoolean in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getBoolean

        public boolean getBoolean​(org.datanucleus.ExecutionContext ec,
                                  java.sql.ResultSet resultSet,
                                  int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getBoolean in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setByte

        public void setByte​(org.datanucleus.ExecutionContext ec,
                            java.sql.PreparedStatement ps,
                            int[] exprIndex,
                            byte value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setByte in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getByte

        public byte getByte​(org.datanucleus.ExecutionContext ec,
                            java.sql.ResultSet resultSet,
                            int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getByte in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setChar

        public void setChar​(org.datanucleus.ExecutionContext ec,
                            java.sql.PreparedStatement ps,
                            int[] exprIndex,
                            char value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setChar in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getChar

        public char getChar​(org.datanucleus.ExecutionContext ec,
                            java.sql.ResultSet resultSet,
                            int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getChar in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setDouble

        public void setDouble​(org.datanucleus.ExecutionContext ec,
                              java.sql.PreparedStatement ps,
                              int[] exprIndex,
                              double value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setDouble in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getDouble

        public double getDouble​(org.datanucleus.ExecutionContext ec,
                                java.sql.ResultSet resultSet,
                                int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getDouble in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setFloat

        public void setFloat​(org.datanucleus.ExecutionContext ec,
                             java.sql.PreparedStatement ps,
                             int[] exprIndex,
                             float value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setFloat in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getFloat

        public float getFloat​(org.datanucleus.ExecutionContext ec,
                              java.sql.ResultSet resultSet,
                              int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getFloat in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setInt

        public void setInt​(org.datanucleus.ExecutionContext ec,
                           java.sql.PreparedStatement ps,
                           int[] exprIndex,
                           int value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setInt in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getInt

        public int getInt​(org.datanucleus.ExecutionContext ec,
                          java.sql.ResultSet resultSet,
                          int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getInt in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setLong

        public void setLong​(org.datanucleus.ExecutionContext ec,
                            java.sql.PreparedStatement ps,
                            int[] exprIndex,
                            long value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setLong in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getLong

        public long getLong​(org.datanucleus.ExecutionContext ec,
                            java.sql.ResultSet resultSet,
                            int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getLong in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setShort

        public void setShort​(org.datanucleus.ExecutionContext ec,
                             java.sql.PreparedStatement ps,
                             int[] exprIndex,
                             short value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setShort in class SingleFieldMapping
        Parameters:
        ec - execution context
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getShort

        public short getShort​(org.datanucleus.ExecutionContext ec,
                              java.sql.ResultSet resultSet,
                              int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getShort in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setString

        public void setString​(org.datanucleus.ExecutionContext ec,
                              java.sql.PreparedStatement ps,
                              int[] exprIndex,
                              java.lang.String value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setString in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getString

        public java.lang.String getString​(org.datanucleus.ExecutionContext ec,
                                          java.sql.ResultSet resultSet,
                                          int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getString in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setObject

        public void setObject​(org.datanucleus.ExecutionContext ec,
                              java.sql.PreparedStatement ps,
                              int[] exprIndex,
                              java.lang.Object value)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setObject in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getObject

        public java.lang.Object getObject​(org.datanucleus.ExecutionContext ec,
                                          java.sql.ResultSet resultSet,
                                          int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getObject in class SingleFieldMapping
        Parameters:
        ec - ExecutionContext
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value