|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.nearform.patrun.Patrun
public class Patrun
Package patrun is a fast pattern matcher on Go map properties For a full guide visit https://github.com/colmharte/patrun-java Need to pick out an object based on a subset of its properties? Say you've got: { x: 1 } -> A { x: 1, y: 1 } -> B { x: 1, y: 2 } -> C Then patrun can give you the following results: { x: 1 } -> A { x: 2 } -> no match { x: 1, y: 1 } -> B { x: 1, y: 2 } -> C { x: 2, y: 2 } -> no match { y: 1 } -> no match It's basically _query-by-example_ for property sets.
| Constructor Summary | |
|---|---|
Patrun()
|
|
Patrun(Customiser custom)
Constructor taking a customiser object to allow the add / find / remove method results to be customised |
|
| Method Summary | |
|---|---|
Patrun |
add(Map<String,String> pat,
Object data)
Register a pattern, and the object that will be returned if an input matches. |
Patrun |
add(String pat,
Object data)
Register a pattern, and the object that will be returned if an input matches. |
Object |
find(Map<String,String> pat)
Return the unique match for this subject, or null if not found. |
Object |
find(Map<String,String> pat,
Boolean exact)
Return the unique match for this subject, or null if not found. |
Object |
find(String pat)
Return the unique match for this subject, or null if not found. |
Object |
find(String pat,
Boolean exact)
Return the unique match for this subject, or null if not found. |
Vector<Pattern> |
list()
Return the list of all registered patterns. |
Vector<Pattern> |
list(Map<String,String> pat)
Return the list of registered patterns that contain this partial pattern. |
Vector<Pattern> |
list(Map<String,String> pat,
Boolean exact)
Return the list of registered patterns that contain this partial pattern. |
Vector<Pattern> |
list(String pat)
Return the list of registered patterns that contain this partial pattern. |
Vector<Pattern> |
list(String pat,
Boolean exact)
Return the list of registered patterns that contain this partial pattern. |
void |
remove(Map<String,String> pat)
Remove this pattern, and it's object, from the matcher. |
void |
remove(String pat)
Remove this pattern, and it's object, from the matcher. |
String |
toString()
Generate a string representation of the decision tree for debugging. |
String |
toString(Printer printer)
Generate a string representation of the decision tree for debugging. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Patrun()
public Patrun(Customiser custom)
custom - an instance of the Customiser interface| Method Detail |
|---|
public Patrun add(Map<String,String> pat,
Object data)
pat - a map of the patterndata - the data to store for this pattern
public Patrun add(String pat,
Object data)
pat - a string defintiion of the pattern
takes the form key:value,key:value
eg "a:1,b:2"data - the data to store for this pattern
public Object find(Map<String,String> pat,
Boolean exact)
pat - a map of the pattern to look forexact - set to true if the match must exactly match the pattern
public Object find(Map<String,String> pat)
pat - a Map representation of the pattern to look for
public Object find(String pat)
pat - a string representation of the pattern to look for
public Object find(String pat,
Boolean exact)
pat - a string representation of the pattern to look forexact - set to true if the match must exactly match the pattern
public void remove(Map<String,String> pat)
pat - a Map representation of the pattern to removepublic void remove(String pat)
pat - a String representation of the pattern to remove
public Vector<Pattern> list(Map<String,String> pat,
Boolean exact)
pat - a Map representation of the pattern to matchexact - set to true if the match must exactly match the pattern
public Vector<Pattern> list()
public Vector<Pattern> list(Map<String,String> pat)
pat - a Map representation of the pattern to match
public Vector<Pattern> list(String pat)
pat - a String representation of the pattern to match
public Vector<Pattern> list(String pat,
Boolean exact)
pat - a String representation of the pattern to matchexact - set to true if the match must exactly match the pattern
public String toString()
toString in class Objectpublic String toString(Printer printer)
printer - an object i9mplementing the Printer interface to allow for customising the string representation of the data objects
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||