org.opencms.xml.types
Class CmsXmlNestedContentDefinition

java.lang.Object
  extended by org.opencms.xml.types.A_CmsXmlContentValue
      extended by org.opencms.xml.types.CmsXmlNestedContentDefinition
All Implemented Interfaces:
java.lang.Comparable, I_CmsWidgetParameter, I_CmsXmlContentValue, I_CmsXmlSchemaType

public class CmsXmlNestedContentDefinition
extends A_CmsXmlContentValue
implements I_CmsXmlSchemaType

A nested content XML definition that is included by another XML content definition.

Since:
6.0.0
Version:
$Revision: 1.18 $
Author:
Alexander Kandzior

Field Summary
 
Fields inherited from class org.opencms.xml.types.A_CmsXmlContentValue
m_defaultValue, m_document, m_element, m_locale, m_maxOccurs, m_minOccurs, m_name
 
Fields inherited from interface org.opencms.xml.types.I_CmsXmlSchemaType
XSI_NAMESPACE, XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION
 
Constructor Summary
CmsXmlNestedContentDefinition(CmsXmlContentDefinition contentDefinition, I_CmsXmlDocument document, org.dom4j.Element element, java.util.Locale locale, I_CmsXmlSchemaType type)
          Creates a new XML content value for the nested content definition.
CmsXmlNestedContentDefinition(CmsXmlContentDefinition contentDefinition, java.lang.String name, java.lang.String minOccurs, java.lang.String maxOccurs)
          Creates a new nested content definition.
 
Method Summary
 I_CmsXmlContentValue createValue(I_CmsXmlDocument document, org.dom4j.Element element, java.util.Locale locale)
          Creates a XML content value object for this type.
 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 getNestedContentDefinition()
          Returns the nested content definition.
 java.lang.String getSchemaDefinition()
          Returns a String representation of the XML definition for this schema type.
 java.lang.String getStringValue(CmsObject cms)
          Returns the value of this parameter.
 java.lang.String getTypeName()
          Returns the schema type name.
 boolean isSimpleType()
          Returns false, since nested content definitions are never simple.
 I_CmsXmlSchemaType newInstance(java.lang.String name, java.lang.String minOccurs, java.lang.String maxOccurs)
          Creates a new instance of this XML schema type initialized with the given values.
 void setStringValue(CmsObject cms, java.lang.String value)
          Sets the value of this parameter.
 
Methods inherited from class org.opencms.xml.types.A_CmsXmlContentValue
appendXmlSchema, compareTo, equals, getContentDefinition, getDefault, getDefault, getDocument, getElement, getId, getIndex, getKey, getLocale, getMaxIndex, getMaxOccurs, getMinOccurs, getName, getPath, getPlainText, hasError, hashCode, moveDown, moveUp, moveValue, readSchemaDefinition, setContentDefinition, setDefault, setKeyPrefix, toString, validateValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opencms.xml.types.I_CmsXmlSchemaType
appendXmlSchema, getContentDefinition, getDefault, getMaxOccurs, getMinOccurs, getName, setContentDefinition, setDefault, validateValue
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

CmsXmlNestedContentDefinition

public CmsXmlNestedContentDefinition(CmsXmlContentDefinition contentDefinition,
                                     I_CmsXmlDocument document,
                                     org.dom4j.Element element,
                                     java.util.Locale locale,
                                     I_CmsXmlSchemaType type)
Creates a new XML content value for the nested content definition.

Parameters:
document - the XML content instance this value belongs to
contentDefinition - the nested XML content definition
element - the XML element that contains this value
locale - the locale this value is created for
type - the type instance to create the value for

CmsXmlNestedContentDefinition

public CmsXmlNestedContentDefinition(CmsXmlContentDefinition contentDefinition,
                                     java.lang.String name,
                                     java.lang.String minOccurs,
                                     java.lang.String maxOccurs)
Creates a new nested content definition.

Parameters:
contentDefinition - the content definition to nest
name - the name of the XML node containing the value according to the XML schema
minOccurs - minimum number of occurences of this type according to the XML schema
maxOccurs - maximum number of occurences of this type according to the XML schema
Method Detail

createValue

public I_CmsXmlContentValue createValue(I_CmsXmlDocument document,
                                        org.dom4j.Element element,
                                        java.util.Locale locale)
Description copied from interface: I_CmsXmlSchemaType
Creates a XML content value object for this type.

Specified by:
createValue in interface I_CmsXmlSchemaType
Parameters:
document - the XML content instance this value belongs to
element - the XML element to create the value from
locale - the locale to create the value for
Returns:
the created XML content value object
See Also:
I_CmsXmlSchemaType.createValue(I_CmsXmlDocument, org.dom4j.Element, Locale)

generateXml

public org.dom4j.Element generateXml(CmsObject cms,
                                     I_CmsXmlDocument document,
                                     org.dom4j.Element root,
                                     java.util.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 interface I_CmsXmlSchemaType
Overrides:
generateXml in class A_CmsXmlContentValue
Parameters:
cms - the current users OpenCms context
document - the document the XML is generated for
root - the element to append the XML to
locale - the locale to generate the element default content for
Returns:
the generated XML element
See Also:
I_CmsXmlSchemaType.generateXml(org.opencms.file.CmsObject, org.opencms.xml.I_CmsXmlDocument, org.dom4j.Element, java.util.Locale)

getNestedContentDefinition

public CmsXmlContentDefinition getNestedContentDefinition()
Returns the nested content definition.

Returns:
the nested content definition

getSchemaDefinition

public java.lang.String getSchemaDefinition()
Description copied from interface: I_CmsXmlSchemaType
Returns a String representation of the XML definition for this schema type.

Specified by:
getSchemaDefinition in interface I_CmsXmlSchemaType
Returns:
a String representation of the XML definition for this schema type
See Also:
I_CmsXmlSchemaType.getSchemaDefinition()

getStringValue

public java.lang.String getStringValue(CmsObject cms)
                                throws CmsRuntimeException
Description copied from interface: I_CmsWidgetParameter
Returns the value of this parameter.

Specified by:
getStringValue in interface I_CmsWidgetParameter
Specified by:
getStringValue in interface I_CmsXmlContentValue
Parameters:
cms - an initialized instance of an OpenCms user context
Returns:
the value of this parameter
Throws:
CmsRuntimeException
See Also:
I_CmsXmlContentValue.getStringValue(org.opencms.file.CmsObject)

getTypeName

public java.lang.String getTypeName()
Description copied from interface: I_CmsXmlSchemaType
Returns the schema type name.

By convention, a XML schema type name has the form "OpenCms + ${name}". Examples are "OpenCmsString" or "OpenCmsBoolean".

The schema type name is fixed by the implementation.

Specified by:
getTypeName in interface I_CmsXmlSchemaType
Returns:
the schema type name
See Also:
I_CmsXmlSchemaType.getTypeName()

isSimpleType

public boolean isSimpleType()
Returns false, since nested content definitions are never simple.

Specified by:
isSimpleType in interface I_CmsXmlSchemaType
Overrides:
isSimpleType in class A_CmsXmlContentValue
Returns:
true if this is a simple type, or false if this type is a nested schema
See Also:
I_CmsXmlSchemaType.isSimpleType()

newInstance

public I_CmsXmlSchemaType newInstance(java.lang.String name,
                                      java.lang.String minOccurs,
                                      java.lang.String maxOccurs)
Description copied from interface: I_CmsXmlSchemaType
Creates a new instance of this XML schema type initialized with the given values.

Specified by:
newInstance in interface I_CmsXmlSchemaType
Parameters:
name - the name to use in the xml document
minOccurs - minimum number of occurences
maxOccurs - maximum number of occurences
Returns:
a new instance of this XML content type initialized with the given values
See Also:
I_CmsXmlSchemaType.newInstance(java.lang.String, java.lang.String, java.lang.String)

setStringValue

public void setStringValue(CmsObject cms,
                           java.lang.String value)
Description copied from interface: I_CmsWidgetParameter
Sets the value of this parameter.

This method does provide processing of the content based on the users current OpenCms context. This can be used e.g. for link extraction and replacement in the content.

Specified by:
setStringValue in interface I_CmsWidgetParameter
Specified by:
setStringValue in interface I_CmsXmlContentValue
Parameters:
cms - an initialized instance of an OpenCms user context
value - the value to set
See Also:
I_CmsXmlContentValue.setStringValue(org.opencms.file.CmsObject, java.lang.String)