Package com.nimbusds.common.monitor
Class WildCardMetricFilter
- java.lang.Object
-
- com.nimbusds.common.monitor.WildCardMetricFilter
-
- All Implemented Interfaces:
com.codahale.metrics.MetricFilter
public class WildCardMetricFilter extends Object implements com.codahale.metrics.MetricFilter
Wild card metric filter.
-
-
Constructor Summary
Constructors Constructor Description WildCardMetricFilter(List<String> whiteList)
Creates a new wild card metrics filter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Collection<String>
getMatches(String t, String p)
Simple computation of the longest common extension (LCE) of two given strings, beginning at two given indices.List<String>
getWhiteList()
Returns the white list.static int
longestCommonExtension(String t1, int i1, String t2, int i2)
This method takes four parameters: t1 and t2 (the two strings) and two indices i1 and i2 (the index to start at in t1 and t2).boolean
matches(String name, com.codahale.metrics.Metric metric)
boolean
matchesAny()
Returnstrue
if the filter will match no metric.boolean
matchesNone()
Returnstrue
if the filter will match any metric.
-
-
-
Constructor Detail
-
WildCardMetricFilter
public WildCardMetricFilter(List<String> whiteList)
Creates a new wild card metrics filter.- Parameters:
whiteList
- The white list entries,null
if none.
-
-
Method Detail
-
getWhiteList
public List<String> getWhiteList()
Returns the white list.- Returns:
- The white list,
null
if none.
-
matchesNone
public boolean matchesNone()
Returnstrue
if the filter will match any metric.- Returns:
true
if any metric will be matched, elsefalse
.
-
matchesAny
public boolean matchesAny()
Returnstrue
if the filter will match no metric.- Returns:
true
if no metric will be matched, elsefalse
.
-
matches
public boolean matches(String name, com.codahale.metrics.Metric metric)
- Specified by:
matches
in interfacecom.codahale.metrics.MetricFilter
-
longestCommonExtension
public static int longestCommonExtension(String t1, int i1, String t2, int i2)
This method takes four parameters: t1 and t2 (the two strings) and two indices i1 and i2 (the index to start at in t1 and t2). It returns the length of the longest common extension starting at i1 in t1 and at i2 in t2. The method simply iterates over the given strings, starting at the given indices. It compares the characters, counts equal characters and returns that number as soon as the characters differ.
-
getMatches
public static Collection<String> getMatches(String t, String p)
Simple computation of the longest common extension (LCE) of two given strings, beginning at two given indices. The LCE computation is part of different algorithms in inexact string matching (Gusfield 1999:196). This simple implementation has a runtime complexity of O(n). Computation in O(1) is possible through constant-time retrieval of Lowest Common Ancestors (LCA) in suffix trees (after linear-time preprocessing). See Gusfield 1999:181 for further reference on constant time LCA retrieval and Gusfield 1999:196 for constant time LCE computation using the LCA.References: Gusfield, Dan (1999), Algorithms on Strings, Sequences and Trees, Cambridge: University Press.
An implementation of string matching with wildcards, as described in Gusfield 1999:199. When used with a longest common extension computation with suffix trees, it allows for searching a pattern with k wildcards in a text T of length m in O(km) time (Gusfield 1999:199). This implementation uses a simple computation of the longest common extension.
-
-