wt.query
Class ClassAttribute

java.lang.Object
  extended bywt.query.ClassAttribute
All Implemented Interfaces:
ColumnExpression, Expression, Externalizable, OrderByExpression, RelationalExpression, Serializable

public class ClassAttribute
extends Object
implements ColumnExpression, Externalizable

This class represents a class attribute which can be used in a SQL statement. Introspection information is used to determine the associated table and column.

When a query executes, a ClassAttribute used in the query internally references a TableExpression from that query. A single instance of ClassAttribute must only be associated to a single TableExpression. If multiple classes are used in the query or a sub-select is used, then a single instances of ClassAttribute should not be reused in different query expressions. Instead, construct multiple instances, as needed.

Supported API: true

Extendable: false

See Also:
Serialized Form

Field Summary
private  boolean advancedQueryEnabled
           
private  String alias
           
private  String attributeName
           
private static String CLASSNAME
           
private  String columnAlias
           
private  ColumnDescriptor columnDescriptor
           
private  boolean correlated
           
private  TableExpression correlatedTable
           
static long EXTERNALIZATION_VERSION_UID
           
private  Class javaType
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
private  Class targetClass
           
private  boolean useExplicitAlias
           
private  boolean useViewTableAlias
           
private  String viewTableAlias
           
private  Class viewTableClass
           
 
Fields inherited from interface wt.query.ColumnExpression
ADVANCED_QUERY, ADVANCED_QUERY_ENABLED, COLUMN_ALIAS, JAVA_TYPE
 
Fields inherited from interface wt.query.Expression
FROM_COUNT
 
Fields inherited from interface wt.query.RelationalExpression
BIND_PARAMETER
 
Constructor Summary
ClassAttribute()
          

Supported API: false
ClassAttribute(Class a_targetClass, String a_attributeName)
          

Supported API: true
ClassAttribute(Class a_targetClass, String a_attributeName, String a_fromAlias)
          

Supported API: false
 
Method Summary
 String getActualTableAlias(Vector a_tableInfos, Vector a_aliases)
           
 Class getActualTargetClass(Vector a_tableInfos, Vector a_aliases)
           
private  AliasDescriptor getAliasDescriptor(Class a_class)
           
 String getAttributeName()
          Gets the value of the attribute: attributeName; The class's attribute.
 Object getBindParameter()
          Gets the value of the attribute: bindParameter; Returns a bind parameter for this expression (if supported).
 List getClassAttributes()
          

Supported API: false
 String getColumnAlias()
          Gets the value of the attribute: columnAlias; Alias for the column expression.
 ColumnDescriptor getColumnDescriptor()
          Gets the value of the attribute: columnDescriptor; The associated introspection ColumnDescriptor.
 TableExpression getCorrelatedTable()
          Gets the value of the attribute: correlatedTable.
 String getExpression(boolean a_useBind, Vector a_tableInfos, Vector a_aliases, boolean a_outerJoin)
          Return string representation of this expression.
 String getFromAlias()
          

Supported API: false
 int getFromCount()
          Gets the value of the attribute: fromCount; Number of from index values that this expression requires

Supported API: false
 Class getJavaType()
          Gets the value of the attribute: javaType; The java type of this expression.
 String getTableAliasInView(Vector a_tableInfos, Vector a_aliases)
           
 Class getTargetClass()
          Gets the object for the association that plays role: targetClass.
 String getViewTableAlias()
          Gets the value of the attribute: viewTableAlias.
 Class getViewTableClass()
          Gets the value of the attribute: viewTableClass.
 boolean isAdvancedQuery()
          Gets the value of the attribute: advancedQuery; Indicates if the expression uses advanced query capabilities.
 boolean isAdvancedQueryEnabled()
          Gets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.
 boolean isCorrelated()
          Gets the value of the attribute: correlated.
 boolean isUseViewTableAlias()
          Gets the value of the attribute: useViewTableAlias.
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(ClassAttribute thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
 void setAdvancedQueryEnabled(boolean a_AdvancedQueryEnabled)
          Sets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.
 void setAttributeName(String a_AttributeName)
          Sets the value of the attribute: attributeName; The class's attribute.
 void setColumnAlias(String a_ColumnAlias)
          Sets the value of the attribute: columnAlias; Alias for the column expression.
 void setCorrelated(boolean a_Correlated)
          Sets the value of the attribute: correlated.
 void setCorrelatedTable(TableExpression a_CorrelatedTable)
          Sets the value of the attribute: correlatedTable.
 int setFromAlias(String[] a_aliases, int a_offset)
          This method sets the FROM clause alias for this expression.
 void setTargetClass(Class a_TargetClass)
          Sets the object for the association that plays role: targetClass.
 void setUseViewTableAlias(boolean a_UseViewTableAlias)
          Sets the value of the attribute: useViewTableAlias.
 void setViewTableAlias(String a_ViewTableAlias)
          Sets the value of the attribute: viewTableAlias.
 void setViewTableClass(Class a_ViewTableClass)
          Sets the value of the attribute: viewTableClass.
private  void targetClassValidate(Class a_TargetClass)
           
 String toString()
           
private  boolean validate(Class a_class, String a_attribute)
           
 int validate(TableExpression[] a_tableExpressions, int a_offset)
          This method validates this expression against the specified table expression.
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

attributeName

private String attributeName

alias

private String alias

useExplicitAlias

private boolean useExplicitAlias

viewTableAlias

private String viewTableAlias

viewTableClass

private Class viewTableClass

useViewTableAlias

private boolean useViewTableAlias

correlated

private boolean correlated

correlatedTable

private TableExpression correlatedTable

targetClass

private Class targetClass

columnAlias

private String columnAlias

advancedQueryEnabled

private transient boolean advancedQueryEnabled

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

columnDescriptor

private transient ColumnDescriptor columnDescriptor

javaType

private transient Class javaType
Constructor Detail

ClassAttribute

public ClassAttribute(Class a_targetClass,
                      String a_attributeName)
               throws QueryException


Supported API: true

Parameters:
a_targetClass - Specifies the class.
a_attributeName - Specifies the class's attribute.
Throws:
QueryException

ClassAttribute

public ClassAttribute(Class a_targetClass,
                      String a_attributeName,
                      String a_fromAlias)
               throws QueryException


Supported API: false

Parameters:
a_targetClass - Specifies the class.
a_attributeName - Specifies the class attribute.
a_fromAlias - Specifies a FROM clause table alias that will be used when constructing the expression.
Throws:
QueryException

ClassAttribute

public ClassAttribute()


Supported API: false

Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(ClassAttribute thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

getAttributeName

public String getAttributeName()
Gets the value of the attribute: attributeName; The class's attribute.

Supported API: true

Returns:
String

setAttributeName

public void setAttributeName(String a_AttributeName)
                      throws WTPropertyVetoException
Sets the value of the attribute: attributeName; The class's attribute.

Supported API: true

Parameters:
a_AttributeName -
Throws:
WTPropertyVetoException

getColumnDescriptor

public ColumnDescriptor getColumnDescriptor()
                                     throws PersistenceException
Gets the value of the attribute: columnDescriptor; The associated introspection ColumnDescriptor.

Supported API: false

Returns:
ColumnDescriptor
Throws:
PersistenceException

getViewTableAlias

public String getViewTableAlias()
Gets the value of the attribute: viewTableAlias.

Supported API: false

Returns:
String

setViewTableAlias

public void setViewTableAlias(String a_ViewTableAlias)
Sets the value of the attribute: viewTableAlias.

Supported API: false

Parameters:
a_ViewTableAlias -

getViewTableClass

public Class getViewTableClass()
Gets the value of the attribute: viewTableClass.

Supported API: false

Returns:
Class

setViewTableClass

public void setViewTableClass(Class a_ViewTableClass)
Sets the value of the attribute: viewTableClass.

Supported API: false

Parameters:
a_ViewTableClass -

isUseViewTableAlias

public boolean isUseViewTableAlias()
Gets the value of the attribute: useViewTableAlias.

Supported API: false

Returns:
boolean

setUseViewTableAlias

public void setUseViewTableAlias(boolean a_UseViewTableAlias)
Sets the value of the attribute: useViewTableAlias.

Supported API: false

Parameters:
a_UseViewTableAlias -

isCorrelated

public boolean isCorrelated()
Gets the value of the attribute: correlated.

Supported API: false

Returns:
boolean

setCorrelated

public void setCorrelated(boolean a_Correlated)
Sets the value of the attribute: correlated.

Supported API: false

Parameters:
a_Correlated -

getCorrelatedTable

public TableExpression getCorrelatedTable()
Gets the value of the attribute: correlatedTable.

Supported API: false

Returns:
TableExpression

setCorrelatedTable

public void setCorrelatedTable(TableExpression a_CorrelatedTable)
Sets the value of the attribute: correlatedTable.

Supported API: false

Parameters:
a_CorrelatedTable -

getTargetClass

public Class getTargetClass()
Gets the object for the association that plays role: targetClass.

Supported API: true

Returns:
Class

setTargetClass

public void setTargetClass(Class a_TargetClass)
                    throws WTPropertyVetoException
Sets the object for the association that plays role: targetClass.

Supported API: true

Parameters:
a_TargetClass -
Throws:
WTPropertyVetoException

targetClassValidate

private void targetClassValidate(Class a_TargetClass)
                          throws WTPropertyVetoException
Parameters:
a_TargetClass -
Throws:
WTPropertyVetoException

getFromAlias

public String getFromAlias()


Supported API: false

Returns:
String

getColumnAlias

public String getColumnAlias()
Gets the value of the attribute: columnAlias; Alias for the column expression.

Supported API: true

Specified by:
getColumnAlias in interface ColumnExpression
Returns:
String

setColumnAlias

public void setColumnAlias(String a_ColumnAlias)
                    throws WTPropertyVetoException
Sets the value of the attribute: columnAlias; Alias for the column expression.

Supported API: true

Specified by:
setColumnAlias in interface ColumnExpression
Parameters:
a_ColumnAlias -
Throws:
WTPropertyVetoException

getJavaType

public Class getJavaType()
                  throws WTException
Gets the value of the attribute: javaType; The java type of this expression.

Supported API: false

Specified by:
getJavaType in interface ColumnExpression
Returns:
Class
Throws:
WTException

isAdvancedQuery

public boolean isAdvancedQuery()
                        throws WTException
Gets the value of the attribute: advancedQuery; Indicates if the expression uses advanced query capabilities.

Supported API: false

Specified by:
isAdvancedQuery in interface ColumnExpression
Returns:
boolean
Throws:
WTException

isAdvancedQueryEnabled

public boolean isAdvancedQueryEnabled()
Gets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.

Supported API: false

Specified by:
isAdvancedQueryEnabled in interface ColumnExpression
Returns:
boolean

setAdvancedQueryEnabled

public void setAdvancedQueryEnabled(boolean a_AdvancedQueryEnabled)
Sets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.

Supported API: false

Specified by:
setAdvancedQueryEnabled in interface ColumnExpression
Parameters:
a_AdvancedQueryEnabled -

getFromCount

public int getFromCount()
Gets the value of the attribute: fromCount; Number of from index values that this expression requires

Supported API: false

Specified by:
getFromCount in interface Expression
Returns:
int

validate

public int validate(TableExpression[] a_tableExpressions,
                    int a_offset)
             throws QueryException
This method validates this expression against the specified table expression. A QueryException is thrown if this expression is not valid.

Supported API: false

Specified by:
validate in interface Expression
Parameters:
a_tableExpressions - Table expression to validate against.
a_offset - Offset index into the TableExpression array for the next valid TableExpression
Returns:
number of TableExpressions validated
Throws:
QueryException

setFromAlias

public int setFromAlias(String[] a_aliases,
                        int a_offset)
This method sets the FROM clause alias for this expression. This alias is used in this Expression in place of the corresponding TableExpression.

Supported API: false

Specified by:
setFromAlias in interface Expression
Parameters:
a_aliases - Array of aliases for expressions
a_offset - Offset index into the alias array for the next valid alias
Returns:
number of aliases used

getBindParameter

public Object getBindParameter()
                        throws WTException
Gets the value of the attribute: bindParameter; Returns a bind parameter for this expression (if supported).

Supported API: false

Specified by:
getBindParameter in interface RelationalExpression
Returns:
Object
Throws:
WTException

getExpression

public String getExpression(boolean a_useBind,
                            Vector a_tableInfos,
                            Vector a_aliases,
                            boolean a_outerJoin)
                     throws QueryException
Return string representation of this expression.

Supported API: false

Specified by:
getExpression in interface RelationalExpression
Parameters:
a_useBind - Indicates that bind variables should be used for this expression.
a_tableInfos -
a_aliases -
a_outerJoin - Indicates that outer join syntax should be used for this expression.
Returns:
String
Throws:
QueryException

getClassAttributes

public List getClassAttributes()


Supported API: false

Specified by:
getClassAttributes in interface RelationalExpression
Returns:
List

getActualTargetClass

public Class getActualTargetClass(Vector a_tableInfos,
                                  Vector a_aliases)
                           throws WTException
Throws:
WTException

getTableAliasInView

public String getTableAliasInView(Vector a_tableInfos,
                                  Vector a_aliases)
                           throws WTException
Throws:
WTException

getActualTableAlias

public String getActualTableAlias(Vector a_tableInfos,
                                  Vector a_aliases)
                           throws WTException
Throws:
WTException

toString

public String toString()

getAliasDescriptor

private AliasDescriptor getAliasDescriptor(Class a_class)
                                    throws WTException
Throws:
WTException

validate

private boolean validate(Class a_class,
                         String a_attribute)
                  throws WTException
Throws:
WTException