public interface I_CmsXmlDocument
Modifier and Type | Method and Description |
---|---|
void |
addLocale(CmsObject cms,
java.util.Locale locale)
Adds the given locale to this XML document.
|
void |
copyLocale(java.util.List<java.util.Locale> possibleSources,
java.util.Locale destination)
Copies the content from the first matching source locale that exists in this XML document
to the given destination locale in this XML document.
|
void |
copyLocale(java.util.Locale source,
java.util.Locale destination)
Copies the content of the given source locale to the given destination locale in this XML document.
|
java.util.Locale |
getBestMatchingLocale(java.util.Locale locale)
Returns the first matching locale (eventually simplified) from the available locales.
|
CmsXmlContentDefinition |
getContentDefinition()
Returns the content definition object used for this XML document.
|
java.lang.String |
getConversion()
Returns the content conversion parameter used for this XML document.
|
java.lang.String |
getEncoding()
Returns the encoding used for this XML document.
|
CmsFile |
getFile()
Returns the file this document was generated from, may be
null if the file not available. |
I_CmsXmlContentHandler |
getHandler()
Returns the content handler associated with the content definition of this XML document.
|
int |
getIndexCount(java.lang.String path,
java.util.Locale locale)
Returns the index count of existing values for the given path,
or
-1 if no such path exists. |
CmsLinkProcessor |
getLinkProcessor(CmsObject cms,
CmsLinkTable linkTable)
Returns a link processor for the values of this XML document.
|
java.util.List<java.util.Locale> |
getLocales()
Returns a List of all locales that have at last one value in this XML document.
|
java.util.List<java.util.Locale> |
getLocales(java.lang.String path)
Returns a List of all locales that have at least one element with the given path in this XML document.
|
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.
|
java.lang.String |
getStringValue(CmsObject cms,
java.lang.String path,
java.util.Locale locale)
Returns the first content value for the given path as a String,
or
null if no such value exists. |
java.lang.String |
getStringValue(CmsObject cms,
java.lang.String path,
java.util.Locale locale,
int index)
Returns the content value for the given path and the selected index as a String,
or
null if no such value exists. |
java.util.List<I_CmsXmlContentValue> |
getSubValues(java.lang.String path,
java.util.Locale locale)
Returns all content values (of type
I_CmsXmlContentValue ) directly below the given path
available in this document for the given locale. |
I_CmsXmlContentValue |
getValue(java.lang.String path,
java.util.Locale locale)
Returns the content value Object for the given path,
or
null if no such value exists. |
I_CmsXmlContentValue |
getValue(java.lang.String path,
java.util.Locale locale,
int index)
Returns the content value Object for the given path and the selected index,
or
null if no such value exists. |
java.util.List<I_CmsXmlContentValue> |
getValues(java.util.Locale locale)
Returns all available content values (of type
I_CmsXmlContentValue )
in this document for the given locale. |
java.util.List<I_CmsXmlContentValue> |
getValues(java.lang.String path,
java.util.Locale locale)
Returns all content values (of type
I_CmsXmlContentValue ) with the given path
available in this document for the given locale. |
boolean |
hasLocale(java.util.Locale locale)
Returns
true if the given locale exists in this XML document. |
boolean |
hasValue(java.lang.String path,
java.util.Locale locale)
Returns
true if a value with the given path exists for the selected locale in this XML document, or
false otherwise. |
boolean |
hasValue(java.lang.String path,
java.util.Locale locale,
int index)
Returns
true if a value with the given path and the provided index exists for the selected locale
in this XML document, or false otherwise. |
void |
initDocument()
Initializes this XML document, required after structural changes to the internal XML.
|
boolean |
isEnabled(java.lang.String path,
java.util.Locale locale)
Returns
true if a value with the given path exists for the selected locale in this XML document,
and that value is enabled,
or false otherwise. |
boolean |
isEnabled(java.lang.String path,
java.util.Locale locale,
int index)
Returns
true if a value with the given path and the provided index exists for the selected locale
in this XML document, and that value is enabled, or false otherwise. |
void |
moveLocale(java.util.Locale source,
java.util.Locale destination)
Moves the content of the given source locale to the given destination locale in this XML document.
|
void |
removeLocale(java.util.Locale locale)
Removes the given locale from this XML document.
|
CmsXmlContentErrorHandler |
validate(CmsObject cms)
Validates the content of this XML document.
|
void addLocale(CmsObject cms, java.util.Locale locale) throws CmsXmlException
cms
- the current users OpenCms contextlocale
- the locale to addCmsXmlException
- in case the locale already existed, or if something else goes wrongvoid copyLocale(java.util.List<java.util.Locale> possibleSources, java.util.Locale destination) throws CmsXmlException
The list of possible sources, has to be sorted in order of preference. The first match that exists in this XML document is used as source for the destination locale. No "locale simplification" ("en_EN" to "en" etc.) is performed for the match.
possibleSources
- the possible source locales in order of preference,
must contain objects of type Locale
destination
- the destination localeCmsXmlException
- in case non of the source locales did not exist,
or the destination locale already exists in the document, or if something else goes wrongvoid copyLocale(java.util.Locale source, java.util.Locale destination) throws CmsXmlException
source
- the source localedestination
- the destination localeCmsXmlException
- in case either the source locale did not exist,
or the destination locale already exists in the document, or if something else goes wrongjava.util.Locale getBestMatchingLocale(java.util.Locale locale)
In case no match is found, code null
is returned.
locale
- the requested localeCmsXmlContentDefinition getContentDefinition()
java.lang.String getConversion()
java.lang.String getEncoding()
CmsFile getFile()
null
if the file not available.The file may not be available if the document was generated from a String or a pure XML document.
I_CmsXmlContentHandler getHandler()
This is a shortcut for getContentDefinition().getContentHandler()
.
int getIndexCount(java.lang.String path, java.util.Locale locale)
-1
if no such path exists.path
- the path to get the index count forlocale
- the locale to get the index count forCmsLinkProcessor getLinkProcessor(CmsObject cms, CmsLinkTable linkTable)
cms
- the current OpenCms user context that provides access to the link processorlinkTable
- the table with the links to processjava.util.List<java.util.Locale> getLocales()
java.util.List<java.util.Locale> getLocales(java.lang.String path)
If no locale for the given element name is available, an empty list is returned.
path
- the path to look up the locale List forjava.util.List<java.lang.String> getNames(java.util.Locale locale)
If no element for the given locale is available, an empty list is returned.
locale
- the locale to look up the elements paths forgetValues(Locale)
java.lang.String getStringValue(CmsObject cms, java.lang.String path, java.util.Locale locale) throws CmsXmlException
null
if no such value exists.cms
- the current OpenCms user contextpath
- the path to get the content value forlocale
- the locale to get the content value forCmsXmlException
- if something goes wrongjava.lang.String getStringValue(CmsObject cms, java.lang.String path, java.util.Locale locale, int index) throws CmsXmlException
null
if no such value exists.cms
- the current OpenCms user contextpath
- the path to get the content value forlocale
- the locale to get the content value forindex
- the index position to get the value fromCmsXmlException
- if something goes wrongjava.util.List<I_CmsXmlContentValue> getSubValues(java.lang.String path, java.util.Locale locale)
I_CmsXmlContentValue
) directly below the given path
available in this document for the given locale.If no content value for the given path is available with this locale, an empty list is returned.
path
- the path to get the sub content values forlocale
- the locale to get the sub content values forI_CmsXmlContentValue
) directly below the given path
available in this document for the given localeI_CmsXmlContentValue getValue(java.lang.String path, java.util.Locale locale)
null
if no such value exists.You can provide an index by appending a number in square brackets to the path parameter like this "Title[1]". If no index is provided, 1 is used for the index position.
path
- the path to get the content value forlocale
- the locale to get the content value forI_CmsXmlContentValue getValue(java.lang.String path, java.util.Locale locale, int index)
null
if no such value exists.path
- the path to get the content value forlocale
- the locale to get the content value forindex
- the index position to get the value fromjava.util.List<I_CmsXmlContentValue> getValues(java.util.Locale locale)
I_CmsXmlContentValue
)
in this document for the given locale.If no content value for the given locale is available, an empty list is returned.
locale
- the locale to get the content values forI_CmsXmlContentValue
) in this document for the given localegetNames(Locale)
java.util.List<I_CmsXmlContentValue> getValues(java.lang.String path, java.util.Locale locale)
I_CmsXmlContentValue
) with the given path
available in this document for the given locale.If no content value for the given path is available with this locale, an empty list is returned.
path
- the path to get the content values forlocale
- the locale to get the content values forI_CmsXmlContentValue
) with the given path
available in this document for the given localeboolean hasLocale(java.util.Locale locale)
true
if the given locale exists in this XML document.locale
- the locale to checktrue
if the given locale exists in this XML document, false
otherwiseboolean hasValue(java.lang.String path, java.util.Locale locale)
true
if a value with the given path exists for the selected locale in this XML document, or
false
otherwise.You can provide an index by appending a number in square brackets to the path parameter like this "Title[1]". If no index is provided, 1 is used for the index position.
path
- the path to checklocale
- the locale to checktrue
if a value with the given path exists for the selected locale in this XML documentboolean hasValue(java.lang.String path, java.util.Locale locale, int index)
true
if a value with the given path and the provided index exists for the selected locale
in this XML document, or false
otherwise.path
- the path to checklocale
- the locale to checkindex
- the index position to checktrue
if a value with the given path and the provided index exists for the selected locale
in this XML documentvoid initDocument()
If nodes in the XML are added, removed or moved, the document needs to be initialized in order to update the internal data structures.
boolean isEnabled(java.lang.String path, java.util.Locale locale)
true
if a value with the given path exists for the selected locale in this XML document,
and that value is enabled,
or false
otherwise.
This is only used with implementations that support enabling and disabling individual values,
such as CmsXmlPage
. If enabling / disabling values is not supported,
this is identical to hasValue(String, Locale)
.
You can provide an index by appending a number in square brackets to the path parameter like this "Title[1]". If no index is provided, 1 is used for the index position.
path
- the path to checklocale
- the locale to checktrue
if a value with the given path exists for the selected locale in this XML document,
and that value is enabledboolean isEnabled(java.lang.String path, java.util.Locale locale, int index)
true
if a value with the given path and the provided index exists for the selected locale
in this XML document, and that value is enabled, or false
otherwise.
This is only used with implementations that support enabling and disabling individual values,
such as CmsXmlPage
. If enabling / disabling values is not supported,
this is identical to hasValue(String, Locale, int)
.
path
- the path to checklocale
- the locale to checkindex
- the index position to checktrue
if a value with the given path and the provided index exists for the selected locale
in this XML document, and that value is enabledvoid moveLocale(java.util.Locale source, java.util.Locale destination) throws CmsXmlException
source
- the source localedestination
- the destination localeCmsXmlException
- in case either the source locale does not exist,
or the destination locale already exists in the document, or if something else goes wrongvoid removeLocale(java.util.Locale locale) throws CmsXmlException
locale
- the locale to removeCmsXmlException
- in case the locale did not exist in the document, or if something else goes wrongCmsXmlContentErrorHandler validate(CmsObject cms)
To check for errors in a single document locale only, use
CmsXmlContentErrorHandler.hasErrors(Locale)
in the result object.
cms
- the current OpenCms user context