Package com.xpn.xwiki.objects
Class BaseCollection<R extends EntityReference>
- java.lang.Object
-
- com.xpn.xwiki.objects.BaseElement<R>
-
- com.xpn.xwiki.objects.BaseCollection<R>
-
- All Implemented Interfaces:
ElementInterface
,ObjectInterface
,Serializable
,Cloneable
- Direct Known Subclasses:
BaseClass
,BaseObject
,PropertyClass
,XWikiStats
public abstract class BaseCollection<R extends EntityReference> extends BaseElement<R> implements ObjectInterface, Cloneable
Base class for representing an element having a collection of properties. For example:- an XClass definition (composed of XClass properties)
- an XObject definition (composed of XObject properties)
- an XWikiStats object (composed of stats properties)
- Version:
- $Id: cc9e7ed2a39523c6d73f833b55c2e9311df1c4fa $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DocumentReferenceResolver<EntityReference>
currentReferenceDocumentReferenceResolver
Used to normalize references.protected Map<String,Object>
fields
List of properties (eg XClass properties, XObject properties, etc).protected List<Object>
fieldsToRemove
protected int
number
The meaning of this reference fields depends on the element represented.protected EntityReferenceResolver<String>
relativeEntityReferenceResolver
Used to resolve XClass references in the way they are stored externally (database, xml, etc), ie relative or absolute.-
Fields inherited from class com.xpn.xwiki.objects.BaseElement
documentReference, ownerDocument, referenceCache
-
-
Constructor Summary
Constructors Constructor Description BaseCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addField(String name, PropertyInterface element)
void
addPropertyForRemoval(PropertyInterface field)
Marks a field as scheduled for removal when saving this entity.boolean
apply(ElementInterface newElement, boolean clean)
Apply the provided element so that the current one contains the same informations and indicate if it was necessary to modify it in any way.BaseCollection
clone()
boolean
equals(Object coll)
PropertyInterface
get(String name)
String
getClassName()
Deprecated.since 2.2M2 usegetXClassReference()
insteadprotected DocumentReferenceResolver<EntityReference>
getCurrentReferenceDocumentReferenceResolver()
Map<String,Object>
getCustomMappingMap()
Date
getDateValue(String name)
List<ObjectDiff>
getDiff(Object oldObject, XWikiContext context)
double
getDoubleValue(String name)
PropertyInterface
getField(String name)
Collection
getFieldList()
List
getFieldsToRemove()
float
getFloatValue(String name)
int
getIntValue(String name)
int
getIntValue(String name, int default_value)
String
getLargeStringValue(String name)
List
getListValue(String name)
long
getLongValue(String name)
int
getNumber()
Object[]
getProperties()
Set<String>
getPropertyList()
String[]
getPropertyNames()
protected EntityReferenceResolver<String>
getRelativeEntityReferenceResolver()
EntityReference
getRelativeXClassReference()
Get the actual reference to the XClass as stored in this instance.Set<?>
getSetValue(String name)
Iterator
getSortedIterator()
Return an iterator that will operate on a collection of values (as would be returned by getProperties or getFieldList) sorted by their name (ElementInterface.getName()).String
getStringValue(String name)
BaseClass
getXClass(XWikiContext context)
DocumentReference
getXClassReference()
Get the absolute reference of the XClass.void
merge(BaseObject object)
MergeManagerResult<ElementInterface,Object>
merge(ElementInterface previousElement, ElementInterface newElement, MergeConfiguration configuration, XWikiContext context)
Apply a 3 ways merge on the current element based on provided previous and new version of the element.protected void
mergeField(PropertyInterface currentElement, ElementInterface previousElement, ElementInterface newElement, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
void
put(String name, PropertyInterface property)
void
removeField(String name)
PropertyInterface
safeget(String name)
void
safeput(String name, PropertyInterface property)
void
setClassName(String name)
Deprecated.since 2.2.3 usesetXClassReference(EntityReference)
()} insteadvoid
setDateValue(String name, Date value)
void
setDBStringListValue(String name, List value)
void
setDocumentReference(DocumentReference reference)
void
setDoubleValue(String name, double value)
void
setFields(Map fields)
void
setFieldsToRemove(List fieldsToRemove)
void
setFloatValue(String name, float value)
void
setIntValue(String name, int value)
void
setLargeStringValue(String name, String value)
void
setLongValue(String name, long value)
void
setNumber(int number)
void
setOwnerDocument(XWikiDocument ownerDocument)
Set the owner document of this base object.void
setSetValue(String name, Set<?> value)
void
setStringListValue(String name, List value)
void
setStringValue(String name, String value)
void
setXClassReference(EntityReference xClassReference)
Set the reference to the XClass (used for an XObject).org.dom4j.Element
toXML()
org.dom4j.Element
toXML(BaseClass bclass)
Deprecated.since 9.0RC1, usetoXML()
insteadString
toXMLString()
Return a XML version of this collection.-
Methods inherited from class com.xpn.xwiki.objects.BaseElement
createReference, fromXML, fromXML, getDocumentReference, getId, getLocalEntityReferenceSerializer, getLocalization, getLocalKey, getLocalUidStringEntityReferenceSerializer, getMergeManager, getName, getOwnerDocument, getPrettyName, getReference, getXWikiContext, hashCode, localizePlain, localizePlainOrKey, merge, setId, setName, setPrettyName, toString, toXMLString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.xpn.xwiki.objects.ElementInterface
getDocumentReference, getName, getReference, merge, setName, toString
-
-
-
-
Field Detail
-
fields
protected Map<String,Object> fields
List of properties (eg XClass properties, XObject properties, etc).
-
number
protected int number
The meaning of this reference fields depends on the element represented. Examples:- When the BaseCollection represents an XObject, this number is the position of this XObject in the document where it's located. The first XObject of a given XClass type is at position 0, and other XObject of the same XClass type are at position 1, etc.
-
relativeEntityReferenceResolver
protected EntityReferenceResolver<String> relativeEntityReferenceResolver
Used to resolve XClass references in the way they are stored externally (database, xml, etc), ie relative or absolute.
-
currentReferenceDocumentReferenceResolver
protected DocumentReferenceResolver<EntityReference> currentReferenceDocumentReferenceResolver
Used to normalize references.
-
-
Method Detail
-
getRelativeEntityReferenceResolver
protected EntityReferenceResolver<String> getRelativeEntityReferenceResolver()
- Returns:
- the component used to resolve XClass references in the way they are stored externally (database, xml, etc), ie relative or absolute
-
getCurrentReferenceDocumentReferenceResolver
protected DocumentReferenceResolver<EntityReference> getCurrentReferenceDocumentReferenceResolver()
- Returns:
- the component used to normalize references
-
getNumber
public int getNumber()
-
setNumber
public void setNumber(int number)
-
addPropertyForRemoval
public void addPropertyForRemoval(PropertyInterface field)
Marks a field as scheduled for removal when saving this entity. Should only be used internally, useremoveField(String)
to actually remove a field.- Parameters:
field
- the field to remove, must belong to this entity- See Also:
removeField(String)
-
getXClassReference
public DocumentReference getXClassReference()
Get the absolute reference of the XClass.- Since:
- 2.2M2
-
getRelativeXClassReference
public EntityReference getRelativeXClassReference()
Get the actual reference to the XClass as stored in this instance.- Since:
- 4.0M2
-
getClassName
@Deprecated public String getClassName()
Deprecated.since 2.2M2 usegetXClassReference()
insteadNote that this method cannot be removed for now since it's used by Hibernate for saving an XObject.
-
setXClassReference
public void setXClassReference(EntityReference xClassReference)
Set the reference to the XClass (used for an XObject).Note that absolute reference are not supported for xclasses which mean that the wiki part (whatever the wiki is) of the reference will be systematically removed.
- Parameters:
xClassReference
- the reference to the XClass of this XObject.- Since:
- 2.2.3
-
setClassName
@Deprecated public void setClassName(String name)
Deprecated.since 2.2.3 usesetXClassReference(EntityReference)
()} insteadNote that this method cannot be removed for now since it's used by Hibernate for loading an XObject.
-
safeget
public PropertyInterface safeget(String name)
- Specified by:
safeget
in interfaceObjectInterface
-
get
public PropertyInterface get(String name) throws XWikiException
- Specified by:
get
in interfaceObjectInterface
- Throws:
XWikiException
-
safeput
public void safeput(String name, PropertyInterface property)
- Specified by:
safeput
in interfaceObjectInterface
-
put
public void put(String name, PropertyInterface property) throws XWikiException
- Specified by:
put
in interfaceObjectInterface
- Throws:
XWikiException
-
getXClass
public BaseClass getXClass(XWikiContext context)
- Specified by:
getXClass
in interfaceObjectInterface
- Since:
- 2.2M1
-
getIntValue
public int getIntValue(String name)
-
getIntValue
public int getIntValue(String name, int default_value)
-
setIntValue
public void setIntValue(String name, int value)
-
getLongValue
public long getLongValue(String name)
-
setLongValue
public void setLongValue(String name, long value)
-
getFloatValue
public float getFloatValue(String name)
-
setFloatValue
public void setFloatValue(String name, float value)
-
getDoubleValue
public double getDoubleValue(String name)
-
setDoubleValue
public void setDoubleValue(String name, double value)
-
setFields
public void setFields(Map fields)
-
getField
public PropertyInterface getField(String name)
-
addField
public void addField(String name, PropertyInterface element)
-
removeField
public void removeField(String name)
-
getFieldList
public Collection getFieldList()
-
getProperties
public Object[] getProperties()
-
getPropertyNames
public String[] getPropertyNames()
-
getSortedIterator
public Iterator getSortedIterator()
Return an iterator that will operate on a collection of values (as would be returned by getProperties or getFieldList) sorted by their name (ElementInterface.getName()).
-
equals
public boolean equals(Object coll)
- Overrides:
equals
in classBaseElement<R extends EntityReference>
-
clone
public BaseCollection clone()
- Overrides:
clone
in classBaseElement<R extends EntityReference>
-
merge
public void merge(BaseObject object)
-
getDiff
public List<ObjectDiff> getDiff(Object oldObject, XWikiContext context)
-
getFieldsToRemove
public List getFieldsToRemove()
-
setFieldsToRemove
public void setFieldsToRemove(List fieldsToRemove)
-
toXML
public org.dom4j.Element toXML()
- Overrides:
toXML
in classBaseElement<R extends EntityReference>
-
toXML
@Deprecated public org.dom4j.Element toXML(BaseClass bclass)
Deprecated.since 9.0RC1, usetoXML()
instead- Specified by:
toXML
in interfaceObjectInterface
-
toXMLString
public String toXMLString()
Return a XML version of this collection.The XML is not formated. to get formatted XML you can use
BaseElement.toXMLString(boolean)
instead.- Returns:
- the XML as a String
-
getCustomMappingMap
public Map<String,Object> getCustomMappingMap() throws XWikiException
- Throws:
XWikiException
- Since:
- 2.4M2
-
setDocumentReference
public void setDocumentReference(DocumentReference reference)
- Specified by:
setDocumentReference
in interfaceElementInterface
- Overrides:
setDocumentReference
in classBaseElement<R extends EntityReference>
-
merge
public MergeManagerResult<ElementInterface,Object> merge(ElementInterface previousElement, ElementInterface newElement, MergeConfiguration configuration, XWikiContext context)
Description copied from interface:ElementInterface
Apply a 3 ways merge on the current element based on provided previous and new version of the element.All 3 elements are supposed to have the same class and reference.
Note that the current element is modified only if
MergeConfiguration.isProvidedVersionsModifiables()
returnstrue
.- Specified by:
merge
in interfaceElementInterface
- Overrides:
merge
in classBaseElement<R extends EntityReference>
- Parameters:
previousElement
- the previous version of the elementnewElement
- the next version of the elementconfiguration
- the configuration of the merge Indicate how to deal with some conflicts use cases, etc.context
- the XWiki context
-
mergeField
protected void mergeField(PropertyInterface currentElement, ElementInterface previousElement, ElementInterface newElement, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
-
apply
public boolean apply(ElementInterface newElement, boolean clean)
Description copied from interface:ElementInterface
Apply the provided element so that the current one contains the same informations and indicate if it was necessary to modify it in any way.- Specified by:
apply
in interfaceElementInterface
- Overrides:
apply
in classBaseElement<R extends EntityReference>
- Parameters:
newElement
- the element to applyclean
- true if informations that are not in the new element should be removed (for example class properties not in the new class)- Returns:
- true if the element has been modified
-
setOwnerDocument
public void setOwnerDocument(XWikiDocument ownerDocument)
Set the owner document of this base object.- Overrides:
setOwnerDocument
in classBaseElement<R extends EntityReference>
- Parameters:
ownerDocument
- The owner document.- Since:
- 5.3M1
-
-