com.xpn.xwiki.objects.classes
Class PropertyClass

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

Version:
$Id: edeb64a82db9f2631cefb5166276c176dd1ca40d $
See Also:
Serialized Form

Field Summary
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
localEntityReferenceSerializer, referenceCache
 
Constructor Summary
PropertyClass()
           
PropertyClass(String name, String prettyname, PropertyMetaClass xWikiClass)
           
 
Method Summary
 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)
           
 String displayEdit(String name, BaseCollection object, XWikiContext context)
           
 void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
           
 String displayEdit(String name, String prefix, BaseCollection object, XWikiContext context)
           
 String displayHidden(String name, BaseCollection object, XWikiContext context)
           
 void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
           
 String displayHidden(String name, String prefix, BaseCollection object, XWikiContext context)
           
 String displayView(String name, BaseCollection object, XWikiContext context)
           
 void displayView(StringBuffer buffer, String name, String prefix, 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 pcel)
           
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()
           
protected  String getFullQueryPropertyName()
           
 long getId()
          Return an truncated MD5 hash of the local key computed in BaseElement.getLocalKey().
 String getName()
          Note that this method is used by Hibernate for saving an element.
 int getNumber()
           
 BaseCollection getObject()
           
 String getPrettyName()
           
 String getPrettyName(XWikiContext context)
           
 String getTooltip()
           
 String getTooltip(XWikiContext context)
          Gets international tooltip
 String 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)
           
 BaseProperty newProperty()
           
 BaseProperty newPropertyfromXML(org.dom4j.Element ppcel)
           
 void setClassType(String type)
          Deprecated. since 4.3M1, the property class type cannot be modified
 void setCustomDisplay(String value)
           
 void setDisabled(boolean disabled)
          Disable or re-enable this property.
 void setId(long id)
          Dummy function, do hibernate is always happy.
 void setName(String name)
          Note that this method is used by Hibernate for loading an element.
 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, getCustomMappingMap, getDateValue, getDiff, getDoubleValue, getField, getFieldList, getFieldsToRemove, getFloatValue, getIntValue, getIntValue, getLargeStringValue, getListValue, getLongValue, getProperties, getPropertyList, getPropertyNames, getRelativeXClassReference, getSetValue, getSortedIterator, getStringValue, getXClassReference, merge, merge, put, removeField, safeget, safeput, setClassName, setDateValue, setDBStringListValue, setDocumentReference, setDoubleValue, setFields, setFieldsToRemove, setFloatValue, setIntValue, setLargeStringValue, setLongValue, setSetValue, setStringListValue, setStringValue, setXClassReference, toString, toXMLString
 
Methods inherited from class com.xpn.xwiki.objects.BaseElement
getDocumentReference, getLocalKey, getLocalUidStringEntityReferenceSerializer, getReference, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.xpn.xwiki.objects.ObjectInterface
get, put, safeget, safeput
 
Methods inherited from interface com.xpn.xwiki.objects.ElementInterface
apply, getDocumentReference, getReference, merge, setDocumentReference, toString
 

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 class BaseElement<ClassPropertyReference>

getXClass

public BaseClass getXClass(XWikiContext context)
Specified by:
getXClass in interface ObjectInterface
Overrides:
getXClass in class BaseCollection<ClassPropertyReference>

getxWikiClass

public BaseClass getxWikiClass()

setxWikiClass

public void setxWikiClass(BaseClass xWikiClass)

getObject

public BaseCollection getObject()
Specified by:
getObject in interface PropertyInterface

setObject

public void setObject(BaseCollection object)
Specified by:
setObject in interface PropertyInterface

getFieldFullName

public String getFieldFullName()

getId

public long getId()
Description copied from class: BaseElement
Return an truncated MD5 hash of the local key computed in BaseElement.getLocalKey().

Specified by:
getId in interface PropertyInterface
Overrides:
getId in class BaseElement<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 interface PropertyInterface
Overrides:
setId in class BaseElement<ClassPropertyReference>
Parameters:
id - the identifier assigned by hibernate.

toString

public String toString(BaseProperty property)
Specified by:
toString in interface PropertyClassInterface

fromString

public BaseProperty fromString(String value)
Specified by:
fromString in interface PropertyClassInterface

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 interface PropertyClassInterface

displayView

public void displayView(StringBuffer buffer,
                        String name,
                        String prefix,
                        BaseCollection object,
                        XWikiContext context)
Specified by:
displayView in interface PropertyClassInterface

displayEdit

public void displayEdit(StringBuffer buffer,
                        String name,
                        String prefix,
                        BaseCollection object,
                        XWikiContext context)
Specified by:
displayEdit in interface PropertyClassInterface

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

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 class BaseCollection<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 interface ElementInterface
Overrides:
getName in class BaseElement<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 interface ElementInterface
Overrides:
setName in class BaseCollection<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 class BaseElement<ClassPropertyReference>

getPrettyName

public String getPrettyName(XWikiContext context)

getTranslatedPrettyName

public String getTranslatedPrettyName(XWikiContext context)

setPrettyName

public void setPrettyName(String prettyName)
Overrides:
setPrettyName in class BaseElement<ClassPropertyReference>

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 class BaseCollection<ClassPropertyReference>

setNumber

public void setNumber(int number)
Overrides:
setNumber in class BaseCollection<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 its classType should not.

The classType can be used as a hint to lookup various components related to this specific XClass property type. See PropertyClassProvider 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 modified

Sets the property class type.

Parameters:
type - the class type

clone

public PropertyClass clone()
Specified by:
clone in interface PropertyInterface
Overrides:
clone in class BaseCollection<ClassPropertyReference>

toXML

public org.dom4j.Element toXML(BaseClass bclass)
Specified by:
toXML in interface ObjectInterface
Specified by:
toXML in class BaseCollection<ClassPropertyReference>

toXML

public org.dom4j.Element toXML()
Specified by:
toXML in interface PropertyInterface

fromXML

public void fromXML(org.dom4j.Element pcel)
             throws XWikiException
Throws:
XWikiException

toFormString

public String toFormString()
Specified by:
toFormString in interface PropertyInterface

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 interface PropertyClassInterface

newProperty

public BaseProperty newProperty()
Specified by:
newProperty in interface PropertyClassInterface

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 interface PropertyClassInterface

compareTo

public int compareTo(PropertyClass other)
Compares two property definitions based on their index number.

Specified by:
compareTo in interface Comparable<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 using flushCache(). 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, or template: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 as boolean, string or dblist
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, or template:displayer_boolean.vm if a template on the filesystem or in the current skin exists.


Copyright © 2004-2013 XWiki. All Rights Reserved.