Business Components

oracle.jbo.server
Class ViewRowImpl

java.lang.Object
  |
  +--oracle.jbo.common.BaseObject
        |
        +--oracle.jbo.server.RowImpl
              |
              +--oracle.jbo.server.ViewRowImpl
Direct Known Subclasses:
EJBEntityImpl

public class ViewRowImpl
extends RowImpl
implements Row

Presents the logical view of a Row returned from the database. This class is the point at which client access is provided, and is as well the point for security access.

A view row represents a set of Entity Objects and some derived data, such as calculated columns.

Since:
JDeveloper 3.0

Fields inherited from class oracle.jbo.server.RowImpl
XML_POSTSTATE_REMOVE, XML_POSTSTATE_TAG
 
Fields inherited from class oracle.jbo.common.BaseObject
TRACE_EVERY_ALLOC, TRACE_NONE, TRACE_OCCASIONAL, TRACE_UNINITIALIZED
 
Fields inherited from interface oracle.jbo.XMLInterface
XML_OPT_CHANGES_ONLY, XML_OPT_LIMIT_RANGE
 
Constructor Summary
ViewRowImpl()
           
 
Method Summary
protected  void appendXMLElementNodes(org.w3c.dom.Document xmlDoc, org.w3c.dom.Node node, int depthCount, long options, AttributeDefImpl[] attrs)
           
protected  void create(AttributeList nvp)
          Initialization method to be over-ridden in generated code for custom defaulting.
protected  EntityImpl[] createEntities()
          Creates blank instances of the Entity Objects that this row is composed of.
 boolean equals(java.lang.Object other)
           
protected  RowSet findAssociatedObjects(java.lang.String name)
          Find Objects in a ViewRowSetImpl that follow the given association.
 ApplicationModule getApplicationModule()
          Gets the Application Module to which the containing View Object belongs.
 java.lang.Object getAttribute(int ix)
          Gets an attribute.
 java.lang.Object getAttribute(java.lang.String name)
          Gets the value of an attribute by name.
 int getAttributeCount()
          Gets the attribute count.
 int getAttributeIndexOf(java.lang.String alias)
          Gets the index of the attribute given it's name.
protected  java.lang.Object getAttributeInternal(int index)
          Get the value of the attribute by index.
protected  EntityImpl getEntity(int index)
          Gets the Entity at the given index.
 Entity getEntityForAttribute(java.lang.String attrName)
          Gets an Entity Object that contains the given attribute name.
 java.lang.Object getHandle()
          Creates a row identifier that is unique in the query collection.
 Key getKey()
          Returns the identifier object for this row.
 QueryCollection getQueryCollection(java.lang.Object accessKey)
           
 ViewObject getViewObject()
          Gets the View Object to which this row belongs.
protected  java.lang.String getXMLElementTag()
           
 int hashCode()
           
 boolean isAttributeUpdateable(int index)
          Tests if an attribute is updateable.
 void lock()
          Locks the row.
protected  void populate(java.sql.ResultSet resultSet)
          Populate this row from the ResultSet.
protected  void populateAttribute(int index, java.lang.Object value)
           
protected  void populateAttributeAsChanged(int index, java.lang.Object value)
           
 void readXML(org.w3c.dom.Element rowElt, int depthCount)
           
 void remove()
          Deletes the row.
 void revert()
          Reverts this row back to its initial state.
 void setAttribute(int index, java.lang.Object val)
          Sets an attribute.
 void setAttribute(java.lang.String name, java.lang.Object val)
          Sets the value of an attribute by name.
protected  void setAttributeInternal(int index, java.lang.Object val)
          This is an "inner" accessor for an attribute and does not call out to the setXXX() method.
protected  void setEntities(EntityImpl[] rows)
          Sets the entities that this view row is composed of.
 void validate()
          Calls validate on each this view row's Entity Objects.
 
Methods inherited from class oracle.jbo.server.RowImpl
createXMLDefinition, getAttributeInternal, printXMLDefinition, readXML, setAttributeInternal, writeXML, writeXML
 
Methods inherited from class oracle.jbo.common.BaseObject
dumpState, setTraceLevel, setTraceWriter
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewRowImpl

public ViewRowImpl()
Method Detail

create

protected void create(AttributeList nvp)
Initialization method to be over-ridden in generated code for custom defaulting. This method invokes create(AttributeList) on each of the "new" entities that makeup this viewrow. The attributelist is simply passed to the new entity rows that make up this viewrow. Caveat- the names in the attributeList are not transformed into entity-relative names hoping that the caller has done so already. If not, entity's create method may fail.
Overrides:
create in class RowImpl

getQueryCollection

public QueryCollection getQueryCollection(java.lang.Object accessKey)

getHandle

public java.lang.Object getHandle()
Creates a row identifier that is unique in the query collection.

Each row in a collection can be identified by either its Java object reference or by its row handle. The row handle, together with the collection name, forms an identifier that can be stored externally, in order to identify the row in future operations.

Applications should not rely on indentifier having a specific format: it is subject to change. A row handle can be converted to a string using toString() methods, and compared using equals()

Returns:
a unique row identifier.

getKey

public Key getKey()
Returns the identifier object for this row.
Specified by:
getKey in interface Row
Overrides:
getKey in class RowImpl
Returns:
The key of the row.

validate

public void validate()
Calls validate on each this view row's Entity Objects.
Specified by:
validate in interface Row
Overrides:
validate in class RowImpl
Throws:
JboException - if validation fails.

getAttributeInternal

protected java.lang.Object getAttributeInternal(int index)
Get the value of the attribute by index. If the attribute is mapped to an entity-attribute, invoke that entity.getAttribute() with the mapped index. For all other attributes, return the value from ViewRow's storage.

Note that this is an "inner" accessor for an attribute and does not callout to the generated getXXX() method on a subclass of a ViewRowImpl. getAttribute() methods are the "outer" methods that callout to a subclass's getXXX() method where XXX is the name of the attribute.

Overrides:
getAttributeInternal in class RowImpl
Parameters:
index - the index of the attribute.
Returns:
the value of the column at the index.

getAttribute

public java.lang.Object getAttribute(int ix)
Gets an attribute.
Parameters:
ix - the attribute's index.
Returns:
the attribute.

getAttribute

public final java.lang.Object getAttribute(java.lang.String name)
Gets the value of an attribute by name.
Parameters:
name - the name of the attribute.
Returns:
the value of the attribute.

setAttribute

public final void setAttribute(java.lang.String name,
                               java.lang.Object val)
Sets the value of an attribute by name.
Parameters:
name - the name of the attribute.
value - the value of the attribute.

setAttribute

public void setAttribute(int index,
                         java.lang.Object val)
Sets an attribute.

This method performs a type-check on the value, so that it matches the Java type of the attribute.

Parameters:
index - the index of the attribute.
value - the new value.
Throws:
ReadOnlyAttrException - if the attribute is not updateable.
InvalidOperException - if this row belongs is to a forward-only View Object.
DataCreationException - if the given value is not convertible to the Java type of the attribute.
AttrSetValException - if any validation logic fails while setting this attribute to the mapped Entity Object attribute.

setAttributeInternal

protected void setAttributeInternal(int index,
                                    java.lang.Object val)
This is an "inner" accessor for an attribute and does not call out to the setXXX() method. This method sets the value to the mapping entity attribute or stores the value in ViewRow cache for the given attribute.

This method also does not perform any type-check for the value's java type and assumes that the value-type is same as the java-type for this attribute.

Overrides:
setAttributeInternal in class RowImpl
Parameters:
index - The index of the attribute.
value - The value.
Throws:
ReadOnlyAttrException - if the attribute is not updateable.
AttrSetValException - if any validation logic fails while setting this attribute to the mapped Entity attribute.

getViewObject

public final ViewObject getViewObject()
Gets the View Object to which this row belongs.
Returns:
the View Object.

getApplicationModule

public final ApplicationModule getApplicationModule()
Gets the Application Module to which the containing View Object belongs.
Returns:
an Application Module.

getAttributeIndexOf

public int getAttributeIndexOf(java.lang.String alias)
Gets the index of the attribute given it's name.
Overrides:
getAttributeIndexOf in class RowImpl
Parameters:
alias - the alias of the attribute.
Returns:
the attribute's index.

createEntities

protected EntityImpl[] createEntities()
Creates blank instances of the Entity Objects that this row is composed of. Advanced method used by subclasses to create their own instances of entities based on custom-logic to bypass entity-creation from the framework.
Returns:
array of EntityImpls that is then set as the array of Entities this ViewRow is composed of.

lock

public void lock()
Locks the row. This method uses design-time metadata to determine which Entity Object's should be locked.
Specified by:
lock in interface Row
Overrides:
lock in class RowImpl
Tags copied from interface: Row
Throws:
JboException, - a runtime exception, if an exception occurs during access.

revert

public void revert()
Reverts this row back to its initial state. If a row is used in multiple View Objects, this operation's effect will be visible to all.

remove

public void remove()
Deletes the row.
Specified by:
remove in interface Row
Overrides:
remove in class RowImpl
Tags copied from interface: Row
Throws:
JboException, - a runtime exception, if an exception occurs during access.

getEntity

protected final EntityImpl getEntity(int index)
Gets the Entity at the given index. Used in generated code for viewrow to get to the attribute mapped to an entity.
Parameters:
index - the index of the Entity.

getEntityForAttribute

public final Entity getEntityForAttribute(java.lang.String attrName)
Gets an Entity Object that contains the given attribute name.

setEntities

protected final void setEntities(EntityImpl[] rows)
Sets the entities that this view row is composed of. Called by framework, after entites are created for this row. Need to make this protected as, subclasses can create their own entity instances and have the viewrow manage them. e.g., In case of a ViewRow on Doc Entity where Doc has subclasses PO and Req, the ViewRow subclas can create PO/Req instances of entities based on some logic and have ViewRow manage them as an entity of type Doc.

getAttributeCount

public final int getAttributeCount()
Gets the attribute count.
Overrides:
getAttributeCount in class RowImpl
Returns:
the number of attributes.

isAttributeUpdateable

public boolean isAttributeUpdateable(int index)
Description copied from interface: Row
Tests if an attribute is updateable.
Specified by:
isAttributeUpdateable in interface Row
Overrides:
isAttributeUpdateable in class RowImpl
Tags copied from interface: Row
Parameters:
index - the index of the attribute.
Returns:
true if the row is marked udpateable, or if the row is marked udpateable_while_new and the current row is new.

populate

protected void populate(java.sql.ResultSet resultSet)
Populate this row from the ResultSet. This is a Framework-internal method. This method is used to fill in entity-attributes from a jdbc resultset that's returned by executeQuery. Note that the method works on the current row of the result set and any currecy change on the resultset could throw us off. This method is protected to let sub-ViewRows fill in custom-entities created based on data. e.g., if fax is a subtype of doc and based on a column value, either doc is created or a fax is created for a given entity type, this method may be used to create entities based on the data values. Note that the developer needs to know exact position of values in the jdbc=result set.
Parameters:
resultSet - the JDBC ResultSet containing the row data.

populateAttribute

protected void populateAttribute(int index,
                                 java.lang.Object value)
Overrides:
populateAttribute in class RowImpl

populateAttributeAsChanged

protected void populateAttributeAsChanged(int index,
                                          java.lang.Object value)

findAssociatedObjects

protected RowSet findAssociatedObjects(java.lang.String name)
Find Objects in a ViewRowSetImpl that follow the given association.
Parameters:
name - that defines the association
Returns:
A set of associated object/s.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

getXMLElementTag

protected java.lang.String getXMLElementTag()

appendXMLElementNodes

protected void appendXMLElementNodes(org.w3c.dom.Document xmlDoc,
                                     org.w3c.dom.Node node,
                                     int depthCount,
                                     long options,
                                     AttributeDefImpl[] attrs)

readXML

public final void readXML(org.w3c.dom.Element rowElt,
                          int depthCount)
Overrides:
readXML in class RowImpl

Business Components