com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes
Class DefaultXObjectDocument

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.api.Document
          extended by com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.DefaultXObjectDocument
All Implemented Interfaces:
XObjectDocument
Direct Known Subclasses:
XWikiApplication

public class DefaultXObjectDocument
extends Document
implements XObjectDocument

Default implementation of XObjectDocument. This class manage an XWiki document containing provided XWiki class. It add some specifics methods, getters and setters for this type of object and fields. It also override Document (and then XWikiDocument) isNew concept considering as new a document that does not contains an XWiki object of the provided XWiki class.

Since:
Application Manager 1.0RC1
Version:
$Id: db70a03ca6f69b372c19f07b86aaba4de62e90b1 $
See Also:
XObjectDocument, XClassManager

Field Summary
protected  boolean isNew
          true if this is a new document of this class (this document can exist but does not contains object of this class).
protected  int objectId
          The id of the XWiki object included in the document to manage.
protected  XClassManager sclass
          The class manager for this document.
 
Fields inherited from class com.xpn.xwiki.api.Document
cloned, currentObj, doc
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Fields inherited from interface com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.XObjectDocument
SPACE_DOC_SEPARATOR, WIKI_SPACE_SEPARATOR
 
Constructor Summary
DefaultXObjectDocument(XClassManager<? extends XObjectDocument> sclass, XWikiDocument xdoc, int objectId, XWikiContext context)
          Create instance of DefaultXObjectDocument from provided XWikiDocument.
 
Method Summary
 void delete()
           
protected  BaseObject getBaseObject(boolean toWrite)
          Get the managed BaseObject.
 Boolean getBooleanValue(String fieldName)
          Get the value of the field fieldName of the managed object's class.
 Document getDocumentApi()
           
 int getIntValue(String fieldName)
          Get the value of the field fieldName of the managed object's class.
 String getLargeStringValue(String fieldName)
          Deprecated. Use getStringValue(String) which support LargeStringProperty and StringProperty.
 List getListValue(String fieldName)
          Deprecated. Use getStringListValue(String) instead. Since 1.4.
 Object getObjectApi()
           
 int getObjectId()
           
 List<String> getStringListValue(String fieldName)
          Get the value of the field fieldName of the managed object's class.
 String getStringValue(String fieldName)
          Get the value of the field fieldName of the managed object's class.
 XClassManager getXClassManager()
           
 boolean isNew()
           
 void mergeObject(DefaultXObjectDocument sdoc)
          Overwrite current BaseObject fields with provided one.
 void reload(XWikiContext context)
          Reload XWiki document from database using Document full name.
protected  void saveDocument(String comment, boolean minorEdit)
           
 void setBooleanValue(String fieldName, Boolean value)
          Modify the value of the field fieldName of the managed object's class.
 void setFullName(String docFullName)
           
 void setIntValue(String fieldName, int value)
          Modify the value of the field fieldName of the managed object's class.
 void setLargeStringValue(String fieldName, String value)
          Deprecated. Use setStringValue(String, String) which support LargeStringProperty and StringProperty.
 void setListValue(String fieldName, List value)
          Deprecated. Use getStringListValue(String) instead. Since 1.4.
 void setStringListValue(String fieldName, List<String> value)
          Modify the value of the field fieldName of the managed object's class.
 void setStringValue(String fieldName, String value)
          Modify the value of the field fieldName of the managed object's class.
 
Methods inherited from class com.xpn.xwiki.api.Document
addAttachment, addAttachment, addAttachments, addAttachments, addObjectFromRequest, addObjectFromRequest, addObjectFromRequest, addObjectsFromRequest, addObjectsFromRequest, checkAccess, convertSyntax, createNewObject, deleteAsAuthor, deleteDocument, deleteWithProgrammingRights, display, display, display, display, display, display, display, displayEdit, displayForm, displayForm, displayForm, displayHidden, displayPrettyName, displayPrettyName, displayPrettyName, displayPrettyName, displayPrettyName, displayPrettyName, displayRendered, displayTooltip, displayTooltip, displayView, dropPermissions, equals, get, getActiveClass, getArchive, getAttachment, getAttachmentDiff, getAttachmentList, getAttachmentRevisionURL, getAttachmentRevisionURL, getAttachmentURL, getAttachmentURL, getAttachmentURL, getAuthor, getBacklinks, getChildren, getChildren, getClassDiff, getComment, getComments, getComments, getContent, getContentAuthor, getContentDiff, getContentUpdateDate, getCreationDate, getCreator, getCurrentMonthPageStats, getCurrentMonthRefStats, getCurrentMonthSpaceStats, getDate, getDefaultEditMode, getDefaultEditURL, getDefaultLanguage, getDefaultTemplate, getDisplayTitle, getDoc, getDocument, getDocumentArchive, getDocumentReference, getDocumentRevision, getEditURL, getEditURL, getEscapedContent, getExternalURL, getExternalURL, getExternalURL, getFirstObject, getFormat, getFullName, getId, getIncludedMacros, getIncludedPages, getLanguage, getLastChanges, getLinkedPages, getLinks, getLocked, getLockingDate, getLockingUser, getMetaDataDiff, getName, getObject, getObject, getObject, getObject, getObject, getObjectDiff, getObjectNumbers, getObjects, getObjects, getParent, getParentURL, getPlainTitle, getPrefixedFullName, getPreviousDocument, getPreviousVersion, getRCSVersion, getRealLanguage, getRecentRevisions, getRecentRevisions, getRenderedContent, getRenderedContent, getRenderedContent, getRenderedContent, getRenderedContent, getRenderedContentDiff, getRenderedContentRestricted, getRenderedTitle, getRevisionInfo, getRevisions, getRevisions, getSections, getSpace, getSyntax, getSyntaxId, getTagList, getTags, getTagsPossibleValues, getTemplate, getTextArea, getTitle, getTOC, getTranslatedContent, getTranslatedContent, getTranslatedDocument, getTranslatedDocument, getTranslationList, getURL, getURL, getURL, getValidationScript, getValue, getValue, getVersion, getVersionHashCode, getWeb, getWiki, getXMLContent, getXMLDiff, getXObjects, getxWikiClass, getxWikiClasses, getxWikiObjects, hasAccessLevel, hasAccessLevel, insertText, isAdvancedContent, isCreator, isCurrentLocalUserPage, isCurrentUserCreator, isCurrentUserPage, isFromCache, isHidden, isMinorEdit, isMostRecent, isProgrammaticContent, newObject, removeObject, removeObjects, rename, rename, rename, rename, rename, renameDocument, renameDocument, save, save, save, saveAsAuthor, saveAsAuthor, saveAsAuthor, saveWithProgrammingRights, saveWithProgrammingRights, saveWithProgrammingRights, set, set, setComment, setContent, setCustomClass, setDefaultTemplate, setHidden, setMinorEdit, setParent, setSyntax, setSyntaxId, setTitle, setValidationScript, toString, toXML, toXMLDocument, updateObjectFromRequest, updateObjectFromRequest, updateObjectsFromRequest, updateObjectsFromRequest, use, use, use, validate, validate
 
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, convert, convertAttachments, getXWikiContext, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sclass

protected XClassManager sclass
The class manager for this document.


objectId

protected int objectId
The id of the XWiki object included in the document to manage.


isNew

protected boolean isNew
true if this is a new document of this class (this document can exist but does not contains object of this class).

Constructor Detail

DefaultXObjectDocument

public DefaultXObjectDocument(XClassManager<? extends XObjectDocument> sclass,
                              XWikiDocument xdoc,
                              int objectId,
                              XWikiContext context)
                       throws XWikiException
Create instance of DefaultXObjectDocument from provided XWikiDocument.

Parameters:
sclass - the class manager for this document.
xdoc - the XWikiDocument to manage.
objectId - the id of the XWiki object included in the document to manage.
context - the XWiki context.
Throws:
XWikiException - error when calling reload(XWikiContext).
Method Detail

setFullName

public void setFullName(String docFullName)
Parameters:
docFullName - modify the full name the the managed XWikiDocument.

reload

public void reload(XWikiContext context)
            throws XWikiException
Description copied from interface: XObjectDocument
Reload XWiki document from database using Document full name.

Specified by:
reload in interface XObjectDocument
Parameters:
context - the XWiki context.
Throws:
XWikiException - error when initialize document.

getDocumentApi

public Document getDocumentApi()
Specified by:
getDocumentApi in interface XObjectDocument
Returns:
the document.

getObjectId

public int getObjectId()
Specified by:
getObjectId in interface XObjectDocument
Returns:
the id of the managed XWiki object;

getObjectApi

public Object getObjectApi()
Specified by:
getObjectApi in interface XObjectDocument
Returns:
the managed XWiki object.

getBaseObject

protected BaseObject getBaseObject(boolean toWrite)
Get the managed BaseObject.

Parameters:
toWrite - indicate that the BaseObject will be modified.
Returns:
the BaseObject.

mergeObject

public void mergeObject(DefaultXObjectDocument sdoc)
Overwrite current BaseObject fields with provided one. Only provided non null fields are copied.

Parameters:
sdoc - the document to merge.

getXClassManager

public XClassManager getXClassManager()
Specified by:
getXClassManager in interface XObjectDocument
Returns:
the class manager for this document.

isNew

public boolean isNew()
Specified by:
isNew in interface XObjectDocument
Overrides:
isNew in class Document
Returns:
true if this is a new document of this class (this document can exist but does not contains object of this class).

saveDocument

protected void saveDocument(String comment,
                            boolean minorEdit)
                     throws XWikiException
Overrides:
saveDocument in class Document
Throws:
XWikiException

delete

public void delete()
            throws XWikiException
Overrides:
delete in class Document
Throws:
XWikiException

getStringValue

public String getStringValue(String fieldName)
Get the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
Returns:
the value in String of the field fieldName of the managed object's class.
See Also:
XWikiDocument.getStringValue(java.lang.String)

setStringValue

public void setStringValue(String fieldName,
                           String value)
Modify the value of the field fieldName of the managed object's class.

This method makes sure the right property type between LargeStringProperty and StringProperty is used.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
value - the new value of the field fieldName of the managed object's class.
See Also:
XWikiDocument.setStringValue(java.lang.String,java.lang.String,java.lang.String)

getLargeStringValue

@Deprecated
public String getLargeStringValue(String fieldName)
Deprecated. Use getStringValue(String) which support LargeStringProperty and StringProperty.

Get the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
Returns:
the value in String of the field fieldName of the managed object's class.
See Also:
XWikiDocument.getStringValue(java.lang.String)

setLargeStringValue

@Deprecated
public void setLargeStringValue(String fieldName,
                                           String value)
Deprecated. Use setStringValue(String, String) which support LargeStringProperty and StringProperty.

Modify the value of the field fieldName of the managed object's class.

This method makes sure the right property type between LargeStringProperty and StringProperty is used.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
value - the new value of the field fieldName of the managed object's class.
See Also:
XWikiDocument.setLargeStringValue(java.lang.String,java.lang.String,java.lang.String)

getStringListValue

public List<String> getStringListValue(String fieldName)
Get the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
Returns:
the value in List of the field fieldName of the managed object's class.
Since:
1.4
See Also:
XWikiDocument.getListValue(java.lang.String)

setStringListValue

public void setStringListValue(String fieldName,
                               List<String> value)
Modify the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
value - the new value of the field fieldName of the managed object's class.
Since:
1.4
See Also:
XWikiDocument.setStringListValue(java.lang.String,java.lang.String,java.util.List)

getListValue

@Deprecated
public List getListValue(String fieldName)
Deprecated. Use getStringListValue(String) instead. Since 1.4.

Get the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
Returns:
the value in List of the field fieldName of the managed object's class.
See Also:
XWikiDocument.getListValue(java.lang.String)

setListValue

@Deprecated
public void setListValue(String fieldName,
                                    List value)
Deprecated. Use getStringListValue(String) instead. Since 1.4.

Modify the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
value - the new value of the field fieldName of the managed object's class.
See Also:
XWikiDocument.setStringListValue(java.lang.String,java.lang.String,java.util.List)

getIntValue

public int getIntValue(String fieldName)
Get the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
Returns:
the value in int of the field fieldName of the managed object's class.
See Also:
XWikiDocument.getListValue(java.lang.String)

setIntValue

public void setIntValue(String fieldName,
                        int value)
Modify the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
value - the new value of the field fieldName of the managed object's class.
See Also:
XWikiDocument.setIntValue(String, String, int)

getBooleanValue

public Boolean getBooleanValue(String fieldName)
Get the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
Returns:
the value in Boolean of the field fieldName of the managed object's class.
See Also:
XWikiDocument.getListValue(java.lang.String)

setBooleanValue

public void setBooleanValue(String fieldName,
                            Boolean value)
Modify the value of the field fieldName of the managed object's class.

Parameters:
fieldName - the name of the field from the managed object's class where to find the value.
value - the new value of the field fieldName of the managed object's class.
See Also:
XWikiDocument.setIntValue(String, String, int)


Copyright © 2004-2013 XWiki. All Rights Reserved.