Package com.xpn.xwiki.objects.classes
Class PropertyClass
- java.lang.Object
-
- com.xpn.xwiki.objects.BaseElement<R>
-
- com.xpn.xwiki.objects.BaseCollection<ClassPropertyReference>
-
- com.xpn.xwiki.objects.classes.PropertyClass
-
- All Implemented Interfaces:
PropertyClassInterface
,ElementInterface
,ObjectInterface
,PropertyInterface
,Serializable
,Cloneable
,Comparable<PropertyClass>
- Direct Known Subclasses:
BooleanClass
,ComputedFieldClass
,DateClass
,ListClass
,NumberClass
,StringClass
public class PropertyClass extends BaseCollection<ClassPropertyReference> implements PropertyClassInterface, Comparable<PropertyClass>
Represents an XClass property and contains property definitions (eg "relational storage", "display type", "separator", "multi select", etc). Each property definition is of typeBaseProperty
.- Version:
- $Id: 42f56f1a31aa076050dc1ffbc4619d77a20fa996 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
cachedCustomDisplayer
-
Fields inherited from class com.xpn.xwiki.objects.BaseCollection
currentReferenceDocumentReferenceResolver, fields, fieldsToRemove, number, relativeEntityReferenceResolver
-
Fields inherited from class com.xpn.xwiki.objects.BaseElement
documentReference, ownerDocument, referenceCache
-
-
Constructor Summary
Constructors Constructor Description PropertyClass()
PropertyClass(String name, String prettyname, PropertyMetaClass xWikiClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PropertyClass
clone()
int
compareTo(PropertyClass other)
Compares two property definitions based on their index number.protected ClassPropertyReference
createReference()
void
displayCustom(StringBuffer buffer, String fieldName, String prefix, String type, BaseObject object, XWikiContext context)
void
displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
String
displayEdit(String name, BaseCollection object, XWikiContext context)
String
displayEdit(String name, String prefix, BaseCollection object, XWikiContext context)
void
displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
String
displayHidden(String name, BaseCollection object, XWikiContext context)
String
displayHidden(String name, String prefix, BaseCollection object, XWikiContext context)
void
displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
String
displayView(String name, BaseCollection object, XWikiContext context)
String
displayView(String name, String prefix, BaseCollection object, XWikiContext context)
void
flushCache()
BaseProperty
fromString(String value)
BaseProperty
fromStringArray(String[] strings)
BaseProperty
fromValue(Object value)
void
fromXML(org.dom4j.Element element)
protected String
getCachedDefaultCustomDisplayer(XWikiContext context)
Returns the current cached default custom displayer for the PropertyClass.String
getClassName()
Note that this method cannot be removed for now since it's used by Hibernate for saving an XObject.String
getClassType()
Each type of XClass property is identified by a string that specifies the data type of the property value (e.g.String
getCustomDisplay()
protected String
getDefaultCustomDisplayer(String propertyClassName, XWikiContext context)
Method to find the default custom displayer to use for a specific Property Class.String
getFieldFullName()
Computes the field full name using this format:parentName_fieldName
.protected String
getFullQueryPropertyName()
String
getHint()
Get the localized hint.long
getId()
Return an truncated MD5 hash of the local key computed inBaseElement.getLocalKey()
.String
getName()
int
getNumber()
BaseCollection
getObject()
String
getPrettyName()
String
getPrettyName(XWikiContext context)
String
getTooltip()
String
getTooltip(XWikiContext context)
Gets international tooltipString
getTranslatedPrettyName(XWikiContext context)
String
getValidationMessage()
String
getValidationRegExp()
BaseClass
getXClass(XWikiContext context)
BaseClass
getxWikiClass()
void
initLazyCollections()
boolean
isCustomDisplayed(XWikiContext context)
boolean
isDisabled()
See if this property is disabled or not.boolean
isUnmodifiable()
boolean
isValidColumnTypes(org.hibernate.mapping.Property hibprop)
<T extends EntityReference>
voidmergeProperty(BaseProperty<T> currentProperty, BaseProperty<T> previousProperty, BaseProperty<T> newProperty, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
Apply a 3 ways merge on passed current, previous and new version of the same property.BaseProperty
newProperty()
BaseProperty
newPropertyfromXML(org.dom4j.Element ppcel)
protected String
renderContentInContext(String content, String syntax, DocumentReference authorReference, XWikiContext context)
Deprecated.since 10.11RC1, userenderContentInContext(String, String, DocumentReference, DocumentReference, XWikiContext)
insteadprotected String
renderContentInContext(String content, String syntax, DocumentReference authorReference, DocumentReference secureDocument, XWikiContext context)
Render content in the current document's context with the rights of the given user.void
setClassType(String type)
Deprecated.since 4.3M1, the property class type cannot be modifiedvoid
setCustomDisplay(String value)
void
setDisabled(boolean disabled)
Disable or re-enable this property.void
setHint(String hint)
Set the text displayed in the object editor to help the user filling some content.void
setId(long id)
Dummy function, do hibernate is always happy.void
setName(String name)
void
setNumber(int number)
void
setObject(BaseCollection object)
void
setPrettyName(String prettyName)
void
setTooltip(String tooltip)
void
setUnmodifiable(boolean unmodifiable)
void
setValidationMessage(String validationMessage)
void
setValidationRegExp(String validationRegExp)
void
setxWikiClass(BaseClass xWikiClass)
String
toFormString()
String
toString(BaseProperty property)
org.dom4j.Element
toXML()
org.dom4j.Element
toXML(BaseClass bclass)
boolean
validateProperty(BaseProperty property, XWikiContext context)
-
Methods inherited from class com.xpn.xwiki.objects.BaseCollection
addField, addPropertyForRemoval, apply, equals, get, getCurrentReferenceDocumentReferenceResolver, getCustomMappingMap, getDateValue, getDiff, getDoubleValue, getField, getFieldList, getFieldsToRemove, getFloatValue, getIntValue, getIntValue, getLargeStringValue, getListValue, getLongValue, getProperties, getPropertyList, getPropertyNames, getRelativeEntityReferenceResolver, getRelativeXClassReference, getSetValue, getSortedIterator, getStringValue, getXClassReference, merge, merge, mergeField, put, removeField, safeget, safeput, setClassName, setDateValue, setDBStringListValue, setDocumentReference, setDoubleValue, setFields, setFieldsToRemove, setFloatValue, setIntValue, setLargeStringValue, setLongValue, setOwnerDocument, setSetValue, setStringListValue, setStringValue, setXClassReference, toXMLString
-
Methods inherited from class com.xpn.xwiki.objects.BaseElement
fromXML, getDocumentReference, getLocalEntityReferenceSerializer, getLocalization, getLocalKey, getLocalUidStringEntityReferenceSerializer, getMergeManager, getOwnerDocument, getReference, getXWikiContext, hashCode, localizePlain, localizePlainOrKey, merge, 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
apply, getDocumentReference, getReference, merge, merge, setDocumentReference, toString
-
Methods inherited from interface com.xpn.xwiki.objects.ObjectInterface
get, put, safeget, safeput
-
Methods inherited from interface com.xpn.xwiki.objects.classes.PropertyClassInterface
displayView
-
-
-
-
Field Detail
-
cachedCustomDisplayer
protected String cachedCustomDisplayer
-
-
Constructor Detail
-
PropertyClass
public PropertyClass()
-
PropertyClass
public PropertyClass(String name, String prettyname, PropertyMetaClass xWikiClass)
-
-
Method Detail
-
createReference
protected ClassPropertyReference createReference()
- Overrides:
createReference
in classBaseElement<ClassPropertyReference>
-
getXClass
public BaseClass getXClass(XWikiContext context)
- Specified by:
getXClass
in interfaceObjectInterface
- Overrides:
getXClass
in classBaseCollection<ClassPropertyReference>
-
getxWikiClass
public BaseClass getxWikiClass()
-
setxWikiClass
public void setxWikiClass(BaseClass xWikiClass)
-
getObject
public BaseCollection getObject()
- Specified by:
getObject
in interfacePropertyInterface
-
setObject
public void setObject(BaseCollection object)
- Specified by:
setObject
in interfacePropertyInterface
-
getFieldFullName
public String getFieldFullName()
Computes the field full name using this format:parentName_fieldName
. There are 2 main cases:- this is a class property: the prefix is the class reference (e.g. XWiki.TagClass_tags)
- this is a meta property: the prefix is the property type (e.g. TextArea_editor)
- Returns:
- the field full name
-
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<ClassPropertyReference>
- 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<ClassPropertyReference>
- Parameters:
id
- the identifier assigned by hibernate.
-
toString
public String toString(BaseProperty property)
- Specified by:
toString
in interfacePropertyClassInterface
-
fromString
public BaseProperty fromString(String value)
- Specified by:
fromString
in interfacePropertyClassInterface
-
newPropertyfromXML
public BaseProperty newPropertyfromXML(org.dom4j.Element ppcel)
-
displayHidden
public void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayHidden
in interfacePropertyClassInterface
-
displayView
public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayView
in interfacePropertyClassInterface
-
displayEdit
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayEdit
in interfacePropertyClassInterface
-
displayHidden
public String displayHidden(String name, String prefix, BaseCollection object, XWikiContext context)
-
displayHidden
public String displayHidden(String name, BaseCollection object, XWikiContext context)
-
displayView
public String displayView(String name, String prefix, BaseCollection object, XWikiContext context)
-
displayView
public String displayView(String name, BaseCollection object, XWikiContext context)
-
displayEdit
public String displayEdit(String name, String prefix, BaseCollection object, XWikiContext context)
-
displayEdit
public String displayEdit(String name, BaseCollection object, XWikiContext context)
-
isCustomDisplayed
public boolean isCustomDisplayed(XWikiContext context)
-
displayCustom
public void displayCustom(StringBuffer buffer, String fieldName, String prefix, String type, BaseObject object, XWikiContext context) throws XWikiException
- Throws:
XWikiException
-
renderContentInContext
@Deprecated protected String renderContentInContext(String content, String syntax, DocumentReference authorReference, XWikiContext context) throws Exception
Deprecated.since 10.11RC1, userenderContentInContext(String, String, DocumentReference, DocumentReference, XWikiContext)
insteadRender content in the current document's context with the rights of the given user.- Throws:
Exception
- Since:
- 8.3M2
-
renderContentInContext
protected String renderContentInContext(String content, String syntax, DocumentReference authorReference, DocumentReference secureDocument, XWikiContext context) throws Exception
Render content in the current document's context with the rights of the given user.- Throws:
Exception
- Since:
- 10.11RC1
-
getClassName
public String getClassName()
Description copied from class:BaseCollection
Note that this method cannot be removed for now since it's used by Hibernate for saving an XObject.- Overrides:
getClassName
in classBaseCollection<ClassPropertyReference>
-
getName
public String getName()
Description copied from class:BaseElement
Note that this method is used by Hibernate for saving an element.
- Specified by:
getName
in interfaceElementInterface
- Overrides:
getName
in classBaseElement<ClassPropertyReference>
- Returns:
- the free form name (for elements which don't point to a reference, for example for instances of
BaseProperty
). - See Also:
ElementInterface.getName()
-
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 interfaceElementInterface
- Overrides:
setName
in classBaseElement<ClassPropertyReference>
- See Also:
ElementInterface.setName(java.lang.String)
-
getCustomDisplay
public String getCustomDisplay()
-
setCustomDisplay
public void setCustomDisplay(String value)
-
getPrettyName
public String getPrettyName()
- Overrides:
getPrettyName
in classBaseElement<ClassPropertyReference>
-
getPrettyName
public String getPrettyName(XWikiContext context)
-
getTranslatedPrettyName
public String getTranslatedPrettyName(XWikiContext context)
-
setPrettyName
public void setPrettyName(String prettyName)
- Overrides:
setPrettyName
in classBaseElement<ClassPropertyReference>
-
getHint
public String getHint()
Get the localized hint. A hint is a text displayed in the object editor to help the user filling some content.- Returns:
- the localized hint.
- Since:
- 9.11RC1
-
setHint
public void setHint(String hint)
Set the text displayed in the object editor to help the user filling some content.- Since:
- 9.11RC1
-
getTooltip
public String getTooltip()
-
getTooltip
public String getTooltip(XWikiContext context)
Gets international tooltip- Parameters:
context
-- Returns:
-
setTooltip
public void setTooltip(String tooltip)
-
getNumber
public int getNumber()
- Overrides:
getNumber
in classBaseCollection<ClassPropertyReference>
-
setNumber
public void setNumber(int number)
- Overrides:
setNumber
in classBaseCollection<ClassPropertyReference>
-
getClassType
public String getClassType()
Each type of XClass property is identified by a string that specifies the data type of the property value (e.g. 'String', 'Number', 'Date') without disclosing implementation details. The internal implementation of an XClass property type can change over time but itsclassType
should not.The
classType
can be used as a hint to lookup various components related to this specific XClass property type. SeePropertyClassProvider
for instance.- Returns:
- an identifier for the data type of the property value (e.g. 'String', 'Number', 'Date')
-
setClassType
@Deprecated public void setClassType(String type)
Deprecated.since 4.3M1, the property class type cannot be modifiedSets the property class type.- Parameters:
type
- the class type
-
clone
public PropertyClass clone()
- Specified by:
clone
in interfacePropertyInterface
- Overrides:
clone
in classBaseCollection<ClassPropertyReference>
-
toXML
public org.dom4j.Element toXML(BaseClass bclass)
- Specified by:
toXML
in interfaceObjectInterface
- Overrides:
toXML
in classBaseCollection<ClassPropertyReference>
-
toXML
public org.dom4j.Element toXML()
- Specified by:
toXML
in interfacePropertyInterface
- Overrides:
toXML
in classBaseCollection<ClassPropertyReference>
-
fromXML
public void fromXML(org.dom4j.Element element) throws XWikiException
- Overrides:
fromXML
in classBaseElement<ClassPropertyReference>
- Throws:
XWikiException
-
toFormString
public String toFormString()
- Specified by:
toFormString
in interfacePropertyInterface
-
initLazyCollections
public void initLazyCollections()
-
isUnmodifiable
public boolean isUnmodifiable()
-
setUnmodifiable
public void setUnmodifiable(boolean unmodifiable)
-
isDisabled
public boolean isDisabled()
See if this property is disabled or not. A disabled property should not be editable, but existing object values are still kept in the database.- Returns:
true
if this property is disabled and should not be used,false
otherwise- Since:
- 2.4M2
- See Also:
setDisabled(boolean)
-
setDisabled
public void setDisabled(boolean disabled)
Disable or re-enable this property. A disabled property should not be editable, but existing object values are still kept in the database.- Parameters:
disabled
- whether the property is disabled or not- Since:
- 2.4M2
- See Also:
isDisabled()
-
fromStringArray
public BaseProperty fromStringArray(String[] strings)
-
isValidColumnTypes
public boolean isValidColumnTypes(org.hibernate.mapping.Property hibprop)
-
fromValue
public BaseProperty fromValue(Object value)
- Specified by:
fromValue
in interfacePropertyClassInterface
-
newProperty
public BaseProperty newProperty()
- Specified by:
newProperty
in interfacePropertyClassInterface
-
setValidationRegExp
public void setValidationRegExp(String validationRegExp)
-
getValidationRegExp
public String getValidationRegExp()
-
getValidationMessage
public String getValidationMessage()
-
setValidationMessage
public void setValidationMessage(String validationMessage)
-
validateProperty
public boolean validateProperty(BaseProperty property, XWikiContext context)
-
flushCache
public void flushCache()
- Specified by:
flushCache
in interfacePropertyClassInterface
-
compareTo
public int compareTo(PropertyClass other)
Compares two property definitions based on their index number.- Specified by:
compareTo
in interfaceComparable<PropertyClass>
- Parameters:
other
- the other property definition to be compared with- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Since:
- 2.4M2
- See Also:
getNumber()
-
getFullQueryPropertyName
protected String getFullQueryPropertyName()
-
getCachedDefaultCustomDisplayer
protected String getCachedDefaultCustomDisplayer(XWikiContext context)
Returns the current cached default custom displayer for the PropertyClass. The result will be cached and can be flushed usingflushCache()
. If it returns the empty string, then there is no default custom displayer for this class.- Parameters:
context
- the current request context- Returns:
- An identifier for the location of a custom displayer. This can be
class
if there's custom display code specified in the class itself,page:currentwiki:XWiki.BooleanDisplayer
if such a document exists in the current wiki,page:xwiki:XWiki.StringDisplayer
if such a document exists in the main wiki, ortemplate:displayer_boolean.vm
if a template on the filesystem or in the current skin exists.
-
getDefaultCustomDisplayer
protected String getDefaultCustomDisplayer(String propertyClassName, XWikiContext context)
Method to find the default custom displayer to use for a specific Property Class.- Parameters:
propertyClassName
- the type of the property; this is defined in each subclass, such asboolean
,string
ordblist
context
- the current request context- Returns:
- An identifier for the location of a custom displayer. This can be
class
if there's custom display code specified in the class itself,page:currentwiki:XWiki.BooleanDisplayer
if such a document exists in the current wiki,page:xwiki:XWiki.StringDisplayer
if such a document exists in the main wiki, ortemplate:displayer_boolean.vm
if a template on the filesystem or in the current skin exists.
-
mergeProperty
public <T extends EntityReference> void mergeProperty(BaseProperty<T> currentProperty, BaseProperty<T> previousProperty, BaseProperty<T> newProperty, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
Apply a 3 ways merge on passed current, previous and new version of the same property. The passed current version is modified as result of the merge.- Parameters:
currentProperty
- the current version of the element and the one to modifypreviousProperty
- the previous version of the elementnewProperty
- the new version of the propertyconfiguration
- the configuration of the merge Indicate how to deal with some conflicts use cases, etc.context
- the XWiki contextmergeResult
- the merge report- Since:
- 6.2M1
-
-