JBoss MetaData Repository 2.2.0.SP1

org.jboss.metadata.spi.scope
Class UnmodifiableScopeKey

java.lang.Object
  extended by org.jboss.metadata.spi.scope.ScopeKey
      extended by org.jboss.metadata.spi.scope.UnmodifiableScopeKey
All Implemented Interfaces:
Serializable, Cloneable

public final class UnmodifiableScopeKey
extends ScopeKey
implements Serializable, Cloneable

The UnmodifiableScopeKey represents a path which is made up of the path entries. The UnmodifiableScopeKey (Server=Bob,Deployment=Foo.war,Class=Bar) is the child of (Server=Bob,Deployment=Foo.war), which is the child of (Server=Bob). Think about this statement in terms of a path relationship. The server (Bob) contains a deployment (Foo.war) and the deployment contains a class (Bar). See historical design notes http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3972233#3972233 http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4013747#4013747 Thread Safety: This class is immutable and therefore thread safe. Note: this class requires that class Scope implement Comparable, so that it can correctly sort the array of Scopes. Note that is not needed for UnmodifiableScopeKey(ScopeKey), which is already sorted. Warning: This class (delicately) extends ScopeKey and overides all ScopeKey methods. Since there is no common interface class between the two classes, there are risks to be aware of. If a new method is added to ScopeKey and not to UnmodifiableScopeKey, undesireable behavior will occur when that new method is invoked (ScopeKey's member variables will be null).

Version:
$Revision: 75678 $
Author:
Scott Marlow
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.metadata.spi.scope.ScopeKey
DEFAULT_SCOPE
 
Constructor Summary
UnmodifiableScopeKey(Collection<Scope> scopes)
          Create a new ScopeKey.
UnmodifiableScopeKey(int max, Scope... scopes)
          Create a new ScopeKey.
UnmodifiableScopeKey(Scope... scopes)
          Create a new ScopeKey.
UnmodifiableScopeKey(ScopeKey key)
           
UnmodifiableScopeKey(ScopeLevel level, Object qualifier)
          Create a new ScopeKey.
 
Method Summary
 Scope addScope(Scope scope)
          Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).
 Scope addScope(ScopeLevel level, Object qualifier)
          Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).
 ScopeKey clone()
          clone will always return a frozen copy of the UnmodifiableScopeKey.
 boolean equals(Object object)
           
 void freeze()
          This method is ignored as UnmodifiableScopeKey is always frozen
protected  Scope[] getArray()
           
 ScopeLevel getMaxScopeLevel()
          Get the maximum scope level
 ScopeKey getOptimizedKey()
          The returned ScopeKey is immutable and optimized for use at runtime.
 ScopeKey getParent()
          Get the parent scope key
 Scope getScope(ScopeLevel level)
          Get a scope
 Scope getScopeLevel(ScopeLevel scopeLevel)
          Get scope for the specified scopeLevel
 Collection<Scope> getScopes()
          Get the scopes
protected  Collection<Scope> getScopesCollection()
           
 int hashCode()
           
 boolean isFrozen()
          Get the frozen.
 boolean isParent(ScopeKey key)
          Is this parent of key parameter.
 Scope removeScope(Scope scope)
          Scope cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).
 Scope removeScopeLevel(ScopeLevel scopeLevel)
          ScopeLevel cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).
 String toString()
           
 
Methods inherited from class org.jboss.metadata.spi.scope.ScopeKey
computeHashCode, computeHashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnmodifiableScopeKey

public UnmodifiableScopeKey(ScopeKey key)

UnmodifiableScopeKey

public UnmodifiableScopeKey(ScopeLevel level,
                            Object qualifier)
Create a new ScopeKey.

Parameters:
level - the scope level
qualifier - the scope qualifier

UnmodifiableScopeKey

public UnmodifiableScopeKey(Collection<Scope> scopes)
Create a new ScopeKey.

Parameters:
scopes - is a collection of Scope instances that make up the represented path
Throws:
IllegalArgumentException - if parameter scopes is null

UnmodifiableScopeKey

public UnmodifiableScopeKey(Scope... scopes)
Create a new ScopeKey.

Parameters:
scopes - is zero or more Scope instances that make up the represented path
Throws:
IllegalArgumentException - if parameter scopes is null

UnmodifiableScopeKey

public UnmodifiableScopeKey(int max,
                            Scope... scopes)
Create a new ScopeKey.

Parameters:
max - number of passed Scope instances to use
scopes - is zero or more Scope instances that make up the represented path
Throws:
IllegalArgumentException - if parameter scopes is null
Method Detail

getOptimizedKey

public ScopeKey getOptimizedKey()
Description copied from class: ScopeKey
The returned ScopeKey is immutable and optimized for use at runtime.

Overrides:
getOptimizedKey in class ScopeKey
Returns:
Optimized immutable ScopeKey

getScopes

public Collection<Scope> getScopes()
Get the scopes

Overrides:
getScopes in class ScopeKey
Returns:
the unmodifiable collection of the scopes in expected path order

getScope

public Scope getScope(ScopeLevel level)
Get a scope

Overrides:
getScope in class ScopeKey
Parameters:
level - the scope level
Returns:
the scope
Throws:
IllegalArgumentException - if level is null.

getMaxScopeLevel

public ScopeLevel getMaxScopeLevel()
Get the maximum scope level

Overrides:
getMaxScopeLevel in class ScopeKey
Returns:
the largest scope level

getParent

public ScopeKey getParent()
Get the parent scope key

Overrides:
getParent in class ScopeKey
Returns:
the parent or null if there is no parent (meaning that we are at the top most element in the path)

isParent

public boolean isParent(ScopeKey key)
Is this parent of key parameter.

Overrides:
isParent in class ScopeKey
Parameters:
key - the key parameter
Returns:
true if this is direct parent of key param
Throws:
IllegalArgumentException - if parameter key is null

getScopeLevel

public Scope getScopeLevel(ScopeLevel scopeLevel)
Get scope for the specified scopeLevel

Overrides:
getScopeLevel in class ScopeKey
Parameters:
scopeLevel - the scope level
Returns:
the scope or null if there is no such level
Throws:
IllegalArgumentException - if parameter scopeLevel is null

toString

public String toString()
Overrides:
toString in class ScopeKey

equals

public boolean equals(Object object)
Overrides:
equals in class ScopeKey

hashCode

public int hashCode()
Overrides:
hashCode in class ScopeKey

isFrozen

public boolean isFrozen()
Get the frozen.

Overrides:
isFrozen in class ScopeKey
Returns:
true as UnmodifiableScopeKey is always frozen

freeze

public void freeze()
This method is ignored as UnmodifiableScopeKey is always frozen

Overrides:
freeze in class ScopeKey

addScope

public Scope addScope(Scope scope)
Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey). Calling addScope will always fail.

Overrides:
addScope in class ScopeKey
Parameters:
scope - the scope
Returns:
the previous value or null if there wasn't one
Throws:
IllegalArgumentException - if scope is null.
IllegalStateException - because UnmodifiableScopeKey is always frozen

addScope

public Scope addScope(ScopeLevel level,
                      Object qualifier)
Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey). Calling addScope will always fail.

Overrides:
addScope in class ScopeKey
Parameters:
level - the scope level
qualifier - the scope qualifier
Returns:
the previous value or null if there wasn't one
Throws:
IllegalStateException - because UnmodifiableScopeKey is always frozen

removeScope

public Scope removeScope(Scope scope)
Scope cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey). Calling removeScope will always fail.

Overrides:
removeScope in class ScopeKey
Parameters:
scope - the scope
Returns:
the previous value or null if there wasn't one
Throws:
IllegalStateException - because UnmodifiableScopeKey is always frozen

removeScopeLevel

public Scope removeScopeLevel(ScopeLevel scopeLevel)
ScopeLevel cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey). Calling removeScope will always fail.

Overrides:
removeScopeLevel in class ScopeKey
Parameters:
scopeLevel - the scopeLevel
Returns:
the scope or null if there is no such level
Throws:
IllegalStateException - because UnmodifiableScopeKey is always frozen

clone

public ScopeKey clone()
clone will always return a frozen copy of the UnmodifiableScopeKey. This is different then ScopeKey.clone(), which returns an unfrozen ScopeKey.

Overrides:
clone in class ScopeKey
Returns:
an unfrozen instance (even if the current instance is frozen).

getArray

protected Scope[] getArray()
Overrides:
getArray in class ScopeKey

getScopesCollection

protected Collection<Scope> getScopesCollection()
Overrides:
getScopesCollection in class ScopeKey

JBoss MetaData Repository 2.2.0.SP1

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.