org.ujoframework.extensions
Class AbstractUjo

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
All Implemented Interfaces:
UjoCloneable, UjoTextable, Ujo
Direct Known Subclasses:
AbstractUjoExt, ArrayUjo, BeanUjo, FactoryUjo, FieldUjo, MapImplUjo, MapUjo, QuickUjo

public abstract class AbstractUjo
extends java.lang.Object
implements Ujo, UjoTextable, UjoCloneable

This is a simple abstract implementation of Ujo.
For implementation define only a "public static final UjoProperty" constants in a child class. The code syntax is Java 1.5 complied.

Features: very simple implementaton and a sufficient performance for common tasks. The architecture is useful for a rare assignment of values in object too.

Author:
Pavel Ponec

Constructor Summary
AbstractUjo()
           
 
Method Summary
 java.lang.Object clone(int depth, java.lang.Object context)
          Object is Cloneable
Note: There are supported attributes null value Ujo UjoCloneable List array of privitive values
 boolean equals(java.lang.Object obj)
          Is the object equals to a parameter Ujo?
protected static UjoPropertyList init(java.lang.Class ujoClass)
          Initializa all properties.
protected static UjoPropertyList init(java.lang.Class ujoClass, boolean checkUniqueProperties)
          Initializa all properties.
 boolean readAuthorization(UjoAction action, UjoProperty property, java.lang.Object value)
          Get an authorization of the property for different actions.
 UjoPropertyList readProperties()
          Returns all direct properties.
protected  UjoManager readUjoManager()
          Returns an UjoManager
 java.lang.String readValueString(UjoProperty property, UjoAction action)
          Get an original value in a String format.
 java.lang.String toString()
          A String representation.
 void writeValueString(UjoProperty property, java.lang.String value, java.lang.Class type, UjoAction action)
          Set value from a String format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujoframework.Ujo
readValue, writeValue
 

Constructor Detail

AbstractUjo

public AbstractUjo()
Method Detail

init

protected static final UjoPropertyList init(java.lang.Class ujoClass)
                                     throws java.lang.IllegalStateException
Initializa all properties. If the properties are unlocked than recalculate index and set an undefined property name by its static field.

Parameters:
ujoClass - Ujo class
Throws:
java.lang.IllegalStateException

init

protected static final UjoPropertyList init(java.lang.Class ujoClass,
                                            boolean checkUniqueProperties)
                                     throws java.lang.IllegalStateException
Initializa all properties. If the properties are unlocked than recalculate index and set an undefined property name by its static field.

Parameters:
ujoClass - Ujo class
checkUniqueProperties - Check unique properties
Throws:
java.lang.IllegalStateException

readUjoManager

protected UjoManager readUjoManager()
Returns an UjoManager


readProperties

public UjoPropertyList readProperties()
Returns all direct properties.
Note 1: An order of properties is sorted by a value of the index attribute.
Note 2: The implemetation returns the original property array so it is possible to change some original property in the array from an extefnal code. Overwrite the method to return a copy array in case you need an assurance of immutable!

Specified by:
readProperties in interface Ujo
See Also:
UjoProperty.isDirect()

readAuthorization

public boolean readAuthorization(UjoAction action,
                                 UjoProperty property,
                                 java.lang.Object value)
Get an authorization of the property for different actions.
A Default value is TRUE for all actions, properties and values.

Specified by:
readAuthorization in interface Ujo
Parameters:
action - Type of request. See constant(s) ACTION_* for more information. The action must not be null, however there is allowed to use a dummy constant UjoAction.DUMMY .
property - A property of the Ujo
value - A value
Returns:
Returns TRUE, if property is authorized.
See Also:
Action Constants

equals

public boolean equals(java.lang.Object obj)
Is the object equals to a parameter Ujo?

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
A String representation.

Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone(int depth,
                              java.lang.Object context)
Object is Cloneable
Note: There are supported attributes

readValueString

public java.lang.String readValueString(UjoProperty property,
                                        UjoAction action)
Get an original value in a String format. Property must be an direct type. otherwise method returns an instance of String.

Specified by:
readValueString in interface UjoTextable
Parameters:
property - A direct property only. See a method UjoProperty.isDirect().
action - A context of the action. The action must not be null, however there is allowed to use a dummy constant UjoAction.DUMMY .
Returns:
If property type is "container" then result is null.

writeValueString

public void writeValueString(UjoProperty property,
                             java.lang.String value,
                             java.lang.Class type,
                             UjoAction action)
Set value from a String format. Property must be an direct type.

Specified by:
writeValueString in interface UjoTextable
Parameters:
property - A direct property only. See a method UjoProperty.isDirect().
value - String value
type - Type can be a subtype of a Property.type. If type is null, then a property.type is used.
action - A context of the action. The action must not be null, however there is allowed to use a dummy constant UjoAction.DUMMY .


Copyright © 2010. All Rights Reserved.