Package com.evolveum.midpoint.prism
Class PrismNamespaceContext
- java.lang.Object
-
- com.evolveum.midpoint.prism.PrismNamespaceContext
-
- All Implemented Interfaces:
Serializable
public abstract class PrismNamespaceContext extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PrismNamespaceContext.Builder
static class
PrismNamespaceContext.PrefixPreference
-
Field Summary
Fields Modifier and Type Field Description static PrismNamespaceContext.PrefixPreference
DEFAULT_PREFERENCE
static String
DEFAULT_PREFIX
static PrismNamespaceContext
EMPTY
static PrismNamespaceContext
PRISM_API
-
Constructor Summary
Constructors Constructor Description PrismNamespaceContext()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Map<String,String>
allPrefixes()
static PrismNamespaceContext.Builder
builder()
abstract PrismNamespaceContext.Builder
childBuilder()
abstract PrismNamespaceContext
childContext(Map<String,String> local)
Creates child namespace context with supplied local mappingPrismNamespaceContext
childDefaultNamespace(String namespace)
Optional<String>
defaultNamespace()
static PrismNamespaceContext
from(Map<String,String> prefixToNs)
abstract PrismNamespaceContext
inherited()
Returns child namespace context with no local mappings.abstract boolean
isDefaultNamespaceOnly()
abstract boolean
isEmpty()
abstract boolean
isInherited()
Returns true if context is only inherited and not explicitly defined.abstract boolean
isLocalEmpty()
Return true, if context is empty on local level (no mappings defined, or context is inherited) Note: This is useful for context serialization - if context is empty, it should not be serializedabstract Map<String,String>
localPrefixes()
Returns mapping of locally defined prefixes to namespaces Returns mapping of prefixes to namespaces defined in this namespace context.abstract Optional<String>
namespaceFor(String prefix)
Returns namespace for specified prefix.static PrismNamespaceContext
of(String ns)
abstract PrismNamespaceContext
optimizedChildContext(Map<String,String> local)
Creates optimized child namespace context with supplied local mappingabstract Optional<PrismNamespaceContext>
parent()
Returns parent namespace contextOptional<String>
prefixFor(String namespace)
Look up suitable prefix for namespace using default prefix search preference-abstract Optional<String>
prefixFor(String namespace, PrismNamespaceContext.PrefixPreference preference)
Look up suitable prefix for namespace using provided preference.abstract PrismNamespaceContext
rebasedOn(PrismNamespaceContext current)
String
toString()
@NotNull PrismNamespaceContext
withoutDefault()
-
-
-
Field Detail
-
EMPTY
public static final PrismNamespaceContext EMPTY
-
DEFAULT_PREFIX
public static final String DEFAULT_PREFIX
- See Also:
- Constant Field Values
-
DEFAULT_PREFERENCE
public static final PrismNamespaceContext.PrefixPreference DEFAULT_PREFERENCE
-
PRISM_API
public static final PrismNamespaceContext PRISM_API
-
-
Method Detail
-
from
public static PrismNamespaceContext from(Map<String,String> prefixToNs)
-
builder
public static PrismNamespaceContext.Builder builder()
-
parent
public abstract Optional<PrismNamespaceContext> parent()
Returns parent namespace context- Returns:
- parent namespace context
-
localPrefixes
public abstract Map<String,String> localPrefixes()
Returns mapping of locally defined prefixes to namespaces Returns mapping of prefixes to namespaces defined in this namespace context. Note that mappings of parent namespaces context also apply, unless the prefix is overriden at current level.- Returns:
- mapping of locally defined prefixes to namespaces
-
isInherited
public abstract boolean isInherited()
Returns true if context is only inherited and not explicitly defined.- Returns:
- True if context is inherited, false if context is explicitly defined.
-
isLocalEmpty
public abstract boolean isLocalEmpty()
Return true, if context is empty on local level (no mappings defined, or context is inherited) Note: This is useful for context serialization - if context is empty, it should not be serialized- Returns:
- True if context does not define local mappings.
-
isEmpty
public abstract boolean isEmpty()
-
isDefaultNamespaceOnly
public abstract boolean isDefaultNamespaceOnly()
-
namespaceFor
public abstract Optional<String> namespaceFor(String prefix)
Returns namespace for specified prefix. If prefix is not defined at current context, parent contexts are lookup up for prefix.- Returns:
- Empty, if no namespace was found, otherwise namespace assigned to supplied prefix.
-
prefixFor
public final Optional<String> prefixFor(String namespace)
Look up suitable prefix for namespace using default prefix search preference-- Parameters:
namespace
- Namespace for which prefix should be returned.- Returns:
- Prefix which is mapped to namespace.
-
prefixFor
public abstract Optional<String> prefixFor(String namespace, PrismNamespaceContext.PrefixPreference preference)
Look up suitable prefix for namespace using provided preference.- Parameters:
namespace
- Namespace for which prefix should be returned.preference
- Preference (top-most or closest prefix) which should be returned.- Returns:
- Prefix which is mapped to namespace.
-
childContext
public abstract PrismNamespaceContext childContext(Map<String,String> local)
Creates child namespace context with supplied local mapping- Parameters:
local
- Local definition of prefixes- Returns:
- Child context with local definitions
-
optimizedChildContext
public abstract PrismNamespaceContext optimizedChildContext(Map<String,String> local)
Creates optimized child namespace context with supplied local mapping- Parameters:
local
- Local definition of prefixes- Returns:
- Child context with local definitions
-
inherited
public abstract PrismNamespaceContext inherited()
Returns child namespace context with no local mappings. Implementation Note: Implementation ensures that instances of inherited context are reused (eg.context.inherited() == context.inherited()
andcontext.inherited() == context.inherited().inherited()
)- Returns:
- child namespace context with no local mappings.
-
of
public static PrismNamespaceContext of(String ns)
-
childDefaultNamespace
public PrismNamespaceContext childDefaultNamespace(String namespace)
-
rebasedOn
public abstract PrismNamespaceContext rebasedOn(PrismNamespaceContext current)
-
withoutDefault
@NotNull public @NotNull PrismNamespaceContext withoutDefault()
-
childBuilder
public abstract PrismNamespaceContext.Builder childBuilder()
-
-