| java.lang.Object java.util.Observable org.ofbiz.entity.GenericEntity
All known Subclasses: org.ofbiz.entity.GenericPK, org.ofbiz.entity.GenericValue,
GenericEntity | public class GenericEntity extends Observable implements Map,LocalizedMap,Serializable,Comparable,Cloneable(Code) | | Generic Entity Value Object - Handles persisntence for any defined entity.
Note that this class extends Observable to achieve change notification for
Observer s. Whenever a field changes the name of the field will be passed to
the notifyObservers() method, and through that to the update() method of each
Observer .
author: David E. Jones author: Andy Zeneski version: $Revision: 1.20 $ since: 2.0 |
Method Summary | |
public static int | addToXmlDocument(Collection values, Document document) | public void | clear() | public Object | clone() | public int | compareTo(Object obj) | public boolean | containsKey(Object key) | public boolean | containsPrimaryKey() Returns true if the entity contains all of the primary key fields. | public boolean | containsValue(Object value) | public Object | dangerousGetNoCheckButFast(ModelField modelField) | public void | dangerousSetNoCheckButFast(ModelField modelField, Object value) | public java.util.Set | entrySet() | public boolean | equals(Object obj) | public Object | get(String name) | public Object | get(String name, Locale locale) Checks a resource bundle for a value for this field using the entity name, the field name
and a composite of the Primary Key field values as a key. | public Object | get(String name, String resource, Locale locale) Same as the getResource method that does not take resource name, but instead allows manually
specifying the resource name. | public Object | get(Object key) | public Map | getAllFields() | public Collection | getAllKeys() | public Boolean | getBoolean(String name) | public byte[] | getBytes(String name) | public java.sql.Date | getDate(String name) | public GenericDelegator | getDelegator() Get the GenericDelegator instance that created this value object and that is repsonsible for it. | public Double | getDouble(String name) | public String | getEntityName() | public Map | getFields(Collection keysofFields) | public Float | getFloat(String name) | public Integer | getInteger(String name) | public boolean | getIsFromEntitySync() | public Long | getLong(String name) | public ModelEntity | getModelEntity() | public GenericPK | getPrimaryKey() | public String | getString(String name) | public java.sql.Time | getTime(String name) | public java.sql.Timestamp | getTimestamp(String name) | public int | hashCode() | public boolean | isEmpty() | public boolean | isModified() | public boolean | isMutable() | public boolean | isPrimaryKey() Returns true if the entity contains all of the primary key fields, but NO others. | public java.util.Set | keySet() | public boolean | lockEnabled() | public static Document | makeXmlDocument(Collection values) | public Element | makeXmlElement(Document document) | public Element | makeXmlElement(Document document, String prefix) | public boolean | matchesFields(Map keyValuePairs) | public Object | put(Object key, Object value) | public void | putAll(java.util.Map map) | public void | refreshFromValue(GenericEntity newValue) | public Object | remove(Object key) | public void | removedFromDatasource() | public void | set(String name, Object value) | public synchronized Object | set(String name, Object value, boolean setIfNull) Sets the named field to the passed value. | public void | setAllFields(Map fields, boolean setIfEmpty, String namePrefix, Boolean pks) | public void | setBytes(String name, byte[] bytes) Sets a field with an array of bytes, wrapping them automatically for easy use. | public void | setDelegator(GenericDelegator internalDelegator) Set the GenericDelegator instance that created this value object and that is repsonsible for it. | public synchronized void | setFields(Map keyValuePairs) | public void | setImmutable() | public void | setIsFromEntitySync(boolean isFromEntitySync) | public void | setNonPKFields(Map fields) | public void | setNonPKFields(Map fields, boolean setIfEmpty) | public void | setPKFields(Map fields) | public void | setPKFields(Map fields, boolean setIfEmpty) | public void | setString(String name, String value) | public int | size() | public void | synchronizedWithDatasource() | public String | toString() | public java.util.Collection | values() | public void | writeXmlText(PrintWriter writer, String prefix) |
delegatorName | protected String delegatorName(Code) | | Name of the GenericDelegator, used to reget the GenericDelegator when deserialized
|
entityName | protected String entityName(Code) | | Contains the entityName of this entity, necessary for efficiency when creating EJBs
|
fields | protected Map fields(Code) | | Contains the fields for this entity. Note that this should always be a
HashMap to allow for two things: non-synchronized reads (synchronized
writes are done through synchronized setters) and being able to store
null values. Null values are important because with them we can distinguish
between desiring to set a value to null and desiring to not modify the
current value on an update.
|
internalDelegator | protected transient GenericDelegator internalDelegator(Code) | | Reference to an instance of GenericDelegator used to do some basic operations on this entity value. If null various methods in this class will fail. This is automatically set by the GenericDelegator for all GenericValue objects instantiated through it. You may set this manually for objects you instantiate manually, but it is optional.
|
isFromEntitySync | protected boolean isFromEntitySync(Code) | | This is an internal field used to specify that a value has come from a sync process and that the auto-stamps should not be over-written
|
modelEntity | protected transient ModelEntity modelEntity(Code) | | Contains the ModelEntity instance that represents the definition of this entity, not to be serialized
|
modified | protected boolean modified(Code) | | Denotes whether or not this entity has been modified, or is known to be out of sync with the persistent record
|
mutable | protected boolean mutable(Code) | | Used to specify whether or not this representation of the entity can be changed; generally cleared when this object comes from a cache
|
GenericEntity | public GenericEntity()(Code) | | Creates new GenericEntity
|
GenericEntity | public GenericEntity(ModelEntity modelEntity)(Code) | | Creates new GenericEntity
|
GenericEntity | public GenericEntity(ModelEntity modelEntity, Map fields)(Code) | | Creates new GenericEntity from existing Map
|
GenericEntity | public GenericEntity(GenericEntity value)(Code) | | Copy Constructor: Creates new GenericEntity from existing GenericEntity
|
clear | public void clear()(Code) | | |
clone | public Object clone()(Code) | | Clones this GenericEntity, this is a shallow clone & uses the default shallow HashMap clone
Object that is a clone of this GenericEntity |
compareTo | public int compareTo(Object obj)(Code) | | Compares this GenericEntity to the passed object
Parameters: obj - Object to compare this to int representing the result of the comparison (-1,0, or 1) |
containsPrimaryKey | public boolean containsPrimaryKey()(Code) | | Returns true if the entity contains all of the primary key fields.
|
containsValue | public boolean containsValue(Object value)(Code) | | |
equals | public boolean equals(Object obj)(Code) | | Determines the equality of two GenericEntity objects, overrides the default equals
Parameters: obj - The object (GenericEntity) to compare this two boolean stating if the two objects are equal |
get | public Object get(String name, Locale locale)(Code) | | Checks a resource bundle for a value for this field using the entity name, the field name
and a composite of the Primary Key field values as a key. If no value is found in the
resource then the field value is returned. Uses the default-resource-name from the entity
definition as the resource name. To specify a resource name manually, use the other getResource method.
So, the key in the resource bundle (properties file) should be as follows:
......
For example:
ProductType.description.FINISHED_GOOD
Parameters: name - The name of the field on the entity Parameters: locale - The locale to use when finding the ResourceBundle, if null uses the defaultlocale for the current instance of Java If the corresponding resource is found and contains a key as described above, then thatproperty value is returned; otherwise returns the field value |
get | public Object get(String name, String resource, Locale locale)(Code) | | Same as the getResource method that does not take resource name, but instead allows manually
specifying the resource name. In general you should use the other method for more consistent
naming and use of the corresponding properties files.
Parameters: name - The name of the field on the entity Parameters: resource - The name of the resource to get the value from; if null defaults to thedefault-resource-name on the entity definition, if specified there Parameters: locale - The locale to use when finding the ResourceBundle, if null uses the defaultlocale for the current instance of Java If the specified resource is found and contains a key as described above, then thatproperty value is returned; otherwise returns the field value |
getAllFields | public Map getAllFields()(Code) | | Returns key/value pairs of entity fields
java.util.Map |
getAllKeys | public Collection getAllKeys()(Code) | | Returns keys of entity fields
java.util.Collection |
getDelegator | public GenericDelegator getDelegator()(Code) | | Get the GenericDelegator instance that created this value object and that is repsonsible for it.
GenericDelegator object |
getFields | public Map getFields(Collection keysofFields)(Code) | | Used by clients to specify exactly the fields they are interested in
Parameters: keysofFields - the name of the fields the client is interested in java.util.Map |
getIsFromEntitySync | public boolean getIsFromEntitySync()(Code) | | Returns the isFromEntitySync. |
hashCode | public int hashCode()(Code) | | Creates a hashCode for the entity, using the default String hashCode and Map hashCode, overrides the default hashCode
Hashcode corresponding to this entity |
isEmpty | public boolean isEmpty()(Code) | | |
isModified | public boolean isModified()(Code) | | |
isMutable | public boolean isMutable()(Code) | | |
isPrimaryKey | public boolean isPrimaryKey()(Code) | | Returns true if the entity contains all of the primary key fields, but NO others.
|
lockEnabled | public boolean lockEnabled()(Code) | | Used to indicate if locking is enabled for this entity
True if locking is enabled |
makeXmlElement | public Element makeXmlElement(Document document)(Code) | | Makes an XML Element object with an attribute for each field of the entity
Parameters: document - The XML Document that the new Element will be part of org.w3c.dom.Element object representing this generic entity |
makeXmlElement | public Element makeXmlElement(Document document, String prefix)(Code) | | Makes an XML Element object with an attribute for each field of the entity
Parameters: document - The XML Document that the new Element will be part of Parameters: prefix - A prefix to put in front of the entity name in the tag name org.w3c.dom.Element object representing this generic entity |
matchesFields | public boolean matchesFields(Map keyValuePairs)(Code) | | |
removedFromDatasource | public void removedFromDatasource()(Code) | | |
set | public void set(String name, Object value)(Code) | | Sets the named field to the passed value, even if the value is null
Parameters: name - The field name to set Parameters: value - The value to set |
set | public synchronized Object set(String name, Object value, boolean setIfNull)(Code) | | Sets the named field to the passed value. If value is null, it is only
set if the setIfNull parameter is true. This is useful because an update
will only set values that are included in the HashMap and will store null
values in the HashMap to the datastore. If a value is not in the HashMap,
it will be left unmodified in the datastore.
Parameters: name - The field name to set Parameters: value - The value to set Parameters: setIfNull - Specifies whether or not to set the value if it is null |
setAllFields | public void setAllFields(Map fields, boolean setIfEmpty, String namePrefix, Boolean pks)(Code) | | Intelligently sets fields on this entity from the Map of fields passed in
Parameters: fields - The fields Map to get the values from Parameters: setIfEmpty - Used to specify whether empty/null values in the field Map should over-write non-empty values in this entity Parameters: namePrefix - If not null or empty will be pre-pended to each field name (upper-casing the first letter of the field name first), and that will be used as the fields Map lookup name instead of the field-name Parameters: pks - If null, get all values, if TRUE just get PKs, if FALSE just get non-PKs |
setBytes | public void setBytes(String name, byte[] bytes)(Code) | | Sets a field with an array of bytes, wrapping them automatically for easy use.
Parameters: name - The field name to set Parameters: bytes - The byte array to be wrapped and set |
setDelegator | public void setDelegator(GenericDelegator internalDelegator)(Code) | | Set the GenericDelegator instance that created this value object and that is repsonsible for it.
|
setFields | public synchronized void setFields(Map keyValuePairs)(Code) | | Used by clients to update particular fields in the entity
Parameters: keyValuePairs - java.util.Map |
setImmutable | public void setImmutable()(Code) | | |
setIsFromEntitySync | public void setIsFromEntitySync(boolean isFromEntitySync)(Code) | | Parameters: isFromEntitySync - The isFromEntitySync to set. |
setNonPKFields | public void setNonPKFields(Map fields)(Code) | | go through the non-pks and for each one see if there is an entry in fields to set
|
setNonPKFields | public void setNonPKFields(Map fields, boolean setIfEmpty)(Code) | | go through the non-pks and for each one see if there is an entry in fields to set
|
setPKFields | public void setPKFields(Map fields)(Code) | | go through the pks and for each one see if there is an entry in fields to set
|
setPKFields | public void setPKFields(Map fields, boolean setIfEmpty)(Code) | | go through the pks and for each one see if there is an entry in fields to set
|
setString | public void setString(String name, String value)(Code) | | Sets the named field to the passed value, converting the value from a String to the corrent type using Type.valueOf()
Parameters: name - The field name to set Parameters: value - The String value to convert and set |
synchronizedWithDatasource | public void synchronizedWithDatasource()(Code) | | |
toString | public String toString()(Code) | | Creates a String for the entity, overrides the default toString
String corresponding to this entity |
writeXmlText | public void writeXmlText(PrintWriter writer, String prefix)(Code) | | Writes XML text with an attribute or CDATA element for each field of the entity
Parameters: writer - A PrintWriter to write to Parameters: prefix - A prefix to put in front of the entity name in the tag name |
|
|