|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.xml.types.A_CmsXmlContentValue
public abstract class A_CmsXmlContentValue
Base class for XML content value implementations.
Field Summary | |
---|---|
protected java.lang.String |
m_defaultValue
The default value for nodes of this value. |
protected I_CmsXmlDocument |
m_document
The XML content instance this value belongs to. |
protected org.dom4j.Element |
m_element
The XML element node that contains this value. |
protected java.util.Locale |
m_locale
The locale this value was generated for. |
protected int |
m_maxOccurs
The maximum occurrences of this value according to the parent schema. |
protected int |
m_minOccurs
The minimum occurrences of this value according to the parent schema. |
protected java.lang.String |
m_name
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 | |
---|---|
protected |
A_CmsXmlContentValue()
Default constructor for a XML content type that initializes some internal values. |
protected |
A_CmsXmlContentValue(I_CmsXmlDocument document,
org.dom4j.Element element,
java.util.Locale locale,
I_CmsXmlSchemaType type)
Initializes the required members for this XML content value. |
protected |
A_CmsXmlContentValue(java.lang.String name,
java.lang.String minOccurs,
java.lang.String maxOccurs)
Initializes the schema type descriptor values for this type descriptor. |
Method Summary | |
---|---|
void |
appendXmlSchema(org.dom4j.Element root)
Appends an element XML representation of this type to the given root node. |
int |
compareTo(I_CmsXmlSchemaType obj)
|
boolean |
equals(java.lang.Object obj)
|
org.dom4j.Element |
generateXml(CmsObject cms,
I_CmsXmlDocument document,
org.dom4j.Element root,
java.util.Locale locale)
Appends an XML for a new, empty node of this schema type to the given root element. |
CmsXmlContentDefinition |
getContentDefinition()
Returns the content definition this schema type belongs to. |
java.lang.String |
getDefault(CmsObject cms)
Returns the default value of this parameter. |
java.lang.String |
getDefault(java.util.Locale locale)
Returns the default value for a node of this type in the current schema. |
I_CmsXmlDocument |
getDocument()
Returns the XML content instance this value belongs to. |
org.dom4j.Element |
getElement()
Returns the original XML element of this XML content value. |
java.lang.String |
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. |
java.lang.String |
getKey()
Returns the localized key identificator of this parameter. |
java.util.Locale |
getLocale()
Returns the locale of this XML content value was generated for. |
int |
getMaxIndex()
Returns the total number of XML elements of this type that currently exist in the source document. |
int |
getMaxOccurs()
Returns the maximum occurrences of this type. |
int |
getMinOccurs()
Returns the minimum occurrences of this type. |
java.lang.String |
getName()
Returns the name. |
java.lang.String |
getPath()
Returns the path of this XML content value in the source document. |
java.lang.String |
getPlainText(CmsObject cms)
Returns the value of this XML content node as a plain text String. |
boolean |
hasError()
Returns true if this widgets value contains an error. |
int |
hashCode()
|
boolean |
isSearchable()
The default implementation always returns true . |
boolean |
isSimpleType()
Returns true if this is a simple type, or false
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(boolean moveUp)
Moves this XML content element up or down in the XML document. |
protected java.lang.String |
readSchemaDefinition(java.lang.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(java.lang.String defaultValue)
Sets the default value for a node of this type. |
void |
setKeyPrefix(java.lang.String prefix)
Sets an optional localized key prefix identificator of this parameter. |
java.lang.String |
toString()
|
boolean |
validateValue(java.lang.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.xml.types.I_CmsXmlContentValue |
---|
getStringValue, setStringValue |
Methods inherited from interface org.opencms.xml.types.I_CmsXmlSchemaType |
---|
createValue, getSchemaDefinition, getTypeName, newInstance |
Methods inherited from interface org.opencms.widgets.I_CmsWidgetParameter |
---|
getStringValue, setStringValue |
Field Detail |
---|
protected java.lang.String m_defaultValue
protected I_CmsXmlDocument m_document
protected org.dom4j.Element m_element
protected java.util.Locale m_locale
protected int m_maxOccurs
protected int m_minOccurs
protected java.lang.String m_name
Constructor Detail |
---|
protected A_CmsXmlContentValue()
protected A_CmsXmlContentValue(I_CmsXmlDocument document, org.dom4j.Element element, java.util.Locale locale, I_CmsXmlSchemaType type)
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 forprotected A_CmsXmlContentValue(java.lang.String name, java.lang.String minOccurs, java.lang.String maxOccurs)
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 schemaMethod Detail |
---|
public void appendXmlSchema(org.dom4j.Element root)
appendXmlSchema
in interface I_CmsXmlSchemaType
root
- the element to append the XML topublic int compareTo(I_CmsXmlSchemaType obj)
compareTo
in interface java.lang.Comparable<I_CmsXmlSchemaType>
Comparable.compareTo(java.lang.Object)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public org.dom4j.Element generateXml(CmsObject cms, I_CmsXmlDocument document, org.dom4j.Element root, java.util.Locale locale)
I_CmsXmlSchemaType
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)
.
generateXml
in interface I_CmsXmlSchemaType
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
I_CmsXmlSchemaType.generateXml(org.opencms.file.CmsObject, org.opencms.xml.I_CmsXmlDocument, org.dom4j.Element, java.util.Locale)
public CmsXmlContentDefinition getContentDefinition()
I_CmsXmlSchemaType
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()
.
getContentDefinition
in interface I_CmsXmlSchemaType
I_CmsXmlSchemaType.getContentDefinition()
public java.lang.String getDefault(CmsObject cms)
I_CmsWidgetParameter
If no default value has been provided, null
is returned.
getDefault
in interface I_CmsWidgetParameter
cms
- an initialized instance of an OpenCms user context
I_CmsWidgetParameter.getDefault(org.opencms.file.CmsObject)
public java.lang.String getDefault(java.util.Locale locale)
I_CmsXmlSchemaType
getDefault
in interface I_CmsXmlSchemaType
locale
- the locale to generate the default value for
I_CmsXmlSchemaType.getDefault(java.util.Locale)
public I_CmsXmlDocument getDocument()
I_CmsXmlContentValue
getDocument
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.getDocument()
public org.dom4j.Element getElement()
I_CmsXmlContentValue
getElement
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.getElement()
public java.lang.String getId()
I_CmsWidgetParameter
getId
in interface I_CmsWidgetParameter
I_CmsWidgetParameter.getId()
public int getIndex()
I_CmsXmlContentValue
This is useful in case there are more then one elements with the same XML node name in the source XML document.
getIndex
in interface I_CmsWidgetParameter
getIndex
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.getIndex()
public java.lang.String getKey()
I_CmsWidgetParameter
getKey
in interface I_CmsWidgetParameter
I_CmsWidgetParameter.getKey()
public java.util.Locale getLocale()
I_CmsXmlContentValue
getLocale
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.getLocale()
public int getMaxIndex()
I_CmsXmlContentValue
getMaxIndex
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.getMaxIndex()
public int getMaxOccurs()
getMaxOccurs
in interface I_CmsWidgetParameter
getMaxOccurs
in interface I_CmsXmlSchemaType
public int getMinOccurs()
getMinOccurs
in interface I_CmsWidgetParameter
getMinOccurs
in interface I_CmsXmlSchemaType
public java.lang.String getName()
getName
in interface I_CmsWidgetParameter
getName
in interface I_CmsXmlSchemaType
public java.lang.String getPath()
I_CmsXmlContentValue
getPath
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.getPath()
public java.lang.String getPlainText(CmsObject cms)
I_CmsXmlContentValue
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).
getPlainText
in interface I_CmsXmlContentValue
cms
- an initialized instance of a CmsObject
I_CmsXmlContentValue.getPlainText(org.opencms.file.CmsObject)
public boolean hasError()
I_CmsWidgetParameter
true
if this widgets value contains an error.
hasError
in interface I_CmsWidgetParameter
true
if this widgets value contains an errorI_CmsWidgetParameter.hasError()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public boolean isSearchable()
true
.
isSearchable
in interface I_CmsXmlContentValue
true
in case this value is searchable by defaultI_CmsXmlContentValue.isSearchable()
public boolean isSimpleType()
I_CmsXmlSchemaType
true
if this is a simple type, or false
if this type is a nested schema.
If a value is a nested schema, it must be an instance of CmsXmlNestedContentDefinition
.
isSimpleType
in interface I_CmsXmlSchemaType
I_CmsXmlSchemaType.isSimpleType()
public void moveDown()
I_CmsXmlContentValue
If the XML content value is already the first in it's sequence, it is not moved.
moveDown
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.moveDown()
public void moveUp()
I_CmsXmlContentValue
If the XML content value is already the last in it's sequence, it is not moved.
moveUp
in interface I_CmsXmlContentValue
I_CmsXmlContentValue.moveUp()
public void setContentDefinition(CmsXmlContentDefinition contentDefinition)
I_CmsXmlSchemaType
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.
setContentDefinition
in interface I_CmsXmlSchemaType
contentDefinition
- the content definition to setI_CmsXmlSchemaType.setContentDefinition(org.opencms.xml.CmsXmlContentDefinition)
public void setDefault(java.lang.String defaultValue)
setDefault
in interface I_CmsXmlSchemaType
defaultValue
- the default value to setpublic void setKeyPrefix(java.lang.String prefix)
I_CmsWidgetParameter
setKeyPrefix
in interface I_CmsWidgetParameter
prefix
- the optional localized key prefix identificator of this parameterI_CmsWidgetParameter.setKeyPrefix(java.lang.String)
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public boolean validateValue(java.lang.String value)
I_CmsXmlSchemaType
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)
.
validateValue
in interface I_CmsXmlSchemaType
value
- the value to validate
I_CmsXmlSchemaType.validateValue(java.lang.String)
protected void moveValue(boolean moveUp)
Please note: No check is performed if the move violates the XML document schema!
moveUp
- if true, move up, otherwise move downprotected java.lang.String readSchemaDefinition(java.lang.String schemaUri) throws CmsRuntimeException
schemaUri
- the schema uri to load the XML schema file from
CmsRuntimeException
- if something goes wrong
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |