Scope

public class Scope

A scope defines a channel of the hierarchical unified bus covered by RSB. It is defined by a surface syntax like “/a/deep/scope”.

Author

jwienke

Fields

COMPONENT_SEPARATOR

public static final String COMPONENT_SEPARATOR

The separator character used between different components of a scope, aka “/”.

Constructors

Scope

public Scope(String stringRep)

Parses a scope from a string representation.

Parameters

stringRep – string representation of the scope

Throws

IllegalArgumentException – if the given string does not have the right syntax

Methods

concat

public Scope concat(Scope childScope)

Creates a new scope that is a sub-scope of this one with the subordinated scope described by the given argument. E.g. “/this/is/”.concat(“/a/test/”) results in “/this/is/a/test”.

Parameters

childScope – child to concatenate to the current scope for forming a sub-scope

Returns

new scope instance representing the created sub-scope

equals

public boolean equals(Object obj)

getComponents

public List<String> getComponents()

Returns all components of the scope as an ordered list. Components are the names between the separator character ‘/’. The first entry in the list is the highest level of hierarchy. The scope ‘/’ returns an empty list.

Returns

components of the represented scope as ordered list with highest level as first entry

hashCode

public int hashCode()

isSubScopeOf

public boolean isSubScopeOf(Scope other)

Tests whether this scope is a sub-scope of the given other scope, which means that the other scope is a prefix of this scope. E.g. “/a/b/” is a sub-scope of “/a/”.

Parameters

other – other scope to test

Returns

true if this is a sub-scope of the other scope, equality gives false, too

isSuperScopeOf

public boolean isSuperScopeOf(Scope other)

Inverse operation of isSubScopeOf(Scope).

Parameters

other – other scope to test

Returns

true if this scope is a strict super scope of the other scope. equality also gives false.

superScopes

public List<Scope> superScopes(boolean includeSelf)

Generates all super scopes of this scope including the root scope “/”. The returned list of scopes is ordered by hierarchy with “/” being the first entry.

Parameters

includeSelf – if set to true, this scope is also included as last element of the returned list

Returns

list of all super scopes ordered by hierarchy, “/” being first

toString

public String toString()