public final class PatternFilter extends QDFilter
SubscriptionFilter
that understands a simple GLOB-like grammar
to specify matching symbols.
This filter always accepts wildcard
symbol regardless
of an actual pattern for all records that are accepted by it.
Modifier and Type | Class and Description |
---|---|
static class |
PatternFilter.RecordPatternFilter |
QDFilter.Kind, QDFilter.SyntaxPrecedence, QDFilter.Updated, QDFilter.UpdateListener
Modifier and Type | Field and Description |
---|---|
static int |
BITS_CHAR_MASK |
static int |
BITS_CHAR_SHIFT |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(QDContract contract,
DataRecord record,
int cipher,
String symbol)
Returns true if this filter accepts a given record and symbol on the specified contract.
|
boolean |
equals(Object o) |
String |
getDefaultName()
Composes default string representation of the filter.
|
QDFilter.Kind |
getKind()
Returns a kind of this filter that constrains and defines its overall behaviour.
|
String |
getPattern()
Returns filter patter that can be always parsed back to this filter.
|
SymbolSet |
getSymbolSet()
Returns a set of symbols that corresponds to this filter.
|
int |
hashCode() |
boolean |
isFast()
Returns
true if this filter is fast, that is it can be quickly checked without blocking. |
QDFilter |
negate()
Returns negation of this filter.
|
static String |
quote(String string)
Quotes all reserved characters in the given string, so that it can be used as a pattern filter.
|
QDFilter |
toStableFilter()
Returns a stable filter that is the same or more encompassing as this filter.
|
static SubscriptionFilter |
valueOf(String pattern,
DataScheme scheme)
Deprecated.
Use
valueOf(String, String, DataScheme) to create project-specific named filters
or CompositeFilters.valueOf(String, DataScheme) to parse an arbitrary string into a filter. |
static QDFilter |
valueOf(String pattern,
String name,
DataScheme scheme)
Returns filter with a specified pattern and a project-specific name.
|
accept, acceptRecord, addUpdateListener, checkShortName, dynamicTrackingStart, dynamicTrackingStop, fireFilterUpdated, fromFilter, getScheme, getSyntaxPrecedence, getUpdated, getUpdatedFilter, hasShortName, isDynamic, isStable, produceUpdatedFilter, removeUpdateListener, setName, setNameOrDefault, setShortName, toString, unwrap
public static final int BITS_CHAR_SHIFT
public static final int BITS_CHAR_MASK
public static String quote(String string) throws FilterSyntaxException
quote("Trade&N")
will be equal to "Trade[&]N"
. Special
characters that are quoted with braces are:
'!', ':', ';', '|', '&', '*', '?', '+',
'(', ')', '{', '}', '<', '>',
'~', ',', '"', ''', and '`'.
These characters are quoted by adding backspace before them: ' ', '[', ']', '\'.
If the input string starts with a lower-case characters (from 'a' to 'z') it is also quoted with braces,
because patterns starting with a lower case letter are reserved. For example,
quote("feed")
is equal to "[f]eed"
.
NullPointerException
- if the string is null
.FilterSyntaxException
- if the string contains characters that cannot be represented in
pattern filter in any form.
All characters with codes larger than 32 and lower than 128 are supported with the exception of '[' and ']'.public static SubscriptionFilter valueOf(String pattern, DataScheme scheme) throws FilterSyntaxException
valueOf(String, String, DataScheme)
to create project-specific named filters
or CompositeFilters.valueOf(String, DataScheme)
to parse an arbitrary string into a filter.CompositeFilters.valueOf(String, DataScheme)
method if
you need to parse an arbitrary filter string.
Use valueOf(String, String, DataScheme)
to create project-specific
named filter.
This is a legacy method, because it has a legacy return type.
NullPointerException
- if pattern is null.FilterSyntaxException
- if pattern is invalid.public static QDFilter valueOf(String pattern, String name, DataScheme scheme) throws FilterSyntaxException
QDFilter.ANYTHING
if pattern is empty or matches anything.
Complex filter transformations (logical operations) try to retain the specified name.NullPointerException
- if pattern is null.FilterSyntaxException
- if pattern is invalid.IllegalArgumentException
- if name is invalid.public QDFilter.Kind getKind()
QDFilter
public SymbolSet getSymbolSet()
QDFilter
null
when this filter does not have a symbol set.getSymbolSet
in class QDFilter
public QDFilter toStableFilter()
QDFilter
QDFilter.ANYTHING
, which means that this filter is not stable
(it is dynamic) and the only stable extension of it constitutes everything.
Stable filters must return this
as a result of this method. The result of this method
satisfies the following constrains:
result.toStableFilter() == result
this.accept(...)
implies result.accept(...)
.
result.toString()
must parse back to the same filter via data scheme's
SubscriptionFilterFactory
.
This method shall never return null.
toStableFilter
in interface StableSubscriptionFilter
toStableFilter
in class QDFilter
public boolean isFast()
QDFilter
true
if this filter is fast, that is it can be quickly checked without blocking.
There filters are checked under the collector's global lock when processing subscription messages.
On the contrast, slow filters are checked outside of global lock when processing subscription messages.
This implementation returns false
and is designed for override.
public String getPattern()
public QDFilter negate()
QDFilter
new NotFilter
(this)
.public String getDefaultName()
QDFilter
QDFilterFactory
.
To parse this string representation back into the instance of this class use
CompositeFilters.valueOf(String, DataScheme)
.
This method must be overriden in custom QDFilter
implementations.
This implementation returns null
.
getDefaultName
in class QDFilter
public boolean accept(QDContract contract, DataRecord record, int cipher, String symbol)
QDFilter
Copyright © 2002-2020 Devexperts LLC. All Rights Reserved.