Package com.xpn.xwiki.objects
Class BaseProperty<R extends EntityReference>
- java.lang.Object
-
- com.xpn.xwiki.objects.BaseElement<R>
-
- com.xpn.xwiki.objects.BaseProperty<R>
-
- All Implemented Interfaces:
ElementInterface
,PropertyInterface
,Serializable
,Cloneable
- Direct Known Subclasses:
BaseStringProperty
,DateProperty
,ListProperty
,NumberProperty
public class BaseProperty<R extends EntityReference> extends BaseElement<R> implements PropertyInterface, Serializable, Cloneable
- Version:
- $Id: b31e1026e08bde7d6e565ab61099916326ceda0e $
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.xpn.xwiki.objects.BaseElement
documentReference, ownerDocument, referenceCache
-
-
Constructor Summary
Constructors Constructor Description BaseProperty()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
apply(ElementInterface newProperty, 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.BaseProperty<R>
clone()
protected void
cloneInternal(BaseProperty clone)
Subclasses override this to copy values during cloning.protected R
createReference()
boolean
equals(Object el)
String
getClassType()
Object
getCustomMappingValue()
long
getId()
Return an truncated MD5 hash of the local key computed inBaseElement.getLocalKey()
.BaseCollection
getObject()
PropertyClass
getPropertyClass(XWikiContext xcontext)
Object
getValue()
int
hashCode()
boolean
isValueDirty()
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.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.protected MergeManagerResult<Object,Object>
mergeValue(Object previousValue, Object newValue, MergeConfiguration mergeConfiguration)
Try to apply 3 ways merge on property value.protected void
mergeValue(Object previousValue, Object newValue, MergeResult mergeResult)
Deprecated.void
setClassType(String type)
void
setId(long id)
Dummy function, do hibernate is always happy.void
setObject(BaseCollection object)
void
setOwnerDocument(XWikiDocument ownerDocument)
Set the owner document of this base property.void
setValue(Object value)
void
setValueDirty(boolean valueDirty)
protected void
setValueDirty(Object newValue)
Set the dirty flag if the new value isn't equal to the old value.String
toFormString()
String
toText()
org.dom4j.Element
toXML()
String
toXMLString()
Return a XML version of this collection.-
Methods inherited from class com.xpn.xwiki.objects.BaseElement
fromXML, fromXML, getDocumentReference, getLocalEntityReferenceSerializer, getLocalization, getLocalKey, getLocalUidStringEntityReferenceSerializer, getMergeManager, getName, getOwnerDocument, getPrettyName, getReference, getXWikiContext, localizePlain, localizePlainOrKey, setDocumentReference, 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, setDocumentReference, setName, toString
-
-
-
-
Method Detail
-
createReference
protected R createReference()
- Overrides:
createReference
in classBaseElement<R extends EntityReference>
-
getObject
public BaseCollection getObject()
- Specified by:
getObject
in interfacePropertyInterface
-
setObject
public void setObject(BaseCollection object)
- Specified by:
setObject
in interfacePropertyInterface
-
equals
public boolean equals(Object el)
- Overrides:
equals
in classBaseElement<R extends EntityReference>
-
getId
public long getId()
Description copied from class:BaseElement
Return an truncated MD5 hash of the local key computed inBaseElement.getLocalKey()
.- Specified by:
getId
in interfacePropertyInterface
- Overrides:
getId
in classBaseElement<R extends EntityReference>
- Returns:
- the identifier used by hibernate for storage.
-
setId
public void setId(long id)
Description copied from class:BaseElement
Dummy function, do hibernate is always happy.- Specified by:
setId
in interfacePropertyInterface
- Overrides:
setId
in classBaseElement<R extends EntityReference>
- Parameters:
id
- the identifier assigned by hibernate.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBaseElement<R extends EntityReference>
-
getClassType
public String getClassType()
-
setClassType
public void setClassType(String type)
-
clone
public BaseProperty<R> clone()
- Specified by:
clone
in interfacePropertyInterface
- Overrides:
clone
in classBaseElement<R extends EntityReference>
-
cloneInternal
protected void cloneInternal(BaseProperty clone)
Subclasses override this to copy values during cloning.- Parameters:
clone
- The cloned value.
-
getValue
public Object getValue()
-
setValue
public void setValue(Object value)
-
toXML
public org.dom4j.Element toXML()
- Specified by:
toXML
in interfacePropertyInterface
- Overrides:
toXML
in classBaseElement<R extends EntityReference>
-
toFormString
public String toFormString()
- Specified by:
toFormString
in interfacePropertyInterface
-
toText
public String toText()
-
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
-
getCustomMappingValue
public Object getCustomMappingValue()
-
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 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 contextmergeResult
- the merge report
-
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
-
mergeValue
@Deprecated(since="14.10.7,15.2RC1") protected void mergeValue(Object previousValue, Object newValue, MergeResult mergeResult)
Deprecated.Try to apply 3 ways merge on property value. Note that this method modifies the internal value of the property.- Parameters:
previousValue
- the previous version of the valuenewValue
- the new version of the valuemergeResult
- merge report- Since:
- 3.2M1
-
mergeValue
@Unstable protected MergeManagerResult<Object,Object> mergeValue(Object previousValue, Object newValue, MergeConfiguration mergeConfiguration)
Try to apply 3 ways merge on property value. Note that this method does not modify the internal value of the property.- Parameters:
previousValue
- the previous version of the valuenewValue
- the new version of the valuemergeConfiguration
- the merge configuration to use- Since:
- 15.2RC1, 14.10.7
-
apply
public boolean apply(ElementInterface newProperty, 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:
newProperty
- 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
-
isValueDirty
public boolean isValueDirty()
- Returns:
- true if the property value doesn't match the value in the database.
- Since:
- 4.3M2
-
setValueDirty
protected void setValueDirty(Object newValue)
Set the dirty flag if the new value isn't equal to the old value.- Parameters:
newValue
- The new value.
-
setValueDirty
public void setValueDirty(boolean valueDirty)
- Parameters:
valueDirty
- Indicate if the dirty flag should be set or cleared.- Since:
- 4.3M2
-
setOwnerDocument
public void setOwnerDocument(XWikiDocument ownerDocument)
Set the owner document of this base property.- Overrides:
setOwnerDocument
in classBaseElement<R extends EntityReference>
- Parameters:
ownerDocument
- The owner document.- Since:
- 4.3M2
-
getPropertyClass
public PropertyClass getPropertyClass(XWikiContext xcontext)
- Parameters:
xcontext
- the XWiki Context- Returns:
- the definition of the property
- Since:
- 8.3M1
-
-