com.threerings.crowd.data
Class TokenRing

java.lang.Object
  extended by com.threerings.io.SimpleStreamableObject
      extended by com.threerings.crowd.data.TokenRing
All Implemented Interfaces:
Streamable

public class TokenRing
extends SimpleStreamableObject

Defines access control tokens that convey certain privileges to users.

See Also:
BodyObject.CrowdPermissionPolicy

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
Streamable.Closure
 
Field Summary
protected  int _tokens
          The tokens contained in this ring (composed together bitwise).
static int ADMIN
          Indicates that this user is an administrator.
 
Constructor Summary
TokenRing(int tokens)
          Constructs a token ring with the supplied set of tokens.
 
Method Summary
 void clearToken(int token)
          Clears the specified token from this ring.
 int getTokens()
          Returns the bitmask that stores the various tokens.
 boolean holdsAnyToken(int tokens)
          Returns true if this token ring contains any one of the specified tokens.
 boolean holdsToken(int token)
          Returns true if this token ring contains the specified token or tokens, exactly.
 boolean isAdmin()
          Convenience function for checking whether this ring holds the ADMIN token.
 void setToken(int token)
          Adds the specified token to this ring.
 void setToken(int token, boolean on)
          Set the specified token to be on or off.
 
Methods inherited from class com.threerings.io.SimpleStreamableObject
toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADMIN

public static final int ADMIN
Indicates that this user is an administrator.

See Also:
Constant Field Values

_tokens

protected int _tokens
The tokens contained in this ring (composed together bitwise).

Constructor Detail

TokenRing

public TokenRing(int tokens)
Constructs a token ring with the supplied set of tokens.

Method Detail

holdsToken

public boolean holdsToken(int token)
Returns true if this token ring contains the specified token or tokens, exactly. For example, if you pass in the OR of two or more tokens, then the ring must contain all of those tokens.


holdsAnyToken

public boolean holdsAnyToken(int tokens)
Returns true if this token ring contains any one of the specified tokens.


isAdmin

public boolean isAdmin()
Convenience function for checking whether this ring holds the ADMIN token.


getTokens

public int getTokens()
Returns the bitmask that stores the various tokens.


setToken

public void setToken(int token,
                     boolean on)
Set the specified token to be on or off.


setToken

public void setToken(int token)
Adds the specified token to this ring.


clearToken

public void clearToken(int token)
Clears the specified token from this ring.