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: 1293 $ Last update: $Date: 2012-01-07 13:01:56 +0100 (Sat, 07 Jan 2012) $ 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 .
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.
protected  String version
          Current version of this wikitty object.
 
Constructor Summary
WikittyImpl()
           
WikittyImpl(String id)
           
 
Method Summary
 void addExtension(List<WikittyExtension> exts)
          Add multiples extensions.
 void addExtension(WikittyExtension ext)
          Add new extension.
 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)
          Add property change listener.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add property change listener on property.
 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()
          Return deletion date.
 Set<String> getDirty()
          get the field modified after wikitty was restored
 WikittyExtension getExtension(String ext)
           
 Collection<WikittyExtension> getExtensionDependencies(String ext, boolean recursively)
          Recherche toutes les extensions de ce wikitty qui dependent d'une extension particuliere
 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)
          Get field value.
<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.
 Map<String,Object> getFieldValue()
          All field value in unmodifiable map
 Object getFqField(String fqFieldName)
          get the value of and field given its fqn, if this field doesn't exists null is returned
 String getId()
          Get wikkity id.
protected  PropertyChangeSupport getPropertyChangeSupport()
          Always call this method because field is transient.
 String getVersion()
           
 boolean hasExtension(String extName)
          Check if current wikitty has extension.
 boolean hasField(String fqfieldName)
          Check if current wikitty has requested fully qualified field.
 boolean hasField(String extName, String fieldName)
          Check if current wikitty has requested field.
 int hashCode()
           
 boolean hasMetaExtension(String metaExtensionName, String extensionName)
          Check that the wikitty has a metaExtension about a given extension.
 boolean isDeleted()
          Return true is wikitty is deleted.
 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)
          Remove property change listener.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove property change listener on property.
 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)
          Set deletion date.
 void setField(String ext, String fieldName, Object value)
          Set field 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()
          Try to find extension with toString tagValue.
 String toString(String extName)
          Return String representation of this wikitty with toString specific format of extension passed in argument.
 String toStringAllField()
          Print all field of all extension
 
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)
Description copied from interface: Wikitty
Add property change listener.

Specified by:
addPropertyChangeListener in interface Wikitty
Parameters:
listener - listener to add

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: Wikitty
Remove property change listener.

Specified by:
removePropertyChangeListener in interface Wikitty
Parameters:
listener - listener to remove

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Description copied from interface: Wikitty
Add property change listener on property.

Specified by:
addPropertyChangeListener in interface Wikitty
Parameters:
propertyName - property to listen
listener - listener to add

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Description copied from interface: Wikitty
Remove property change listener on property.

Specified by:
removePropertyChangeListener in interface Wikitty
Parameters:
propertyName - property to listen
listener - listener to remove

getId

public String getId()
Description copied from interface: Wikitty
Get wikkity id.

Specified by:
getId in interface Wikitty
Returns:
wikytty id

isDeleted

public boolean isDeleted()
Description copied from interface: Wikitty
Return true is wikitty is deleted.

Specified by:
isDeleted in interface Wikitty
Returns:
true is wikitty is deleted

getDeleteDate

public Date getDeleteDate()
Description copied from interface: Wikitty
Return deletion date.

Specified by:
getDeleteDate in interface Wikitty
Returns:
deletion date or null if not deleted

setDeleteDate

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

Specified by:
setDeleteDate in interface Wikitty
Parameters:
delete - deletion date

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)
Description copied from interface: Wikitty
Add new extension.

Specified by:
addExtension in interface Wikitty
Parameters:
ext - extension to add

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
Returns:
true if current wikitty has meta extension
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)
Description copied from interface: Wikitty
Add multiples extensions.

Specified by:
addExtension in interface Wikitty
Parameters:
exts - extensions to add

hasExtension

public boolean hasExtension(String extName)
Description copied from interface: Wikitty
Check if current wikitty has extension.

Specified by:
hasExtension in interface Wikitty
Parameters:
extName - extension name to check
Returns:
true if current wikitty has extension.

hasField

public boolean hasField(String extName,
                        String fieldName)
Description copied from interface: Wikitty
Check if current wikitty has requested field.

Specified by:
hasField in interface Wikitty
Parameters:
extName - extension name
fieldName - field name on extension
Returns:
true if wikitty has field

hasField

public boolean hasField(String fqfieldName)
Description copied from interface: Wikitty
Check if current wikitty has requested fully qualified field.

Specified by:
hasField in interface Wikitty
Parameters:
fqfieldName - fully qualified field name
Returns:
true if wikitty has field

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)
Description copied from interface: Wikitty
Recherche toutes les extensions de ce wikitty qui dependent d'une extension particuliere

Specified by:
getExtensionDependencies in interface Wikitty
Parameters:
ext - le nom d'une extension
recursively - si la dependance doit aussi etre recherche recursivement
Returns:
la liste des extensions de ce Wikitty qui depande de l'extension dont le nom est passé en parametre (de facon direct ou indirect)

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)
Description copied from interface: Wikitty
Set field value.

Specified by:
setField in interface Wikitty
Parameters:
ext - extension
fieldName - field name

getFieldAsObject

public Object getFieldAsObject(String ext,
                               String fieldName)
Description copied from interface: Wikitty
Get field value. if fieldName doesn't exists on this extension an exception is throw

Specified by:
getFieldAsObject in interface Wikitty
Parameters:
ext - extension name
fieldName - field name
Returns:

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:

getFieldValue

public Map<String,Object> getFieldValue()
Description copied from interface: Wikitty
All field value in unmodifiable map

Specified by:
getFieldValue in interface Wikitty
Returns:

getAllFieldNames

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

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, if this field doesn't exists null is returned

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()
Try to find extension with toString tagValue. The first tagValue found is used. If no toString tagValue found, then toStringAllField() is used.

Overrides:
toString in class Object
Returns:

toStringAllField

public String toStringAllField()
Print all field of all extension

Specified by:
toStringAllField in interface Wikitty

toString

public String toString(String extName)
Return String representation of this wikitty with toString specific format of extension passed in argument. If this extension doesn't have specifique toString, normal toString is called toString()

Specified by:
toString in interface Wikitty

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-2012 CodeLutin. All Rights Reserved.