org.ujoframework.implementation.array
Class ArrayUjo

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
      extended by org.ujoframework.implementation.array.ArrayUjo
All Implemented Interfaces:
java.io.Serializable, UjoCloneable, UjoTextable, Ujo

public abstract class ArrayUjo
extends AbstractUjo
implements java.io.Serializable

This is a very fast abstract implementation of Ujo. For implementation define only a "public static final UjoProperty" constants and a "readPropertyCount()" method in a child class. The code syntax is Java 1.5 complied.
All properties must be objects (no primitive types) in the current version of UJO Framework.
Features: very good performance, an order of properties from "readProperties()" method is guaranteed and independed on a Java implementation.

Sample of usage

 import org.ujoframework.implementation.array.*;
 public class Person extends ArrayUjo {

    protected static int propertyCount = ArrayUjo.propertyCount;

    public static final UjoProperty<Person,String > NAME  = newProperty("name" , String.class , propertyCount++);
    public static final UjoProperty<Person,Boolean> MALE  = newProperty("male" , Boolean.class, propertyCount++);
    public static final UjoProperty<Person,Date   > BIRTH = newProperty("birth", Date.class   , propertyCount++);

    @Override
    public int readPropertyCount() {
        return propertyCount;
    }
 }
 

Author:
Pavel Ponec
See Also:
Property, Serialized Form

Field Summary
protected static int propertyCount
          An Incrementator.
 
Constructor Summary
ArrayUjo()
          Constructor
ArrayUjo(java.lang.Object[] data)
           
 
Method Summary
protected  java.lang.Object[] initData()
          The method is called from top constructor.
protected static
<UJO extends ArrayUjo,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 ArrayUjo,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 ArrayUjo,VALUE>
Property<UJO,VALUE>
newProperty(java.lang.String name, VALUE value, int index)
          A Property Factory Method assigns a next property index.
protected static
<UJO extends ArrayUjo,ITEM>
ListProperty<UJO,ITEM>
newPropertyList_(java.lang.String name, java.lang.Class<ITEM> type, int index)
          Deprecated. Use method newListProperty
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(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(Ujo,Object) to an external access for a better type safe.
 
Methods inherited from class org.ujoframework.extensions.AbstractUjo
clone, 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
 

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
Constructor Detail

ArrayUjo

public ArrayUjo()
Constructor


ArrayUjo

public ArrayUjo(java.lang.Object[] data)
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(Ujo,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(Ujo,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(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(Ujo)

newProperty

public static <UJO extends ArrayUjo,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 ArrayUjo,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 ArrayUjo,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.


newPropertyList_

protected static <UJO extends ArrayUjo,ITEM> ListProperty<UJO,ITEM> newPropertyList_(java.lang.String name,
                                                                                     java.lang.Class<ITEM> type,
                                                                                     int index)
Deprecated. Use method newListProperty

A ListProperty Factory Method assigns a next property index.



Copyright © 2010. All Rights Reserved.