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
protected  Database db
          database connection
protected  Entity entity
          parent entity
protected  java.lang.String foreignKey
          if used, name of the foreign key
protected  java.lang.String name
          name
protected  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
protected  int type
          attribute type
static int UNDEFINED
          constant meaning the return type is undefined
 
Constructor Summary
Attribute(java.lang.String name, Entity entity)
           
 
Method Summary
 void addParamName(java.lang.String name)
           
 java.util.List buildArrayList(ReadOnlyMap source)
          builds the list of parameter values - do not use directly
 java.lang.Object evaluate(ReadOnlyMap source)
          evaluate this scalar attribute
 java.lang.Object fetch(ReadOnlyMap source)
          fetch the row result of this attribute
 Database getDB()
          gets the database connection
 java.lang.String getName()
          gets the name of the attribute
protected  java.lang.String getQuery()
           
 java.lang.String getResultEntity()
           
 int getType()
          gets the type of this attribute
 RowIterator query(ReadOnlyMap source)
          query the resultset for this multivalued attribute
 RowIterator query(ReadOnlyMap source, java.util.List refineCriteria, java.lang.String order)
          query the rowset for this attribute
 void setForeignKeyColumn(java.lang.String col)
           
 void setQuery(java.lang.String query)
           
 void setResultEntity(java.lang.String entityName)
           
 void setResultType(int 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

protected 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

protected java.lang.String foreignKey
if used, name of the foreign key


paramNames

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


query

protected java.lang.String query
attribute query


type

protected int type
attribute type

Constructor Detail

Attribute

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

setResultType

public void setResultType(int type)

getResultEntity

public java.lang.String getResultEntity()

setResultEntity

public void setResultEntity(java.lang.String entityName)

setForeignKeyColumn

public void setForeignKeyColumn(java.lang.String col)

addParamName

public void addParamName(java.lang.String name)

setQuery

public void setQuery(java.lang.String query)

fetch

public java.lang.Object fetch(ReadOnlyMap source)
                       throws java.sql.SQLException
fetch the row result of this attribute

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

query

public RowIterator query(ReadOnlyMap 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(ReadOnlyMap 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(ReadOnlyMap 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()
gets the type of this attribute

Returns:
this attribute's type

buildArrayList

public java.util.List buildArrayList(ReadOnlyMap source)
                              throws java.sql.SQLException
builds the list of parameter values - do not use directly

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 the 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()
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

getDB

public Database getDB()
gets the database connection

Returns:
database connection


~ooOoo~