velosurf.model
Class Attribute

java.lang.Object
  extended by velosurf.model.Attribute
Direct Known Subclasses:
ExportedKey, ImportedKey

public class Attribute
extends java.lang.Object

This class represents an attribute in the object model.

Author:
Claude Brisson

Field Summary
private  boolean caching
          Caching
protected  Database db
          Database connection.
protected  Entity entity
          Parent entity.
private  java.lang.String foreignKey
          Deprecated.  
private  java.lang.String name
          Name.
private  java.util.List<java.lang.String> paramNames
          List of the parameter names.
protected  java.lang.String query
          Attribute query.
protected  java.lang.String resultEntity
          For row and rowset attributes, the resulting entity (if specified).
static int ROW
          Constant meaning the result is a single row.
static int ROWSET
          Constant meaning the result is a rowset.
static int SCALAR
          Constant meaning the result is a scalar.
private  int type
          Attribute type.
static int UNDEFINED
          Constant meaning the return type is undefined.
 
Constructor Summary
Attribute(java.lang.String name, Entity entity)
          Constructor.
 
Method Summary
 void addParamName(java.lang.String name)
          Adds a parameter name.
private  java.util.List<java.lang.Object> buildArrayList(java.util.Map<java.lang.String,java.lang.Object> source)
          Builds the list of parameter values.
 java.lang.Object evaluate(java.util.Map<java.lang.String,java.lang.Object> source)
          Evaluate this scalar attribute.
 java.lang.Object fetch(java.util.Map<java.lang.String,java.lang.Object> source)
          Fetch a row.
 boolean getCaching()
          Gets caching state
 Database getDB()
          Gets the database connection.
 Entity getEntity()
          Gets the parent entity
 java.lang.String getName()
          Gets the name of this attribute.
protected  java.lang.String getQuery()
           
 java.lang.String getResultEntity()
          Gets the result type.
 int getType()
          Get the type of this attribute.
 RowIterator query(java.util.Map<java.lang.String,java.lang.Object> source)
          Query the resultset for this multivalued attribute.
 RowIterator query(java.util.Map<java.lang.String,java.lang.Object> source, java.util.List refineCriteria, java.lang.String order)
          Query the rowset for this attribute.
 void setCaching(boolean c)
          Sets caching on or off
 void setForeignKeyColumn(java.lang.String col)
          Deprecated. since Velosurf 2.0. Use a <imported-key> tag instead.
 void setQuery(java.lang.String query)
          Sets the query.
 void setResultEntity(java.lang.String entityName)
          Sets the result entity.
 void setResultType(int type)
          Sets the result type.
 java.lang.String toString()
          Debug method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
Constant meaning the return type is undefined.

See Also:
Constant Field Values

ROW

public static final int ROW
Constant meaning the result is a single row.

See Also:
Constant Field Values

ROWSET

public static final int ROWSET
Constant meaning the result is a rowset.

See Also:
Constant Field Values

SCALAR

public static final int SCALAR
Constant meaning the result is a scalar.

See Also:
Constant Field Values

db

protected Database db
Database connection.


name

private java.lang.String name
Name.


entity

protected Entity entity
Parent entity.


resultEntity

protected java.lang.String resultEntity
For row and rowset attributes, the resulting entity (if specified).


foreignKey

private java.lang.String foreignKey
Deprecated. 
If used, name of the foreign key.


paramNames

private java.util.List<java.lang.String> paramNames
List of the parameter names.


query

protected java.lang.String query
Attribute query.


type

private int type
Attribute type.


caching

private boolean caching
Caching

Constructor Detail

Attribute

public Attribute(java.lang.String name,
                 Entity entity)
Constructor.

Parameters:
name - name of this attribute
entity - parent entity
Method Detail

setResultType

public void setResultType(int type)
Sets the result type.

Parameters:
type -

getEntity

public Entity getEntity()
Gets the parent entity

Returns:
parent entity

getResultEntity

public java.lang.String getResultEntity()
Gets the result type.

Returns:
a string describing the result type.

setResultEntity

public void setResultEntity(java.lang.String entityName)
Sets the result entity.

Parameters:
entityName - the name of the result entity.

setForeignKeyColumn

public void setForeignKeyColumn(java.lang.String col)
Deprecated. since Velosurf 2.0. Use a <imported-key> tag instead.

Declares this attribute as a foreign-key and specifies its foreign-key column.

Parameters:
col - the foreign-key column.

addParamName

public void addParamName(java.lang.String name)
Adds a parameter name.

Parameters:
name - name of a parameter.

setQuery

public void setQuery(java.lang.String query)
Sets the query.

Parameters:
query - this attribute's query

fetch

public java.lang.Object fetch(java.util.Map<java.lang.String,java.lang.Object> source)
                       throws java.sql.SQLException
Fetch a row.

Parameters:
source - source object
Returns:
instance fetched
Throws:
java.sql.SQLException - when thrown by the database

query

public RowIterator query(java.util.Map<java.lang.String,java.lang.Object> source)
                  throws java.sql.SQLException
Query the resultset for this multivalued attribute.

Parameters:
source - the source object
Returns:
the resulting row iterator
Throws:
java.sql.SQLException - when thrown from the database

query

public RowIterator query(java.util.Map<java.lang.String,java.lang.Object> source,
                         java.util.List refineCriteria,
                         java.lang.String order)
                  throws java.sql.SQLException
Query the rowset for this attribute.

Parameters:
source - source object
refineCriteria - refine criteria
order - order clause
Returns:
the resulting row iterator
Throws:
java.sql.SQLException - when thrown by the database

evaluate

public java.lang.Object evaluate(java.util.Map<java.lang.String,java.lang.Object> source)
                          throws java.sql.SQLException
Evaluate this scalar attribute.

Parameters:
source - source object
Returns:
the resulting scalar
Throws:
java.sql.SQLException - when thrown from the database

getType

public int getType()
Get the type of this attribute.

Returns:
this attribute's type

buildArrayList

private java.util.List<java.lang.Object> buildArrayList(java.util.Map<java.lang.String,java.lang.Object> source)
                                                 throws java.sql.SQLException
Builds the list of parameter values.

Parameters:
source - source object
Returns:
the built list
Throws:
java.sql.SQLException - thrown by the database engine

getName

public java.lang.String getName()
Gets the name of this attribute.

Returns:
name of the attribute

toString

public java.lang.String toString()
Debug method.

Overrides:
toString in class java.lang.Object
Returns:
the definition string of this attribute

getQuery

protected java.lang.String getQuery()

getDB

public Database getDB()
Gets the database connection.

Returns:
database connection

getCaching

public boolean getCaching()
Gets caching state

Returns:
caching state

setCaching

public void setCaching(boolean c)
Sets caching on or off

Parameters:
c - caching state


~ooOoo~