org.nuiton.wikitty.entities
Class WikittyImpl

java.lang.Object
  extended by org.nuiton.wikitty.entities.WikittyImpl
All Implemented Interfaces:
Serializable, Cloneable, Wikitty

public class WikittyImpl
extends Object
implements Wikitty

Wikitty implementation.

Version:
$Revision: 825 $ Last update: $Date: 2011-04-20 23:01:17 +0200 (mer., 20 avril 2011) $ by : $Author: bpoussin $
Author:
poussin
See Also:
Serialized Form

Field Summary
protected  Date deleteDate
          If not null, date of deletion, if date this object is marked as deleted.
protected  Map<String,WikittyExtension> extensions
          Map is LinkedHashMap to maintains order like user want key: extension name value: extension definition
protected  Set<String> fieldDirty
          all field name currently modified (field name = extension . fieldname)
protected  HashMap<String,Object> fieldValue
          key: field name prefixed by extension name (dot separator) value: value of field
protected  String id
          Technical id for this wikitty object. id must be never null.
protected  String version
          Current version of this wikitty object.
 
Constructor Summary
WikittyImpl()
           
WikittyImpl(String id)
           
 
Method Summary
 void addExtension(List<WikittyExtension> exts)
           
 void addExtension(WikittyExtension ext)
           
 void addMetaExtension(WikittyExtension metaExtension, String extensionName)
          add a meta-extension on the given extension to this wikitty.
 void addMetaExtension(WikittyExtension metaExtension, WikittyExtension extension)
          add a meta-extension about the given extension to this wikitty.
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
           
 void addToField(String fqFieldName, Object value)
          Add an element in a field
 void addToField(String ext, String fieldName, Object value)
           
 void clearDirty()
          clear the lists of modified field since last restore.
 void clearField(String fqFieldName)
          Clear a field
 void clearField(String ext, String fieldName)
           
 WikittyImpl clone()
          Clone is deep for extension and values
 boolean equals(Object obj)
           
 Set<String> fieldNames()
          Return only used fieldNames
 Set<String> getAllFieldNames()
          Return all fieldName available in all extension
 Date getDeleteDate()
           
 Set<String> getDirty()
          get the field modified after wikitty was restored
 WikittyExtension getExtension(String ext)
           
 Collection<WikittyExtension> getExtensionDependencies(String ext, boolean recursively)
           
 Collection<String> getExtensionNames()
           
 Collection<WikittyExtension> getExtensions()
           
 BigDecimal getFieldAsBigDecimal(String ext, String fieldName)
           
 boolean getFieldAsBoolean(String ext, String fieldName)
           
 byte[] getFieldAsBytes(String ext, String fieldName)
           
 Date getFieldAsDate(String ext, String fieldName)
           
 double getFieldAsDouble(String ext, String fieldName)
           
 float getFieldAsFloat(String ext, String fieldName)
           
 int getFieldAsInt(String ext, String fieldName)
           
<E> List<E>
getFieldAsList(String ext, String fieldName, Class<E> clazz)
          If object is a set, it is automatically transform to list.
 long getFieldAsLong(String ext, String fieldName)
           
 Object getFieldAsObject(String ext, String fieldName)
           
<E> Set<E>
getFieldAsSet(String ext, String fieldName, Class<E> clazz)
           
 String getFieldAsString(String ext, String fieldName)
           
 String getFieldAsWikitty(String ext, String fieldName)
          return wikitty id and not wikitty objet because this method can be call on server or client side and it's better to keep conversion between id and objet to the caller
 FieldType getFieldType(String fqfieldName)
          return field type for the given fieldName.
 Object getFqField(String fqFieldName)
          get the value of and field given its fqn
 String getId()
           
protected  PropertyChangeSupport getPropertyChangeSupport()
          Always call this method because field is transient.
 String getVersion()
           
 boolean hasExtension(String extName)
           
 boolean hasField(String fqfieldName)
           
 boolean hasField(String extName, String fieldName)
           
 int hashCode()
           
 boolean hasMetaExtension(String metaExtensionName, String extensionName)
          check that the wikitty has a metaExtension about a given extension.
 boolean isDeleted()
           
 boolean isEmpty()
           
 void removeFromField(String fqFieldName, Object value)
          Remove an element from a field
 void removeFromField(String ext, String fieldName, Object value)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
           
 void replaceWith(Wikitty w)
          Replace all field of current wikitty with field found in w.
 void replaceWith(Wikitty w, boolean force)
          Replace all field of current wikitty with field found in w.
 void setDeleteDate(Date delete)
          Server only used
 void setField(String ext, String fieldName, Object value)
           
protected  void setFieldDirty(String ext, String fieldName, Object oldValue, Object newValue)
          Mark field as dirty.
 void setFqField(String fieldName, Object value)
          set the value of a field given is fqn.
 void setVersion(String version)
          Server only used
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected String id
Technical id for this wikitty object. id must be never null.


version

protected String version
Current version of this wikitty object.


deleteDate

protected Date deleteDate
If not null, date of deletion, if date this object is marked as deleted.


fieldValue

protected HashMap<String,Object> fieldValue
key: field name prefixed by extension name (dot separator) value: value of field


fieldDirty

protected Set<String> fieldDirty
all field name currently modified (field name = extension . fieldname)


extensions

protected Map<String,WikittyExtension> extensions
Map is LinkedHashMap to maintains order like user want key: extension name value: extension definition

Constructor Detail

WikittyImpl

public WikittyImpl()

WikittyImpl

public WikittyImpl(String id)
Method Detail

replaceWith

public void replaceWith(Wikitty w)
Replace all field of current wikitty with field found in w. This two wikitty must have same id. This method is used to clone Wikitty too

Specified by:
replaceWith in interface Wikitty
Parameters:
w - wikitty where we take information

replaceWith

public void replaceWith(Wikitty w,
                        boolean force)
Replace all field of current wikitty with field found in w. This two wikitty must have same id if force is false. This method is used to clone Wikitty too

Specified by:
replaceWith in interface Wikitty
Parameters:
w - wikitty where we take information

getPropertyChangeSupport

protected PropertyChangeSupport getPropertyChangeSupport()
Always call this method because field is transient.

Returns:

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface Wikitty

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface Wikitty

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface Wikitty

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface Wikitty

getId

public String getId()
Specified by:
getId in interface Wikitty

isDeleted

public boolean isDeleted()
Specified by:
isDeleted in interface Wikitty

getDeleteDate

public Date getDeleteDate()
Specified by:
getDeleteDate in interface Wikitty

setDeleteDate

public void setDeleteDate(Date delete)
Description copied from interface: Wikitty
Server only used

Specified by:
setDeleteDate in interface Wikitty

setFieldDirty

protected void setFieldDirty(String ext,
                             String fieldName,
                             Object oldValue,
                             Object newValue)
Mark field as dirty.

Parameters:
ext -
fieldName -

addExtension

public void addExtension(WikittyExtension ext)
Specified by:
addExtension in interface Wikitty

hasMetaExtension

public boolean hasMetaExtension(String metaExtensionName,
                                String extensionName)
Description copied from interface: Wikitty
check that the wikitty has a metaExtension about a given extension.

Specified by:
hasMetaExtension in interface Wikitty
Parameters:
metaExtensionName - the metaExtension to be checked
extensionName - an extension already added to the wikitty
See Also:
Wikitty.hasMetaExtension(String, String)

addMetaExtension

public void addMetaExtension(WikittyExtension metaExtension,
                             WikittyExtension extension)
Description copied from interface: Wikitty
add a meta-extension about the given extension to this wikitty.

Specified by:
addMetaExtension in interface Wikitty
Parameters:
metaExtension - the metaExtension to add
extension - an extension already added to the wikitty
See Also:
Wikitty.addMetaExtension(WikittyExtension, WikittyExtension)

addMetaExtension

public void addMetaExtension(WikittyExtension metaExtension,
                             String extensionName)
Description copied from interface: Wikitty
add a meta-extension on the given extension to this wikitty.

Specified by:
addMetaExtension in interface Wikitty
Parameters:
metaExtension - the metaExtension to add
extensionName - the name of the extension already added to the wikitty
See Also:
Wikitty.addMetaExtension(WikittyExtension, String)

addExtension

public void addExtension(List<WikittyExtension> exts)
Specified by:
addExtension in interface Wikitty

hasExtension

public boolean hasExtension(String extName)
Specified by:
hasExtension in interface Wikitty

hasField

public boolean hasField(String extName,
                        String fieldName)
Specified by:
hasField in interface Wikitty

hasField

public boolean hasField(String fqfieldName)
Specified by:
hasField in interface Wikitty

getExtension

public WikittyExtension getExtension(String ext)
Specified by:
getExtension in interface Wikitty

getExtensionNames

public Collection<String> getExtensionNames()
Specified by:
getExtensionNames in interface Wikitty

getExtensions

public Collection<WikittyExtension> getExtensions()
Specified by:
getExtensions in interface Wikitty

getExtensionDependencies

public Collection<WikittyExtension> getExtensionDependencies(String ext,
                                                             boolean recursively)
Specified by:
getExtensionDependencies in interface Wikitty

getFieldType

public FieldType getFieldType(String fqfieldName)
Description copied from interface: Wikitty
return field type for the given fieldName.

Specified by:
getFieldType in interface Wikitty
Parameters:
fqfieldName - fully qualified fieldName extension.fieldname
Returns:
field type

setField

public void setField(String ext,
                     String fieldName,
                     Object value)
Specified by:
setField in interface Wikitty

getFieldAsObject

public Object getFieldAsObject(String ext,
                               String fieldName)
Specified by:
getFieldAsObject in interface Wikitty

getFieldAsBytes

public byte[] getFieldAsBytes(String ext,
                              String fieldName)
Specified by:
getFieldAsBytes in interface Wikitty

getFieldAsBoolean

public boolean getFieldAsBoolean(String ext,
                                 String fieldName)
Specified by:
getFieldAsBoolean in interface Wikitty

getFieldAsBigDecimal

public BigDecimal getFieldAsBigDecimal(String ext,
                                       String fieldName)
Specified by:
getFieldAsBigDecimal in interface Wikitty

getFieldAsInt

public int getFieldAsInt(String ext,
                         String fieldName)
Specified by:
getFieldAsInt in interface Wikitty

getFieldAsLong

public long getFieldAsLong(String ext,
                           String fieldName)
Specified by:
getFieldAsLong in interface Wikitty

getFieldAsFloat

public float getFieldAsFloat(String ext,
                             String fieldName)
Specified by:
getFieldAsFloat in interface Wikitty

getFieldAsDouble

public double getFieldAsDouble(String ext,
                               String fieldName)
Specified by:
getFieldAsDouble in interface Wikitty

getFieldAsString

public String getFieldAsString(String ext,
                               String fieldName)
Specified by:
getFieldAsString in interface Wikitty

getFieldAsDate

public Date getFieldAsDate(String ext,
                           String fieldName)
Specified by:
getFieldAsDate in interface Wikitty

getFieldAsWikitty

public String getFieldAsWikitty(String ext,
                                String fieldName)
Description copied from interface: Wikitty
return wikitty id and not wikitty objet because this method can be call on server or client side and it's better to keep conversion between id and objet to the caller

Specified by:
getFieldAsWikitty in interface Wikitty
Parameters:
ext - extension name where this field must to be
fieldName - the field name
Returns:
id of wikitty object or null

getFieldAsList

public <E> List<E> getFieldAsList(String ext,
                                  String fieldName,
                                  Class<E> clazz)
Description copied from interface: Wikitty
If object is a set, it is automatically transform to list.

Specified by:
getFieldAsList in interface Wikitty
Returns:
unmodifiable list

getFieldAsSet

public <E> Set<E> getFieldAsSet(String ext,
                                String fieldName,
                                Class<E> clazz)
Specified by:
getFieldAsSet in interface Wikitty
Returns:
unmodifiable list

addToField

public void addToField(String ext,
                       String fieldName,
                       Object value)
Specified by:
addToField in interface Wikitty

removeFromField

public void removeFromField(String ext,
                            String fieldName,
                            Object value)
Specified by:
removeFromField in interface Wikitty

clearField

public void clearField(String ext,
                       String fieldName)
Specified by:
clearField in interface Wikitty

addToField

public void addToField(String fqFieldName,
                       Object value)
Description copied from interface: Wikitty
Add an element in a field

Specified by:
addToField in interface Wikitty
Parameters:
fqFieldName - the fully qualified name of a collection field
value - the value to be added to the collection
See Also:
org.nuiton.wikitty.Wikitty#addToField(String, Object)

removeFromField

public void removeFromField(String fqFieldName,
                            Object value)
Description copied from interface: Wikitty
Remove an element from a field

Specified by:
removeFromField in interface Wikitty
Parameters:
fqFieldName - the fully qualified name of a collection field
value - the value to be removed to the collection
See Also:
Wikitty.removeFromField(String, Object)

clearField

public void clearField(String fqFieldName)
Description copied from interface: Wikitty
Clear a field

Specified by:
clearField in interface Wikitty
Parameters:
fqFieldName - the fully qualified name of a collection field
See Also:
Wikitty.clearField(String)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

fieldNames

public Set<String> fieldNames()
Description copied from interface: Wikitty
Return only used fieldNames

Specified by:
fieldNames in interface Wikitty
Returns:

getAllFieldNames

public Set<String> getAllFieldNames()
Description copied from interface: Wikitty
Return all fieldName available in all extension

Specified by:
getAllFieldNames in interface Wikitty
Returns:

getFqField

public Object getFqField(String fqFieldName)
Description copied from interface: Wikitty
get the value of and field given its fqn

Specified by:
getFqField in interface Wikitty

getVersion

public String getVersion()
Specified by:
getVersion in interface Wikitty

setVersion

public void setVersion(String version)
Description copied from interface: Wikitty
Server only used

Specified by:
setVersion in interface Wikitty

getDirty

public Set<String> getDirty()
Description copied from interface: Wikitty
get the field modified after wikitty was restored

Specified by:
getDirty in interface Wikitty
Returns:
a set of fully qualified field names
See Also:
Wikitty.getDirty()

clearDirty

public void clearDirty()
Description copied from interface: Wikitty
clear the lists of modified field since last restore.

Specified by:
clearDirty in interface Wikitty

setFqField

public void setFqField(String fieldName,
                       Object value)
Description copied from interface: Wikitty
set the value of a field given is fqn.

Specified by:
setFqField in interface Wikitty
Parameters:
fieldName - fqn (ex: extensionName.fieldName)
value - new value

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Wikitty

toString

public String toString()
Overrides:
toString in class Object

clone

public WikittyImpl clone()
                  throws CloneNotSupportedException
Clone is deep for extension and values

Specified by:
clone in interface Wikitty
Overrides:
clone in class Object
Returns:
Throws:
CloneNotSupportedException
See Also:
Object.clone()


Copyright © 2009-2011 CodeLutin. All Rights Reserved.