com.xpn.xwiki.objects
Class BaseCollection<R extends EntityReference>

java.lang.Object
  extended by com.xpn.xwiki.objects.BaseElement<R>
      extended by 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:

Version:
$Id: 8ea6c2eb9b816561dcd4c76f495dc1fac802c7b3 $
See Also:
Serialized Form

Field Summary
protected  DocumentReferenceResolver<EntityReference> currentReferenceDocumentReferenceResolver
          Used to normalize references.
protected  Map<String,Object> fields
          List of properties (eg XClass properties, XObject properties, etc).
protected  List 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
localEntityReferenceSerializer, referenceCache
 
Constructor Summary
BaseCollection()
           
 
Method Summary
 void addField(String name, PropertyInterface element)
           
 void addPropertyForRemoval(PropertyInterface field)
           
 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 use getXClassReference() instead
 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()
           
 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)
           
 void merge(ElementInterface previousElement, ElementInterface newElement, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
          Apply a 3 ways merge on the current element based on provided previous and new version of the element.
 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 use setXClassReference(EntityReference) ()} instead
 void 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 setName(String name)
          Note that this method is used by Hibernate for loading an element.
 void setNumber(int number)
           
 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).
 String toString()
           
abstract  org.dom4j.Element toXML(BaseClass bclass)
           
 String toXMLString()
           
 
Methods inherited from class com.xpn.xwiki.objects.BaseElement
createReference, getDocumentReference, getId, getLocalKey, getLocalUidStringEntityReferenceSerializer, getName, getPrettyName, getReference, hashCode, setId, setPrettyName
 
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
 

Field Detail

fields

protected Map<String,Object> fields
List of properties (eg XClass properties, XObject properties, etc).


fieldsToRemove

protected List fieldsToRemove

number

protected int number
The meaning of this reference fields depends on the element represented. Examples:


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.

Constructor Detail

BaseCollection

public BaseCollection()
Method Detail

getNumber

public int getNumber()

setNumber

public void setNumber(int number)

addPropertyForRemoval

public void addPropertyForRemoval(PropertyInterface field)

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 use getXClassReference() instead

Note 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 use setXClassReference(EntityReference) ()} instead

Note 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 interface ObjectInterface

get

public PropertyInterface get(String name)
                      throws XWikiException
Specified by:
get in interface ObjectInterface
Throws:
XWikiException

safeput

public void safeput(String name,
                    PropertyInterface property)
Specified by:
safeput in interface ObjectInterface

put

public void put(String name,
                PropertyInterface property)
         throws XWikiException
Specified by:
put in interface ObjectInterface
Throws:
XWikiException

getXClass

public BaseClass getXClass(XWikiContext context)
Specified by:
getXClass in interface ObjectInterface
Since:
2.2M1

getStringValue

public String getStringValue(String name)

getLargeStringValue

public String getLargeStringValue(String name)

setStringValue

public void setStringValue(String name,
                           String value)

setLargeStringValue

public void setLargeStringValue(String name,
                                String value)

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)

getDateValue

public Date getDateValue(String name)

setDateValue

public void setDateValue(String name,
                         Date value)

getSetValue

public Set<?> getSetValue(String name)

setSetValue

public void setSetValue(String name,
                        Set<?> value)

getListValue

public List getListValue(String name)

setStringListValue

public void setStringListValue(String name,
                               List value)

setDBStringListValue

public void setDBStringListValue(String name,
                                 List 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()

getPropertyList

public Set<String> getPropertyList()

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 class BaseElement<R extends EntityReference>

clone

public BaseCollection clone()
Overrides:
clone in class BaseElement<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 abstract org.dom4j.Element toXML(BaseClass bclass)
Specified by:
toXML in interface ObjectInterface

toXMLString

public String toXMLString()

toString

public String toString()
Specified by:
toString in interface ElementInterface
Overrides:
toString in class Object

getCustomMappingMap

public Map<String,Object> getCustomMappingMap()
                                       throws XWikiException
Throws:
XWikiException
Since:
2.4M2

setDocumentReference

public void setDocumentReference(DocumentReference reference)
Specified by:
setDocumentReference in interface ElementInterface
Overrides:
setDocumentReference in class BaseElement<R extends EntityReference>

setName

public void setName(String name)
Description copied from class: BaseElement
Note that this method is used by Hibernate for loading an element.

Specified by:
setName in interface ElementInterface
Overrides:
setName in class BaseElement<R extends EntityReference>
See Also:
ElementInterface.setName(java.lang.String)

merge

public void merge(ElementInterface previousElement,
                  ElementInterface newElement,
                  MergeConfiguration configuration,
                  XWikiContext context,
                  MergeResult mergeResult)
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.

Specified by:
merge in interface ElementInterface
Overrides:
merge in class BaseElement<R extends EntityReference>
Parameters:
previousElement - the previous version of the element
newElement - the next version of the element
configuration - the configuration of the merge Indicate how to deal with some conflicts use cases, etc.
context - the XWiki context
mergeResult - the merge report

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 interface ElementInterface
Overrides:
apply in class BaseElement<R extends EntityReference>
Parameters:
newElement - the element to apply
clean - 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


Copyright © 2004-2013 XWiki. All Rights Reserved.