|
|||||||
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
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 | |
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,
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. |
protected |
CmsXmlContent(org.dom4j.Document document,
java.lang.String encoding,
org.xml.sax.EntityResolver resolver)
Creates a new XML content based on the provided XML document. |
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. |
protected java.lang.Object |
getBookmark(java.lang.String bookmark)
Returns the bookmarked value for the given bookmark, which must be a valid bookmark name. |
protected java.util.Set |
getBookmarks()
Returns the names of all bookmarked elements. |
CmsXmlContentDefinition |
getContentDefinition()
Returns the content definition object for this xml content object. |
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(org.dom4j.Document document,
java.lang.String encoding,
CmsXmlContentDefinition definition)
Initializes an XML document based on the provided document, encoding and content definition. |
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. |
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)
Visists all values of this XML content with the given value visitor. |
Methods inherited from class org.opencms.xml.A_CmsXmlDocument |
addBookmark, addLocale, clearBookmarks, copyLocale, correctXmlStructure, 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 |
Methods inherited from interface org.opencms.xml.I_CmsXmlDocument |
copyLocale, getConversion, getEncoding, getFile, getIndexCount, getLocales, getLocales, getNames, getStringValue, getStringValue, getValue, getValue, getValues, getValues, hasLocale, hasValue, hasValue, initDocument, isEnabled, isEnabled, moveLocale, removeLocale |
Field Detail |
public static final java.lang.String XERCES_SCHEMA_PROPERTY
protected CmsXmlContentDefinition m_contentDefinition
Constructor Detail |
protected CmsXmlContent()
protected 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 forprotected CmsXmlContent(org.dom4j.Document document, java.lang.String encoding, org.xml.sax.EntityResolver resolver)
The given encoding is used when marshalling the XML again later.
document
- the document to create the xml content fromencoding
- the encoding of the xml contentresolver
- the XML entitiy resolver to useMethod Detail |
public void addLocale(CmsObject cms, java.util.Locale locale) throws CmsXmlException
I_CmsXmlDocument
addLocale
in interface 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 occured I_CmsXmlSchemaType.getMaxOccurs()
or the given index
is invalid (too high).public CmsXmlContentDefinition getContentDefinition()
I_CmsXmlDocument
getContentDefinition
in interface I_CmsXmlDocument
I_CmsXmlDocument.getContentDefinition()
public CmsLinkProcessor getLinkProcessor(CmsObject cms, CmsLinkTable linkTable)
I_CmsXmlDocument
getLinkProcessor
in interface 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 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 CmsXmlContentErrorHandler validate(CmsObject cms)
I_CmsXmlDocument
validate
in interface I_CmsXmlDocument
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 apper 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 java.lang.Object 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 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(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 |