public class FilterRuleChainXmlParser extends Object
PatternFilterRules from XML and build an
according FilterRuleChain. The rules (include/exclude patterns) are proceeded in the order of their
appearance in the list. <filter-chain id="default-filter" default-result="true"> <!-- 1. rule says that all strings that start (^) with "/doc/" will be accepted --> <include pattern="^/doc/"/> <!-- 2. rule says that all strings that end ($) with ".pdf" ignoring the case of the characters will be rejected --> <exclude pattern="(?i)\.pdf$"/> <!-- 3. rule says that all strings that start with "/data/" will be accepted --> <include pattern="^/data/"/> <!-- 4. rule says that all string that end ($) with ".xml" or ".xsl" ignoring the case (?i) of the characters will be rejected: --> <exclude pattern="(?i)\.(xml|xsl)$"/> </filter-chain>
| Modifier and Type | Field and Description |
|---|---|
private DomUtil |
domUtil |
static String |
XML_ATR_CHAIN_DEFAULT
The name of the XML attribute for the default-result.
|
static String |
XML_ATR_CHAIN_ID
The name of the XML attribute for the ID of a
chain. |
static String |
XML_ATR_CHAIN_PARENT
The name of the XML attribute for the parent of a
chain. |
static String |
XML_ATR_RULE_PATTERN
The name of the XML attribute for the pattern of a (include or exclude) rule.
|
static String |
XML_TAG_CHAIN
The name of the XML element for a
FilterRuleChain. |
static String |
XML_TAG_RULE_EXCLUDE
The name of the XML element for an excluding rule.
|
static String |
XML_TAG_RULE_INCLUDE
The name of the XML element for an including rule.
|
| Constructor and Description |
|---|
FilterRuleChainXmlParser()
The constructor.
|
FilterRuleChainXmlParser(DomUtil domUtil)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
FilterRuleChain<String> |
parseChain(Element xmlElement)
This method parses a
chain given by xmlElement. |
FilterRuleChain<String> |
parseChain(Element xmlElement,
FilterRuleChain<String> parent)
This method parses a
chain given as XML via xmlElement. |
FilterRuleChain<String> |
parseChain(InputStream inStream)
This method parses the chain from the given
inStream. |
Map<String,FilterRuleChain<String>> |
parseChains(Element xmlElement)
This method parses a map of
chains given by xmlElement. |
public static final String XML_TAG_CHAIN
FilterRuleChain.public static final String XML_ATR_CHAIN_ID
chain.public static final String XML_ATR_CHAIN_PARENT
chain.public static final String XML_ATR_CHAIN_DEFAULT
public static final String XML_TAG_RULE_INCLUDE
public static final String XML_TAG_RULE_EXCLUDE
public static final String XML_ATR_RULE_PATTERN
private final DomUtil domUtil
FilterRuleChainXmlParser(DomUtil)public FilterRuleChain<String> parseChain(InputStream inStream) throws IOException, SAXException
inStream. The XML contained in inStream needs
to contain the chain rules as child-nodes of the root-element. The name of
the root-element is ignored (use e.g. "chain").inStream - is the stream containing the XML to parse. It will be closed by this method (on success as well as
in an exceptional state).IOException - if an input/output error occurred.SAXException - if the inStream contains invalid XML.public Map<String,FilterRuleChain<String>> parseChains(Element xmlElement)
chains given by xmlElement.xmlElement - is the XML element containing the filter-chains (see XML_TAG_CHAIN) as children and puts
them into a map with the ID as key. Unknown child elements or attributes are
simply ignored.public FilterRuleChain<String> parseChain(Element xmlElement)
chain given by xmlElement.xmlElement - is the XML element containing the filter-rules (see XML_TAG_RULE_INCLUDE and
XML_TAG_RULE_EXCLUDE) as children.XML_TAG_CHAINpublic FilterRuleChain<String> parseChain(Element xmlElement, FilterRuleChain<String> parent)
chain given as XML via xmlElement.xmlElement - is the XML element containing the filter-rules (see XML_TAG_RULE_INCLUDE and
XML_TAG_RULE_EXCLUDE) as children. Unknown child elements or attributes are simply ignored.parent - is the parent chain that is to be extended by the chain to parse.Copyright © 2001–2015 mmm-Team. All rights reserved.