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>currentReferenceDocumentReferenceResolverUsed to normalize references.protected Map<String,Object>fieldsList of properties (eg XClass properties, XObject properties, etc).protected List<Object>fieldsToRemoveprotected intnumberThe meaning of this reference fields depends on the element represented.protected EntityReferenceResolver<String>relativeEntityReferenceResolverUsed 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 voidaddField(String name, PropertyInterface element)voidaddPropertyForRemoval(PropertyInterface field)Marks a field as scheduled for removal when saving this entity.booleanapply(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.BaseCollectionclone()booleanequals(Object coll)PropertyInterfaceget(String name)StringgetClassName()Deprecated.since 2.2M2 usegetXClassReference()insteadprotected DocumentReferenceResolver<EntityReference>getCurrentReferenceDocumentReferenceResolver()Map<String,Object>getCustomMappingMap()DategetDateValue(String name)List<ObjectDiff>getDiff(Object oldObject, XWikiContext context)doublegetDoubleValue(String name)PropertyInterfacegetField(String name)CollectiongetFieldList()ListgetFieldsToRemove()floatgetFloatValue(String name)intgetIntValue(String name)intgetIntValue(String name, int default_value)StringgetLargeStringValue(String name)ListgetListValue(String name)longgetLongValue(String name)intgetNumber()Object[]getProperties()Set<String>getPropertyList()String[]getPropertyNames()protected EntityReferenceResolver<String>getRelativeEntityReferenceResolver()EntityReferencegetRelativeXClassReference()Get the actual reference to the XClass as stored in this instance.Set<?>getSetValue(String name)IteratorgetSortedIterator()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()).StringgetStringValue(String name)BaseClassgetXClass(XWikiContext context)DocumentReferencegetXClassReference()Get the absolute reference of the XClass.voidmerge(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 voidmergeField(PropertyInterface currentElement, ElementInterface previousElement, ElementInterface newElement, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)voidput(String name, PropertyInterface property)voidremoveField(String name)PropertyInterfacesafeget(String name)voidsafeput(String name, PropertyInterface property)voidsetClassName(String name)Deprecated.since 2.2.3 usesetXClassReference(EntityReference)()} insteadvoidsetDateValue(String name, Date value)voidsetDBStringListValue(String name, List value)voidsetDocumentReference(DocumentReference reference)voidsetDoubleValue(String name, double value)voidsetFields(Map fields)voidsetFieldsToRemove(List fieldsToRemove)voidsetFloatValue(String name, float value)voidsetIntValue(String name, int value)voidsetLargeStringValue(String name, String value)voidsetLongValue(String name, long value)voidsetNumber(int number)voidsetOwnerDocument(XWikiDocument ownerDocument)Set the owner document of this base object.voidsetSetValue(String name, Set<?> value)voidsetStringListValue(String name, List value)voidsetStringValue(String name, String value)voidsetXClassReference(EntityReference xClassReference)Set the reference to the XClass (used for an XObject).org.dom4j.ElementtoXML()org.dom4j.ElementtoXML(BaseClass bclass)Deprecated.since 9.0RC1, usetoXML()insteadStringtoXMLString()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:
safegetin interfaceObjectInterface
-
get
public PropertyInterface get(String name) throws XWikiException
- Specified by:
getin interfaceObjectInterface- Throws:
XWikiException
-
safeput
public void safeput(String name, PropertyInterface property)
- Specified by:
safeputin interfaceObjectInterface
-
put
public void put(String name, PropertyInterface property) throws XWikiException
- Specified by:
putin interfaceObjectInterface- Throws:
XWikiException
-
getXClass
public BaseClass getXClass(XWikiContext context)
- Specified by:
getXClassin 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:
equalsin classBaseElement<R extends EntityReference>
-
clone
public BaseCollection clone()
- Overrides:
clonein 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:
toXMLin classBaseElement<R extends EntityReference>
-
toXML
@Deprecated public org.dom4j.Element toXML(BaseClass bclass)
Deprecated.since 9.0RC1, usetoXML()instead- Specified by:
toXMLin 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:
setDocumentReferencein interfaceElementInterface- Overrides:
setDocumentReferencein classBaseElement<R extends EntityReference>
-
merge
public MergeManagerResult<ElementInterface,Object> merge(ElementInterface previousElement, ElementInterface newElement, MergeConfiguration configuration, XWikiContext context)
Description copied from interface:ElementInterfaceApply 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:
mergein interfaceElementInterface- Overrides:
mergein 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:ElementInterfaceApply 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:
applyin interfaceElementInterface- Overrides:
applyin 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:
setOwnerDocumentin classBaseElement<R extends EntityReference>- Parameters:
ownerDocument- The owner document.- Since:
- 5.3M1
-
-