Package pygar.documents
Class SimpleXmlMatcher
java.lang.Object
pygar.documents.SimpleXmlMatcher
- All Implemented Interfaces:
Matcher<java.io.InputStream,java.io.OutputStream>
@NotThreadSafe public class SimpleXmlMatcher extends java.lang.Object implements Matcher<java.io.InputStream,java.io.OutputStream>
The SimpleXmlMatcher looks for matching records in XML documents according to a
specification contained in a FieldMatchList object. The name of this class
roughly describes its properties and limitations. It must work with XML documents
provided on an InputStream. It writes a basis for agreement (the results of matching)
in an OutputStream. The XML documents have a carefully limited format described as
follows:
- The outermost tagged block in the input XML document uses the tag "position" - meaning the negotiation position of one of the members of the match group.
- The second level of nesting within the <position> block has a tag that identifies the type of record in the position. The matching operation will match a record of one type with a record of another type.
- The third level contains blocks that specify attributes. The tag name at level 3 is the name of the field. The body of the block is its value. Attributes of this type can be matched by the matcher.
- The third level might also contain a block that has substructure at nesting level 4 or higher. Such blocks cannot be matched by the matcher. However, when a successful match occurs, the FieldMatchList can specify that information in blocks with this property can be copied without change into the resulting basis. However, this feature is not currently supported by this class!
Internally, the class operates fully in-memory. It creates and then sorts lists of field values for rapid evaluation of the match criteria.
This module is under active development. It is incomplete and the parts that work need to be re-engineered to sort as efficiently as possible. The matching part remains to be written. Also, thread safety has not been considered.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SimpleXmlMatcher.ComparableRange
The ComparableRange class describes ranges of real value and introduces the idea of comparison based on overlap.class
SimpleXmlMatcher.DocLevelInclude
class
SimpleXmlMatcher.FieldHolder
class
SimpleXmlMatcher.MemberData
-
Constructor Summary
Constructors Constructor Description SimpleXmlMatcher(EncryptedFieldTable table, SimpleFieldMatchList ml)
-
Method Summary
Modifier and Type Method Description void
close()
Complete any cleanup operations after the matching operation.void
compare()
Compare negotiation statements and find matches.java.io.OutputStream
getBasis(int memberNumber)
This class does not implement the method for getBasis.void
load(int memberNumber, java.lang.String memberName, java.io.InputStream position)
Load the negotiation position for one of the members into the match object.void
open(int nMembers, boolean inclusive)
Prepare the matcher object to conduct a match among a match group of nMembers participants.java.lang.Comparable<?>
returnComparable(EncryptedFieldTable.EFTYPE ftype, java.lang.String value)
boolean
test1()
boolean
test2()
boolean
test3()
void
writeBasis(int memberNumber, java.io.OutputStream out)
Return an XML document containing the basis of agreement determined for the memberNumber placing the document on the OutputStream.
-
Constructor Details
-
Method Details
-
open
public void open(int nMembers, boolean inclusive)Description copied from interface:Matcher
Prepare the matcher object to conduct a match among a match group of nMembers participants. Usually there are two members. Obviously, they both receive any basis for agreement. For three or more members, we need a policy about whether a member receives only matches to which they contributed data or whether every member of the group receives the same basis of agreement regardless of contribution. It is difficult to supply the correct decision for this policy, which is why most match groups will probably have two members for most applications. -
returnComparable
public java.lang.Comparable<?> returnComparable(EncryptedFieldTable.EFTYPE ftype, java.lang.String value) -
load
public void load(int memberNumber, java.lang.String memberName, java.io.InputStream position) throws ConfigurationError, DocumentErrorDescription copied from interface:Matcher
Load the negotiation position for one of the members into the match object. Throw exception if the object was not initialized by an open call.- Specified by:
load
in interfaceMatcher<java.io.InputStream,java.io.OutputStream>
- Parameters:
memberNumber
- sequence number in the group, zero based, e.g. for two members: 0 and 1memberName
- optional name for the memberposition
- the member's negotiation statement for matching- Throws:
ConfigurationError
DocumentError
-
compare
public void compare()Description copied from interface:Matcher
Compare negotiation statements and find matches. The position for each member must be loaded before this method is called or an exception is thrown. -
getBasis
This class does not implement the method for getBasis. It will throw and exception if called. Users of this class are expected to use the method: writeBasis().- Specified by:
getBasis
in interfaceMatcher<java.io.InputStream,java.io.OutputStream>
- Returns:
- the basis for agreement with matching statements.
- Throws:
ConfigurationError
-
writeBasis
public void writeBasis(int memberNumber, java.io.OutputStream out)Return an XML document containing the basis of agreement determined for the memberNumber placing the document on the OutputStream.- Parameters:
memberNumber
- number of the member who receives the basisout
- stream where the basis document is written
-
close
public void close()Description copied from interface:Matcher
Complete any cleanup operations after the matching operation. -
test1
public boolean test1() -
test2
public boolean test2() -
test3
public boolean test3()
-