public abstract class ModelImpl extends Object implements Model
Model.Attribute
Modifier and Type | Field and Description |
---|---|
protected Map<String,Model.Attribute> |
_attributes
The attributes.
|
Constructor and Description |
---|
ModelImpl()
Instantiates a new ModelImpl.
|
Modifier and Type | Method and Description |
---|---|
Object |
access(String attributeName)
Returns the value of the attribute.
|
void |
addAttribute(String attributeName,
Class<?> elementClass,
String getter,
String setter)
Creates an Attribute and adds it to the model.
|
void |
addAttribute(String attributeName,
Class<?> elementClass,
String getter,
String setter,
Object params)
Creates an Attribute and adds it to the model.
|
void |
addAttribute(String attributeName,
Class<?> elementClass,
String getter,
String setter,
Object params,
String reader,
String writer)
Creates an Attribute and adds it to the model.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds the property change listener.
|
void |
addSubModel(Model model)
Adds the sub model.
|
void |
attributeChanged(String attributeName,
Object newValue)
Executed when attribute value has changed.
|
boolean |
attributeExists(String attributeName)
Checks if attribute exists in the model or sub-models.
|
void |
baseline()
Sets the state of the mutable object to baselined.
|
Object |
clone()
Clones model
|
void |
copyFrom(Model model)
Copies model from another model.
|
Map<String,Model.Attribute> |
getAllAttributes()
Gets the map of all attributes, including sub-models.
|
Model.Attribute |
getAttribute(String attributeName)
Gets the Attribute by name
|
Map<String,Model.Attribute> |
getAttributes()
Gets the map of attributes for this model only, excluding sub-models.
|
Object |
getAttributeValue(String attributeName)
Gets the attribute value by attributeName
|
protected Object |
getAttrParams(Class<?> paramsClass)
Creates the attribute parameter object.
|
Model |
getModelByAttributeName(String attributeName)
Gets the model by attribute name.
|
Model |
getOwner()
Gets the owner model.
|
String |
getRealName(String attributeName)
Gets the name of the attribute using replacement map and exclude
property.
|
protected boolean |
isCDataMethod(Method method)
Checks if it is a cdata method.
|
boolean |
isDirty()
Checks if object has changed but hasn't been baselined.
|
protected boolean |
isGetterMethod(Method method)
Checks if it is a getter method.
|
protected boolean |
isReaderMethod(Method method)
Checks if it is a reader method.
|
protected boolean |
isSetterMethod(Method method)
Checks if it is a setter method.
|
boolean |
isSilentUpdate()
Checks if "silent update" flag is set.
|
boolean |
isUpdateDirtyOnChange()
Checks if "is update dirty on change" flag is set.
|
protected boolean |
isWriterMethod(Method method)
Checks if it is a writer method.
|
void |
populate(String attributeName,
Object newValue)
Sets the value for the attribute.
|
void |
propertyChange(PropertyChangeEvent event) |
void |
read(String attributeName,
Object value)
Reads the attribute from the storage such as xml, database, etc
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes the property change listener.
|
void |
removeSubModel(Model model)
Removes the sub model.
|
void |
replaceAttrNames(String suffix)
Replaces attribute names using model's substitution map and a suffix.
|
void |
replaceAttrNames(String suffix,
Map<String,String> map,
boolean exclude)
Replaces attribute names using given substitution map, suffix and a
exclude flag.
|
void |
setAttributeValue(String attributeName,
Object newValue)
Sets the new attribute value.
|
void |
setDirty(boolean value)
Sets the state of the object to dirty or baselined
|
void |
setOwner(Model value)
Sets the owner.
|
void |
setSilentUpdate(boolean value)
Sets the "silent update" flag.
|
void |
setUpdateDirtyOnChange(boolean value)
Sets the "update dirty on change" flag.
|
Object |
write(String attributeName)
Writes the attribute to the storage such as xml, database, etc
|
protected Map<String,Model.Attribute> _attributes
public ModelImpl()
public Object access(String attributeName)
Model
public void addAttribute(String attributeName, Class<?> elementClass, String getter, String setter)
attributeName
- the attribute nameelementClass
- the element classgetter
- the name of the getter methodsetter
- the name of the setter methodpublic void addAttribute(String attributeName, Class<?> elementClass, String getter, String setter, Object params)
attributeName
- the attribute nameelementClass
- the element classgetter
- the name of the getter methodsetter
- the name of the setter methodparams
- the parameters of the attributepublic void addAttribute(String attributeName, Class<?> elementClass, String getter, String setter, Object params, String reader, String writer)
attributeName
- the attribute nameelementClass
- the element classgetter
- the name of the getter methodsetter
- the name of the setter methodparams
- the parameters of the attributereader
- the name of the reader methodwriter
- the name of the writer methodpublic void addPropertyChangeListener(PropertyChangeListener listener)
Model
addPropertyChangeListener
in interface Model
listener
- the listenerpublic void addSubModel(Model model)
Model
addSubModel
in interface Model
model
- the modelpublic void attributeChanged(String attributeName, Object newValue)
attributeName
- the attribute namenewValue
- the new valuepublic boolean attributeExists(String attributeName)
Model
attributeExists
in interface Model
attributeName
- the attribute namepublic void baseline()
Mutable
public Object clone() throws CloneNotSupportedException
Model
public void copyFrom(Model model) throws Exception
Model
public Map<String,Model.Attribute> getAllAttributes()
Model
getAllAttributes
in interface Model
public Model.Attribute getAttribute(String attributeName)
attributeName
- the attribute namepublic Map<String,Model.Attribute> getAttributes()
Model
getAttributes
in interface Model
public Object getAttributeValue(String attributeName)
attributeName
- the attribute nameprotected Object getAttrParams(Class<?> paramsClass)
paramsClass
- the parameter classpublic Model getModelByAttributeName(String attributeName)
Model
getModelByAttributeName
in interface Model
attributeName
- the attribute namepublic Model getOwner()
Model
public String getRealName(String attributeName)
return _replacementMap == null || (_exclude && !_replacementMap.containsKey(attributeName)) || (!_exclude && _replacementMap.containsKey(attributeName)) ? attributeName + _suffix : attributeName;
attributeName
- the attribute nameprotected boolean isCDataMethod(Method method)
method
- the methodpublic boolean isDirty()
Mutable
protected boolean isGetterMethod(Method method)
method
- the methodprotected boolean isReaderMethod(Method method)
method
- the methodprotected boolean isSetterMethod(Method method)
method
- the methodpublic boolean isSilentUpdate()
public boolean isUpdateDirtyOnChange()
protected boolean isWriterMethod(Method method)
method
- the methodpublic void populate(String attributeName, Object newValue)
Model
public void propertyChange(PropertyChangeEvent event)
propertyChange
in interface Model
propertyChange
in interface PropertyChangeListener
public void read(String attributeName, Object value)
Model
public void removePropertyChangeListener(PropertyChangeListener listener)
Model
removePropertyChangeListener
in interface Model
listener
- the listenerpublic void removeSubModel(Model model)
Model
removeSubModel
in interface Model
model
- the modelpublic void replaceAttrNames(String suffix)
suffix
- the suffixpublic void replaceAttrNames(String suffix, Map<String,String> map, boolean exclude)
suffix
- the suffixmap
- the substitution mapexclude
- the exclude flagpublic void setAttributeValue(String attributeName, Object newValue)
attributeName
- the attribute namenewValue
- the new valuepublic void setDirty(boolean value)
Mutable
public void setSilentUpdate(boolean value)
value
- the new value for "silent update" flagpublic void setUpdateDirtyOnChange(boolean value)
value
- the new value for the "update dirty on change" flagCopyright © 2010-2020 Toolsverse. All Rights Reserved.