public class GenericEntity extends Observable implements Map<String,Object>, Serializable, Comparable<GenericEntity>, Cloneable
Note that this class extends Observable to achieve change notification for
Observers. 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.
| Modifier and Type | Field and Description |
|---|---|
String |
delegatorName
Name of the GenericDelegator, used to re-get the GenericDelegator when deserialized
|
String |
entityName
Contains the entityName of this entity, necessary for efficiency when creating EJBs
|
protected Map<String,Object> |
fields
Contains the fields for this entity.
|
GenericDelegator |
internalDelegator
Reference to an instance of GenericDelegator used to do some basic operations on this entity value.
|
ModelEntity |
modelEntity
Contains the ModelEntity instance that represents the definition of this entity, not to be serialized
|
boolean |
modified
Denotes whether or not this entity has been modified, or is known to be out of sync with the persistent record
|
| Constructor and Description |
|---|
GenericEntity()
Deprecated.
since 1.0.13 Use
GenericEntity(GenericDelegator internalDelegator) |
GenericEntity(GenericDelegator delegator)
Creates new GenericEntity
|
GenericEntity(GenericDelegator delegator,
ModelEntity modelEntity)
Creates new GenericEntity.
|
GenericEntity(GenericDelegator delegator,
ModelEntity modelEntity,
Map<String,?> fields)
Creates new GenericEntity from existing Map.
|
GenericEntity(GenericEntity value)
Copy Constructor: Creates new GenericEntity from existing GenericEntity
|
GenericEntity(ModelEntity modelEntity)
Deprecated.
|
GenericEntity(ModelEntity modelEntity,
Map<String,?> fields)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
addToXmlDocument(Collection<GenericValue> values,
Document document) |
void |
clear() |
Object |
clone()
Clones this GenericEntity, this is a shallow clone & uses the default shallow HashMap clone
|
int |
compareTo(GenericEntity obj)
Compares this GenericEntity to the passed object
|
boolean |
containsKey(Object key) |
boolean |
containsPrimaryKey()
Returns true if the entity contains all of the primary key fields.
|
boolean |
containsValue(Object value) |
Object |
dangerousGetNoCheckButFast(ModelField modelField) |
void |
dangerousSetNoCheckButFast(ModelField modelField,
Object value) |
Set<Map.Entry<String,Object>> |
entrySet() |
boolean |
equals(Object obj)
Determines the equality of two GenericEntity objects, overrides the default equals
|
Object |
get(Object key) |
Object |
get(String name) |
Map<String,Object> |
getAllFields()
Returns key/value pairs of entity fields
|
Collection<String> |
getAllKeys()
Returns keys of entity fields
|
Boolean |
getBoolean(String name) |
byte[] |
getBytes(String name) |
Date |
getDate(String name) |
GenericDelegator |
getDelegator()
Get the GenericDelegator instance that created this value object and that is responsible for it.
|
Double |
getDouble(String name) |
String |
getEntityName() |
Map<String,Object> |
getFields(Collection<String> keysofFields)
Used by clients to specify exactly the fields they are interested in
|
Float |
getFloat(String name) |
Integer |
getInteger(String name) |
Long |
getLong(String name) |
ModelEntity |
getModelEntity() |
GenericPK |
getPrimaryKey() |
String |
getString(String name) |
Time |
getTime(String name) |
Timestamp |
getTimestamp(String name) |
int |
hashCode()
Creates a hashCode for the entity, using the default String hashCode and Map hashCode, overrides the default hashCode
|
boolean |
isEmpty() |
boolean |
isModified() |
boolean |
isPrimaryKey()
Returns true if the entity contains all of the primary key fields, but NO others.
|
Set<String> |
keySet() |
boolean |
lockEnabled()
Used to indicate if locking is enabled for this entity
|
static Document |
makeXmlDocument(Collection<GenericValue> values) |
Element |
makeXmlElement(Document document)
Makes an XML Element object with an attribute for each field of the entity
|
Element |
makeXmlElement(Document document,
String prefix)
Makes an XML Element object with an attribute for each field of the entity
|
boolean |
matchesFields(Map<String,?> keyValuePairs) |
Object |
put(String key,
Object value) |
void |
putAll(Map<? extends String,?> map) |
Object |
remove(Object key) |
void |
set(String name,
Object value)
Sets the named field to the passed value, even if the value is null
|
Object |
set(String field,
Object value,
boolean setIfNull)
Sets the named field to the passed value.
|
void |
setBytes(String name,
byte[] bytes)
Sets a field with an array of bytes, wrapping them automatically for easy use.
|
void |
setDelegator(GenericDelegator internalDelegator)
Set the GenericDelegator instance that created this value object and that is responsible for it.
|
void |
setFields(Map<? extends String,?> newFieldValues)
Updates the given fields of this entity with the values in the given map, including nulls.
|
void |
setNonPKFields(Map<String,Object> fields)
go through the non-pks and for each one see if there is an entry in fields to set
|
void |
setNonPKFields(Map<String,Object> fields,
boolean setIfEmpty)
go through the non-pks and for each one see if there is an entry in fields to set
|
void |
setPKFields(Map<String,Object> fields)
go through the pks and for each one see if there is an entry in fields to set
|
void |
setPKFields(Map<String,Object> fields,
boolean setIfEmpty)
go through the pks and for each one see if there is an entry in fields to set
|
void |
setString(String name,
String value)
Sets the named field to the passed value, converting the value from a String to the correct type using
Type.valueOf() or similar. |
int |
size() |
String |
toString()
Creates a String for the entity, overrides the default toString
|
Collection<Object> |
values() |
void |
writeXmlText(PrintWriter writer,
String prefix)
Writes XML text with an attribute or CDATA element for each field of the entity
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedpublic String delegatorName
public transient GenericDelegator internalDelegator
public String entityName
public transient ModelEntity modelEntity
public boolean modified
public GenericEntity(GenericDelegator delegator)
public GenericEntity(GenericDelegator delegator, ModelEntity modelEntity)
public GenericEntity(GenericDelegator delegator, ModelEntity modelEntity, Map<String,?> fields)
public GenericEntity()
GenericEntity(GenericDelegator internalDelegator)public GenericEntity(ModelEntity modelEntity)
GenericEntity(GenericDelegator internalDelegator, ModelEntity modelEntity)public GenericEntity(ModelEntity modelEntity, Map<String,?> fields)
GenericEntity(GenericDelegator internalDelegator, ModelEntity modelEntity, Map fields)public GenericEntity(GenericEntity value)
public boolean isModified()
public String getEntityName()
public ModelEntity getModelEntity()
public GenericDelegator getDelegator()
public void setDelegator(GenericDelegator internalDelegator)
public boolean isPrimaryKey()
public boolean containsPrimaryKey()
public void set(String name, Object value)
name - The field name to setvalue - The value to setpublic Object set(String field, Object value, boolean setIfNull)
field - the name of the field to set; must be a valid field of this entityvalue - the value to set; if null, will only be stored if setIfNull is truesetIfNull - specifies whether or not to set the value if it is nullpublic void dangerousSetNoCheckButFast(ModelField modelField, Object value)
public Object dangerousGetNoCheckButFast(ModelField modelField)
public void setString(String name, String value)
Type.valueOf() or similar.
WARNING: calling this for an OBJECT field is ambiguous, because
you could mean either that the String is the Base64-encoded representation of the object and
should be be deserialized or that the String is the actual object to be stored. Since this
method is intended for use in restoring the entity from an XML export, it assumes that the value is
the Base64-encoding of an arbitrary object and attempts to deserialize it. If this is not what is
intended, then it is up to the caller to use set(String, Object) for those fields, instead.
name - The field name to setvalue - The String value to convert and setpublic void setBytes(String name, byte[] bytes)
name - The field name to setbytes - The byte array to be wrapped and setpublic byte[] getBytes(String name)
public GenericPK getPrimaryKey()
public void setPKFields(Map<String,Object> fields)
public void setPKFields(Map<String,Object> fields, boolean setIfEmpty)
public void setNonPKFields(Map<String,Object> fields)
public void setNonPKFields(Map<String,Object> fields, boolean setIfEmpty)
public Collection<String> getAllKeys()
public Map<String,Object> getAllFields()
public Map<String,Object> getFields(Collection<String> keysofFields)
keysofFields - the name of the fields the client is interested inpublic void setFields(Map<? extends String,?> newFieldValues)
newFieldValues - map of valid field names to new values; if null, this method does nothingpublic boolean lockEnabled()
public static Document makeXmlDocument(Collection<GenericValue> values)
public static int addToXmlDocument(Collection<GenericValue> values, Document document)
public Element makeXmlElement(Document document)
document - The XML Document that the new Element will be part ofpublic Element makeXmlElement(Document document, String prefix)
document - The XML Document that the new Element will be part ofprefix - A prefix to put in front of the entity name in the tag namepublic void writeXmlText(PrintWriter writer, String prefix)
writer - A PrintWriter to write toprefix - A prefix to put in front of the entity name in the tag namepublic boolean equals(Object obj)
public int hashCode()
public String toString()
public int compareTo(GenericEntity obj)
compareTo in interface Comparable<GenericEntity>obj - Object to compare this topublic Object clone()
public boolean containsKey(Object key)
containsKey in interface Map<String,Object>public boolean containsValue(Object value)
containsValue in interface Map<String,Object>Copyright © 2016 Atlassian. All rights reserved.