public interface Namespace
A Namespace
is used to determine if a subject is of interest to an
DataProvider
.
A subject name is defined within a DataSource namespace. For example, if the DataSource
namespace is the prefix "/FX" the subject name "/FX/EURUSD" is within that namespace, but
"/FY/EURUSD" is not. Namespace
is the interface that represents a DataSource
namespace.
A Namespace
is used to construct a Publisher
and to ensure that the associated DataProvider
only
receives requests for subjects that it can supply.
DataSource for Java includes the following implementations of NameSpace
:
PrefixNamespace
, which matches the start of a subject
name.RegexNamespace
, for more complex subject matching
requirements.
In particular, the RegexNamespace
provides a flexible way
to match subjects against inclusion and exclusion patterns, so you should not normally need to
use Namespace
directly. However, should the supplied DataSource namespace
implementations not match your requirements you can write your own custom subject matching logic
in an implementation of Namespace
.
The following example provides a simple prefix matching Namespace
implementation
import com.caplin.datasource.namespace.Namespace;
public class PrefixNamespaceExample implements Namespace
{
private String prefix;
public PrefixNamespaceExample(String prefix)
{
this.prefix = prefix;
}
@Override
public boolean match(String subject)
{
return subject != null && subject.startsWith(prefix);
}
}
Modifier and Type | Method and Description |
---|---|
boolean |
match(java.lang.String subject)
Tests a
String to see if it falls within this Namespace . |
Please send bug reports and comments to Caplin support