Class FormParser
- java.lang.Object
-
- org.ametys.plugins.forms.workflow.FormParser
-
public class FormParser extends Object
Form parser.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FormParser.RichTextPrefixResolver
XML prefix resolver which declares docbook and html namespaces.
-
Field Summary
Fields Modifier and Type Field Description protected static String
_CAPTCHA_ELEMENT
The captcha XML element name.protected static String
_FIELDSET_ELEMENT
The fieldset XML element name.protected static String
_INPUT_ELEMENT
The input XML element name.protected static String
_LABEL_ELEMENT
The label XML element name.protected static String
_LEGEND_ELEMENT
The fieldset XML element name.protected static String
_OPTION_ELEMENT
The option XML element name.protected static String
_SELECT_ELEMENT
The select XML element name.protected static String
_TEXTAREA_ELEMENT
The textarea XML element name.protected XPathProcessor
_xpathProcessor
An XPath processor.static PrefixResolver
RICH_TEXT_PREFIX_RESOLVER
The rich text prefix resolver.
-
Constructor Summary
Constructors Constructor Description FormParser(XPathProcessor xpathProcessor)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
_getAttribute(Node node, String attributeName)
Return the value of an attribute of an inputprotected Field.FieldType
_getInputType(Node inputNode)
Get the input type.protected void
_parseFields(Node formNode, Form form)
Parse the fields of a form.protected void
_processAttributes(Node node, Field field)
Process common field attributes and properties.protected Field
_processCaptcha(Node captchaNode)
Process a captcha.protected Fieldset
_processFieldset(Node fieldsetNode)
Process a fieldset.protected Field
_processInput(Node inputNode)
Process an input.protected void
_processLabel(Node labelNode, Map<String,String> labels)
Process a label.protected Field
_processSelect(Node selectNode)
Process a select.protected Field
_processTextarea(Node textareaNode)
Process an textarea.List<Node>
getNodesAsList(Node context, String xpathExpression)
Return a list of nodes selected by an xpath expression.Form
parseForm(Node formNode)
Parses the form.
-
-
-
Field Detail
-
RICH_TEXT_PREFIX_RESOLVER
public static final PrefixResolver RICH_TEXT_PREFIX_RESOLVER
The rich text prefix resolver.
-
_LABEL_ELEMENT
protected static final String _LABEL_ELEMENT
The label XML element name.- See Also:
- Constant Field Values
-
_INPUT_ELEMENT
protected static final String _INPUT_ELEMENT
The input XML element name.- See Also:
- Constant Field Values
-
_TEXTAREA_ELEMENT
protected static final String _TEXTAREA_ELEMENT
The textarea XML element name.- See Also:
- Constant Field Values
-
_SELECT_ELEMENT
protected static final String _SELECT_ELEMENT
The select XML element name.- See Also:
- Constant Field Values
-
_OPTION_ELEMENT
protected static final String _OPTION_ELEMENT
The option XML element name.- See Also:
- Constant Field Values
-
_CAPTCHA_ELEMENT
protected static final String _CAPTCHA_ELEMENT
The captcha XML element name.- See Also:
- Constant Field Values
-
_FIELDSET_ELEMENT
protected static final String _FIELDSET_ELEMENT
The fieldset XML element name.- See Also:
- Constant Field Values
-
_LEGEND_ELEMENT
protected static final String _LEGEND_ELEMENT
The fieldset XML element name.- See Also:
- Constant Field Values
-
_xpathProcessor
protected XPathProcessor _xpathProcessor
An XPath processor.
-
-
Constructor Detail
-
FormParser
public FormParser(XPathProcessor xpathProcessor)
Default constructor.- Parameters:
xpathProcessor
- the xpath processor
-
-
Method Detail
-
getNodesAsList
public List<Node> getNodesAsList(Node context, String xpathExpression)
Return a list of nodes selected by an xpath expression.- Parameters:
context
- the context node.xpathExpression
- the expression used to select nodes.- Returns:
- a list of nodes selected by an xpath expression.
-
parseForm
public Form parseForm(Node formNode)
Parses the form.- Parameters:
formNode
- the node to parse (must be a node <html:form type="cms">)- Returns:
- the extracted Form.
-
_getAttribute
public String _getAttribute(Node node, String attributeName)
Return the value of an attribute of an input- Parameters:
node
- the nodeattributeName
- the name of the attribute- Returns:
- the value of an attribute of an input
-
_parseFields
protected void _parseFields(Node formNode, Form form)
Parse the fields of a form.- Parameters:
formNode
- the form node.form
- the form object.
-
_processFieldset
protected Fieldset _processFieldset(Node fieldsetNode)
Process a fieldset.- Parameters:
fieldsetNode
- the fielset DOM node.- Returns:
- the fieldset.
-
_processLabel
protected void _processLabel(Node labelNode, Map<String,String> labels)
Process a label.- Parameters:
labelNode
- the label DOM node.labels
- the label map.
-
_processInput
protected Field _processInput(Node inputNode)
Process an input.- Parameters:
inputNode
- the input DOM node.- Returns:
- the input as a Field.
-
_processTextarea
protected Field _processTextarea(Node textareaNode)
Process an textarea.- Parameters:
textareaNode
- the textarea DOM node.- Returns:
- the textarea as a Field.
-
_processSelect
protected Field _processSelect(Node selectNode)
Process a select.- Parameters:
selectNode
- the select DOM node.- Returns:
- the select as a Field.
-
_processCaptcha
protected Field _processCaptcha(Node captchaNode)
Process a captcha.- Parameters:
captchaNode
- the captcha DOM node.- Returns:
- the captcha as a Field.
-
_getInputType
protected Field.FieldType _getInputType(Node inputNode)
Get the input type.- Parameters:
inputNode
- the input node.- Returns:
- the field type.
-
_processAttributes
protected void _processAttributes(Node node, Field field)
Process common field attributes and properties.- Parameters:
node
- the field node.field
- the field object to fill.
-
-