org.datanucleus.store.mapped
Class StatementMappingIndex

java.lang.Object
  extended by org.datanucleus.store.mapped.StatementMappingIndex

public class StatementMappingIndex
extends java.lang.Object

Representation of a mapping in a statement (such as JDBC), and its mapping to the associated column(s) or parameters that the mapping relates to. The mapping may be for a field of a class (whether it is a real field or a surrogate), or for a parameter.

For example, fields of a class in the result clause of a statement.
 CLASS                 FIELDNUM     MAPPING            TABLE                COLUMN POSITIONS
 -----------------     --------     --------------     ----------------     ----------------
 class A           -->          -->                --> TABLE_A              
 {
    short fieldA;  --> 1        --> ShortMapping   --> COL_FIELDA       --> 1
    String fieldB; --> 2        --> StringMapping  --> COL_FIELDB_PART1 --> 2
                   -->          -->                --> COL_FIELDB_PART2 --> 3
    ...
 }
 


Constructor Summary
StatementMappingIndex(JavaTypeMapping mapping)
           
 
Method Summary
 void addParameterOccurrence(int[] positions)
          Method to register statement position(s) that this mapping is used as a parameter.
 java.lang.String getColumnAlias()
          Accessor for the column name alias (if any).
 int[] getColumnPositions()
          Accessor for the column position(s).
 JavaTypeMapping getMapping()
           
 int getNumberOfParameterOccurrences()
          Accessor for the number of times this mapping is used as a parameter.
 int[] getParameterPositionsForOccurrence(int num)
          Accessor for the parameter positions for this occurrence of use of the mapping as a parameter.
 void removeParameterOccurrence(int[] positions)
          Method to deregister statement positions that this mapping is used as a parameter.
 void setColumnAlias(java.lang.String alias)
          Mutator for the column name (alias).
 void setColumnPositions(int[] pos)
          Mutator for the column positions in the result clause of a statement.
 void setMapping(JavaTypeMapping mapping)
           
 java.lang.String toString()
          Method to return a string version of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StatementMappingIndex

public StatementMappingIndex(JavaTypeMapping mapping)
Method Detail

getMapping

public JavaTypeMapping getMapping()

setMapping

public void setMapping(JavaTypeMapping mapping)

getColumnAlias

public java.lang.String getColumnAlias()
Accessor for the column name alias (if any). Only applies to the first column for this field.

Returns:
The column alias.

setColumnAlias

public void setColumnAlias(java.lang.String alias)
Mutator for the column name (alias). Overrides the name of the field that the mapping refers to.

Parameters:
alias - The name of the column (alias).

getColumnPositions

public int[] getColumnPositions()
Accessor for the column position(s).

Returns:
The column position(s) in the result clause of the statement.

setColumnPositions

public void setColumnPositions(int[] pos)
Mutator for the column positions in the result clause of a statement.

Parameters:
pos - The column position(s)

addParameterOccurrence

public void addParameterOccurrence(int[] positions)
Method to register statement position(s) that this mapping is used as a parameter. The number of positions must be the same as the mapping number of columns.

Parameters:
positions - The parameter positions in the statement.

removeParameterOccurrence

public void removeParameterOccurrence(int[] positions)
Method to deregister statement positions that this mapping is used as a parameter.

Parameters:
positions - The param positions to deregister

getNumberOfParameterOccurrences

public int getNumberOfParameterOccurrences()
Accessor for the number of times this mapping is used as a parameter.

Returns:
Number of times used as a parameter

getParameterPositionsForOccurrence

public int[] getParameterPositionsForOccurrence(int num)
Accessor for the parameter positions for this occurrence of use of the mapping as a parameter.

Parameters:
num - The occurrence of using this mapping as a parameter.
Returns:
The parameter positions

toString

public java.lang.String toString()
Method to return a string version of this object.

Overrides:
toString in class java.lang.Object
Returns:
String version


Copyright © 2010. All Rights Reserved.