|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
org.ofbiz.entity.GenericEntity
public class GenericEntity
Generic Entity Value Object - Handles persistence 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
.
Nested Class Summary | |
---|---|
static interface |
GenericEntity.NULL
|
static class |
GenericEntity.NullField
|
static class |
GenericEntity.NullGenericEntity
|
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Field Summary | |
---|---|
protected int |
cachedHashCode
|
protected java.lang.String |
delegatorName
Name of the GenericDelegator, used to re-get the GenericDelegator when deserialized |
protected java.lang.String |
entityName
Contains the entityName of this entity, necessary for efficiency when creating EJBs |
protected java.util.Map<java.lang.String,java.lang.Object> |
fields
Contains the fields for this entity. |
protected boolean |
generateHashCode
|
protected GenericDelegator |
internalDelegator
Reference to an instance of GenericDelegator used to do some basic operations on this entity value. |
protected boolean |
isFromEntitySync
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 |
protected ModelEntity |
modelEntity
Contains the ModelEntity instance that represents the definition of this entity, not to be serialized |
protected boolean |
modified
Denotes whether or not this entity has been modified, or is known to be out of sync with the persistent record |
static java.lang.String |
module
|
protected boolean |
mutable
Used to specify whether or not this representation of the entity can be changed; generally cleared when this object comes from a cache |
static GenericEntity |
NULL_ENTITY
|
static GenericEntity.NullField |
NULL_FIELD
|
Constructor Summary | |
---|---|
protected |
GenericEntity()
Creates new GenericEntity - Should never be used, prefer the other options. |
Method Summary | |
---|---|
static int |
addToXmlDocument(java.util.Collection<GenericValue> values,
org.w3c.dom.Document document)
|
static int |
addToXmlElement(java.util.Collection<GenericValue> values,
org.w3c.dom.Document document,
org.w3c.dom.Element element)
|
void |
clear()
|
java.lang.Object |
clone()
Clones this GenericEntity, this is a shallow clone & uses the default shallow HashMap clone |
int |
compareTo(GenericEntity that)
Compares this GenericEntity to the passed object |
protected int |
compareToFields(GenericEntity that,
java.lang.String name)
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsPrimaryKey()
Returns true if the entity contains all of the primary key fields. |
boolean |
containsPrimaryKey(boolean requireValue)
|
boolean |
containsValue(java.lang.Object value)
|
static GenericEntity |
createGenericEntity(GenericEntity value)
Copy Factory Method: Creates new GenericEntity from existing GenericEntity |
static GenericEntity |
createGenericEntity(ModelEntity modelEntity)
Creates new GenericEntity |
static GenericEntity |
createGenericEntity(ModelEntity modelEntity,
java.util.Map<java.lang.String,? extends java.lang.Object> fields)
Creates new GenericEntity from existing Map |
java.lang.Object |
dangerousGetNoCheckButFast(ModelField modelField)
|
void |
dangerousSetNoCheckButFast(ModelField modelField,
java.lang.Object value)
|
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> |
entrySet()
|
boolean |
equals(java.lang.Object obj)
Determines the equality of two GenericEntity objects, overrides the default equals |
java.lang.Object |
get(java.lang.Object key)
|
java.lang.Object |
get(java.lang.String name)
|
java.lang.Object |
get(java.lang.String name,
java.util.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. |
java.lang.Object |
get(java.lang.String name,
java.lang.String resource,
java.util.Locale locale)
Same as the getResource method that does not take resource name, but instead allows manually specifying the resource name. |
java.util.Map<java.lang.String,java.lang.Object> |
getAllFields()
Returns key/value pairs of entity fields |
java.util.Collection<java.lang.String> |
getAllKeys()
Returns keys of entity fields |
java.math.BigDecimal |
getBigDecimal(java.lang.String name)
|
java.lang.Boolean |
getBoolean(java.lang.String name)
|
byte[] |
getBytes(java.lang.String name)
|
java.sql.Date |
getDate(java.lang.String name)
|
GenericDelegator |
getDelegator()
Get the GenericDelegator instance that created this value object and that is responsible for it. |
java.lang.Double |
getDouble(java.lang.String name)
|
java.lang.String |
getEntityName()
|
java.util.Map<java.lang.String,java.lang.Object> |
getFields(java.util.Collection<java.lang.String> keysofFields)
Used by clients to specify exactly the fields they are interested in |
java.lang.Float |
getFloat(java.lang.String name)
|
java.lang.Integer |
getInteger(java.lang.String name)
|
boolean |
getIsFromEntitySync()
|
java.lang.Long |
getLong(java.lang.String name)
|
ModelEntity |
getModelEntity()
|
java.lang.String |
getPkShortValueString()
|
GenericPK |
getPrimaryKey()
|
java.lang.String |
getString(java.lang.String name)
|
java.sql.Time |
getTime(java.lang.String name)
|
java.sql.Timestamp |
getTimestamp(java.lang.String name)
|
int |
hashCode()
Creates a hashCode for the entity, using the default String hashCode and Map hashCode, overrides the default hashCode |
protected void |
init(GenericEntity value)
Copy Constructor: Creates new GenericEntity from existing GenericEntity |
protected void |
init(ModelEntity modelEntity)
Creates new GenericEntity |
protected void |
init(ModelEntity modelEntity,
java.util.Map<java.lang.String,? extends java.lang.Object> fields)
Creates new GenericEntity from existing Map |
protected void |
init(ModelEntity modelEntity,
java.lang.Object singlePkValue)
Creates new GenericEntity from existing Map |
boolean |
isEmpty()
|
boolean |
isModified()
|
boolean |
isMutable()
|
boolean |
isPrimaryKey()
Returns true if the entity contains all of the primary key fields, but NO others. |
boolean |
isPrimaryKey(boolean requireValue)
|
java.util.Set<java.lang.String> |
keySet()
|
boolean |
lockEnabled()
Used to indicate if locking is enabled for this entity |
static org.w3c.dom.Document |
makeXmlDocument(java.util.Collection<GenericValue> values)
|
org.w3c.dom.Element |
makeXmlElement(org.w3c.dom.Document document)
Makes an XML Element object with an attribute for each field of the entity |
org.w3c.dom.Element |
makeXmlElement(org.w3c.dom.Document document,
java.lang.String prefix)
Makes an XML Element object with an attribute for each field of the entity |
boolean |
matches(EntityCondition condition)
|
boolean |
matchesFields(java.util.Map<java.lang.String,? extends java.lang.Object> keyValuePairs)
|
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
|
void |
putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
|
void |
refreshFromValue(GenericEntity newValue)
|
java.lang.Object |
remove(java.lang.Object key)
|
void |
removedFromDatasource()
|
void |
reset()
|
void |
set(java.lang.String name,
java.lang.Object value)
Sets the named field to the passed value, even if the value is null |
java.lang.Object |
set(java.lang.String name,
java.lang.Object value,
boolean setIfNull)
Sets the named field to the passed value. |
void |
setAllFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields,
boolean setIfEmpty,
java.lang.String namePrefix,
java.lang.Boolean pks)
Intelligently sets fields on this entity from the Map of fields passed in |
void |
setBytes(java.lang.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(java.util.Map<? extends java.lang.String,? extends java.lang.Object> keyValuePairs)
Used by clients to update particular fields in the entity |
void |
setImmutable()
|
void |
setIsFromEntitySync(boolean isFromEntitySync)
|
void |
setNextSeqId()
|
void |
setNonPKFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields)
go through the non-pks and for each one see if there is an entry in fields to set |
void |
setNonPKFields(java.util.Map<? extends java.lang.Object,? extends java.lang.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(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields)
go through the pks and for each one see if there is an entry in fields to set |
void |
setPKFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields,
boolean setIfEmpty)
go through the pks and for each one see if there is an entry in fields to set |
void |
setString(java.lang.String name,
java.lang.String value)
Sets the named field to the passed value, converting the value from a String to the corrent type using Type.valueOf() |
int |
size()
|
void |
synchronizedWithDatasource()
|
java.lang.String |
toString()
Creates a String for the entity, overrides the default toString This method is secure, it will not display encrypted fields |
java.lang.String |
toStringInsecure()
Creates a String for the entity, overrides the default toString This method is NOT secure, it WILL display encrypted fields |
java.util.Collection<java.lang.Object> |
values()
|
void |
writeXmlText(java.io.PrintWriter writer,
java.lang.String prefix)
Writes XML text with an attribute or CDATA element for each field of the entity |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String module
public static final GenericEntity NULL_ENTITY
public static final GenericEntity.NullField NULL_FIELD
protected java.lang.String delegatorName
protected transient GenericDelegator internalDelegator
protected java.util.Map<java.lang.String,java.lang.Object> fields
protected java.lang.String entityName
protected transient ModelEntity modelEntity
protected boolean modified
protected boolean generateHashCode
protected int cachedHashCode
protected boolean mutable
protected boolean isFromEntitySync
Constructor Detail |
---|
protected GenericEntity()
Method Detail |
---|
public static GenericEntity createGenericEntity(ModelEntity modelEntity)
public static GenericEntity createGenericEntity(ModelEntity modelEntity, java.util.Map<java.lang.String,? extends java.lang.Object> fields)
public static GenericEntity createGenericEntity(GenericEntity value)
protected void init(ModelEntity modelEntity)
protected void init(ModelEntity modelEntity, java.util.Map<java.lang.String,? extends java.lang.Object> fields)
protected void init(ModelEntity modelEntity, java.lang.Object singlePkValue)
protected void init(GenericEntity value)
public void reset()
public void refreshFromValue(GenericEntity newValue) throws GenericEntityException
GenericEntityException
public boolean isModified()
public void synchronizedWithDatasource()
public void removedFromDatasource()
public boolean isMutable()
public void setImmutable()
public boolean getIsFromEntitySync()
public void setIsFromEntitySync(boolean isFromEntitySync)
isFromEntitySync
- The isFromEntitySync to set.public java.lang.String getEntityName()
public ModelEntity getModelEntity()
public GenericDelegator getDelegator()
public void setDelegator(GenericDelegator internalDelegator)
public java.lang.Object get(java.lang.String name)
public boolean isPrimaryKey()
public boolean isPrimaryKey(boolean requireValue)
public boolean containsPrimaryKey()
public boolean containsPrimaryKey(boolean requireValue)
public java.lang.String getPkShortValueString()
public void set(java.lang.String name, java.lang.Object value)
name
- The field name to setvalue
- The value to setpublic java.lang.Object set(java.lang.String name, java.lang.Object value, boolean setIfNull)
name
- The field name to setvalue
- The value to setsetIfNull
- Specifies whether or not to set the value if it is nullpublic void dangerousSetNoCheckButFast(ModelField modelField, java.lang.Object value)
public java.lang.Object dangerousGetNoCheckButFast(ModelField modelField)
public void setString(java.lang.String name, java.lang.String value)
Type.valueOf()
name
- The field name to setvalue
- The String value to convert and setpublic void setBytes(java.lang.String name, byte[] bytes)
name
- The field name to setbytes
- The byte array to be wrapped and setpublic void setNextSeqId()
public java.lang.Boolean getBoolean(java.lang.String name)
public java.lang.String getString(java.lang.String name)
public java.sql.Timestamp getTimestamp(java.lang.String name)
public java.sql.Time getTime(java.lang.String name)
public java.sql.Date getDate(java.lang.String name)
public java.lang.Integer getInteger(java.lang.String name)
public java.lang.Long getLong(java.lang.String name)
public java.lang.Float getFloat(java.lang.String name)
public java.lang.Double getDouble(java.lang.String name)
public java.math.BigDecimal getBigDecimal(java.lang.String name)
public byte[] getBytes(java.lang.String name)
public java.lang.Object get(java.lang.String name, java.util.Locale locale)
get
in interface LocalizedMap
name
- The name of the field on the entitylocale
- The locale to use when finding the ResourceBundle, if null uses the default
locale for the current instance of Java
public java.lang.Object get(java.lang.String name, java.lang.String resource, java.util.Locale locale)
name
- The name of the field on the entityresource
- The name of the resource to get the value from; if null defaults to the
default-resource-name on the entity definition, if specified therelocale
- The locale to use when finding the ResourceBundle, if null uses the default
locale for the current instance of Java
public GenericPK getPrimaryKey()
public void setPKFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields)
public void setPKFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields, boolean setIfEmpty)
public void setNonPKFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields)
public void setNonPKFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields, boolean setIfEmpty)
public void setAllFields(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> fields, boolean setIfEmpty, java.lang.String namePrefix, java.lang.Boolean pks)
fields
- The fields Map to get the values fromsetIfEmpty
- Used to specify whether empty/null values in the field Map should over-write non-empty values in this entitynamePrefix
- 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-namepks
- If null, get all values, if TRUE just get PKs, if FALSE just get non-PKspublic java.util.Collection<java.lang.String> getAllKeys()
public java.util.Map<java.lang.String,java.lang.Object> getAllFields()
public java.util.Map<java.lang.String,java.lang.Object> getFields(java.util.Collection<java.lang.String> keysofFields)
keysofFields
- the name of the fields the client is interested in
public void setFields(java.util.Map<? extends java.lang.String,? extends java.lang.Object> keyValuePairs)
keyValuePairs
- java.util.Mappublic boolean matchesFields(java.util.Map<java.lang.String,? extends java.lang.Object> keyValuePairs)
public boolean lockEnabled()
public static org.w3c.dom.Document makeXmlDocument(java.util.Collection<GenericValue> values)
public static int addToXmlDocument(java.util.Collection<GenericValue> values, org.w3c.dom.Document document)
public static int addToXmlElement(java.util.Collection<GenericValue> values, org.w3c.dom.Document document, org.w3c.dom.Element element)
public org.w3c.dom.Element makeXmlElement(org.w3c.dom.Document document)
document
- The XML Document that the new Element will be part of
public org.w3c.dom.Element makeXmlElement(org.w3c.dom.Document document, java.lang.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 name
public void writeXmlText(java.io.PrintWriter writer, java.lang.String prefix)
writer
- A PrintWriter to write toprefix
- A prefix to put in front of the entity name in the tag namepublic boolean equals(java.lang.Object obj)
equals
in interface java.util.Map<java.lang.String,java.lang.Object>
equals
in class java.lang.Object
obj
- The object (GenericEntity) to compare this two
public int hashCode()
hashCode
in interface java.util.Map<java.lang.String,java.lang.Object>
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringInsecure()
protected int compareToFields(GenericEntity that, java.lang.String name)
public int compareTo(GenericEntity that)
compareTo
in interface java.lang.Comparable<GenericEntity>
that
- Object to compare this to
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.Object put(java.lang.String key, java.lang.Object value)
put
in interface java.util.Map<java.lang.String,java.lang.Object>
public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
putAll
in interface java.util.Map<java.lang.String,java.lang.Object>
public void clear()
clear
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Collection<java.lang.Object> values()
values
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,java.lang.Object>
public int size()
size
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean matches(EntityCondition condition)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |