|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.xml.A_CmsXmlDocument
org.opencms.xml.content.CmsXmlContent
public class CmsXmlContent
Implementation of a XML content object, used to access and manage structured content.
Use the CmsXmlContentFactory
to generate an
instance of this class.
Field Summary | |
---|---|
static java.lang.String |
AUTO_CORRECTION_ATTRIBUTE
The name of the XML content auto correction runtime attribute, this must always be a Boolean. |
protected boolean |
m_autoCorrectionEnabled
Flag to control if auto correction is enabled when saving this XML content. |
protected CmsXmlContentDefinition |
m_contentDefinition
The XML content definition object (i.e. |
static java.lang.String |
XERCES_SCHEMA_PROPERTY
The property to set to enable xerces schema validation. |
Fields inherited from class org.opencms.xml.A_CmsXmlDocument |
---|
m_conversion, m_document, m_elementLocales, m_elementNames, m_encoding, m_file, m_locales |
Constructor Summary | |
---|---|
protected |
CmsXmlContent()
Hides the public constructor. |
protected |
CmsXmlContent(CmsObject cms,
org.dom4j.Document document,
java.lang.String encoding,
org.xml.sax.EntityResolver resolver)
Creates a new XML content based on the provided XML document. |
protected |
CmsXmlContent(CmsObject cms,
java.util.Locale locale,
java.lang.String modelUri)
Create a new XML content based on the given default content, that will have all language nodes of the default content and ensures the presence of the given locale. |
protected |
CmsXmlContent(CmsObject cms,
java.util.Locale locale,
java.lang.String encoding,
CmsXmlContentDefinition contentDefinition)
Create a new XML content based on the given content definiton, that will have one language node for the given locale all initialized with default values. |
Method Summary | |
---|---|
void |
addLocale(CmsObject cms,
java.util.Locale locale)
Adds the given locale to this XML document. |
I_CmsXmlContentValue |
addValue(CmsObject cms,
java.lang.String path,
java.util.Locale locale,
int index)
Adds a new XML content value for the given element name and locale at the given index position to this XML content document. |
void |
copyLocale(java.util.Locale source,
java.util.Locale destination,
java.util.Set<java.lang.String> elements)
Copies the content of the given source locale to the given destination locale in this XML document. |
protected I_CmsXmlContentValue |
getBookmark(java.lang.String bookmark)
Returns the bookmarked value for the given bookmark, which must be a valid bookmark name. |
protected java.util.Set<java.lang.String> |
getBookmarks()
Returns the names of all bookmarked elements. |
CmsXmlContentDefinition |
getContentDefinition()
Returns the content definition object used for this XML document. |
CmsLinkProcessor |
getLinkProcessor(CmsObject cms,
CmsLinkTable linkTable)
Returns a link processor for the values of this XML document. |
protected org.dom4j.Element |
getLocaleNode(java.util.Locale locale)
Returns the XML root element node for the given locale. |
CmsXmlContentValueSequence |
getValueSequence(java.lang.String name,
java.util.Locale locale)
Returns the value sequence for the selected element name in this XML content. |
protected void |
initDocument(CmsObject cms,
org.dom4j.Document document,
java.lang.String encoding,
CmsXmlContentDefinition definition)
Initializes an XML document based on the provided document, encoding and content definition. |
protected void |
initDocument(org.dom4j.Document document,
java.lang.String encoding,
CmsXmlContentDefinition definition)
Initializes an XML document based on the provided document, encoding and content definition. |
boolean |
isAutoCorrectionEnabled()
Returns true if the auto correction feature is enabled for saving this XML content. |
void |
removeValue(java.lang.String name,
java.util.Locale locale,
int index)
Removes an existing XML content value of the given element name and locale at the given index position from this XML content document. |
void |
resolveMappings(CmsObject cms)
Resolves the mappings for all values of this XML content. |
void |
setAutoCorrectionEnabled(boolean value)
Sets the flag to control if auto correction is enabled when saving this XML content. |
protected void |
setFile(CmsFile file)
Sets the file this XML content is written to. |
CmsXmlContentErrorHandler |
validate(CmsObject cms)
Validates the content of this XML document. |
void |
visitAllValuesWith(I_CmsXmlContentValueVisitor visitor)
Visits all values of this XML content with the given value visitor. |
Methods inherited from class org.opencms.xml.A_CmsXmlDocument |
---|
addBookmark, addLocale, clearBookmarks, copyLocale, copyLocale, correctXmlStructure, createDeepElementCopy, getBookmark, getBookmarkName, getConversion, getEncoding, getFile, getIndexCount, getLocales, getLocales, getNames, getStringValue, getStringValue, getValue, getValue, getValues, getValues, hasLocale, hasValue, hasValue, initDocument, isEnabled, isEnabled, marshal, marshal, moveLocale, removeBookmark, removeLocale, setConversion, toString, validateXmlStructure |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String AUTO_CORRECTION_ATTRIBUTE
public static final java.lang.String XERCES_SCHEMA_PROPERTY
protected boolean m_autoCorrectionEnabled
protected CmsXmlContentDefinition m_contentDefinition
Constructor Detail |
---|
protected CmsXmlContent()
protected CmsXmlContent(CmsObject cms, org.dom4j.Document document, java.lang.String encoding, org.xml.sax.EntityResolver resolver)
The given encoding is used when marshalling the XML again later.
cms
- the cms context, if null
no link validation is performeddocument
- the document to create the xml content fromencoding
- the encoding of the xml contentresolver
- the XML entitiy resolver to useprotected CmsXmlContent(CmsObject cms, java.util.Locale locale, java.lang.String modelUri) throws CmsException
The given encoding is used when marshalling the XML again later.
cms
- the current users OpenCms contentlocale
- the locale to generate the default content formodelUri
- the absolute path to the XML content file acting as model
CmsException
- in case the model file is not found or not validprotected CmsXmlContent(CmsObject cms, java.util.Locale locale, java.lang.String encoding, CmsXmlContentDefinition contentDefinition)
The given encoding is used when marshalling the XML again later.
cms
- the current users OpenCms contentlocale
- the locale to generate the default content forencoding
- the encoding to use when marshalling the XML content latercontentDefinition
- the content definiton to create the content forMethod Detail |
---|
public void addLocale(CmsObject cms, java.util.Locale locale) throws CmsXmlException
I_CmsXmlDocument
cms
- the current users OpenCms contextlocale
- the locale to add
CmsXmlException
- in case the locale already existed, or if something else goes wrongI_CmsXmlDocument.addLocale(org.opencms.file.CmsObject, java.util.Locale)
public I_CmsXmlContentValue addValue(CmsObject cms, java.lang.String path, java.util.Locale locale, int index) throws CmsIllegalArgumentException, CmsRuntimeException
cms
- the current users OpenCms contextpath
- the path to the XML content value elementlocale
- the locale where to add the new valueindex
- the index where to add the value (relative to all other values of this type)
CmsIllegalArgumentException
- if the given path is invalid
CmsRuntimeException
- if the element identified by the path already occurred I_CmsXmlSchemaType.getMaxOccurs()
or the given index
is invalid (too high).public void copyLocale(java.util.Locale source, java.util.Locale destination, java.util.Set<java.lang.String> elements) throws CmsXmlException
source
- the source localedestination
- the destination loacleelements
- the set of elements to copy
CmsXmlException
- if something goes wrongpublic CmsXmlContentDefinition getContentDefinition()
I_CmsXmlDocument
I_CmsXmlDocument.getContentDefinition()
public CmsLinkProcessor getLinkProcessor(CmsObject cms, CmsLinkTable linkTable)
I_CmsXmlDocument
cms
- the current OpenCms user context that provides access to the link processorlinkTable
- the table with the links to process
I_CmsXmlDocument.getLinkProcessor(org.opencms.file.CmsObject, org.opencms.staticexport.CmsLinkTable)
public CmsXmlContentValueSequence getValueSequence(java.lang.String name, java.util.Locale locale)
If the given element name is not valid according to the schema of this XML content,
null
is returned.
name
- the element name (XML node name) to the the value sequence forlocale
- the locale to get the value sequence for
public boolean isAutoCorrectionEnabled()
A_CmsXmlDocument
true
if the auto correction feature is enabled for saving this XML content.
isAutoCorrectionEnabled
in class A_CmsXmlDocument
true
if the auto correction feature is enabled for saving this XML contentA_CmsXmlDocument.isAutoCorrectionEnabled()
public void removeValue(java.lang.String name, java.util.Locale locale, int index)
name
- the name of the XML content value elementlocale
- the locale where to remove the valueindex
- the index where to remove the value (relative to all other values of this type)public void resolveMappings(CmsObject cms)
cms
- the current users OpenCms contextpublic void setAutoCorrectionEnabled(boolean value)
value
- the flag to control if auto correction is enabled when saving this XML contentpublic CmsXmlContentErrorHandler validate(CmsObject cms)
I_CmsXmlDocument
To check for errors in a single document locale only, use
CmsXmlContentErrorHandler.hasErrors(Locale)
in the result object.
cms
- the current OpenCms user context
I_CmsXmlDocument.validate(org.opencms.file.CmsObject)
public void visitAllValuesWith(I_CmsXmlContentValueVisitor visitor)
Please note that the order in which the values are visited may NOT be the order they appear in the XML document. It is ensured that the the parent of a nested value is visited before the element it contains.
visitor
- the value visitor implementation to visit the values withprotected I_CmsXmlContentValue getBookmark(java.lang.String bookmark)
A_CmsXmlDocument
A_CmsXmlDocument.getBookmarks()
to get the list of all valid bookmark names.
getBookmark
in class A_CmsXmlDocument
bookmark
- the bookmark name to look up
A_CmsXmlDocument.getBookmark(java.lang.String)
protected java.util.Set<java.lang.String> getBookmarks()
A_CmsXmlDocument
getBookmarks
in class A_CmsXmlDocument
A_CmsXmlDocument.getBookmarks()
protected org.dom4j.Element getLocaleNode(java.util.Locale locale) throws CmsRuntimeException
locale
- the locale to get the root element for
CmsRuntimeException
- if no language element is found in the documentprotected void initDocument(CmsObject cms, org.dom4j.Document document, java.lang.String encoding, CmsXmlContentDefinition definition)
Checks the links and removes invalid ones in the initialized document.
cms
- the current users OpenCms contentdocument
- the base XML document to use for initializingencoding
- the encoding to use when marshalling the document laterdefinition
- the content definition to useprotected void initDocument(org.dom4j.Document document, java.lang.String encoding, CmsXmlContentDefinition definition)
A_CmsXmlDocument
initDocument
in class A_CmsXmlDocument
document
- the base XML document to use for initializingencoding
- the encoding to use when marshalling the document laterdefinition
- the content definition to useA_CmsXmlDocument.initDocument(org.dom4j.Document, java.lang.String, org.opencms.xml.CmsXmlContentDefinition)
protected void setFile(CmsFile file)
file
- the file this XML content content is written to
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |