Package com.cobber.fta.token
Class TokenStreams
- java.lang.Object
-
- com.cobber.fta.token.TokenStreams
-
public class TokenStreams extends java.lang.Object
This Singleton class captures the sum of all input observed as a set of instances of the TokenStream Class.
-
-
Constructor Summary
Constructors Constructor Description TokenStreams(int maxStreams)
Construct a TokenStreams object with a maximum number of TokenStream instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenStream
getBest()
Get the 'best' TokenStream - where 'best' is the one with the highest count.java.lang.String
getRegExp(boolean fitted)
Get the 'best' Regular Expression we can based on the set of TokenStreams.long
getSamples()
java.util.Map<java.lang.String,java.lang.Long>
getShapes()
Get the Map of shapes.java.util.Map<java.lang.String,TokenStream>
getStreams()
Get the Map of streams.boolean
isAnyShape()
boolean
matches(java.lang.String regExp)
Check if the TokenStreams (i.e.int
size()
Get the size of the Map.void
track(java.lang.String trimmed, long count)
Track the supplied input.
-
-
-
Method Detail
-
track
public void track(java.lang.String trimmed, long count)
Track the supplied input.- Parameters:
trimmed
- The trimmed input.count
- The number of occurrences of this input.
-
isAnyShape
public boolean isAnyShape()
-
getSamples
public long getSamples()
- Returns:
- The number of inputs this TokenStream has captured.
-
getRegExp
public java.lang.String getRegExp(boolean fitted)
Get the 'best' Regular Expression we can based on the set of TokenStreams.- Parameters:
fitted
- If true the Regular Expression should be a 'more closely fitted' Regular Expression.- Returns:
- The 'best' Regular Expression we can based on the set of TokenStreams, or null if nothing clever can be discerned.
-
matches
public boolean matches(java.lang.String regExp)
Check if the TokenStreams (i.e. if all member TokenStream's) match the supplied Regular Expression.- Parameters:
regExp
- The Regular Expression to match.- Returns:
- True if the TokenStreams match the supplied Regular Expression.
-
getBest
public TokenStream getBest()
Get the 'best' TokenStream - where 'best' is the one with the highest count.- Returns:
- The 'best' TokenStream entry.
-
getShapes
public java.util.Map<java.lang.String,java.lang.Long> getShapes()
Get the Map of shapes.- Returns:
- The ordered (by shape) Map of all shapes.
-
getStreams
public java.util.Map<java.lang.String,TokenStream> getStreams()
Get the Map of streams.- Returns:
- The Map of all streams.
-
size
public int size()
Get the size of the Map.- Returns:
- The Map size.
-
-