at.ac.tuwien.infosys.sm4all.copal.api.event
Class ContextEventType

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.event.ContextEventType
Direct Known Subclasses:
XMLContextEventType

public class ContextEventType
extends java.lang.Object

Class which defines type for each ContextEvent, i.e. each ContextEvent must have a corresponding ContextEventType associated with it. The name of the ContextEventType is also the name of each ContextEvent associated with this type and is a globally unique name on which ContextPublishers and ContextListeners have to agree on and use it to publish and listen on events respectively. This class is not thread safe.

Author:
sanjin

Field Summary
static int PRIORITY_DEFAULT
          Default priority of ContextEvents.
static int PRIORITY_MAX
          Maximal priority of ContextEvents.
static int PRIORITY_MIN
          Minimal priority of ContextEvents.
static long TTL_DEFAULT
          Default time-to-live of ContextEvents.
 
Constructor Summary
ContextEventType(java.lang.String name)
          Create instance of ContextEventType.
 
Method Summary
 void add(Attribute attribute)
          Add specified Attribute into this ContextEventType.
 void add(Authorization authorization)
          Add specified Authorization into this ContextEventType.
 void append(DefaultAction... defaultActions)
          Append specified DefaultActions.
 boolean equals(java.lang.Object obj)
          Compare this ContextEventType to the specified Object.
 DefaultAction getAction(int index)
          Return the DefaultAction at specified index.
 DefaultAction[] getActions()
          Return all currently added DefaultActions.
 java.lang.String getAttribute(java.lang.String name)
          Return the value of ContextEventType Attribute that has specified name.
 Attribute[] getAttributes()
          Return all currently added Attributes.
 Authorization getAuthorization(java.lang.String method)
          Return the Authorization that has specified name of AuthorizationMethod.
 Authorization[] getAuthorizations()
          Return all currently added Authorizations.
 java.lang.String getName()
          Return the globally unique name of this ContextEventType.
 int getNumberOfActions()
          Return the number of DefaultActions.
 int getPriority()
          Return the priority of this ContextEventType.
 long getTTL()
          Return the time-to-live in milliseconds of this ContextEventType.
 boolean hasAction(java.lang.String name)
          Return if there is at least one DefaultAction with specified name.
 boolean hasAttribute(java.lang.String name)
          Return if an Attribute that has specified name is currently present in this ContextEventType.
 boolean hasAuthorization(java.lang.String method)
          Return if an Authorization that has specified name of AuthorizationMethod is currently present in this ContextEventType.
 boolean hasAuthorizations()
          Return if there is any added Authorization in this ContextEventType.
 int hashCode()
          Return hash code for this ContextEventType.
 void insert(int index, DefaultAction action)
          Insert specified DefaultAction at specified index.
 void removeAction(int index)
          Remove the DefaultAction at specified index.
 void removeAttribute(java.lang.String name)
          Remove an Attribute that has specified from this ContextEventType.
 void removeAuthorization(java.lang.String method)
          Remove an Authorization that has specified name of AuthorizationMethod from this ContextEventType.
 void replace(int index, DefaultAction action)
          Replace the DefaultAction at specified index with specified DefaultAction.
protected  void set(Attribute... attributes)
          Add specified Attributes and remove all previously registered Attributes.
protected  void set(Authorization... authorizations)
          Add specified Authorizations and remove all previously registered Authorizations.
protected  void set(DefaultAction... actions)
          Remove all previously added DefaultActions and adds specified DefaultActions.
 void setPriority(int priority)
          Set the priority of this ContextEventType.
 void setTTL(long ttl)
          Set the time-to-live of this ContextEventType.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TTL_DEFAULT

public static final long TTL_DEFAULT
Default time-to-live of ContextEvents.

See Also:
Constant Field Values

PRIORITY_MIN

public static final int PRIORITY_MIN
Minimal priority of ContextEvents.

See Also:
Constant Field Values

PRIORITY_MAX

public static final int PRIORITY_MAX
Maximal priority of ContextEvents.

See Also:
Constant Field Values

PRIORITY_DEFAULT

public static final int PRIORITY_DEFAULT
Default priority of ContextEvents.

See Also:
Constant Field Values
Constructor Detail

ContextEventType

public ContextEventType(java.lang.String name)
Create instance of ContextEventType. The name must be globally unique name of the event. TTL and priority are set to TTL_DEFAULT and PRIORITY_DEFAULT respectively.

Parameters:
name - the globally unique name of ContextEventType.
Throws:
java.lang.NullPointerException - if specified name null.
java.lang.IllegalArgumentException - if specified name is an empty or blank string.
Method Detail

getName

public java.lang.String getName()
Return the globally unique name of this ContextEventType.

Returns:
the globally unique name of this ContextEventType.

getTTL

public long getTTL()
Return the time-to-live in milliseconds of this ContextEventType.

Returns:
the time-to-live in milliseconds of this ContextEventType .

setTTL

public void setTTL(long ttl)
Set the time-to-live of this ContextEventType. The specified value represents time in milliseconds. If specified value is negative then time-to-live will be set to zero. Value of zero means that time-to-live is indefinite, i.e. the ContextEvent never gets old.

Parameters:
ttl - the time-to-live of this ContextEventType.

getPriority

public int getPriority()
Return the priority of this ContextEventType.

Returns:
the priority of this ContextEventType.

setPriority

public void setPriority(int priority)
Set the priority of this ContextEventType. If specified value is greater than PRIORITY_MAX than the priority will be set to PRIORITY_MAX. If specified value is less than PRIORITY_MIN than the priority will be set to PRIORITY_MIN

Parameters:
priority - the priority of this ContextEventType.

getAction

public DefaultAction getAction(int index)
Return the DefaultAction at specified index.

Parameters:
index - the index of DefaultAction.
Returns:
the DefaultAction.

getActions

public DefaultAction[] getActions()
Return all currently added DefaultActions.

Returns:
all currently added DefaultActions.

set

protected void set(DefaultAction... actions)
Remove all previously added DefaultActions and adds specified DefaultActions.

Parameters:
actions - the DefaultActions.

hasAction

public boolean hasAction(java.lang.String name)
Return if there is at least one DefaultAction with specified name.

Parameters:
name - the name of the DefaultAction.
Returns:
if there is at least one DefaultAction with specified name.

getNumberOfActions

public int getNumberOfActions()
Return the number of DefaultActions.

Returns:
the number of DefaultActions.

append

public void append(DefaultAction... defaultActions)
Append specified DefaultActions.

Parameters:
defaultActions - the DefaultActions.

insert

public void insert(int index,
                   DefaultAction action)
Insert specified DefaultAction at specified index.

Parameters:
index - the index at which the DefaultAction is inserted.
action - the DefaultAction.

replace

public void replace(int index,
                    DefaultAction action)
Replace the DefaultAction at specified index with specified DefaultAction.

Parameters:
index - the index at which the DefaultAction is replaced.
action - the DefaultAction.=

removeAction

public void removeAction(int index)
Remove the DefaultAction at specified index.

Parameters:
index - the index at which the DefaultAction is removed.

add

public void add(Attribute attribute)
Add specified Attribute into this ContextEventType. If there is already an Attribute with same name as specified Attribute, specified Attribute will overwrite Attribute that is already added.

Parameters:
attribute - the Attribute.

removeAttribute

public void removeAttribute(java.lang.String name)
Remove an Attribute that has specified from this ContextEventType.

Parameters:
name - the name of Attribute.

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Return the value of ContextEventType Attribute that has specified name. If this ContextEventType does not have Attribute with specified name, null will be returned.

Parameters:
name - the name of the Attribute.
Returns:
the value of Attribute or null if there is no such Attribute.

getAttributes

public Attribute[] getAttributes()
Return all currently added Attributes.

Returns:
all currently added Attributes.

hasAttribute

public boolean hasAttribute(java.lang.String name)
Return if an Attribute that has specified name is currently present in this ContextEventType. If the Attribute was never added (or was added and consequently removed by adding it with null value), false will be returned; otherwise true will be returned.

Parameters:
name - the name of Attribute.
Returns:
if an Attribute that has specified name is currently present in this ContextEventType.

set

protected void set(Attribute... attributes)
Add specified Attributes and remove all previously registered Attributes.

Parameters:
attributes - Attributes.

add

public void add(Authorization authorization)
Add specified Authorization into this ContextEventType. If there is already an Authorization with same name of the AuthorizationMethod as specified Authorization, their attributes will be merged with attributes from specified Authorization overwriting ones in already added Authorization.

Parameters:
authorization - the Authorization.

removeAuthorization

public void removeAuthorization(java.lang.String method)
Remove an Authorization that has specified name of AuthorizationMethod from this ContextEventType.

Parameters:
method - the name of AuthorizationMethod.

getAuthorization

public Authorization getAuthorization(java.lang.String method)
Return the Authorization that has specified name of AuthorizationMethod. If this ContextEventType does not have Authorization with specified name AuthorizationMethod, null will be returned.

Parameters:
method - the name of AuthorizationMethod.
Returns:
the Authorization; or null if there is no such Authorization.

getAuthorizations

public Authorization[] getAuthorizations()
Return all currently added Authorizations.

Returns:
all currently added Authorizations.

hasAuthorization

public boolean hasAuthorization(java.lang.String method)
Return if an Authorization that has specified name of AuthorizationMethod is currently present in this ContextEventType. If the Authorization was never added (or was added and consequently removed), false will be returned; otherwise true will be returned.

Parameters:
method - the name of AuthorizationMethod.
Returns:
if an Authorization that has specified name of AuthorizationMethod is currently present in this ContextEventType.

hasAuthorizations

public boolean hasAuthorizations()
Return if there is any added Authorization in this ContextEventType.

Returns:
if there is any added Authorization in this ContextEventType.

set

protected void set(Authorization... authorizations)
Add specified Authorizations and remove all previously registered Authorizations.

Parameters:
authorizations - Authorizations.

hashCode

public int hashCode()
Return hash code for this ContextEventType. The hash code for a ContextEventType object is hash code of its name.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this ContextEventType.

equals

public boolean equals(java.lang.Object obj)
Compare this ContextEventType to the specified Object. The result is true if and only if the argument is not null and is a ContextEventType object that has same name as this ContextEventType.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object to compare this ContextEventType against.
Returns:
true if ContextEventTypes are equal; false otherwise.


Copyright © 2010 Distributed Systems Group, Vienna University of Technology. All Rights Reserved.