org.ujoframework.extensions
Class AbstractUjoExt<UJO_IMPL extends UjoExt>

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
      extended by org.ujoframework.extensions.AbstractUjoExt<UJO_IMPL>
All Implemented Interfaces:
UjoCloneable, UjoExt<UJO_IMPL>, UjoMiddle<UJO_IMPL>, UjoTextable, Ujo
Direct Known Subclasses:
ArrayUjoExt, BeanUjoExt, FieldUjoExt, MapUjoExt

public abstract class AbstractUjoExt<UJO_IMPL extends UjoExt>
extends AbstractUjo
implements UjoExt<UJO_IMPL>

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
AbstractUjoExt()
           
 
Method Summary
<UJO extends UJO_IMPL,ITEM>
UJO_IMPL
add(ListUjoProperty<UJO,ITEM> property, ITEM value)
          Add Value, if the List is null then the list will be created.
 UJO_IMPL clone(int depth, java.lang.Object context)
          Clone the UjoCloneable object.
 void copyTo(Ujo target, java.lang.Object context)
          Copy all attributes to the target
 void copyTo(Ujo target, UjoProperty... properties)
          Copy selected attributes to the target
 java.util.List<UjoPropertyRow> createPropertyList()
          Create a list of UjoProperty.
<UJO extends UJO_IMPL,VALUE>
boolean
equals(UjoProperty<UJO,VALUE> property, VALUE value)
          Compare the property value with a parametrer value.
 UjoProperty findProperty(java.lang.String propertyName)
          Find a property by a "property name".
<UJO extends UJO_IMPL,ITEM>
ITEM
get(ListUjoProperty<UJO,ITEM> property, int index)
          Get Value
Inside is called a method ListUjoPropertyCommon.getItem(...) internally.
<UJO1 extends UJO_IMPL,UJO2 extends Ujo,UJO3 extends Ujo,VALUE>
VALUE
get(UjoProperty<UJO1,UJO2> property1, UjoProperty<UJO2,UJO3> property2, UjoProperty<UJO3,VALUE> property3)
          Getter based on three properties
<UJO1 extends UJO_IMPL,UJO2 extends Ujo,VALUE>
VALUE
get(UjoProperty<UJO1,UJO2> property1, UjoProperty<UJO2,VALUE> property2)
          Getter based on two properties
<UJO extends UJO_IMPL,VALUE>
VALUE
get(UjoProperty<UJO,VALUE> property)
          Getter based on one UjoProperty
<UJO extends UJO_IMPL,ITEM>
int
getItemCount(ListUjoProperty<UJO,ITEM> property)
          Returns a count of Items.
 java.lang.String getText(UjoProperty property)
          Returns a String value by a NULL context.
<UJO extends UJO_IMPL,VALUE>
boolean
isDefault(UjoProperty<UJO,VALUE> property)
          Indicates whether a parameter value "equal to" property default value.
<UJO extends UJO_IMPL,LIST extends java.util.List<ITEM>,ITEM>
LIST
list(ListUjoProperty<UJO,ITEM> property)
          Returns a not null List.
<UJO extends UJO_IMPL,ITEM>
ITEM
remove(ListUjoProperty<UJO,ITEM> property, int index)
          Remove an item from the List by an index.
<UJO extends UJO_IMPL,ITEM>
boolean
remove(ListUjoProperty<UJO,ITEM> property, ITEM item)
          Removes the first occurrence in this list of the specified element.
<UJO extends UJO_IMPL,ITEM>
UJO_IMPL
set(ListUjoProperty<UJO,ITEM> property, int index, ITEM value)
          Add Value, if the List is null then the list will be created.
<UJO1 extends UJO_IMPL,UJO2 extends Ujo,UJO3 extends Ujo,VALUE>
void
set(UjoProperty<UJO1,UJO2> property1, UjoProperty<UJO2,UJO3> property2, UjoProperty<UJO3,VALUE> property3, VALUE value)
          Setter based on three properties.
<UJO1 extends UJO_IMPL,UJO2 extends Ujo,VALUE>
void
set(UjoProperty<UJO1,UJO2> property1, UjoProperty<UJO2,VALUE> property2, VALUE value)
          Setter based on two properties.
<UJO extends UJO_IMPL,VALUE>
UJO_IMPL
set(UjoProperty<UJO,VALUE> property, VALUE value)
          Setter based on UjoProperty.
 void setText(UjoProperty property, java.lang.String value)
          Set value from a String format by a NULL context.
 
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, readValue, writeValue
 

Constructor Detail

AbstractUjoExt

public AbstractUjoExt()
Method Detail

get

public <UJO extends UJO_IMPL,VALUE> VALUE get(UjoProperty<UJO,VALUE> property)
Getter based on one UjoProperty

Specified by:
get in interface UjoMiddle<UJO_IMPL extends UjoExt>

get

public <UJO1 extends UJO_IMPL,UJO2 extends Ujo,VALUE> VALUE get(UjoProperty<UJO1,UJO2> property1,
                                                                UjoProperty<UJO2,VALUE> property2)
Getter based on two properties

Specified by:
get in interface UjoExt<UJO_IMPL extends UjoExt>

get

public <UJO1 extends UJO_IMPL,UJO2 extends Ujo,UJO3 extends Ujo,VALUE> VALUE get(UjoProperty<UJO1,UJO2> property1,
                                                                                 UjoProperty<UJO2,UJO3> property2,
                                                                                 UjoProperty<UJO3,VALUE> property3)
Getter based on three properties

Specified by:
get in interface UjoExt<UJO_IMPL extends UjoExt>

set

public <UJO extends UJO_IMPL,VALUE> UJO_IMPL set(UjoProperty<UJO,VALUE> property,
                                                 VALUE value)
Setter based on UjoProperty. Type of value is checked in the runtime.

Specified by:
set in interface UjoMiddle<UJO_IMPL extends UjoExt>

set

public <UJO1 extends UJO_IMPL,UJO2 extends Ujo,VALUE> void set(UjoProperty<UJO1,UJO2> property1,
                                                               UjoProperty<UJO2,VALUE> property2,
                                                               VALUE value)
Setter based on two properties. Type of value is checked in the runtime.

Specified by:
set in interface UjoExt<UJO_IMPL extends UjoExt>

set

public <UJO1 extends UJO_IMPL,UJO2 extends Ujo,UJO3 extends Ujo,VALUE> void set(UjoProperty<UJO1,UJO2> property1,
                                                                                UjoProperty<UJO2,UJO3> property2,
                                                                                UjoProperty<UJO3,VALUE> property3,
                                                                                VALUE value)
Setter based on three properties. Type of value is checked in the runtime.

Specified by:
set in interface UjoExt<UJO_IMPL extends UjoExt>

getItemCount

public <UJO extends UJO_IMPL,ITEM> int getItemCount(ListUjoProperty<UJO,ITEM> property)
Returns a count of Items. If the property is null, method returns 0.
Inside is called a method ListUjoPropertyCommon.getItemCount() internally.

Specified by:
getItemCount in interface UjoExt<UJO_IMPL extends UjoExt>

add

public <UJO extends UJO_IMPL,ITEM> UJO_IMPL add(ListUjoProperty<UJO,ITEM> property,
                                                ITEM value)
Add Value, if the List is null then the list will be created.
Inside is called a method ListUjoPropertyCommon.addItem(...) internally.

Specified by:
add in interface UjoExt<UJO_IMPL extends UjoExt>

set

public <UJO extends UJO_IMPL,ITEM> UJO_IMPL set(ListUjoProperty<UJO,ITEM> property,
                                                int index,
                                                ITEM value)
Add Value, if the List is null then the list will be created.
Inside is called a method ListUjoPropertyCommon.setItem(...) internally.

Specified by:
set in interface UjoExt<UJO_IMPL extends UjoExt>

get

public <UJO extends UJO_IMPL,ITEM> ITEM get(ListUjoProperty<UJO,ITEM> property,
                                            int index)
Get Value
Inside is called a method ListUjoPropertyCommon.getItem(...) internally.

Specified by:
get in interface UjoExt<UJO_IMPL extends UjoExt>

remove

public <UJO extends UJO_IMPL,ITEM> ITEM remove(ListUjoProperty<UJO,ITEM> property,
                                               int index)
Remove an item from the List by an index.

Specified by:
remove in interface UjoExt<UJO_IMPL extends UjoExt>
Parameters:
property -
index -
Returns:
removed item

remove

public <UJO extends UJO_IMPL,ITEM> boolean remove(ListUjoProperty<UJO,ITEM> property,
                                                  ITEM item)
Removes the first occurrence in this list of the specified element.

Parameters:
property - ListUjoPropertyCommon
item - Item to remove
Returns:
true if the list is not null and contains the specified element

list

public <UJO extends UJO_IMPL,LIST extends java.util.List<ITEM>,ITEM> LIST list(ListUjoProperty<UJO,ITEM> property)
Returns a not null List. If original list value is empty, the new List is created.
Inside is called a method ListUjoPropertyCommon.getList() internally.

Specified by:
list in interface UjoExt<UJO_IMPL extends UjoExt>

isDefault

public <UJO extends UJO_IMPL,VALUE> boolean isDefault(UjoProperty<UJO,VALUE> property)
Indicates whether a parameter value "equal to" property default value.

Specified by:
isDefault in interface UjoExt<UJO_IMPL extends UjoExt>

getText

public java.lang.String getText(UjoProperty property)
Returns a String value by a NULL context. otherwise method returns an instance of String.

Specified by:
getText in interface UjoMiddle<UJO_IMPL extends UjoExt>
Parameters:
property - A Property
Returns:
If property type is "container" then result is null.

setText

public void setText(UjoProperty property,
                    java.lang.String value)
Set value from a String format by a NULL context. Types Ujo, List, Object[] are not supported by default.
The method is an alias for a method writeValueString(...)

Specified by:
setText in interface UjoMiddle<UJO_IMPL extends UjoExt>
Parameters:
property - Property
value - String value

equals

public <UJO extends UJO_IMPL,VALUE> boolean equals(UjoProperty<UJO,VALUE> property,
                                                   VALUE value)
Compare the property value with a parametrer value. The property value can be null.


findProperty

public UjoProperty findProperty(java.lang.String propertyName)
                         throws java.lang.IllegalArgumentException
Find a property by a "property name".

Parameters:
propertyName - The name of property
Returns:
The first UjoProperty with the same name.
Throws:
java.lang.IllegalArgumentException - If property not found.

createPropertyList

public java.util.List<UjoPropertyRow> createPropertyList()
Create a list of UjoProperty.


clone

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

copyTo

public void copyTo(Ujo target,
                   java.lang.Object context)
Copy all attributes to the target


copyTo

public void copyTo(Ujo target,
                   UjoProperty... properties)
Copy selected attributes to the target



Copyright © 2010. All Rights Reserved.