net.sf.fikin.pojostate.state
Class AbstractState

java.lang.Object
  extended by net.sf.fikin.pojostate.state.AbstractState
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Iterable, java.util.Collection, State, StatePrototype
Direct Known Subclasses:
DynamicState, EmptyState, SnapshotState

public abstract class AbstractState
extends java.lang.Object
implements StatePrototype

Prototype implementation of State interface.

It provides with default handling for all methods.

Subclasses can modify any of them to suite their needs better. created on Mar 6, 2007

Since:
Version:
$Revision: 1.3 $
Author:
fiykov

Nested Class Summary
protected  class AbstractState.PropertyNameComparator
          This class is solely created to be used by getProperty(String) to search in the Vector with Properties for given name.
 
Field Summary
 
Fields inherited from interface net.sf.fikin.pojostate.State
SORT_ASC, SORT_BY_DESC, SORT_BY_NAME, SORT_BY_VALUE, SORT_DESC
 
Constructor Summary
AbstractState()
           
 
Method Summary
 boolean add(java.lang.Object arg0)
          adds the given object to the collection with Properties
 void add(Property property)
           
 boolean addAll(java.util.Collection arg0)
          not implemented, dummy method
 void clear()
          not implemented, dummy method
 java.lang.Object clone()
          implements cloning
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection arg0)
          test if given collection is present in the Properties
 java.lang.ClassLoader getClassLoader()
           
 StateFormat getFormat()
          get state's formatting object Formatting object is responsible to convey this State object to a string representation.
 java.util.Locale getLocale()
           
 java.lang.Object getObject()
           
 java.util.Vector getProperties()
           
 Property getProperty(java.lang.String propertyName)
          look for Property object with given UI name
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 boolean remove(java.lang.Object o)
          not implemented, dummy method
 boolean removeAll(java.util.Collection arg0)
          not implemented, dummy method
 boolean retainAll(java.util.Collection arg0)
          not implemented, dummy method
 void setClassLoader(java.lang.ClassLoader loader)
           
 void setFormat(StateFormat format)
          assign the formating object
 void setLocale(java.util.Locale locale)
           
 void setObject(java.lang.Object object)
          assign the underlying POJO
protected  void setProperties(java.util.Vector properties)
           
 int size()
           
 void sort(int leadField, int order)
          sort the objects directly in the underlying collection
protected  java.lang.Object[] sortArray(int leadField, int order)
          implementation of the sorting subclasses can utilize it in their particular implementation of sort(int,int) method.
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] arg0)
           
 java.lang.String toString()
          print the State in its appropriate textual format.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.fikin.pojostate.StatePrototype
newProperty
 
Methods inherited from interface net.sf.fikin.pojostate.State
update
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

AbstractState

public AbstractState()
Method Detail

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in interface State
Returns:
Returns the loader.

setClassLoader

public void setClassLoader(java.lang.ClassLoader loader)
Specified by:
setClassLoader in interface StatePrototype
Parameters:
loader - The loader to set.

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface State
Returns:
Returns the locale.

setLocale

public void setLocale(java.util.Locale locale)
Specified by:
setLocale in interface StatePrototype
Parameters:
locale - The locale to set.

getProperties

public java.util.Vector getProperties()
Returns:
Returns the properties.

setProperties

protected void setProperties(java.util.Vector properties)

add

public void add(Property property)
Parameters:
property - to add the list

getObject

public java.lang.Object getObject()
Specified by:
getObject in interface State
Returns:
decorated POJO

setObject

public void setObject(java.lang.Object object)
assign the underlying POJO

Specified by:
setObject in interface StatePrototype
Parameters:
object -

getFormat

public StateFormat getFormat()
Description copied from interface: State
get state's formatting object

Formatting object is responsible to convey this State object to a string representation. >Typical layout formats is to be expected to be tabular text, XML, HTML or similar.

This object is used by State.toString() too.

Specified by:
getFormat in interface State
Returns:
assigned Format object used by this State

setFormat

public void setFormat(StateFormat format)
assign the formating object

Specified by:
setFormat in interface StatePrototype
Parameters:
format -

getProperty

public Property getProperty(java.lang.String propertyName)
look for Property object with given UI name

Specified by:
getProperty in interface State
Parameters:
propertyName - to look for
Returns:
Property object with that UI name or null if no such found

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
implements cloning

Specified by:
clone in interface StatePrototype
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

sort

public void sort(int leadField,
                 int order)
sort the objects directly in the underlying collection

Specified by:
sort in interface State
Parameters:
leadField -
order -

sortArray

protected java.lang.Object[] sortArray(int leadField,
                                       int order)
implementation of the sorting

subclasses can utilize it in their particular implementation of sort(int,int) method.

Parameters:
leadField - is the leading property
order - is ascending or descending
Returns:
sorted array with Properties

toString

public java.lang.String toString()
print the State in its appropriate textual format.

This implementation is a dynamic i.e. uses the assigned formatter object to generate the appearance upon each call.

Specified by:
toString in interface State
Overrides:
toString in class java.lang.Object
Returns:
getFormat().format( this )

size

public int size()
Specified by:
size in interface java.util.Collection
Returns:
the size of Properties

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection
Returns:
are Properties empty

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection
Returns:
test if given object exists in the Properties

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Returns:
iterator over Properties

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection
Returns:
array with Properties

toArray

public java.lang.Object[] toArray(java.lang.Object[] arg0)
Specified by:
toArray in interface java.util.Collection
Returns:
array with Properties

add

public boolean add(java.lang.Object arg0)
adds the given object to the collection with Properties

Specified by:
add in interface java.util.Collection
Returns:
false

remove

public boolean remove(java.lang.Object o)
not implemented, dummy method

Specified by:
remove in interface java.util.Collection
Returns:
false

containsAll

public boolean containsAll(java.util.Collection arg0)
test if given collection is present in the Properties

Specified by:
containsAll in interface java.util.Collection
Parameters:
arg0 -
Returns:
true or false

addAll

public boolean addAll(java.util.Collection arg0)
not implemented, dummy method

Specified by:
addAll in interface java.util.Collection
Returns:
false

removeAll

public boolean removeAll(java.util.Collection arg0)
not implemented, dummy method

Specified by:
removeAll in interface java.util.Collection
Returns:
false

retainAll

public boolean retainAll(java.util.Collection arg0)
not implemented, dummy method

Specified by:
retainAll in interface java.util.Collection
Returns:
false

clear

public void clear()
not implemented, dummy method

Specified by:
clear in interface java.util.Collection


Copyright © 2005 Nikolay Fiykov. All Rights Reserved.