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 StringcachedCustomDisplayer-
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 PropertyClassclone()intcompareTo(PropertyClass other)Compares two property definitions based on their index number.protected ClassPropertyReferencecreateReference()voiddisplayCustom(StringBuffer buffer, String fieldName, String prefix, String type, BaseObject object, XWikiContext context)voiddisplayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)StringdisplayEdit(String name, BaseCollection object, XWikiContext context)StringdisplayEdit(String name, String prefix, BaseCollection object, XWikiContext context)voiddisplayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)StringdisplayHidden(String name, BaseCollection object, XWikiContext context)StringdisplayHidden(String name, String prefix, BaseCollection object, XWikiContext context)voiddisplayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)StringdisplayView(String name, BaseCollection object, XWikiContext context)StringdisplayView(String name, String prefix, BaseCollection object, XWikiContext context)voidflushCache()BasePropertyfromString(String value)BasePropertyfromStringArray(String[] strings)BasePropertyfromValue(Object value)voidfromXML(org.dom4j.Element element)protected StringgetCachedDefaultCustomDisplayer(XWikiContext context)Returns the current cached default custom displayer for the PropertyClass.StringgetClassName()Note that this method cannot be removed for now since it's used by Hibernate for saving an XObject.StringgetClassType()Each type of XClass property is identified by a string that specifies the data type of the property value (e.g.StringgetCustomDisplay()protected StringgetDefaultCustomDisplayer(String propertyClassName, XWikiContext context)Method to find the default custom displayer to use for a specific Property Class.StringgetFieldFullName()Computes the field full name using this format:parentName_fieldName.protected StringgetFullQueryPropertyName()StringgetHint()Get the localized hint.longgetId()Return an truncated MD5 hash of the local key computed inBaseElement.getLocalKey().StringgetName()intgetNumber()BaseCollectiongetObject()StringgetPrettyName()StringgetPrettyName(XWikiContext context)StringgetTooltip()StringgetTooltip(XWikiContext context)Gets international tooltipStringgetTranslatedPrettyName(XWikiContext context)StringgetValidationMessage()StringgetValidationRegExp()BaseClassgetXClass(XWikiContext context)BaseClassgetxWikiClass()voidinitLazyCollections()booleanisCustomDisplayed(XWikiContext context)booleanisDisabled()See if this property is disabled or not.booleanisUnmodifiable()booleanisValidColumnTypes(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.BasePropertynewProperty()BasePropertynewPropertyfromXML(org.dom4j.Element ppcel)protected StringrenderContentInContext(String content, String syntax, DocumentReference authorReference, XWikiContext context)Deprecated.since 10.11RC1, userenderContentInContext(String, String, DocumentReference, DocumentReference, XWikiContext)insteadprotected StringrenderContentInContext(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.voidsetClassType(String type)Deprecated.since 4.3M1, the property class type cannot be modifiedvoidsetCustomDisplay(String value)voidsetDisabled(boolean disabled)Disable or re-enable this property.voidsetHint(String hint)Set the text displayed in the object editor to help the user filling some content.voidsetId(long id)Dummy function, do hibernate is always happy.voidsetName(String name)voidsetNumber(int number)voidsetObject(BaseCollection object)voidsetPrettyName(String prettyName)voidsetTooltip(String tooltip)voidsetUnmodifiable(boolean unmodifiable)voidsetValidationMessage(String validationMessage)voidsetValidationRegExp(String validationRegExp)voidsetxWikiClass(BaseClass xWikiClass)StringtoFormString()StringtoString(BaseProperty property)org.dom4j.ElementtoXML()org.dom4j.ElementtoXML(BaseClass bclass)booleanvalidateProperty(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:
createReferencein classBaseElement<ClassPropertyReference>
-
getXClass
public BaseClass getXClass(XWikiContext context)
- Specified by:
getXClassin interfaceObjectInterface- Overrides:
getXClassin classBaseCollection<ClassPropertyReference>
-
getxWikiClass
public BaseClass getxWikiClass()
-
setxWikiClass
public void setxWikiClass(BaseClass xWikiClass)
-
getObject
public BaseCollection getObject()
- Specified by:
getObjectin interfacePropertyInterface
-
setObject
public void setObject(BaseCollection object)
- Specified by:
setObjectin 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:BaseElementReturn an truncated MD5 hash of the local key computed inBaseElement.getLocalKey().- Specified by:
getIdin interfacePropertyInterface- Overrides:
getIdin classBaseElement<ClassPropertyReference>- Returns:
- the identifier used by hibernate for storage.
-
setId
public void setId(long id)
Description copied from class:BaseElementDummy function, do hibernate is always happy.- Specified by:
setIdin interfacePropertyInterface- Overrides:
setIdin classBaseElement<ClassPropertyReference>- Parameters:
id- the identifier assigned by hibernate.
-
toString
public String toString(BaseProperty property)
- Specified by:
toStringin interfacePropertyClassInterface
-
fromString
public BaseProperty fromString(String value)
- Specified by:
fromStringin 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:
displayHiddenin interfacePropertyClassInterface
-
displayView
public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayViewin interfacePropertyClassInterface
-
displayEdit
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayEditin 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:BaseCollectionNote that this method cannot be removed for now since it's used by Hibernate for saving an XObject.- Overrides:
getClassNamein classBaseCollection<ClassPropertyReference>
-
getName
public String getName()
Description copied from class:BaseElementNote that this method is used by Hibernate for saving an element.
- Specified by:
getNamein interfaceElementInterface- Overrides:
getNamein 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:BaseElementNote that this method is used by Hibernate for loading an element.
- Specified by:
setNamein interfaceElementInterface- Overrides:
setNamein classBaseElement<ClassPropertyReference>- See Also:
ElementInterface.setName(java.lang.String)
-
getCustomDisplay
public String getCustomDisplay()
-
setCustomDisplay
public void setCustomDisplay(String value)
-
getPrettyName
public String getPrettyName()
- Overrides:
getPrettyNamein classBaseElement<ClassPropertyReference>
-
getPrettyName
public String getPrettyName(XWikiContext context)
-
getTranslatedPrettyName
public String getTranslatedPrettyName(XWikiContext context)
-
setPrettyName
public void setPrettyName(String prettyName)
- Overrides:
setPrettyNamein 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:
getNumberin classBaseCollection<ClassPropertyReference>
-
setNumber
public void setNumber(int number)
- Overrides:
setNumberin 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 itsclassTypeshould not.The
classTypecan be used as a hint to lookup various components related to this specific XClass property type. SeePropertyClassProviderfor 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:
clonein interfacePropertyInterface- Overrides:
clonein classBaseCollection<ClassPropertyReference>
-
toXML
public org.dom4j.Element toXML(BaseClass bclass)
- Specified by:
toXMLin interfaceObjectInterface- Overrides:
toXMLin classBaseCollection<ClassPropertyReference>
-
toXML
public org.dom4j.Element toXML()
- Specified by:
toXMLin interfacePropertyInterface- Overrides:
toXMLin classBaseCollection<ClassPropertyReference>
-
fromXML
public void fromXML(org.dom4j.Element element) throws XWikiException- Overrides:
fromXMLin classBaseElement<ClassPropertyReference>- Throws:
XWikiException
-
toFormString
public String toFormString()
- Specified by:
toFormStringin 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:
trueif this property is disabled and should not be used,falseotherwise- 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:
fromValuein interfacePropertyClassInterface
-
newProperty
public BaseProperty newProperty()
- Specified by:
newPropertyin 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:
flushCachein interfacePropertyClassInterface
-
compareTo
public int compareTo(PropertyClass other)
Compares two property definitions based on their index number.- Specified by:
compareToin 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
classif there's custom display code specified in the class itself,page:currentwiki:XWiki.BooleanDisplayerif such a document exists in the current wiki,page:xwiki:XWiki.StringDisplayerif such a document exists in the main wiki, ortemplate:displayer_boolean.vmif 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,stringordblistcontext- the current request context- Returns:
- An identifier for the location of a custom displayer. This can be
classif there's custom display code specified in the class itself,page:currentwiki:XWiki.BooleanDisplayerif such a document exists in the current wiki,page:xwiki:XWiki.StringDisplayerif such a document exists in the main wiki, ortemplate:displayer_boolean.vmif 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
-
-