|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opencms.xml.A_CmsXmlDocument
public abstract class A_CmsXmlDocument
Provides basic XML document handling functions useful when dealing with XML documents that are stored in the OpenCms VFS.
| Field Summary | |
|---|---|
protected String |
m_conversion
The content conversion to use for this xml document. |
protected Document |
m_document
The document object of the document. |
protected Map |
m_elementLocales
Maps element names to available locales. |
protected Map |
m_elementNames
Maps locales to avaliable element names. |
protected String |
m_encoding
The encoding to use for this xml document. |
protected CmsFile |
m_file
The file that contains the document data (note: is not set when creating an empty or document based document). |
protected Set |
m_locales
Set of locales contained in this document. |
| Constructor Summary | |
|---|---|
protected |
A_CmsXmlDocument()
Default constructor for a XML document that initializes some internal values. |
| Method Summary | |
|---|---|
protected void |
addBookmark(String name,
Locale locale,
boolean enabled,
Object value)
Adds a bookmark for the given value. |
protected void |
addLocale(Locale locale)
Adds a locale to the set of locales of the XML document. |
protected void |
clearBookmarks()
Clears the XML document bookmarks. |
void |
copyLocale(Locale source,
Locale destination)
Copies the content of the given source locale to the given destination locale in this XML document. |
CmsFile |
correctXmlStructure(CmsObject cms)
Corrects the structure of this XML content. |
protected Object |
getBookmark(String bookmark)
Returns the bookmarked value for the given bookmark, which must be a valid bookmark name. |
protected Object |
getBookmark(String name,
Locale locale)
Returns the bookmarked value for the given name. |
protected static String |
getBookmarkName(String name,
Locale locale)
Creates the bookmark name for a localized element to be used in the bookmark lookup table. |
protected Set |
getBookmarks()
Returns the names of all bookmarked elements. |
String |
getConversion()
Returns the content converison used for the page content. |
String |
getEncoding()
Returns the encoding used for this XML document. |
CmsFile |
getFile()
Returns the file with the xml page content or null if not set. |
int |
getIndexCount(String name,
Locale locale)
Returns the index count of existing values for the given key name, or -1 if no such value exists. |
List |
getLocales()
Returns a List of all locales that have at last one element in this XML document. |
List |
getLocales(String name)
Returns a List of all locales that have the named element set in this document. |
List |
getNames(Locale locale)
Returns all available elements names used in this document for the given locale. |
String |
getStringValue(CmsObject cms,
String name,
Locale locale)
Returns the first content value for the given key name as a String, or null if no such value exists. |
String |
getStringValue(CmsObject cms,
String name,
Locale locale,
int index)
Returns the content value for the given key name from the selected index as a String, or null if no such value exists. |
I_CmsXmlContentValue |
getValue(String name,
Locale locale)
Returns the content value Object for the given key name, or null if no such value exists. |
I_CmsXmlContentValue |
getValue(String name,
Locale locale,
int index)
Returns the content value Object for the given key name from the selected index, or null if no such value exists. |
List |
getValues(Locale locale)
Returns all available elements values used in this document for the given locale. |
List |
getValues(String name,
Locale locale)
Returns all content value Objects for the given key name in a List, or null if no such value exists. |
boolean |
hasLocale(Locale locale)
Checks if the given locale exists in this XML document. |
boolean |
hasValue(String name,
Locale locale)
Returns true if a value exists with the given key name,
false otherwise. |
boolean |
hasValue(String name,
Locale locale,
int index)
Returns true if a value exists with the given key name at the selected index,
false otherwise. |
void |
initDocument()
Initializes this XML document, required after structural changes to the XML. |
protected abstract void |
initDocument(Document document,
String encoding,
CmsXmlContentDefinition contentDefinition)
Initializes an XML document based on the provided document, encoding and content definition. |
boolean |
isEnabled(String name,
Locale locale)
Returns true if a value exists with the given key name,
and that value is enabled,
false otherwise. |
boolean |
isEnabled(String name,
Locale locale,
int index)
Returns true if a value exists with the given key name at the selected index,
and that value is enabled,
false otherwise. |
byte[] |
marshal()
Marshals (writes) the content of the current XML document into a byte array using the selected encoding. |
protected OutputStream |
marshal(OutputStream out,
String encoding)
Marshals (writes) the content of the current XML document into an output stream. |
void |
moveLocale(Locale source,
Locale destination)
Moves the content of the given source locale to the given destination locale in this XML document. |
protected I_CmsXmlContentValue |
removeBookmark(String name,
Locale locale)
Removes the bookmark for an element with the given name and locale. |
void |
removeLocale(Locale locale)
Removes the given locale from this XML document. |
void |
setConversion(String conversion)
Sets the content conversion mode for this document. |
String |
toString()
|
void |
validateXmlStructure(EntityResolver resolver)
Validates the xml structure of the document with the DTD ot schema used by the document. |
| 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 |
|---|
addLocale, getContentDefinition, getLinkProcessor, validate |
| Field Detail |
|---|
protected String m_conversion
protected Document m_document
protected Map m_elementLocales
protected Map m_elementNames
protected String m_encoding
protected CmsFile m_file
protected Set m_locales
| Constructor Detail |
|---|
protected A_CmsXmlDocument()
| Method Detail |
|---|
protected static final String getBookmarkName(String name,
Locale locale)
name - the element namelocale - the element locale
public void copyLocale(Locale source,
Locale destination)
throws CmsXmlException
I_CmsXmlDocument
copyLocale in interface I_CmsXmlDocumentsource - the source localedestination - the destination locale
CmsXmlException - in case either the source locale did not exist, or the destination locale already exists in the document, or if something else goes wrongI_CmsXmlDocument.copyLocale(java.util.Locale, java.util.Locale)
public CmsFile correctXmlStructure(CmsObject cms)
throws CmsXmlException
cms - the current cms object
CmsXmlException - if something goes wrongpublic String getConversion()
getConversion in interface I_CmsXmlDocumentpublic String getEncoding()
I_CmsXmlDocument
getEncoding in interface I_CmsXmlDocumentI_CmsXmlDocument.getEncoding()public CmsFile getFile()
null if not set.
getFile in interface I_CmsXmlDocument
public int getIndexCount(String name,
Locale locale)
I_CmsXmlDocument-1 if no such value exists.
getIndexCount in interface I_CmsXmlDocumentname - the key to get the index count forlocale - the locale to get the index count for
I_CmsXmlDocument.getIndexCount(java.lang.String, java.util.Locale)public List getLocales()
I_CmsXmlDocument
getLocales in interface I_CmsXmlDocumentI_CmsXmlDocument.getLocales()public List getLocales(String name)
If no locale for the given element name is available, an empty list is returned.
getLocales in interface I_CmsXmlDocumentname - the element to look up the locale List for
public List getNames(Locale locale)
I_CmsXmlDocumentIf no element for the given locale is available, an empty list is returned.
getNames in interface I_CmsXmlDocumentlocale - the locale
I_CmsXmlDocument.getNames(java.util.Locale)
public String getStringValue(CmsObject cms,
String name,
Locale locale)
I_CmsXmlDocumentnull if no such value exists..
getStringValue in interface I_CmsXmlDocumentcms - the current OpenCms user contextname - the key to get the content value forlocale - the locale to get the content value for
I_CmsXmlDocument.getStringValue(org.opencms.file.CmsObject, java.lang.String, java.util.Locale)
public String getStringValue(CmsObject cms,
String name,
Locale locale,
int index)
I_CmsXmlDocumentnull if no such value exists.
getStringValue in interface I_CmsXmlDocumentcms - the current OpenCms user contextname - the key to get the content value forlocale - the locale to get the content value forindex - the index position to get the value from
I_CmsXmlDocument.getStringValue(CmsObject, java.lang.String, Locale, int)
public I_CmsXmlContentValue getValue(String name,
Locale locale)
I_CmsXmlDocumentnull if no such value exists..
You can provide an index for the value by appending a numer in aquare brackets to the name parameter like this "Title[1]". If no index is provided, 0 is used for the index position.
getValue in interface I_CmsXmlDocumentname - the key to get the content value forlocale - the locale to get the content value for
I_CmsXmlDocument.getValue(java.lang.String, java.util.Locale)
public I_CmsXmlContentValue getValue(String name,
Locale locale,
int index)
I_CmsXmlDocumentnull if no such value exists.
getValue in interface I_CmsXmlDocumentname - the key to get the content value forlocale - the locale to get the content value forindex - the index position to get the value from
I_CmsXmlDocument.getValue(java.lang.String, java.util.Locale, int)public List getValues(Locale locale)
I_CmsXmlDocumentIf no element for the given locale is available, an empty list is returned.
getValues in interface I_CmsXmlDocumentlocale - the locale
I_CmsXmlContentValue)I_CmsXmlDocument.getValues(java.util.Locale)
public List getValues(String name,
Locale locale)
I_CmsXmlDocumentnull if no such value exists.
getValues in interface I_CmsXmlDocumentname - the key to get the content values forlocale - the locale to get the content values for
I_CmsXmlDocument.getValues(java.lang.String, java.util.Locale)public boolean hasLocale(Locale locale)
I_CmsXmlDocument
hasLocale in interface I_CmsXmlDocumentlocale - the locale to check
I_CmsXmlDocument.hasLocale(java.util.Locale)
public boolean hasValue(String name,
Locale locale)
I_CmsXmlDocumenttrue if a value exists with the given key name,
false otherwise.You can provide an index for the value by appending a numer in aquare brackets to the name parameter like this "Title[1]". If no index is provided, 0 is used for the index position.
hasValue in interface I_CmsXmlDocumentname - the key to checklocale - the locale to check
I_CmsXmlDocument.hasValue(java.lang.String, java.util.Locale)
public boolean hasValue(String name,
Locale locale,
int index)
I_CmsXmlDocumenttrue if a value exists with the given key name at the selected index,
false otherwise.
hasValue in interface I_CmsXmlDocumentname - the key to checklocale - the locale to checkindex - the index position to check
I_CmsXmlDocument.hasValue(java.lang.String, java.util.Locale, int)public void initDocument()
I_CmsXmlDocumentIf nodes in the XML are added, removed or moved, the document needs to be initialized in order to update the internal data structures.
initDocument in interface I_CmsXmlDocumentI_CmsXmlDocument.initDocument()
public boolean isEnabled(String name,
Locale locale)
I_CmsXmlDocumenttrue if a value exists with the given key name,
and that value is enabled,
false otherwise.You can provide an index for the value by appending a numer in aquare brackets to the name parameter like this "Title[1]". If no index is provided, 0 is used for the index position.
isEnabled in interface I_CmsXmlDocumentname - the key to checklocale - the locale to check
I_CmsXmlDocument.isEnabled(java.lang.String, java.util.Locale)
public boolean isEnabled(String name,
Locale locale,
int index)
I_CmsXmlDocumenttrue if a value exists with the given key name at the selected index,
and that value is enabled,
false otherwise.
isEnabled in interface I_CmsXmlDocumentname - the key to checklocale - the locale to checkindex - the index position to check
I_CmsXmlDocument.isEnabled(java.lang.String, java.util.Locale, int)
public byte[] marshal()
throws CmsXmlException
CmsXmlException - if something goes wrong
public void moveLocale(Locale source,
Locale destination)
throws CmsXmlException
I_CmsXmlDocument
moveLocale in interface I_CmsXmlDocumentsource - the source localedestination - the destination locale
CmsXmlException - in case either the source locale did not exist, or the destination locale already exists in the document, or if something else goes wrongI_CmsXmlDocument.moveLocale(java.util.Locale, java.util.Locale)
public void removeLocale(Locale locale)
throws CmsXmlException
I_CmsXmlDocument
removeLocale in interface I_CmsXmlDocumentlocale - the locale to remove
CmsXmlException - in case the locale did not exist in the document, or if something else goes wrongI_CmsXmlDocument.removeLocale(java.util.Locale)public void setConversion(String conversion)
conversion - the conversion mode to set for this documentpublic String toString()
toString in class ObjectObject.toString()
public void validateXmlStructure(EntityResolver resolver)
throws CmsXmlException
This is required in case someone modifies the xml structure of a document using the "edit control code" option.
resolver - the XML entitiy resolver to use
CmsXmlException - if the validation fails
protected void addBookmark(String name,
Locale locale,
boolean enabled,
Object value)
name - the name to use for the bookmarklocale - the locale to use for the bookmarkenabled - if true, the value is enabled, if false it is disabledvalue - the value to bookmarkprotected void addLocale(Locale locale)
locale - the locale to addprotected void clearBookmarks()
protected Object getBookmark(String bookmark)
getBookmarks() to get the list of all valid bookmark names.
bookmark - the bookmark name to look up
protected Object getBookmark(String name,
Locale locale)
name - the name to get the bookmark forlocale - the locale to get the bookmark for
protected Set getBookmarks()
protected abstract void initDocument(Document document,
String encoding,
CmsXmlContentDefinition contentDefinition)
document - the base XML document to use for initializingencoding - the encoding to use when marshalling the document latercontentDefinition - the content definition to use
protected OutputStream marshal(OutputStream out,
String encoding)
throws CmsXmlException
out - the output stream to write toencoding - the encoding to use
CmsXmlException - if something goes wrong
protected I_CmsXmlContentValue removeBookmark(String name,
Locale locale)
name - the name of the elementlocale - the locale of the element
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||