Package com.cobber.fta
Class LogicalTypeRegExp
- Object
-
- LogicalType
-
- LogicalTypeRegExp
-
- All Implemented Interfaces:
LTRandom
,Comparable<LogicalType>
public class LogicalTypeRegExp extends LogicalType
This class supports all plugins that are based on a RegExp.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.security.SecureRandom
random
-
Fields inherited from class com.cobber.fta.LogicalType
defn, locale, pluginLocaleEntry, priority, threshold
-
-
Constructor Summary
Constructors Constructor Description LogicalTypeRegExp(PluginDefinition plugin)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PluginAnalysis
analyzeSet(AnalyzerContext context, long matchCount, long realSamples, String currentRegExp, Facts facts, Map<String,Long> cardinality, Map<String,Long> outliers, TokenStreams tokenStreams, AnalysisConfig analysisConfig)
Given the data to date as embodied by the arguments return an analysis.FTAType
getBaseType()
The underlying type we are qualifying.int
getMinSamples()
String
getQualifier()
The user-friendly name of the Qualifier.String
getRegExp()
The Regular Expression that most closely matches (SeeLogicalType.isRegExpComplete()
) this Logical Type.boolean
initialize(Locale locale)
Called to perform any initialization.boolean
isClosed()
Does the set of members enumerated reflect the entire set.boolean
isMatch(String regExp)
boolean
isMinMaxPresent()
boolean
isRegExpComplete()
Is the returned Regular Expression a true and complete representation of the Logical Type.boolean
isValid(String input)
Is the supplied String an instance of this logical type?String
nextRandom()
nextRandom will generate a random (secure) valid example of this Semantic Type.void
seed(byte[] seed)
Seed the secure random number generator used to create examples.-
Methods inherited from class com.cobber.fta.LogicalType
acceptsBaseType, compareTo, getConfidence, getDescription, getHeaderConfidence, getPluginDefinition, getPriority, getSignature, getThreshold, isLocaleSensitive, setThreshold
-
-
-
-
Constructor Detail
-
LogicalTypeRegExp
public LogicalTypeRegExp(PluginDefinition plugin) throws FTAPluginException
- Throws:
FTAPluginException
-
-
Method Detail
-
initialize
public boolean initialize(Locale locale) throws FTAPluginException
Description copied from class:LogicalType
Called to perform any initialization.- Overrides:
initialize
in classLogicalType
- Parameters:
locale
- The locale used for this analysis- Returns:
- True if initialization was successful.
- Throws:
FTAPluginException
- Thrown when the plugin is incorrectly configured.
-
getQualifier
public String getQualifier()
Description copied from class:LogicalType
The user-friendly name of the Qualifier. For example, EMAIL for an email address- Specified by:
getQualifier
in classLogicalType
- Returns:
- The user-friendly name of the type-qualifier.
-
isRegExpComplete
public boolean isRegExpComplete()
Description copied from class:LogicalType
Is the returned Regular Expression a true and complete representation of the Logical Type. For example, \\d{5} is not for US ZIP codes (e.g. 00000 is not a valid Zip), whereas (?i)(male|female) could be valid for a Gender.- Overrides:
isRegExpComplete
in classLogicalType
- Returns:
- The Java Regular Expression that most closely matches this Logical Type.
-
getRegExp
public String getRegExp()
Description copied from class:LogicalType
The Regular Expression that most closely matches (SeeLogicalType.isRegExpComplete()
) this Logical Type. Note: All valid matches will match this RE, but the inverse is not necessarily true.- Specified by:
getRegExp
in classLogicalType
- Returns:
- The Java Regular Expression that most closely matches this Logical Type.
-
getBaseType
public FTAType getBaseType()
Description copied from class:LogicalType
The underlying type we are qualifying.- Overrides:
getBaseType
in classLogicalType
- Returns:
- The underlying type - e.g. STRING, LONG, etc.
-
isValid
public boolean isValid(String input)
Description copied from class:LogicalType
Is the supplied String an instance of this logical type?- Specified by:
isValid
in classLogicalType
- Parameters:
input
- String to check (trimmed for Numeric base Types, un-trimmed for String base Type)- Returns:
- true iff the supplied String is an instance of this Logical type.
-
analyzeSet
public PluginAnalysis analyzeSet(AnalyzerContext context, long matchCount, long realSamples, String currentRegExp, Facts facts, Map<String,Long> cardinality, Map<String,Long> outliers, TokenStreams tokenStreams, AnalysisConfig analysisConfig)
Description copied from class:LogicalType
Given the data to date as embodied by the arguments return an analysis. If we think this is an instance of this logical type then valid will be true , if invalid then valid will be false and a new Pattern will be returned.- Specified by:
analyzeSet
in classLogicalType
- Parameters:
context
- The context used to interpret the Data Stream (for example, stream name, date resolution mode, etc)matchCount
- Number of samples that match so far (as determined by isValid()realSamples
- Number of real (i.e. non-blank and non-null) samples that we have processed so far.currentRegExp
- The current Regular Expression that we matched againstfacts
- Facts (min, max, sum) for the analysis to date (optional - i.e. maybe null)cardinality
- Cardinality set, up to the maximum maintainedoutliers
- Outlier set, up to the maximum maintainedtokenStreams
- Shapes observedanalysisConfig
- The Configuration of the current analysis- Returns:
- Null if we think this is an instance of this logical type (backout pattern otherwise)
-
isMatch
public boolean isMatch(String regExp)
-
getMinSamples
public int getMinSamples()
-
isMinMaxPresent
public boolean isMinMaxPresent()
-
isClosed
public boolean isClosed()
Description copied from class:LogicalType
Does the set of members enumerated reflect the entire set. For example any of the ISO sets are reference sets and hence complete, compared to FirstName and LastName where the set provided is of the common names. If isClosed() is true then isValid() false does not imply that the input is not valid just that it is not in the set of 'known' members.- Specified by:
isClosed
in classLogicalType
- Returns:
- A boolean indicating if the set is closed.
-
nextRandom
public String nextRandom()
Description copied from interface:LTRandom
nextRandom will generate a random (secure) valid example of this Semantic Type.- Returns:
- a new valid example of the Semantic Type.
-
seed
public void seed(byte[] seed)
Description copied from interface:LTRandom
Seed the secure random number generator used to create examples.- Parameters:
seed
- The Byte array used to seed the random number geerator.
-
-