public interface TopicSelector
TopicSelector
is a value that identifies one or more topics.
Depending on where it is used, a selector may be evaluated by either the
server or the client library. For example, the server evaluates the selector
used to subscribe to a topic. In contrast, the selector used to register a
topic handler is evaluated by the client. Applications do not normally need
to evaluate selectors, but may do so using selects
.
A client may receive a selector providing the context for certain operations.
For example, to allow it to veto subscriptions. Limited ability to query the
selector's type
, associated expression
, and topic path
is provided.
Selectors may be compared using equals
.
Selectors of different types are never equal.
TopicSelectors
.TopicSelectors
Modifier and Type | Interface and Description |
---|---|
static class |
TopicSelector.Type
Topic selector type.
|
Modifier and Type | Field and Description |
---|---|
static char |
FULL_PATH_PATTERN_PREFIX
Prefix used for
FULL_PATH_PATTERN expressions. |
static char |
PATH_PREFIX
Prefix used for
PATH expressions. |
static char |
SELECTOR_SET_PREFIX
Prefix used for
SET expressions. |
static char |
SPLIT_PATH_PATTERN_PREFIX
Prefix used for
SPLIT_PATH_PATTERN expressions. |
Modifier and Type | Method and Description |
---|---|
String |
getExpression()
The expression associated with this selector.
|
String |
getPathPrefix()
Get the topic path prefix from this selector pattern.
|
TopicSelector.Type |
getType()
The type of this selector.
|
boolean |
selects(String topicPath)
Evaluate this selector against a topic path.
|
static final char PATH_PREFIX
PATH
expressions.static final char SPLIT_PATH_PATTERN_PREFIX
SPLIT_PATH_PATTERN
expressions.static final char FULL_PATH_PATTERN_PREFIX
FULL_PATH_PATTERN
expressions.static final char SELECTOR_SET_PREFIX
SET
expressions.TopicSelector.Type getType()
String getExpression()
See TopicSelectors.parse(String)
for the expression format for
PATH
, SPLIT_PATH_PATTERN
, FULL_PATH_PATTERN
, and
SELECTOR_SET
selectors. Expressions for these types of selectors
can be re-parsed, and selector.equals(
Diffusion.topicSelectors().parse(selector.getExpression())
) == true
.
String getPathPrefix()
Returns the largest fixed topic path that begins the selector expression.
For PATH
selectors, this is the entire path. For
SPLIT_PATH_PATTERN
or FULL_PATH_PATTERN
selectors, this
is a topic path up to, but not including, the first part of the path that
contains a regular expression.
For SELECTOR_SET
s, this method will return the largest prefix
that is common to all included selectors.
If there is no common prefix, an empty string will be returned.
boolean selects(String topicPath)
topicPath
- The topic path.true
If this selector selects topicPath
.Copyright © 2024 DiffusionData Ltd. All Rights Reserved.