com.livis.livingtalks.model
Class AbstractModel

java.lang.Object
  |
  +--com.livis.livingtalks.model.AbstractModel
Direct Known Subclasses:
AuthorModel, AuthorshipModel, BlockModel, PitemModel, TalkModel, TrackModel, TypeModel

public abstract class AbstractModel
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
 java.lang.String editor
           
 java.lang.String key
           
 java.lang.String timestamp
           
 
Constructor Summary
AbstractModel()
           
 
Method Summary
protected  AbstractModel assignAbstractModel(java.lang.String key, java.lang.String editor, java.lang.String timestamp)
           
 void check()
          Checks if model is logically OK.
 void checkForKeyCreation()
          Checks whether a key can be created from other model data.
protected  void checkForNonEmptyKey()
          Checks if a key value is not empty.
 void clear()
          Set this Model to a clear state suitable for data entry into a clear form it is not recommended behaviour for a clear model to pass a subsequent check() test.
protected  java.lang.String createKey()
          Creates a key from other model data which must pass the check() test if isKeyCreatable() returns true.
 java.lang.String getAutoKey()
          A text instructing the user about what are legal key values.
 java.lang.String getEditor()
           
 java.lang.String getKey()
           
 java.lang.String getTimestamp()
           
 boolean isKeyCreatable()
          Checks whether a key can, in theory, be created from other model data.
 void makeShort()
          Modifies the model such that less relevant properties are deleted from the model.
 void setAutoKey(java.lang.String autoKey)
           
 void setEditor(java.lang.String editor)
           
 void setKey(java.lang.String key)
           
 void setTimestamp(java.lang.String timestamp)
           
 void setTimestampFromDate(java.util.Date date)
           
protected  boolean shallCreateKey()
           
 void touch()
           
 java.util.List XMLTagProperties()
           
protected abstract  java.util.List xmlTagPropertiesStore()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

public java.lang.String key

editor

public java.lang.String editor

timestamp

public java.lang.String timestamp
Constructor Detail

AbstractModel

public AbstractModel()
Method Detail

assignAbstractModel

protected AbstractModel assignAbstractModel(java.lang.String key,
                                            java.lang.String editor,
                                            java.lang.String timestamp)

makeShort

public void makeShort()
Modifies the model such that less relevant properties are deleted from the model. The version of AbstractModel does nothing. A derived version may set a memory-consuming property to null if it is not used in any master or tabular view, i.e. a view of many models at once. A derived version may set a flag if makeShort got called and throw a LivingTalksException if a property is gotten which was nulled by makeShort.

clear

public void clear()
Set this Model to a clear state suitable for data entry into a clear form it is not recommended behaviour for a clear model to pass a subsequent check() test.

getKey

public java.lang.String getKey()

setKey

public void setKey(java.lang.String key)

getEditor

public java.lang.String getEditor()

setEditor

public void setEditor(java.lang.String editor)

getTimestamp

public java.lang.String getTimestamp()

setTimestamp

public void setTimestamp(java.lang.String timestamp)

setTimestampFromDate

public void setTimestampFromDate(java.util.Date date)

touch

public void touch()

checkForKeyCreation

public void checkForKeyCreation()
Checks whether a key can be created from other model data. This method is called by check() if isKeyCreatable() returns true. This default implementation does nothing and should be re-implemented by derived classes in conjunction with isKeyCreatable() and createKey().
Throws:
LivingTalksException - if a key cannot be created from other model data.
See Also:
isKeyCreatable(), createKey(), check()

check

public void check()
Checks if model is logically OK. This default implementation checks for an non-empty key and -- if isKeyCreatable() returns true -- whether the key can in fact be created (using checkForKeyCreation()). Also, special charcters (<, >, &, ", ', \r, and \n) are removed from the key.
Throws:
LivingTalksException - if model is invalid. Must not check for duplicate keys as this is checked anyway at database insertion time.
See Also:
isKeyCreatable(), createKey()

getAutoKey

public java.lang.String getAutoKey()
A text instructing the user about what are legal key values. When left unchanged by user it will trigger a createKey() method. Therefore, the text should state also whether this is ok or not.

setAutoKey

public void setAutoKey(java.lang.String autoKey)

isKeyCreatable

public boolean isKeyCreatable()
Checks whether a key can, in theory, be created from other model data. This default implementation returns false. If derived classes re-implement this to return true, they should also overwrite createKey() to return a suitable key and checkForKeyCreation() to test whether a key is valid.
Returns:
true if a key can be created
See Also:
createKey(), checkForKeyCreation()

createKey

protected java.lang.String createKey()
Creates a key from other model data which must pass the check() test if isKeyCreatable() returns true. The generated key is returned. This default implementation always throws an exception.
Throws:
LivingTalksException - if cannot create a key.
See Also:
isKeyCreatable(), check()

shallCreateKey

protected final boolean shallCreateKey()

checkForNonEmptyKey

protected final void checkForNonEmptyKey()
Checks if a key value is not empty.
Throws:
LivingTalksException - if key is empty.

xmlTagPropertiesStore

protected abstract java.util.List xmlTagPropertiesStore()

XMLTagProperties

public java.util.List XMLTagProperties()