org.ujoframework.implementation.array
Class ArrayUjoExt<UJO extends ArrayUjoExt>

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
      extended by org.ujoframework.extensions.AbstractUjoExt<UJO>
          extended by org.ujoframework.implementation.array.ArrayUjoExt<UJO>
All Implemented Interfaces:
java.io.Serializable, UjoCloneable, UjoExt<UJO>, UjoMiddle<UJO>, UjoTextable, Ujo

public abstract class ArrayUjoExt<UJO extends ArrayUjoExt>
extends AbstractUjoExt<UJO>
implements java.io.Serializable

This is an Groovy style implementation of a setter and getter methods for an easier access for developpers, however the methods have got an weaker type control in compare to the MapUjo implementation.
Sample of usage:

public class Person extends ArrayUjoExt<Person> {

  public static final UjoProperty<Person, String > NAME = newProperty("Name" , String.class, propertyCount++);
  public static final UjoProperty<Person, Double > CASH = newProperty("Cash" , Double.class, propertyCount++);
  public static final UjoProperty<Person, Person> CHILD = newProperty("Child", Person.class, propertyCount++);
    
  public void init() {
    set(NAME, "George");
    set(CHILD, new Person());
    set(CHILD, NAME, "Jane");
    set(CHILD, CASH, 200d);
        
    String name = get(CHILD, NAME);
    double cash = get(CHILD, CASH);
  }
}

Since:
UJO release 0.80
Author:
Pavel Ponec
See Also:
Property, Serialized Form

Field Summary
protected  java.lang.Object[] data
          Object data
protected static int propertyCount
          An Incrementator.
 
Constructor Summary
ArrayUjoExt()
          Constructor
 
Method Summary
protected  java.lang.Object[] initData()
          The method is called from top constructor.
protected static
<UJO extends ArrayUjoExt,ITEM>
ListProperty<UJO,ITEM>
newListProperty(java.lang.String name, java.lang.Class<ITEM> type, int index)
          A ListProperty Factory Method assigns a next property index.
static
<UJO extends ArrayUjoExt,VALUE>
Property<UJO,VALUE>
newProperty(java.lang.String name, java.lang.Class<VALUE> type, int index)
          Returns a new instance of property where the default value is null.
protected static
<UJO extends ArrayUjoExt,VALUE>
Property<UJO,VALUE>
newProperty(java.lang.String name, VALUE value, int index)
          A Property Factory Method assigns a next property index.
abstract  int readPropertyCount()
          Return a count of properties.
 java.lang.Object readValue(UjoProperty property)
          It is a common method for reading all object values, however there is strongly recomended to use a method Property.getValue(org.ujoframework.Ujo) to an external access for a better type safe.
 void writeValue(UjoProperty property, java.lang.Object value)
          It is a common method for writing all object values, however there is strongly recomended to use a method Property.setValue(org.ujoframework.Ujo, java.lang.Object) to an external access for a better type safe.
 
Methods inherited from class org.ujoframework.extensions.AbstractUjoExt
add, clone, copyTo, copyTo, createPropertyList, equals, findProperty, get, get, get, get, getItemCount, getText, isDefault, list, remove, remove, set, set, set, set, setText
 
Methods inherited from class org.ujoframework.extensions.AbstractUjo
equals, init, init, readAuthorization, readProperties, readUjoManager, readValueString, toString, writeValueString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujoframework.Ujo
readAuthorization, readProperties
 

Field Detail

propertyCount

protected static final int propertyCount
An Incrementator. Use a new counter for each subclass by sample:
 /** An Incrementator. Use a new counter for each subclass. */
 protected static int propertyCount = [SuperClass].propertyCount;

See Also:
Constant Field Values

data

protected java.lang.Object[] data
Object data

Constructor Detail

ArrayUjoExt

public ArrayUjoExt()
Constructor

Method Detail

initData

protected java.lang.Object[] initData()
The method is called from top constructor.


readPropertyCount

public abstract int readPropertyCount()
Return a count of properties.


writeValue

public void writeValue(UjoProperty property,
                       java.lang.Object value)
It is a common method for writing all object values, however there is strongly recomended to use a method Property.setValue(org.ujoframework.Ujo, java.lang.Object) to an external access for a better type safe. The method have got a strategy place for an implementation of several listeners and validators.
NOTE: If property is an incorrect then method can throws an ArrayIndexOutOfBoundsException.

Specified by:
writeValue in interface Ujo
Parameters:
property - Property must be a direct type only!
See Also:
Property.setValue(org.ujoframework.Ujo, java.lang.Object)

readValue

public java.lang.Object readValue(UjoProperty property)
It is a common method for reading all object values, however there is strongly recomended to use a method Property.getValue(org.ujoframework.Ujo) to an external access for a better type safe. The method have got a strategy place for an implementation of several listeners and convertors.
NOTE: If property is an incorrect then method can throws an ArrayIndexOutOfBoundsException.

Specified by:
readValue in interface Ujo
Parameters:
property - Property must be a direct type only!
Returns:
Property value
See Also:
Property.getValue(org.ujoframework.Ujo)

newProperty

public static <UJO extends ArrayUjoExt,VALUE> Property<UJO,VALUE> newProperty(java.lang.String name,
                                                                              java.lang.Class<VALUE> type,
                                                                              int index)
Returns a new instance of property where the default value is null. Method assigns a next property index.


newProperty

protected static <UJO extends ArrayUjoExt,VALUE> Property<UJO,VALUE> newProperty(java.lang.String name,
                                                                                 VALUE value,
                                                                                 int index)
A Property Factory Method assigns a next property index.


newListProperty

protected static <UJO extends ArrayUjoExt,ITEM> ListProperty<UJO,ITEM> newListProperty(java.lang.String name,
                                                                                       java.lang.Class<ITEM> type,
                                                                                       int index)
A ListProperty Factory Method assigns a next property index.



Copyright © 2010. All Rights Reserved.