public class WidgetDefinitionParser
extends java.lang.Object
Definition element.
Under the root element, the parser by default reads the following elements:
<slot internalSlotId="bodySlot1" slotType="ReadOnly"/>
A single value property:
<widget-property name="property1" required="true" type="java.lang.Integer" value="1"/>
A multi value property:
<widget-property name="property1" required="true" type="java.lang.Integer" >
<value>1</value>
<value>2</value>
</widget-property>
<widget-manager j2se="com.ibm.commerce.pagelayout.widget.manager.J2SEWidgetManager" j2ee="com.ibm.commerce.pagelayout.widget.manager.J2EEWidgetManager"/>
<suppported-device-class>
<value>Web</value>
</suppported-device-class>
getWidgetPropertiesDefined and getSlotsDefined
should be used to retrieve the widget properties and configurable slots
respectively. The widget manager class is returned as a property in the
widget properties. The property name is
PageLayoutFacadeConstants.WIDGETMANAGER_PROPERTY_NAME. The supported
device classes for the widget are also returned as widget property. The
property name is
PageLayoutFacadeConstants.SUPPORTED_DEVICE_CLASSES_PROPERTY_NAME| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
COPYRIGHT
Copyright field.
|
static java.lang.String |
DEFINITION_ELEMENT_NAME
The tag name for the root element of the widget definition.
|
static java.lang.String |
ID_ATTRIBUTE
The attribute used to define the id of the element.
|
static java.lang.String |
INTERNAL_SLOT_ID_ATTRIBUTE
The name of the attribute used to define the internal slot ID for the slot.
|
static java.lang.String |
NAME_ATTRIBUTE
The attribute used to define the name of the widget property.
|
static java.lang.String |
POSITIONAL_PROPERTY_LEFT
The attribute name for the positional property
left for slots. |
static java.lang.String |
POSITIONAL_PROPERTY_TOP
The attribute name for the positional property
top for slots. |
static java.lang.String |
POSITIONAL_PROPERTY_X
The attribute name for the positional property
x for slots. |
static java.lang.String |
POSITIONAL_PROPERTY_Y
The attribute name for the positional property
y for slots. |
static java.lang.String |
SLOT_ELEMENT_NAME
The element name for defining the configurable slots offered by the widget.
|
static java.lang.String |
SLOT_TYPE_ATTRIBUTE
The name of the attribute used to define the type of slot.
|
static java.lang.String |
SUPPORTED_DEVICE_CLASS_ELEMENT_NAME
The element name for defining the device classes supported by the widget.If
the widget supports a single device class, it can define a
value attribute. |
static java.lang.String |
VALUE_NODE
This tag is used to define the value for the widget property.
|
static java.lang.String |
WIDGET_MANAGER_ELEMENT_NAME
The tag used to define the widget's manager class name.
|
static java.lang.String |
WIDGET_PROPERTY_ELEMENT_NAME
The element name for defining the properties of the widget.
|
| Constructor and Description |
|---|
WidgetDefinitionParser()
Default constructor
|
WidgetDefinitionParser(com.ibm.commerce.pagelayout.facade.datatypes.WidgetDefinitionType widgetDefinition)
Constructor for the parser.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getDataTypeForProperty(java.lang.String propertyName)
This method indicates the data type of the property specified.
|
java.util.Set<java.lang.String> |
getMandatoryWidgetProperties()
This method returns all the widget property names that are marked mandatory.
|
java.util.List<com.ibm.commerce.pagelayout.facade.datatypes.GenericSlotType> |
getSlotsDefined()
Returns the slots defined in the widget's XML definition.
|
java.util.List<com.ibm.commerce.pagelayout.facade.datatypes.WidgetPropertyType> |
getWidgetPropertiesDefined()
Returns the list of widget properties defined for the widget.
|
java.lang.Boolean |
isMandatoryProperty(java.lang.String propertyName)
This method indicates if the property specified is required or not.
|
java.lang.String |
mergeXML(java.lang.String xml1,
java.lang.String xml2)
Given 2 XML definitions, this method merges both the XML's and returns
the final merged XML.
|
void |
parse()
This method parses the widget's XML definition to extract the
configurable slots, widget properties and the widget manager class.
|
public static final java.lang.String COPYRIGHT
public static final java.lang.String SLOT_TYPE_ATTRIBUTE
public static final java.lang.String INTERNAL_SLOT_ID_ATTRIBUTE
public static final java.lang.String VALUE_NODE
value elements (if the property takes
multiple values). The text content of the value node is the
value of the widget property.public static final java.lang.String NAME_ATTRIBUTE
public static final java.lang.String ID_ATTRIBUTE
public static final java.lang.String WIDGET_MANAGER_ELEMENT_NAME
j2se and j2ee whose values
represent the widget manager class to be used based on the execution
environment.public static final java.lang.String WIDGET_PROPERTY_ELEMENT_NAME
name attribute. If the property takes a single value, the element can define a value attribute.
If the property takes multiple values, the element can define a list of value nodes.public static final java.lang.String SLOT_ELEMENT_NAME
internalSlotId, slotType as attributes.public static final java.lang.String SUPPORTED_DEVICE_CLASS_ELEMENT_NAME
value attribute. If the widget supports multiple device
classes, it can define a list of value nodes.public static final java.lang.String DEFINITION_ELEMENT_NAME
public static final java.lang.String POSITIONAL_PROPERTY_X
x for slots.public static final java.lang.String POSITIONAL_PROPERTY_Y
y for slots.public static final java.lang.String POSITIONAL_PROPERTY_TOP
top for slots.public static final java.lang.String POSITIONAL_PROPERTY_LEFT
left for slots.public WidgetDefinitionParser(com.ibm.commerce.pagelayout.facade.datatypes.WidgetDefinitionType widgetDefinition)
widgetDefinition - The widget whose XML definition is being parsed.public WidgetDefinitionParser()
public void parse()
throws WidgetDefinitionException
WidgetDefinitionException - When the parsing fails due malformed XML.WidgetDefinitionParser#createSlotFromElement(Element)},
WidgetDefinitionParser#createWidgetPropertyFromElement(Element)}public java.lang.String mergeXML(java.lang.String xml1,
java.lang.String xml2)
throws WidgetDefinitionException
xml1 - - First XMLxml2 - - Second XMLWidgetDefinitionExceptionpublic java.util.List<com.ibm.commerce.pagelayout.facade.datatypes.GenericSlotType> getSlotsDefined()
public java.util.List<com.ibm.commerce.pagelayout.facade.datatypes.WidgetPropertyType> getWidgetPropertiesDefined()
public java.lang.Boolean isMandatoryProperty(java.lang.String propertyName)
propertyName - The name of the widget property.public java.util.Set<java.lang.String> getMandatoryWidgetProperties()
public java.lang.String getDataTypeForProperty(java.lang.String propertyName)
propertyName - The name of the widget property.