com.xpn.xwiki.objects.classes
Class BaseClass

java.lang.Object
  extended by com.xpn.xwiki.objects.BaseElement<R>
      extended by com.xpn.xwiki.objects.BaseCollection<DocumentReference>
          extended by com.xpn.xwiki.objects.classes.BaseClass
All Implemented Interfaces:
ClassInterface, ElementInterface, ObjectInterface, Serializable, Cloneable
Direct Known Subclasses:
MetaClass, PropertyMetaClass

public class BaseClass
extends BaseCollection<DocumentReference>
implements ClassInterface

Represents an XClass, and contains XClass properties. Each field from BaseCollection is of type PropertyClass and defines a single XClass property.

Version:
$Id: 6fce7fd72fa80544ba7d88675d7c6a4a8605c247 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.xpn.xwiki.objects.BaseCollection
currentReferenceDocumentReferenceResolver, fields, fieldsToRemove, number, relativeEntityReferenceResolver
 
Fields inherited from class com.xpn.xwiki.objects.BaseElement
documentReference, localEntityReferenceSerializer, ownerDocument, referenceCache
 
Constructor Summary
BaseClass()
           
 
Method Summary
 boolean addBooleanField(String fieldName, String fieldPrettyName, String displayType)
           
 boolean addDateField(String fieldName, String fieldPrettyName)
           
 boolean addDateField(String fieldName, String fieldPrettyName, String dformat)
           
 boolean addDateField(String fieldName, String fieldPrettyName, String dformat, int emptyIsToday)
           
 boolean addDBListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, boolean relationalStorage, String sql)
           
 boolean addDBListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, String sql)
           
 boolean addDBListField(String fieldName, String fieldPrettyName, String sql)
           
 boolean addDBTreeListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, boolean relationalStorage, String sql)
           
 boolean addDBTreeListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, String sql)
           
 boolean addDBTreeListField(String fieldName, String fieldPrettyName, String sql)
           
 boolean addEmailField(String fieldName, String fieldPrettyName, int size)
           
 void addField(String name, PropertyInterface element)
          
 boolean addGroupsField(String fieldName, String fieldPrettyName)
           
 boolean addGroupsField(String fieldName, String fieldPrettyName, int size)
           
 boolean addLevelsField(String fieldName, String fieldPrettyName)
           
 boolean addLevelsField(String fieldName, String fieldPrettyName, int size)
           
 boolean addNumberField(String fieldName, String fieldPrettyName, int size, String type)
           
 boolean addPasswordField(String fieldName, String fieldPrettyName, int size)
           
 boolean addStaticListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, boolean relationalStorage, String values, String displayType, String separators)
           
 boolean addStaticListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, String values)
           
 boolean addStaticListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, String values, String displayType)
           
 boolean addStaticListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, String values, String displayType, String separators)
           
 boolean addStaticListField(String fieldName, String fieldPrettyName, String values)
           
 boolean addTemplateField(String fieldName, String fieldPrettyName)
           
 boolean addTextAreaField(String fieldName, String fieldPrettyName, int cols, int rows)
           
 boolean addTextField(String fieldName, String fieldPrettyName, int size)
           
 boolean addUsersField(String fieldName, String fieldPrettyName)
           
 boolean addUsersField(String fieldName, String fieldPrettyName, boolean multiSelect)
           
 boolean addUsersField(String fieldName, String fieldPrettyName, int size)
           
 boolean addUsersField(String fieldName, String fieldPrettyName, int size, boolean multiSelect)
           
 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.
 BaseClass clone()
           
 void disableField(String name)
          Mark a property as disabled.
 void enableField(String name)
          Re-enable a property.
 boolean equals(Object obj)
           
 void flushCache()
           
 BaseCollection fromMap(Map<String,?> map, BaseCollection object)
           
 BaseCollection fromMap(Map<String,?> map, XWikiContext context)
          Deprecated. since 2.2.3 use fromMap(java.util.Map, com.xpn.xwiki.objects.BaseCollection)
 BaseProperty fromString(String value)
           
 BaseCollection fromValueMap(Map<String,?> map, BaseCollection object)
           
 void fromXML(org.dom4j.Element cel)
           
 void fromXML(String xml)
           
 PropertyInterface get(String name)
           
 String getCustomClass()
           
 String getCustomMapping()
           
 List<String> getCustomMappingPropertyList(XWikiContext context)
           
 String getDefaultEditSheet()
           
 String getDefaultViewSheet()
           
 String getDefaultWeb()
           
 List<BaseProperty> getDeprecatedObjectProperties(BaseObject object)
          Retrieves deprecated properties of the given object compared to the class.
 List<ObjectDiff> getDiff(Object oldObject, XWikiContext context)
           
 List<PropertyClass> getDisabledObjectProperties(BaseObject object)
          Get the list of disabled properties that exist in a given object.
 List<PropertyClass> getDisabledProperties()
          Get the list of disabled property definitions that exist in this class.
 List<PropertyClass> getEnabledProperties()
          Get the list of enabled (the default, normal state) property definitions that exist in this class.
 String getName()
          Deprecated. since 2.2M2 use BaseElement.getDocumentReference()
 String getNameField()
           
 DocumentReference getReference()
           
 String getValidationScript()
           
 boolean hasCustomMapping()
           
 boolean hasExternalCustomMapping()
           
 boolean hasInternalCustomMapping()
           
 boolean isCustomMappingValid(String custommapping, XWikiContext context)
           
 boolean isCustomMappingValid(XWikiContext context)
           
 void merge(BaseClass bclass)
           
 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.
static BaseObject newCustomClassInstance(DocumentReference classReference, XWikiContext context)
           
static BaseObject newCustomClassInstance(String className, XWikiContext context)
          Deprecated. since 2.2.3 use newCustomClassInstance(DocumentReference, XWikiContext)
 BaseObject newCustomClassInstance(XWikiContext context)
           
 BaseCollection newObject(XWikiContext context)
          Deprecated. since 2.2.3 use XWikiDocument.newXObject(org.xwiki.model.reference.EntityReference, com.xpn.xwiki.XWikiContext)
 void put(String name, PropertyInterface property)
           
 void setCustomClass(String customClass)
           
 void setCustomMapping(String customMapping)
           
 void setDefaultEditSheet(String defaultEditSheet)
           
 void setDefaultViewSheet(String defaultViewSheet)
           
 void setDefaultWeb(String defaultWeb)
           
 void setDirty(boolean isDirty)
           
 void setName(String name)
          Deprecated. since 2.2M2 use BaseCollection.setDocumentReference(org.xwiki.model.reference.DocumentReference)
 void setNameField(String nameField)
           
 void setOwnerDocument(XWikiDocument ownerDocument)
          Set the owner document of this base property.
 void setValidationScript(String validationScript)
           
 org.dom4j.Element toXML()
           
 org.dom4j.Element toXML(BaseClass bclass)
           
 boolean validateObject(BaseObject obj, XWikiContext context)
           
 
Methods inherited from class com.xpn.xwiki.objects.BaseCollection
addPropertyForRemoval, getClassName, getCustomMappingMap, getDateValue, getDoubleValue, getField, getFieldList, getFieldsToRemove, getFloatValue, getIntValue, getIntValue, getLargeStringValue, getListValue, getLongValue, getNumber, getProperties, getPropertyList, getPropertyNames, getRelativeXClassReference, getSetValue, getSortedIterator, getStringValue, getXClass, getXClassReference, merge, removeField, safeget, safeput, setClassName, setDateValue, setDBStringListValue, setDocumentReference, setDoubleValue, setFields, setFieldsToRemove, setFloatValue, setIntValue, setLargeStringValue, setLongValue, setNumber, setSetValue, setStringListValue, setStringValue, setXClassReference, toString, toXMLString
 
Methods inherited from class com.xpn.xwiki.objects.BaseElement
createReference, getDocumentReference, getId, getLocalKey, getLocalUidStringEntityReferenceSerializer, getOwnerDocument, getPrettyName, 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.ObjectInterface
getXClass, safeget, safeput
 
Methods inherited from interface com.xpn.xwiki.objects.ElementInterface
getDocumentReference, setDocumentReference, toString
 

Constructor Detail

BaseClass

public BaseClass()
Method Detail

getReference

public DocumentReference getReference()
Specified by:
getReference in interface ElementInterface
Overrides:
getReference in class BaseElement<DocumentReference>
Returns:
the reference of the element

getName

@Deprecated
public String getName()
Deprecated. since 2.2M2 use BaseElement.getDocumentReference()

Note that this method is used by Hibernate for saving an element.

Note: This method is overridden to add the deprecation warning so that code using is can see it's deprecated.

Specified by:
getName in interface ElementInterface
Overrides:
getName in class BaseElement<DocumentReference>
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

@Deprecated
public void setName(String name)
Deprecated. since 2.2M2 use BaseCollection.setDocumentReference(org.xwiki.model.reference.DocumentReference)

Note that this method is used by Hibernate for loading an element.

Note: BaseElement#setName() does not support setting reference anymore since 2.4M2. This was broken and has been replaced by this overridden method. See XWIKI-5285

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

addField

public void addField(String name,
                     PropertyInterface element)

This insures natural ordering between properties.

Overrides:
addField in class BaseCollection<DocumentReference>
See Also:
BaseCollection.addField(java.lang.String, com.xpn.xwiki.objects.PropertyInterface)

disableField

public void disableField(String name)
Mark a property as disabled. A disabled property should not be editable, but existing object values are still kept in the database.

Parameters:
name - the name of the property to disable
Since:
2.4M2

enableField

public void enableField(String name)
Re-enable a property. This field will appear again in object instances.

Parameters:
name - the name of the property to enable
Since:
2.4M2

get

public PropertyInterface get(String name)
Specified by:
get in interface ObjectInterface
Overrides:
get in class BaseCollection<DocumentReference>

put

public void put(String name,
                PropertyInterface property)
Specified by:
put in interface ObjectInterface
Overrides:
put in class BaseCollection<DocumentReference>

getEnabledProperties

public List<PropertyClass> getEnabledProperties()
Get the list of enabled (the default, normal state) property definitions that exist in this class. The resulting list is unmodifiable, but the contained elements are live.

Returns:
an unmodifiable list containing the enabled properties of the class
Since:
2.4M2
See Also:
PropertyClass.isDisabled()

getDisabledProperties

public List<PropertyClass> getDisabledProperties()
Get the list of disabled property definitions that exist in this class. The resulting list is unmodifiable, but the contained elements are live.

Returns:
an unmodifiable list containing the disabled properties of the class
Since:
2.4M2
See Also:
PropertyClass.isDisabled()

getDisabledObjectProperties

public List<PropertyClass> getDisabledObjectProperties(BaseObject object)
Get the list of disabled properties that exist in a given object. This list is a subset of all the disabled properties in a class, since the object could have been created and stored before some of the class properties were added. The resulting list is unmodifiable, but the contained elements are live.

Parameters:
object - the instance of this class where the disabled properties must exist
Returns:
an unmodifiable list containing the disabled properties of the given object
Since:
2.4M2
See Also:
PropertyClass.isDisabled()

getDeprecatedObjectProperties

public List<BaseProperty> getDeprecatedObjectProperties(BaseObject object)
Retrieves deprecated properties of the given object compared to the class. A deprecated property is a property which exists in the Object but doesn't exist anymore in the Class, or which has the wrong data type. This is used for synchronization of existing or imported Objects with respect to the modifications of their associated Class.

Parameters:
object - the instance of this class where to look for undefined properties
Returns:
an unmodifiable list containing the properties of the object which don't exist in the class
Since:
2.4M2

fromString

public BaseProperty fromString(String value)

newObject

@Deprecated
public BaseCollection newObject(XWikiContext context)
                         throws XWikiException
Deprecated. since 2.2.3 use XWikiDocument.newXObject(org.xwiki.model.reference.EntityReference, com.xpn.xwiki.XWikiContext)

Throws:
XWikiException

fromMap

@Deprecated
public BaseCollection fromMap(Map<String,?> map,
                                         XWikiContext context)
                       throws XWikiException
Deprecated. since 2.2.3 use fromMap(java.util.Map, com.xpn.xwiki.objects.BaseCollection)

Throws:
XWikiException

fromMap

public BaseCollection fromMap(Map<String,?> map,
                              BaseCollection object)

fromValueMap

public BaseCollection fromValueMap(Map<String,?> map,
                                   BaseCollection object)

clone

public BaseClass clone()
Overrides:
clone in class BaseCollection<DocumentReference>

equals

public boolean equals(Object obj)
Overrides:
equals in class BaseCollection<DocumentReference>

merge

public void merge(BaseClass bclass)

toXML

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

toXML

public org.dom4j.Element toXML()

fromXML

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

fromXML

public void fromXML(String xml)
             throws XWikiException
Throws:
XWikiException

addTextField

public boolean addTextField(String fieldName,
                            String fieldPrettyName,
                            int size)

addPasswordField

public boolean addPasswordField(String fieldName,
                                String fieldPrettyName,
                                int size)

addEmailField

public boolean addEmailField(String fieldName,
                             String fieldPrettyName,
                             int size)

addBooleanField

public boolean addBooleanField(String fieldName,
                               String fieldPrettyName,
                               String displayType)

addUsersField

public boolean addUsersField(String fieldName,
                             String fieldPrettyName)

addUsersField

public boolean addUsersField(String fieldName,
                             String fieldPrettyName,
                             boolean multiSelect)
Since:
XWiki Core 1.1.2, XWiki Core 1.2M2

addUsersField

public boolean addUsersField(String fieldName,
                             String fieldPrettyName,
                             int size)

addUsersField

public boolean addUsersField(String fieldName,
                             String fieldPrettyName,
                             int size,
                             boolean multiSelect)
Since:
XWiki Core 1.1.2, XWiki Core 1.2M2

addLevelsField

public boolean addLevelsField(String fieldName,
                              String fieldPrettyName)

addLevelsField

public boolean addLevelsField(String fieldName,
                              String fieldPrettyName,
                              int size)

addGroupsField

public boolean addGroupsField(String fieldName,
                              String fieldPrettyName)

addGroupsField

public boolean addGroupsField(String fieldName,
                              String fieldPrettyName,
                              int size)

addTemplateField

public boolean addTemplateField(String fieldName,
                                String fieldPrettyName)

addTextAreaField

public boolean addTextAreaField(String fieldName,
                                String fieldPrettyName,
                                int cols,
                                int rows)

addStaticListField

public boolean addStaticListField(String fieldName,
                                  String fieldPrettyName,
                                  String values)

addStaticListField

public boolean addStaticListField(String fieldName,
                                  String fieldPrettyName,
                                  int size,
                                  boolean multiSelect,
                                  String values)

addStaticListField

public boolean addStaticListField(String fieldName,
                                  String fieldPrettyName,
                                  int size,
                                  boolean multiSelect,
                                  String values,
                                  String displayType)

addStaticListField

public boolean addStaticListField(String fieldName,
                                  String fieldPrettyName,
                                  int size,
                                  boolean multiSelect,
                                  String values,
                                  String displayType,
                                  String separators)
Since:
XWiki Core 1.1.2, XWiki Core 1.2M2

addStaticListField

public boolean addStaticListField(String fieldName,
                                  String fieldPrettyName,
                                  int size,
                                  boolean multiSelect,
                                  boolean relationalStorage,
                                  String values,
                                  String displayType,
                                  String separators)
Since:
1.8M1

addNumberField

public boolean addNumberField(String fieldName,
                              String fieldPrettyName,
                              int size,
                              String type)

addDateField

public boolean addDateField(String fieldName,
                            String fieldPrettyName)

addDateField

public boolean addDateField(String fieldName,
                            String fieldPrettyName,
                            String dformat)

addDateField

public boolean addDateField(String fieldName,
                            String fieldPrettyName,
                            String dformat,
                            int emptyIsToday)

addDBListField

public boolean addDBListField(String fieldName,
                              String fieldPrettyName,
                              String sql)

addDBListField

public boolean addDBListField(String fieldName,
                              String fieldPrettyName,
                              int size,
                              boolean multiSelect,
                              String sql)

addDBListField

public boolean addDBListField(String fieldName,
                              String fieldPrettyName,
                              int size,
                              boolean multiSelect,
                              boolean relationalStorage,
                              String sql)
Since:
1.8M1

addDBTreeListField

public boolean addDBTreeListField(String fieldName,
                                  String fieldPrettyName,
                                  String sql)

addDBTreeListField

public boolean addDBTreeListField(String fieldName,
                                  String fieldPrettyName,
                                  int size,
                                  boolean multiSelect,
                                  String sql)

addDBTreeListField

public boolean addDBTreeListField(String fieldName,
                                  String fieldPrettyName,
                                  int size,
                                  boolean multiSelect,
                                  boolean relationalStorage,
                                  String sql)
Since:
1.8M1

setCustomMapping

public void setCustomMapping(String customMapping)

getCustomMapping

public String getCustomMapping()

hasCustomMapping

public boolean hasCustomMapping()

hasExternalCustomMapping

public boolean hasExternalCustomMapping()

hasInternalCustomMapping

public boolean hasInternalCustomMapping()

isCustomMappingValid

public boolean isCustomMappingValid(XWikiContext context)
                             throws XWikiException
Throws:
XWikiException

isCustomMappingValid

public boolean isCustomMappingValid(String custommapping,
                                    XWikiContext context)
                             throws XWikiException
Throws:
XWikiException

getCustomMappingPropertyList

public List<String> getCustomMappingPropertyList(XWikiContext context)

setCustomClass

public void setCustomClass(String customClass)

getCustomClass

public String getCustomClass()

newCustomClassInstance

public BaseObject newCustomClassInstance(XWikiContext context)
                                  throws XWikiException
Throws:
XWikiException

newCustomClassInstance

public static BaseObject newCustomClassInstance(DocumentReference classReference,
                                                XWikiContext context)
                                         throws XWikiException
Throws:
XWikiException
Since:
2.2.3

newCustomClassInstance

@Deprecated
public static BaseObject newCustomClassInstance(String className,
                                                           XWikiContext context)
                                         throws XWikiException
Deprecated. since 2.2.3 use newCustomClassInstance(DocumentReference, XWikiContext)

Throws:
XWikiException

getDefaultWeb

public String getDefaultWeb()

setDefaultWeb

public void setDefaultWeb(String defaultWeb)

getDefaultViewSheet

public String getDefaultViewSheet()

setDefaultViewSheet

public void setDefaultViewSheet(String defaultViewSheet)

getDefaultEditSheet

public String getDefaultEditSheet()

setDefaultEditSheet

public void setDefaultEditSheet(String defaultEditSheet)

getNameField

public String getNameField()

setNameField

public void setNameField(String nameField)

setValidationScript

public void setValidationScript(String validationScript)

getValidationScript

public String getValidationScript()

validateObject

public boolean validateObject(BaseObject obj,
                              XWikiContext context)
                       throws XWikiException
Throws:
XWikiException

flushCache

public void flushCache()

getDiff

public List<ObjectDiff> getDiff(Object oldObject,
                                XWikiContext context)
Overrides:
getDiff in class BaseCollection<DocumentReference>

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 BaseCollection<DocumentReference>
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 BaseCollection<DocumentReference>
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

setOwnerDocument

public void setOwnerDocument(XWikiDocument ownerDocument)
Set the owner document of this base property.

Overrides:
setOwnerDocument in class BaseCollection<DocumentReference>
Parameters:
ownerDocument - The owner document.
Since:
4.3M2

setDirty

public void setDirty(boolean isDirty)
Parameters:
isDirty - Indicate if the dirty flag should be set or cleared.
Since:
4.3M2


Copyright © 2004–2014 XWiki. All rights reserved.