org.opencms.xml.types
Class CmsXmlBooleanValue

java.lang.Object
  extended byorg.opencms.xml.types.A_CmsXmlContentValue
      extended byorg.opencms.xml.types.A_CmsXmlValueTextBase
          extended byorg.opencms.xml.types.CmsXmlBooleanValue
All Implemented Interfaces:
java.lang.Comparable, I_CmsWidgetParameter, I_CmsXmlContentValue, I_CmsXmlSchemaType

public class CmsXmlBooleanValue
extends A_CmsXmlValueTextBase

Describes the XML content type "OpenCmsBoolean".

Since:
6.0.0
Version:
$Revision: 1.23 $
Author:
Andreas Zahner

Field Summary
static java.lang.String TYPE_NAME
          The name of this type as used in the XML schema.
static java.lang.String TYPE_RULE
          The validation rule used for this schema type.
 
Fields inherited from class org.opencms.xml.types.A_CmsXmlValueTextBase
m_stringValue
 
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
CmsXmlBooleanValue()
          Creates a new, empty schema type descriptor of type "OpenCmsBoolean".
CmsXmlBooleanValue(I_CmsXmlDocument document, org.dom4j.Element element, java.util.Locale locale, I_CmsXmlSchemaType type)
          Creates a new XML content value of type "OpenCmsBoolean".
CmsXmlBooleanValue(java.lang.String name, java.lang.String minOccurs, java.lang.String maxOccurs)
          Creates a new schema type descriptor for the type "OpenCmsBoolean".
 
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.
 boolean getBooleanValue()
          Returns the boolean value as a boolean type.
static boolean getBooleanValue(CmsObject cms, I_CmsWidgetParameter value)
          Returns the boolean value of the given widget parameter.
 java.lang.String getDefault(java.util.Locale locale)
          Returns the default value for a node of this type in the current schema.
 java.lang.String getSchemaDefinition()
          Returns a String representation of the XML definition for this schema type.
 java.lang.String getTypeName()
          Returns the schema type name.
 boolean isSearchable()
          The default implementation always returns true.
 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 provided String as value of this XML content node.
 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 org.opencms.xml.types.A_CmsXmlValueTextBase
getStringValue
 
Methods inherited from class org.opencms.xml.types.A_CmsXmlContentValue
appendXmlSchema, compareTo, equals, generateXml, getContentDefinition, getDefault, getDocument, getElement, getId, getIndex, getKey, getLocale, getMaxIndex, getMaxOccurs, getMinOccurs, getName, getPath, getPlainText, hasError, hashCode, isSimpleType, moveDown, moveUp, moveValue, readSchemaDefinition, setContentDefinition, setDefault, setKeyPrefix, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_NAME

public static final java.lang.String TYPE_NAME
The name of this type as used in the XML schema.

See Also:
Constant Field Values

TYPE_RULE

public static final java.lang.String TYPE_RULE
The validation rule used for this schema type.

See Also:
Constant Field Values
Constructor Detail

CmsXmlBooleanValue

public CmsXmlBooleanValue()
Creates a new, empty schema type descriptor of type "OpenCmsBoolean".


CmsXmlBooleanValue

public CmsXmlBooleanValue(I_CmsXmlDocument document,
                          org.dom4j.Element element,
                          java.util.Locale locale,
                          I_CmsXmlSchemaType type)
Creates a new XML content value of type "OpenCmsBoolean".

Parameters:
document - the XML content instance this value belongs to
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

CmsXmlBooleanValue

public CmsXmlBooleanValue(java.lang.String name,
                          java.lang.String minOccurs,
                          java.lang.String maxOccurs)
Creates a new schema type descriptor for the type "OpenCmsBoolean".

Parameters:
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

getBooleanValue

public static boolean getBooleanValue(CmsObject cms,
                                      I_CmsWidgetParameter value)
Returns the boolean value of the given widget parameter.

Parameters:
cms - an initialized instance of a CmsObject
value - the XML content value to get the boolean value of
Returns:
the boolean value of the given widget parameter

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.

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)

getBooleanValue

public boolean getBooleanValue()
Returns the boolean value as a boolean type.

Returns:
the boolean value as a boolean type

getDefault

public java.lang.String getDefault(java.util.Locale locale)
Description copied from interface: I_CmsXmlSchemaType
Returns the default value for a node of this type in the current schema.

Specified by:
getDefault in interface I_CmsXmlSchemaType
Overrides:
getDefault in class A_CmsXmlContentValue
See Also:
A_CmsXmlContentValue.getDefault(Locale)

getSchemaDefinition

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

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

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.

Returns:
the schema type name
See Also:
I_CmsXmlSchemaType.getTypeName()

isSearchable

public boolean isSearchable()
Description copied from class: A_CmsXmlContentValue
The default implementation always returns true.

Specified by:
isSearchable in interface I_CmsXmlContentValue
Overrides:
isSearchable in class A_CmsXmlContentValue
See Also:
A_CmsXmlContentValue.isSearchable()

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.

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)
                    throws CmsIllegalArgumentException
Description copied from interface: I_CmsXmlContentValue
Sets the provided String as value of this XML content node.

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_CmsXmlContentValue
Overrides:
setStringValue in class A_CmsXmlValueTextBase
Throws:
CmsIllegalArgumentException
See Also:
A_CmsXmlValueTextBase.setStringValue(org.opencms.file.CmsObject, java.lang.String)

validateValue

public boolean validateValue(java.lang.String value)
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 interface I_CmsXmlSchemaType
Overrides:
validateValue in class A_CmsXmlContentValue
See Also:
I_CmsXmlSchemaType.validateValue(java.lang.String)