|
||||||
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.page.CmsXmlPage
public class CmsXmlPage
Implementation of a page object used to access and manage xml data.
This implementation consists of several named elements optionally available for various languages. The data of each element is accessible via its name and language. The content of each element is stored as CDATA, links within the content are processed and are separately accessible as entries of a CmsLinkTable.
Field Summary | |
---|---|
static java.lang.String |
ATTRIBUTE_ENABLED
Name of the name attribute of the elements node. |
static java.lang.String |
ATTRIBUTE_LANGUAGE
Name of the language attribute of the elements node. |
static java.lang.String |
ATTRIBUTE_NAME
Name of the name attribute of the elements node. |
static java.lang.String |
NODE_CONTENT
Name of the element node. |
static java.lang.String |
NODE_ELEMENTS
Name of the elements node. |
static java.lang.String |
NODE_LINK
Name of the link node. |
static java.lang.String |
NODE_LINKS
Name of the links node. |
static java.lang.String |
NODE_PAGE
Name of the page node. |
static java.lang.String |
NODE_PAGES
Name of the page node. |
static java.lang.String |
PROPERTY_ALLOW_RELATIVE
Property to check if relative links are allowed. |
static java.lang.String |
XMLPAGE_XSD_SYSTEM_ID
The DTD address of the OpenCms xmlpage. |
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 | |
---|---|
CmsXmlPage(org.dom4j.Document document,
java.lang.String encoding)
Creates a new CmsXmlPage based on the provided document and encoding. |
|
CmsXmlPage(java.util.Locale locale,
java.lang.String encoding)
Creates an empty XML page in the provided locale using the provided encoding. |
Method Summary | |
---|---|
void |
addLocale(CmsObject cms,
java.util.Locale locale)
Adds the given locale to this XML document. |
void |
addValue(java.lang.String name,
java.util.Locale locale)
Adds a new, empty value with the given name and locale to this XML document. |
boolean |
getAllowRelativeLinks()
Returns if relative links are accepted (and left unprocessed). |
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. |
CmsLinkTable |
getLinkTable(java.lang.String name,
java.util.Locale locale)
Returns the link table of an element. |
java.util.List<java.lang.String> |
getNames(java.util.Locale locale)
Returns a List of all available elements paths (Strings) used in this document for the given locale. |
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 |
isEnabled(java.lang.String name,
java.util.Locale locale)
Checks if the element of a page object is enabled. |
void |
removeValue(java.lang.String name,
java.util.Locale locale)
Removes an existing value with the given name and locale from this XML document. |
void |
renameValue(java.lang.String oldValue,
java.lang.String newValue,
java.util.Locale locale)
Renames the page-element value from the old to the new one. |
protected void |
setAllowRelativeLinks(boolean value)
Sets the parameter that controls the relative link generation. |
void |
setEnabled(java.lang.String name,
java.util.Locale locale,
boolean isEnabled)
Sets the enabled flag of an already existing element. |
protected void |
setFile(CmsFile file)
Sets the file this XML page content is written to. |
void |
setStringValue(CmsObject cms,
java.lang.String name,
java.util.Locale locale,
java.lang.String content)
Sets the data of an already existing value. |
CmsXmlContentErrorHandler |
validate(CmsObject cms)
Validates the content of this XML document. |
Methods inherited from class org.opencms.xml.A_CmsXmlDocument |
---|
addBookmark, addLocale, clearBookmarks, copyLocale, copyLocale, correctXmlStructure, createDeepElementCopy, getBookmark, getBookmark, getBookmarkName, getBookmarks, getConversion, getEncoding, getFile, getIndexCount, getLocales, getLocales, getStringValue, getStringValue, getValue, getValue, getValues, getValues, hasLocale, hasValue, hasValue, initDocument, isAutoCorrectionEnabled, 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 ATTRIBUTE_ENABLED
public static final java.lang.String ATTRIBUTE_LANGUAGE
public static final java.lang.String ATTRIBUTE_NAME
public static final java.lang.String NODE_CONTENT
public static final java.lang.String NODE_ELEMENTS
public static final java.lang.String NODE_LINK
public static final java.lang.String NODE_LINKS
public static final java.lang.String NODE_PAGE
public static final java.lang.String NODE_PAGES
public static final java.lang.String PROPERTY_ALLOW_RELATIVE
public static final java.lang.String XMLPAGE_XSD_SYSTEM_ID
Constructor Detail |
---|
public CmsXmlPage(org.dom4j.Document document, java.lang.String encoding)
The encoding is used for marshalling the XML document later.
document
- the document to create the CmsXmlPage fromencoding
- the encoding of the xml pagepublic CmsXmlPage(java.util.Locale locale, java.lang.String encoding)
The page is initialized according to the minimal necessary xml structure. The encoding is used for marshalling the XML document later.
locale
- the initial locale of the XML pageencoding
- the encoding of the XML pageMethod 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 void addValue(java.lang.String name, java.util.Locale locale) throws CmsIllegalArgumentException
name
- the name of the valuelocale
- the locale of the value
CmsIllegalArgumentException
- if the name contains an index ("[<number>]") or the value for the
given locale already exists in the xmlpage.public boolean getAllowRelativeLinks()
public CmsXmlContentDefinition getContentDefinition() throws CmsRuntimeException
I_CmsXmlDocument
CmsRuntimeException
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 CmsLinkTable getLinkTable(java.lang.String name, java.util.Locale locale)
name
- name of the elementlocale
- locale of the element
public java.util.List<java.lang.String> getNames(java.util.Locale locale)
I_CmsXmlDocument
If no element for the given locale is available, an empty list is returned.
getNames
in interface I_CmsXmlDocument
getNames
in class A_CmsXmlDocument
locale
- the locale to look up the elements paths for
A_CmsXmlDocument.getNames(java.util.Locale)
public boolean isEnabled(java.lang.String name, java.util.Locale locale)
isEnabled
in interface I_CmsXmlDocument
isEnabled
in class A_CmsXmlDocument
name
- the name of the elementlocale
- the locale of the element
I_CmsXmlDocument.isEnabled(java.lang.String, java.util.Locale)
public void removeValue(java.lang.String name, java.util.Locale locale)
name
- the name of the valuelocale
- the locale of the valuepublic void renameValue(java.lang.String oldValue, java.lang.String newValue, java.util.Locale locale) throws CmsIllegalArgumentException
oldValue
- the old valuenewValue
- the new valuelocale
- the locale
CmsIllegalArgumentException
- if the name contains an index ("[<number>]"), the new value for the
given locale already exists in the xmlpage or the the old value does not exist for the locale in the xmlpage.public void setEnabled(java.lang.String name, java.util.Locale locale, boolean isEnabled)
Note: if isEnabled is set to true, the attribute is removed since true is the default
name
- name name of the elementlocale
- locale of the elementisEnabled
- enabled flag for the elementpublic void setStringValue(CmsObject cms, java.lang.String name, java.util.Locale locale, java.lang.String content) throws CmsXmlException
The data will be enclosed as CDATA within the xml page structure. When setting the element data, the content of this element will be processed automatically.
cms
- the cms objectname
- name of the elementlocale
- locale of the elementcontent
- character data (CDATA) of the element
CmsXmlException
- if something goes wrongpublic 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)
protected 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 setAllowRelativeLinks(boolean value)
value
- the parameter that controls the relative link generationprotected void setFile(CmsFile file)
file
- the file this XML page content is written to
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |