org.ujoframework.core
Class UjoManager

java.lang.Object
  extended by org.ujoframework.core.UjoManager
All Implemented Interfaces:
java.util.Comparator<UjoProperty>

public class UjoManager
extends java.lang.Object
implements java.util.Comparator<UjoProperty>

General Ujo Manager

Author:
Pavel Ponec

Field Summary
protected static UjoManager instance
          UjoManager instance
static int PROPERTY_MODIFIER
          Requested modifier of property definitions.
 
Constructor Summary
UjoManager()
          Constructor.
 
Method Summary
 boolean assertAssign(UjoProperty property, java.lang.Object value)
          An assignable test.
 boolean assertDirect(UjoProperty property, java.lang.Object value)
          An assignable test.
 boolean assertDirectAssign(UjoProperty property, java.lang.Object value)
          An assignable test.
 Ujo clone(Ujo ujo, int depth, java.lang.Object context)
          Clone the UjoCloneable object.
 int compare(UjoProperty p1, UjoProperty p2)
          Compare Ujo properties.
 void copy(Ujo source, Ujo target)
          Copy ALL properties of the source to target.
 void copy(Ujo source, Ujo target, UjoAction action, UjoProperty... properties)
          Copy selected properties from source to target.
 void copy(Ujo source, Ujo target, UjoProperty... properties)
          Copy selected properties of the source to target.
 java.util.List<UjoPropertyRow> createPropertyList(Ujo content, UjoAction action)
          Create a list of UjoPropertyList
 java.lang.Object decodeValue(java.lang.Class type, java.lang.String aValue)
          Decode text value
 java.lang.Object decodeValue(UjoProperty property, java.lang.String aValue)
          Decode text value
 java.lang.Object decodeValue(UjoProperty property, java.lang.String aValue, java.lang.Class type)
          Decode text value
 java.lang.String encodeValue(java.lang.Object value, boolean regenerationTest)
          Convert value to a String representation.
 boolean equals(java.lang.Object o1, java.lang.Object o2)
          Test if Object o1 equalsUjo o2.
 boolean equalsArray(java.lang.Object array1, java.lang.Object array2)
          Test if array1 equalsUjo to array2.
 boolean equalsUjo(Ujo u1, Ujo u2)
          Test if obj1 equalsUjo obj2.
 boolean equalsUjo(Ujo u1, Ujo u2, UjoPropertyList properties)
          Test if obj1 equalsUjo obj2.
 UjoProperty findIndirectProperty(java.lang.Class ujoType, java.lang.String names)
          Find indirect property by the name
 UjoProperty findProperty(Ujo ujo, java.lang.String name, boolean throwException)
          Deprecated. Use UjoPropertyList.findPropety(...)
 UjoProperty findProperty(Ujo ujo, java.lang.String name, UjoAction action, boolean result, boolean throwException)
          Find a property by property name from parameter.
 UjoCoder getCoder()
          UjoCoder
 int getHash(Ujo ujo)
          Calculate a Hash Code.
 int getHash(Ujo ujo, UjoPropertyList properties)
          Calculate a Hash Code.
static UjoManager getInstance()
          Get a default initialization
 java.lang.reflect.Field getPropertyField(java.lang.Class type, UjoProperty property)
          Get a UjoProperty field.
 java.lang.reflect.Field getPropertyField(Ujo ujo, UjoProperty property)
          Get a UjoProperty field.
 java.lang.String getText(Ujo ujo, UjoProperty property, UjoAction action)
          Get a text value from property
<VALUE> VALUE
getValue(Ujo ujo, UjoProperty... props)
          Get a value from an Ujo object by a chain of properties.
static java.lang.Object getValue(Ujo ujo, UjoProperty prop)
          Deprecated. Use a expression prop.of(ujo) rather.
 UjoProperty getXmlElementBody(java.lang.Class type)
          Returns a Element body of the class or the null if no property was found.
 void checkUniqueProperties(java.lang.Class<? extends Ujo> type)
          Check ujo properties to a unique name.
protected  void checkUniqueProperties(java.lang.Class<? extends Ujo> type, boolean enabled)
          Check ujo properties to a unique name.
protected  boolean isAbstract(java.lang.Class type)
          Returns true, if the class is abstract.
 boolean isPropertiesReversed()
          Are properties reversed by default?
 boolean isTransientProperty(UjoProperty property)
          Is the property an Transient?
static boolean isUsable(java.lang.CharSequence text)
          Returns true, if text is not null and is not empty.
 boolean isXmlAttribute(UjoProperty property)
          Is the property an XML attribute?
static void main(java.lang.String[] args)
          Show an information about the framework
static java.lang.String projectInfo()
          Regurns information about current library.
static java.lang.String projectVersion()
          Regurns information about current library.
 UjoPropertyList readProperties(java.lang.Class type)
          Read all properties.
 UjoProperty[] readPropertiesNocache(java.lang.Class type, boolean sorted)
          Returns all direct properties (see an method UjoProperty.isDirect() for more information).
 void revertArray(java.lang.Object[] array)
          Returns a reversed order of objects.
 void setCoder(UjoCoder ujoCoder)
          UjoCoder
 void setText(Ujo ujo, UjoProperty property, java.lang.String value, java.lang.Class type, UjoAction action)
          Set a text value by property.
 Ujo setValue(Ujo ujo, UjoPropertyList props, java.lang.Object value)
          Set a value to an Ujo object by a chain of properties.
static void setValue(Ujo ujo, UjoProperty prop, java.lang.Object value)
          Set a value to an Ujo object by a selected properties.
protected  void sortProperties(java.lang.Class type, UjoProperty[] properties)
          Sort properties.
 java.lang.String toString(Ujo ujo)
          Print a String representation
 java.lang.String toString(Ujo ujo, UjoPropertyList properties)
          Print a String representation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

PROPERTY_MODIFIER

public static final int PROPERTY_MODIFIER
Requested modifier of property definitions.

See Also:
Constant Field Values

instance

protected static UjoManager instance
UjoManager instance

Constructor Detail

UjoManager

public UjoManager()
Constructor.

Method Detail

getInstance

public static final UjoManager getInstance()
Get a default initialization


revertArray

public void revertArray(java.lang.Object[] array)
Returns a reversed order of objects.


isPropertiesReversed

public boolean isPropertiesReversed()
Are properties reversed by default?


isAbstract

protected boolean isAbstract(java.lang.Class type)
Returns true, if the class is abstract.


readProperties

public UjoPropertyList readProperties(java.lang.Class type)
Read all properties. The first result is cached.


readPropertiesNocache

public UjoProperty[] readPropertiesNocache(java.lang.Class type,
                                           boolean sorted)
                                    throws java.lang.IllegalStateException
Returns all direct properties (see an method UjoProperty.isDirect() for more information).

Parameters:
type - Ujo class
sorted - I want to sortd the result by a natural order.
Returns:
Array of Properties
Throws:
java.lang.IllegalStateException

compare

public int compare(UjoProperty p1,
                   UjoProperty p2)
Compare Ujo properties. An undefined property indexes (-1 are sorted to the end.

Specified by:
compare in interface java.util.Comparator<UjoProperty>

sortProperties

protected void sortProperties(java.lang.Class type,
                              UjoProperty[] properties)
Sort properties.


getHash

public int getHash(Ujo ujo)
Calculate a Hash Code.


getHash

public int getHash(Ujo ujo,
                   UjoPropertyList properties)
Calculate a Hash Code.


equals

public boolean equals(java.lang.Object o1,
                      java.lang.Object o2)
Test if Object o1 equalsUjo o2.

Parameters:
o1 - First parameter
o2 - Second parameter
Returns:
Returns true, if objects are the same.

equalsUjo

public boolean equalsUjo(Ujo u1,
                         Ujo u2)
Test if obj1 equalsUjo obj2. If obj1 object is Array, method call an equalsArray() method, else use en method equalsUjo().

Parameters:
u1 - First parameter
u2 - Optional parameter
Returns:
Returns true, if objects are the same.

equalsUjo

public boolean equalsUjo(Ujo u1,
                         Ujo u2,
                         UjoPropertyList properties)
Test if obj1 equalsUjo obj2. If obj1 object is Array, method call an equalsArray() method, else use en method equalsUjo().

Parameters:
u1 - First parameter
u2 - Optional parameter
Returns:
Returns true, if objects are the same.

equalsArray

public boolean equalsArray(java.lang.Object array1,
                           java.lang.Object array2)
Test if array1 equalsUjo to array2. There are supported types:

Parameters:
array1 - Mandatory parameter
array2 - Optional parameter
Returns:
Returns true, if two objects are the same.

clone

public Ujo clone(Ujo ujo,
                 int depth,
                 java.lang.Object context)
          throws java.lang.IllegalStateException
Clone the UjoCloneable object. The Object and its items must have got a constructor with no parameters.
Note: There are supported attributes

findProperty

public UjoProperty findProperty(Ujo ujo,
                                java.lang.String name,
                                boolean throwException)
                         throws java.lang.IllegalArgumentException
Deprecated. Use UjoPropertyList.findPropety(...)

Find a property by property name from parameter. Use rather the UjoPropertyList.findPropety(...).

Parameters:
ujo - An Ujo object
name - A property name.
throwException - If result not found an Exception is throwed, or a null can be returned.
Throws:
java.lang.IllegalArgumentException
See Also:
UjoPropertyList.find(org.ujoframework.Ujo, java.lang.String, boolean)

findProperty

public UjoProperty findProperty(Ujo ujo,
                                java.lang.String name,
                                UjoAction action,
                                boolean result,
                                boolean throwException)
                         throws java.lang.IllegalArgumentException
Find a property by property name from parameter. Use rather the UjoPropertyList.findPropety(...).

Parameters:
ujo - An Ujo object
name - A property name.
action - Action type UjoAction.ACTION_* .
result - Required result of action.
throwException - If result not found an Exception is throwed, or a null can be returned.
Throws:
java.lang.IllegalArgumentException
See Also:
UjoPropertyList.find(java.lang.String, boolean)

findIndirectProperty

public UjoProperty findIndirectProperty(java.lang.Class ujoType,
                                        java.lang.String names)
Find indirect property by the name


toString

public java.lang.String toString(Ujo ujo)
Print a String representation


toString

public java.lang.String toString(Ujo ujo,
                                 UjoPropertyList properties)
Print a String representation


isUsable

public static boolean isUsable(java.lang.CharSequence text)
Returns true, if text is not null and is not empty.


getXmlElementBody

public final UjoProperty getXmlElementBody(java.lang.Class type)
Returns a Element body of the class or the null if no property was found.


isXmlAttribute

public final boolean isXmlAttribute(UjoProperty property)
Is the property an XML attribute?


isTransientProperty

public final boolean isTransientProperty(UjoProperty property)
Is the property an Transient?


decodeValue

public final java.lang.Object decodeValue(UjoProperty property,
                                          java.lang.String aValue,
                                          java.lang.Class type)
Decode text value

Parameters:
property - Property is used for a result class
aValue - Text value to decode.
type - Optional subtype class of the property type.
Returns:
Instance of new result.

decodeValue

public final java.lang.Object decodeValue(UjoProperty property,
                                          java.lang.String aValue)
Decode text value

Parameters:
property - Property is used for a result class
aValue - Text value to decode.
Returns:
Instance of new result.

decodeValue

public final java.lang.Object decodeValue(java.lang.Class type,
                                          java.lang.String aValue)
Decode text value

Parameters:
type - Parameter is used for a result class.
aValue - Text value to decode.
Returns:
Instance of new result.

encodeValue

public final java.lang.String encodeValue(java.lang.Object value,
                                          boolean regenerationTest)
Convert value to a String representation.


assertDirectAssign

public boolean assertDirectAssign(UjoProperty property,
                                  java.lang.Object value)
                           throws java.lang.IllegalArgumentException
An assignable test.

Throws:
java.lang.IllegalArgumentException

assertDirect

public boolean assertDirect(UjoProperty property,
                            java.lang.Object value)
                     throws java.lang.IllegalArgumentException
An assignable test.

Throws:
java.lang.IllegalArgumentException

assertAssign

public boolean assertAssign(UjoProperty property,
                            java.lang.Object value)
                     throws java.lang.IllegalArgumentException
An assignable test.

Throws:
java.lang.IllegalArgumentException

setValue

public static void setValue(Ujo ujo,
                            UjoProperty prop,
                            java.lang.Object value)
Set a value to an Ujo object by a selected properties.


setValue

public Ujo setValue(Ujo ujo,
                    UjoPropertyList props,
                    java.lang.Object value)
             throws java.lang.IllegalArgumentException
Set a value to an Ujo object by a chain of properties.
Type of value is checked in the runtime.

Throws:
java.lang.IllegalArgumentException

getValue

@Deprecated
public static java.lang.Object getValue(Ujo ujo,
                                                   UjoProperty prop)
Deprecated. Use a expression prop.of(ujo) rather.

Get a value from an Ujo object by a selected property. If a not getLastProperty value is null, then is throwded a NullPointe exception.


getValue

public <VALUE> VALUE getValue(Ujo ujo,
                              UjoProperty... props)
Get a value from an Ujo object by a chain of properties. If a not getLastProperty value is null, then is throwded a NullPointe exception.


getCoder

public UjoCoder getCoder()
UjoCoder


setCoder

public void setCoder(UjoCoder ujoCoder)
UjoCoder


getText

public java.lang.String getText(Ujo ujo,
                                UjoProperty property,
                                UjoAction action)
Get a text value from property


setText

public void setText(Ujo ujo,
                    UjoProperty property,
                    java.lang.String value,
                    java.lang.Class type,
                    UjoAction action)
Set a text value by property. The method recognise an UjoTextable object.

Parameters:
ujo - Ujo
property - Direct property
value - Value
type - Subtype of value
action - Context action

createPropertyList

public java.util.List<UjoPropertyRow> createPropertyList(Ujo content,
                                                         UjoAction action)
Create a list of UjoPropertyList


copy

public void copy(Ujo source,
                 Ujo target,
                 UjoAction action,
                 UjoProperty... properties)
Copy selected properties from source to target.

Parameters:
source - Source UJO
target - Target UJO
action - An action of source.
properties - If the value is null, then all properties of source will be used.

copy

public void copy(Ujo source,
                 Ujo target,
                 UjoProperty... properties)
Copy selected properties of the source to target. An action is ACTION_COPY, an context is UjoManager.

Parameters:
source - Source UJO
target - Target UJO
properties - If the value is null, then all properties of source will be used.

copy

public void copy(Ujo source,
                 Ujo target)
Copy ALL properties of the source to target. An action is ACTION_COPY, an context is UjoManager.

Parameters:
source - Source UJO
target - Target UJO

getPropertyField

public java.lang.reflect.Field getPropertyField(Ujo ujo,
                                                UjoProperty property)
Get a UjoProperty field.


getPropertyField

public java.lang.reflect.Field getPropertyField(java.lang.Class type,
                                                UjoProperty property)
Get a UjoProperty field.


checkUniqueProperties

protected void checkUniqueProperties(java.lang.Class<? extends Ujo> type,
                                     boolean enabled)
                              throws java.lang.IllegalStateException
Check ujo properties to a unique name. There is recommended to calll the method from static block after UjoProperty initialization. The beneficial side effect is loading a property cache.

Throws:
java.lang.IllegalStateException - If an duplicity is found than an exception is throwed.

checkUniqueProperties

public void checkUniqueProperties(java.lang.Class<? extends Ujo> type)
                           throws java.lang.IllegalStateException
Check ujo properties to a unique name. There is recommended to calll the method from static block after UjoProperty initialization. The beneficial side effect is loading a property cache.

Throws:
java.lang.IllegalStateException - If an duplicity is found than an exception is throwed.

projectInfo

public static java.lang.String projectInfo()
Regurns information about current library.


projectVersion

public static java.lang.String projectVersion()
Regurns information about current library.


main

public static void main(java.lang.String[] args)
Show an information about the framework



Copyright © 2010. All Rights Reserved.