Class A_CmsXmlContentValue
- All Implemented Interfaces:
Comparable<I_CmsXmlSchemaType>
,I_CmsWidgetParameter
,I_CmsXmlContentValue
,I_CmsXmlSchemaType
- Direct Known Subclasses:
A_CmsXmlValueCdataBase
,A_CmsXmlValueTextBase
,CmsXmlAccessRestrictionValue
,CmsXmlCategoryValue
,CmsXmlDynamicCategoryValue
,CmsXmlHtmlValue
,CmsXmlNestedContentDefinition
,CmsXmlVarLinkValue
,CmsXmlVfsFileValue
- Since:
- 6.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opencms.xml.types.I_CmsXmlContentValue
I_CmsXmlContentValue.CmsSearchContentConfig, I_CmsXmlContentValue.SearchContentType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
The default value for nodes of this value.protected I_CmsXmlDocument
The XML content instance this value belongs to.protected org.dom4j.Element
The XML element node that contains this value.protected Locale
The locale this value was generated for.protected int
The maximum occurrences of this value according to the parent schema.protected int
The minimum occurrences of this value according to the parent schema.protected String
The configured XML node name of this value.Fields inherited from interface org.opencms.xml.types.I_CmsXmlSchemaType
XSI_NAMESPACE, XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default constructor for a XML content type that initializes some internal values.protected
A_CmsXmlContentValue
(String name, String minOccurs, String maxOccurs) Initializes the schema type descriptor values for this type descriptor.protected
A_CmsXmlContentValue
(I_CmsXmlDocument document, org.dom4j.Element element, Locale locale, I_CmsXmlSchemaType type) Initializes the required members for this XML content value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendXmlSchema
(org.dom4j.Element root) Appends an element XML representation of this type to the given root node.int
boolean
org.dom4j.Element
generateXml
(CmsObject cms, I_CmsXmlDocument document, org.dom4j.Element root, Locale locale) Appends an XML for a new, empty node of this schema type to the given root element.int
Returns the maximum occurrences of choice options for this type in the current schema.Returns the content definition this schema type belongs to.getDefault
(Locale locale) Returns the default value for a node of this type in the current schema.getDefault
(CmsObject cms) Returns the default value of this parameter.Returns the XML content instance this value belongs to.org.dom4j.Element
Returns the original XML element of this XML content value.getId()
Returns the form id of this parameter.int
getIndex()
Returns the node index of this XML content value in the source XML document, starting with 0, with special handling of elements in choice groups.getKey()
Returns the localized key identificator of this parameter.Returns the locale of this XML content value was generated for.int
Returns the total number of XML elements of this type that currently exist in the source document.int
Returns the maximum occurrences of this type.int
Returns the minimum occurrences of this type.getName()
Returns the name.getPath()
Returns the path of this XML content value in the source document.getPlainText
(CmsObject cms) Returns the value of this XML content node as a plain text String.protected CmsRelationType
getRelationType
(String path) Returns the relation type for the given path.int
Returns the node index of this XML content value in the source XML document, starting with 0, based on the XML ordering.boolean
hasError()
Returnstrue
if this widgets value contains an error.int
hashCode()
boolean
Returnstrue
if this type is an option inside of a choice sequence.boolean
Returnstrue
if this type defines a choice sequence.boolean
The default implementation always returnstrue
.boolean
Returnstrue
if this is a simple type, orfalse
if this type is a nested schema.void
moveDown()
Moves this XML content value one position down in the source document, if possible.void
moveUp()
Moves this XML content value one position up in the source document, if possible.protected void
moveValue
(int step) Moves this XML content element up or down in the XML document.protected String
readSchemaDefinition
(String schemaUri) Convenience method to loads the XML schema definition for this value type from an external file.void
setContentDefinition
(CmsXmlContentDefinition contentDefinition) Sets the content definition this schema type belongs to.void
setDefault
(String defaultValue) Sets the default value for a node of this type.void
setKeyPrefix
(String prefix) Sets an optional localized key prefix identificator of this parameter.toString()
boolean
validateValue
(String value) Checks if a given value is valid according to the validation rule (regular expression) used for validation of this schema type in the XML schema.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opencms.widgets.I_CmsWidgetParameter
getStringValue, setStringValue
Methods inherited from interface org.opencms.xml.types.I_CmsXmlContentValue
getSearchContentConfig, getStringValue, setStringValue
Methods inherited from interface org.opencms.xml.types.I_CmsXmlSchemaType
createValue, getSchemaDefinition, getTypeName, newInstance
-
Field Details
-
m_defaultValue
The default value for nodes of this value. -
m_document
The XML content instance this value belongs to. -
m_element
The XML element node that contains this value. -
m_locale
The locale this value was generated for. -
m_maxOccurs
The maximum occurrences of this value according to the parent schema. -
m_minOccurs
The minimum occurrences of this value according to the parent schema. -
m_name
The configured XML node name of this value.
-
-
Constructor Details
-
A_CmsXmlContentValue
protected A_CmsXmlContentValue()Default constructor for a XML content type that initializes some internal values. -
A_CmsXmlContentValue
protected A_CmsXmlContentValue(I_CmsXmlDocument document, org.dom4j.Element element, Locale locale, I_CmsXmlSchemaType type) Initializes the required members for this XML content value.- Parameters:
document
- the XML content instance this value belongs toelement
- the XML element that contains this valuelocale
- the locale this value is created fortype
- the type instance to create the value for
-
A_CmsXmlContentValue
Initializes the schema type descriptor values for this type descriptor.- Parameters:
name
- the name of the XML node containing the value according to the XML schemaminOccurs
- minimum number of occurrences of this type according to the XML schemamaxOccurs
- maximum number of occurrences of this type according to the XML schema
-
-
Method Details
-
appendXmlSchema
Appends an element XML representation of this type to the given root node.- Specified by:
appendXmlSchema
in interfaceI_CmsXmlSchemaType
- Parameters:
root
- the element to append the XML to
-
compareTo
- Specified by:
compareTo
in interfaceComparable<I_CmsXmlSchemaType>
- See Also:
-
equals
-
generateXml
public org.dom4j.Element generateXml(CmsObject cms, I_CmsXmlDocument document, org.dom4j.Element root, Locale locale) Description copied from interface:I_CmsXmlSchemaType
Appends an XML for a new, empty node of this schema type to the given root element.This is used to dynamically build a vaild XML content object from an initialized
CmsXmlContentDefinition
class.Important: This method can only be used during initialization of a XML content object, not to add values to an already initialized XML content. To add values after initialization, use
CmsXmlContent.addValue(CmsObject, String, Locale, int)
.- Specified by:
generateXml
in interfaceI_CmsXmlSchemaType
- Parameters:
cms
- the current users OpenCms contextdocument
- the document the XML is generated forroot
- the element to append the XML tolocale
- the locale to generate the element default content for- Returns:
- the generated XML element
- See Also:
-
getChoiceMaxOccurs
Description copied from interface:I_CmsXmlSchemaType
Returns the maximum occurrences of choice options for this type in the current schema.This will be greater than 0 only if
I_CmsXmlSchemaType.isChoiceType()
istrue
.- Specified by:
getChoiceMaxOccurs
in interfaceI_CmsXmlSchemaType
- Returns:
- the maximum occurrences of choice options for this type in the current schema
- See Also:
-
getContentDefinition
Description copied from interface:I_CmsXmlSchemaType
Returns the content definition this schema type belongs to.If the value belongs to a nested content, then the nested content definition is returned. This means that for documents with nested schemas, the content definition of a value is not necessarily equal to the content definition of the document itself, which can be obtained using
I_CmsXmlContentValue.getDocument()
.- Specified by:
getContentDefinition
in interfaceI_CmsXmlSchemaType
- Returns:
- the content definition this schema type belongs to
- See Also:
-
getDefault
Description copied from interface:I_CmsWidgetParameter
Returns the default value of this parameter.If no default value has been provided,
null
is returned.- Specified by:
getDefault
in interfaceI_CmsWidgetParameter
- Parameters:
cms
- an initialized instance of an OpenCms user context- Returns:
- the default value of this parameter
- See Also:
-
getDefault
Description copied from interface:I_CmsXmlSchemaType
Returns the default value for a node of this type in the current schema.- Specified by:
getDefault
in interfaceI_CmsXmlSchemaType
- Parameters:
locale
- the locale to generate the default value for- Returns:
- the default value for a node of this type in the current schema
- See Also:
-
getDocument
Description copied from interface:I_CmsXmlContentValue
Returns the XML content instance this value belongs to.- Specified by:
getDocument
in interfaceI_CmsXmlContentValue
- Returns:
- the XML content instance this value belongs to
- See Also:
-
getElement
Description copied from interface:I_CmsXmlContentValue
Returns the original XML element of this XML content value.- Specified by:
getElement
in interfaceI_CmsXmlContentValue
- Returns:
- the original XML element of this XML content value
- See Also:
-
getId
Description copied from interface:I_CmsWidgetParameter
Returns the form id of this parameter.- Specified by:
getId
in interfaceI_CmsWidgetParameter
- Returns:
- the form id of this parameter
- See Also:
-
getIndex
Description copied from interface:I_CmsXmlContentValue
Returns the node index of this XML content value in the source XML document, starting with 0, with special handling of elements in choice groups.This is useful in case there are more than one elements with the same XML node name in the source XML document.
Elements in XML choice groups will share the same number space, so a choice sequence will be numbered like this:
Title[1], Text[2], Title[3], Image[4]
- Specified by:
getIndex
in interfaceI_CmsWidgetParameter
- Specified by:
getIndex
in interfaceI_CmsXmlContentValue
- Returns:
- the index of this XML content node in the source document with special handling of elements in choice groups
- See Also:
-
getKey
Description copied from interface:I_CmsWidgetParameter
Returns the localized key identificator of this parameter.- Specified by:
getKey
in interfaceI_CmsWidgetParameter
- Returns:
- the localized key identificator of this parameter
- See Also:
-
getLocale
Description copied from interface:I_CmsXmlContentValue
Returns the locale of this XML content value was generated for.- Specified by:
getLocale
in interfaceI_CmsXmlContentValue
- Returns:
- the locale of this XML content value was generated for
- See Also:
-
getMaxIndex
Description copied from interface:I_CmsXmlContentValue
Returns the total number of XML elements of this type that currently exist in the source document.- Specified by:
getMaxIndex
in interfaceI_CmsXmlContentValue
- Returns:
- the total number of XML elements of this type that currently exist in the source document
- See Also:
-
getMaxOccurs
Returns the maximum occurrences of this type.- Specified by:
getMaxOccurs
in interfaceI_CmsWidgetParameter
- Specified by:
getMaxOccurs
in interfaceI_CmsXmlSchemaType
- Returns:
- the maximum occurrences of this type
-
getMinOccurs
Returns the minimum occurrences of this type.- Specified by:
getMinOccurs
in interfaceI_CmsWidgetParameter
- Specified by:
getMinOccurs
in interfaceI_CmsXmlSchemaType
- Returns:
- the minimum occurrences of this type
-
getName
Returns the name.- Specified by:
getName
in interfaceI_CmsWidgetParameter
- Specified by:
getName
in interfaceI_CmsXmlSchemaType
- Returns:
- the name
-
getPath
Description copied from interface:I_CmsXmlContentValue
Returns the path of this XML content value in the source document.- Specified by:
getPath
in interfaceI_CmsXmlContentValue
- Returns:
- the path of this XML content value in the source document
- See Also:
-
getPlainText
Description copied from interface:I_CmsXmlContentValue
Returns the value of this XML content node as a plain text String.Plain text in this context means a pure textual representation of the content (i.e. without html tags). The plain text may be
null
, too, if there is no sound or useful textual representation (i.e. color values).- Specified by:
getPlainText
in interfaceI_CmsXmlContentValue
- Parameters:
cms
- an initialized instance of a CmsObject- Returns:
- the value of this XML content node as a plain text String
- See Also:
-
getXmlIndex
Description copied from interface:I_CmsXmlContentValue
Returns the node index of this XML content value in the source XML document, starting with 0, based on the XML ordering.Elements in choice groups will be numbered like this:
Title[1], Text[1], Title[2], Image[1]
- Specified by:
getXmlIndex
in interfaceI_CmsXmlContentValue
- Returns:
- the index of this XML content node in the source document with special handling of elements in choice groups
- See Also:
-
hasError
Description copied from interface:I_CmsWidgetParameter
Returnstrue
if this widgets value contains an error.- Specified by:
hasError
in interfaceI_CmsWidgetParameter
- Returns:
true
if this widgets value contains an error- See Also:
-
hashCode
-
isChoiceOption
Description copied from interface:I_CmsXmlSchemaType
Returnstrue
if this type is an option inside of a choice sequence.This method is intended to check if this type is a node inside a choice sequence. In order to check if this type defines a choice sequence, use
I_CmsXmlSchemaType.isChoiceType()
.- Specified by:
isChoiceOption
in interfaceI_CmsXmlSchemaType
- Returns:
true
if this node defines a choice sequence- See Also:
-
isChoiceType
Description copied from interface:I_CmsXmlSchemaType
Returnstrue
if this type defines a choice sequence.This method is intended to check if this type is a node defining a choice sequence. In order to check if this type is an option inside of a choice sequence, use
I_CmsXmlSchemaType.isChoiceOption()
.- Specified by:
isChoiceType
in interfaceI_CmsXmlSchemaType
- Returns:
true
if this node defines a choice sequence- See Also:
-
isSearchable
The default implementation always returnstrue
.- Specified by:
isSearchable
in interfaceI_CmsXmlContentValue
- Returns:
true
in case this value is searchable by default- See Also:
-
isSimpleType
Description copied from interface:I_CmsXmlSchemaType
Returnstrue
if this is a simple type, orfalse
if this type is a nested schema.If a value is a nested schema, it must be an instance of
CmsXmlNestedContentDefinition
.- Specified by:
isSimpleType
in interfaceI_CmsXmlSchemaType
- Returns:
- true if this is a simple type, or false if this type is a nested schema
- See Also:
-
moveDown
Description copied from interface:I_CmsXmlContentValue
Moves this XML content value one position down in the source document, if possible.If the XML content value is already the first in it's sequence, it is not moved.
- Specified by:
moveDown
in interfaceI_CmsXmlContentValue
- See Also:
-
moveUp
Description copied from interface:I_CmsXmlContentValue
Moves this XML content value one position up in the source document, if possible.If the XML content value is already the last in it's sequence, it is not moved.
- Specified by:
moveUp
in interfaceI_CmsXmlContentValue
- See Also:
-
setContentDefinition
Description copied from interface:I_CmsXmlSchemaType
Sets the content definition this schema type belongs to.This is done automatically when the scheme type is added to a content definition. Usually there is no need to call this method from the application.
- Specified by:
setContentDefinition
in interfaceI_CmsXmlSchemaType
- Parameters:
contentDefinition
- the content definition to set- See Also:
-
setDefault
Sets the default value for a node of this type.- Specified by:
setDefault
in interfaceI_CmsXmlSchemaType
- Parameters:
defaultValue
- the default value to set
-
setKeyPrefix
Description copied from interface:I_CmsWidgetParameter
Sets an optional localized key prefix identificator of this parameter.- Specified by:
setKeyPrefix
in interfaceI_CmsWidgetParameter
- Parameters:
prefix
- the optional localized key prefix identificator of this parameter- See Also:
-
toString
-
validateValue
Description copied from interface:I_CmsXmlSchemaType
Checks if a given value is valid according to the validation rule (regular expression) used for validation of this schema type in the XML schema.To have a more refined validation according to the special requirements of the content type, use custom validation rules in the appinfo which are processed with
I_CmsXmlContentHandler.resolveValidation(CmsObject, I_CmsXmlContentValue, org.opencms.xml.content.CmsXmlContentErrorHandler)
.- Specified by:
validateValue
in interfaceI_CmsXmlSchemaType
- Parameters:
value
- the value to validate- Returns:
- the validation rule (regular expression) used for this schema type in the XML schema
- See Also:
-
getRelationType
Returns the relation type for the given path.- Parameters:
path
- the element path- Returns:
- the relation type
-
moveValue
Moves this XML content element up or down in the XML document.Please note: No check is performed if the move violates the XML document schema!
- Parameters:
step
- move the element up or down according to the given step value
-
readSchemaDefinition
Convenience method to loads the XML schema definition for this value type from an external file.- Parameters:
schemaUri
- the schema uri to load the XML schema file from- Returns:
- the loaded XML schema
- Throws:
CmsRuntimeException
- if something goes wrong
-