Interface I_CmsXmlDocument
- All Known Implementing Classes:
A_CmsXmlDocument
,CmsXmlContainerPage
,CmsXmlContent
,CmsXmlGroupContainer
,CmsXmlPage
- Since:
- 6.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given locale to this XML document.void
copyLocale
(List<Locale> possibleSources, 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
(Locale source, Locale destination) Copies the content of the given source locale to the given destination locale in this XML document.getBestMatchingLocale
(Locale locale) Returns the first matching locale (eventually simplified) from the available locales.Returns the content definition object used for this XML document.Returns the content conversion parameter used for this XML document.Returns the encoding used for this XML document.getFile()
Returns the file this document was generated from, may benull
if the file not available.Returns the content handler associated with the content definition of this XML document.int
getIndexCount
(String path, Locale locale) Returns the index count of existing values for the given path, or-1
if no such path exists.getLinkProcessor
(CmsObject cms, CmsLinkTable linkTable) Returns a link processor for the values of this XML document.Returns a List of all locales that have at last one value in this XML document.getLocales
(String path) Returns a List of all locales that have at least one element with the given path in this XML document.Returns a List of all available elements paths (Strings) used in this document for the given locale.getStringValue
(CmsObject cms, String path, Locale locale) Returns the first content value for the given path as a String, ornull
if no such value exists.getStringValue
(CmsObject cms, String path, Locale locale, int index) Returns the content value for the given path and the selected index as a String, ornull
if no such value exists.getSubValues
(String path, Locale locale) Returns all content values (of typeI_CmsXmlContentValue
) directly below the given path available in this document for the given locale.Returns the content value Object for the given path, ornull
if no such value exists.Returns the content value Object for the given path and the selected index, ornull
if no such value exists.Returns all content values (of typeI_CmsXmlContentValue
) with the given path available in this document for the given locale.Returns all available content values (of typeI_CmsXmlContentValue
) in this document for the given locale.boolean
Returnstrue
if the given locale exists in this XML document.boolean
Returnstrue
if a value with the given path exists for the selected locale in this XML document, orfalse
otherwise.boolean
Returnstrue
if a value with the given path and the provided index exists for the selected locale in this XML document, orfalse
otherwise.void
Initializes this XML document, required after structural changes to the internal XML.boolean
Returnstrue
if a value with the given path exists for the selected locale in this XML document, and that value is enabled, orfalse
otherwise.boolean
Returnstrue
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, orfalse
otherwise.void
moveLocale
(Locale source, Locale destination) Moves the content of the given source locale to the given destination locale in this XML document.void
removeLocale
(Locale locale) Removes the given locale from this XML document.Validates the content of this XML document.
-
Method Details
-
addLocale
Adds the given locale to this XML document.- Parameters:
cms
- the current users OpenCms contextlocale
- the locale to add- Throws:
CmsXmlException
- in case the locale already existed, or if something else goes wrong
-
copyLocale
Copies the content from the first matching source locale that exists in this XML document to the given destination locale in this XML document.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.
- Parameters:
possibleSources
- the possible source locales in order of preference, must contain objects of typeLocale
destination
- the destination locale- Throws:
CmsXmlException
- in case non of the source locales did not exist, or the destination locale already exists in the document, or if something else goes wrong
-
copyLocale
Copies the content of the given source locale to the given destination locale in this XML document.- Parameters:
source
- the source localedestination
- the destination locale- Throws:
CmsXmlException
- in case either the source locale did not exist, or the destination locale already exists in the document, or if something else goes wrong
-
getBestMatchingLocale
Returns the first matching locale (eventually simplified) from the available locales.In case no match is found, code
null
is returned.- Parameters:
locale
- the requested locale- Returns:
- the matching locale available within the document
-
getContentDefinition
Returns the content definition object used for this XML document.- Returns:
- the content definition object used for this XML document
-
getConversion
Returns the content conversion parameter used for this XML document.- Returns:
- the content conversion parameter used for this XML document
-
getEncoding
Returns the encoding used for this XML document.- Returns:
- the encoding used for this XML document
-
getFile
Returns the file this document was generated from, may benull
if the file not available.The file may not be available if the document was generated from a String or a pure XML document.
- Returns:
- the file this document was generated from
-
getHandler
Returns the content handler associated with the content definition of this XML document.This is a shortcut for
getContentDefinition().getContentHandler()
.- Returns:
- the content handler associated with the content definition of this XML document
-
getIndexCount
Returns the index count of existing values for the given path, or-1
if no such path exists.- Parameters:
path
- the path to get the index count forlocale
- the locale to get the index count for- Returns:
- the index count for the given key name
-
getLinkProcessor
Returns a link processor for the values of this XML document.- Parameters:
cms
- the current OpenCms user context that provides access to the link processorlinkTable
- the table with the links to process- Returns:
- a link processor for the values of this XML document
-
getLocales
List<Locale> getLocales()Returns a List of all locales that have at last one value in this XML document.- Returns:
- a List of all locales that have at last one value in this XML document
-
getLocales
Returns a List of all locales that have at least one element with the given path in this XML document.If no locale for the given element name is available, an empty list is returned.
- Parameters:
path
- the path to look up the locale List for- Returns:
- a List of all locales that have at least one element with the given path in this XML document
-
getNames
Returns a List of all available elements paths (Strings) used in this document for the given locale.If no element for the given locale is available, an empty list is returned.
- Parameters:
locale
- the locale to look up the elements paths for- Returns:
- a List of all available elements paths (Strings) used in this document for the given locale
- See Also:
-
getStringValue
Returns the first content value for the given path as a String, ornull
if no such value exists.- Parameters:
cms
- the current OpenCms user contextpath
- the path to get the content value forlocale
- the locale to get the content value for- Returns:
- the first content value for the given path as a String
- Throws:
CmsXmlException
- if something goes wrong
-
getStringValue
Returns the content value for the given path and the selected index as a String, ornull
if no such value exists.- Parameters:
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 from- Returns:
- the content value for the given path and the selected index as a String
- Throws:
CmsXmlException
- if something goes wrong
-
getSubValues
Returns all content values (of typeI_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.
- Parameters:
path
- the path to get the sub content values forlocale
- the locale to get the sub content values for- Returns:
- all content values (of type
I_CmsXmlContentValue
) directly below the given path available in this document for the given locale
-
getValue
Returns the content value Object for the given path, ornull
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.
- Parameters:
path
- the path to get the content value forlocale
- the locale to get the content value for- Returns:
- the content value Object for the given path
-
getValue
Returns the content value Object for the given path and the selected index, ornull
if no such value exists.- Parameters:
path
- the path to get the content value forlocale
- the locale to get the content value forindex
- the index position to get the value from- Returns:
- the content value Object for the given path and the selected index
-
getValues
Returns all available content values (of typeI_CmsXmlContentValue
) in this document for the given locale.If no content value for the given locale is available, an empty list is returned.
- Parameters:
locale
- the locale to get the content values for- Returns:
- all available content values (of type
I_CmsXmlContentValue
) in this document for the given locale - See Also:
-
getValues
Returns all content values (of typeI_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.
- Parameters:
path
- the path to get the content values forlocale
- the locale to get the content values for- Returns:
- all content values (of type
I_CmsXmlContentValue
) with the given path available in this document for the given locale
-
hasLocale
Returnstrue
if the given locale exists in this XML document.- Parameters:
locale
- the locale to check- Returns:
true
if the given locale exists in this XML document,false
otherwise
-
hasValue
Returnstrue
if a value with the given path exists for the selected locale in this XML document, orfalse
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.
- Parameters:
path
- the path to checklocale
- the locale to check- Returns:
true
if a value with the given path exists for the selected locale in this XML document
-
hasValue
Returnstrue
if a value with the given path and the provided index exists for the selected locale in this XML document, orfalse
otherwise.- Parameters:
path
- the path to checklocale
- the locale to checkindex
- the index position to check- Returns:
true
if a value with the given path and the provided index exists for the selected locale in this XML document
-
initDocument
void initDocument()Initializes this XML document, required after structural changes to the internal XML.If nodes in the XML are added, removed or moved, the document needs to be initialized in order to update the internal data structures.
-
isEnabled
Returnstrue
if a value with the given path exists for the selected locale in this XML document, and that value is enabled, orfalse
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 tohasValue(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.
- Parameters:
path
- the path to checklocale
- the locale to check- Returns:
true
if a value with the given path exists for the selected locale in this XML document, and that value is enabled
-
isEnabled
Returnstrue
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, orfalse
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 tohasValue(String, Locale, int)
.- Parameters:
path
- the path to checklocale
- the locale to checkindex
- the index position to check- 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
-
moveLocale
Moves the content of the given source locale to the given destination locale in this XML document.- Parameters:
source
- the source localedestination
- the destination locale- Throws:
CmsXmlException
- in case either the source locale does not exist, or the destination locale already exists in the document, or if something else goes wrong
-
removeLocale
Removes the given locale from this XML document.- Parameters:
locale
- the locale to remove- Throws:
CmsXmlException
- in case the locale did not exist in the document, or if something else goes wrong
-
validate
Validates the content of this XML document.To check for errors in a single document locale only, use
CmsXmlContentErrorHandler.hasErrors(Locale)
in the result object.- Parameters:
cms
- the current OpenCms user context- Returns:
- an error handler instance that provides information about the errors or warnings that have been found
-