|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.digester.RulesBase | +--org.apache.commons.digester.ExtendedBaseRules
Extension of RulesBase
for complex schema.
This is an extension of the basic pattern matching scheme intended to improve support for mapping complex xml-schema. It is intended to be a minimal extension of the standard rules big enough to support complex schema but without the full generality offered by more exotic matching pattern rules.
These rules are complex and slower but offer more functionality.
The RulesBase
matching set allows interaction between patterns.
This allows sophisticated matching schema to be created
but it also means that it can be hard to create and debug mappings
for complex schema.
This extension introduces universal versions of these patterns
that always act independently.
Another three kinds of matching pattern are also introduced. The parent matchs allow common method to be easily called for children. The wildcard match allows rules to be specified for all elements.
"a/b/c/?"
matches any child whose parent matches
"a/b/c"
. Exact parent rules take precedence over
standard wildcard tail endings."*/a/b/c/?"
matches any child whose parent matches
"*/a/b/c". The longest matching still applies to parent
matches but the length excludes the '?', which effectively means
that standard wildcard matches with the same level of depth are
chosen in preference."a/b/*"
matches any element whose parentage path starts with
'a' then 'b'. Exact parent and parent match rules take precedence. The longest
ancester match will take precedence."*/a/b/*"
matches any elements whose parentage path contains
an element 'a' followed by an element 'b'. The longest matching still applies
but the length excludes the '*' at the end."!*/a/b"
matches whenever an 'b' element
is inside an 'a'."!a/b/?"
matches any child of a parent
matching "a/b"
."!*/a/b/?"
matches any child of a parent
matching "!*/a/b"
"!a/b/*"
matches any element whose parentage path starts with
"a" then "b"."!*/a/b/*"
matches any elements whose parentage path contains
'a/b'"*"
matches every pattern that isn't matched
by any other basic rule."!*"
matches every pattern.The most important thing to remember when using the extended rules is that universal and non-universal patterns are completely independent. Universal patterns are never effected by the addition of new patterns or the removal of existing ones. Non-universal patterns are never effected by the addition of new universal patterns or the removal of existing universal patterns. As in the basic matching rules, non-universal (basic) patterns can be effected by the addition of new non-universal patterns or the removal of existing non-universal patterns.
This means that you can use universal patterns to build up the simple parts of your structure - for example defining universal creation and property setting rules. More sophisticated and complex mapping will require non-universal patterns and this might mean that some of the universal rules will need to be replaced by a series of special cases using non-universal rules. But by using universal rules as your backbone, these additions should not break your existing rules.
Field Summary | |
private int |
counter
Counts the entry number for the rules. |
private java.util.Map |
order
The decision algorithm used (unfortunately) doesn't preserve the entry order. |
Fields inherited from class org.apache.commons.digester.RulesBase |
cache, digester, namespaceURI, rules |
Constructor Summary | |
ExtendedBaseRules()
|
Method Summary | |
void |
add(java.lang.String pattern,
Rule rule)
Register a new Rule instance matching the specified pattern. |
private boolean |
basicMatch(java.lang.String key,
java.lang.String pattern)
Standard match. |
private java.util.List |
findExactAncesterMatch(java.lang.String parentPattern)
Finds an exact ancester match for given pattern |
java.util.List |
match(java.lang.String namespace,
java.lang.String pattern)
Return a List of all registered Rule instances that match the specified nesting pattern, or a zero-length List if there are no matches. |
private boolean |
parentMatch(java.lang.String key,
java.lang.String pattern,
java.lang.String parentPattern)
Matching parent. |
Methods inherited from class org.apache.commons.digester.RulesBase |
clear, getDigester, getNamespaceURI, lookup, match, rules, setDigester, setNamespaceURI |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int counter
private java.util.Map order
Constructor Detail |
public ExtendedBaseRules()
Method Detail |
public void add(java.lang.String pattern, Rule rule)
add
in interface Rules
add
in class RulesBase
pattern
- Nesting pattern to be matched for this Rulerule
- Rule instance to be registeredpublic java.util.List match(java.lang.String namespace, java.lang.String pattern)
add()
method.
match
in interface Rules
match
in class RulesBase
pattern
- Nesting pattern to be matchednamespace
- Namespace URI for which to select matching rules,
or null
to match regardless of namespace URIprivate boolean parentMatch(java.lang.String key, java.lang.String pattern, java.lang.String parentPattern)
private boolean basicMatch(java.lang.String key, java.lang.String pattern)
private java.util.List findExactAncesterMatch(java.lang.String parentPattern)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |