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

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

public class XMLContextEventType
extends ContextEventType

Class which defines type for each XMLContextEvent, i.e. each XMLContextEvent must have a corresponding XMLContextEventType associated with it. The name of the XMLContextEventType is also the name of each XMLContextEvent 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
 
Fields inherited from class at.ac.tuwien.infosys.sm4all.copal.api.event.ContextEventType
PRIORITY_DEFAULT, PRIORITY_MAX, PRIORITY_MIN, TTL_DEFAULT
 
Constructor Summary
XMLContextEventType(java.lang.String name)
          Create instance of XMLContextEventType.
XMLContextEventType(java.lang.String name, java.lang.String rootElementName)
          Create instance of XMLContextEventType.
 
Method Summary
 org.w3c.dom.Document createEvent(javax.xml.parsers.DocumentBuilder builder)
          Create a Document for this ContextEventType using specified DocumentBuilder with root element having name equal to getRootElementName() and default namespace set to getNamespaceURI() if there is one.
 java.net.URI getNamespaceURI()
           
 java.lang.String getRootElementName()
           
 java.net.URL getSchemaURL()
           
 boolean hasNamespace()
           
 boolean hasSchema()
           
 void setNamespaceURI(java.net.URI namespaceURI)
          Sets the value of the namespace URI used by event for its XML elements.
 void setSchemaURL(java.net.URL schemaURL)
          Sets the XML Schema URL that defines the XML document structure of this ContextEventType.
 void validate(org.w3c.dom.Document document)
          Checks if specified Document is valid for this ContextEventType.
 
Methods inherited from class at.ac.tuwien.infosys.sm4all.copal.api.event.ContextEventType
add, add, append, equals, getAction, getActions, getAttribute, getAttributes, getAuthorization, getAuthorizations, getName, getNumberOfActions, getPriority, getTTL, hasAction, hasAttribute, hasAuthorization, hasAuthorizations, hashCode, insert, removeAction, removeAttribute, removeAuthorization, replace, set, set, set, setPriority, setTTL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLContextEventType

public XMLContextEventType(java.lang.String name,
                           java.lang.String rootElementName)
Create instance of XMLContextEventType. The name must be globally unique name of the event. If name and rootElementName have same value use the XMLContextEventType(String) constructor instead.

Parameters:
name - the globally unique name of the XMLContextEventType.
rootElementName - the local (unqualified) name of event's Document root element.
Throws:
java.lang.NullPointerException - if specified name or root element name is null.
java.lang.IllegalArgumentException - if specified name or root element name is an empty or blank string.

XMLContextEventType

public XMLContextEventType(java.lang.String name)
Create instance of XMLContextEventType. The name must be globally unique name. If name and rootElementName have different values use the XMLContextEventType(String, String) constructor instead.

Parameters:
name - the globally unique name of the event and the local (unqualified) name of XML document root element.
Throws:
java.lang.NullPointerException - if specified name is null.
java.lang.IllegalArgumentException - if specified name is an empty or blank string.
Method Detail

getRootElementName

public java.lang.String getRootElementName()
Returns:
the local (unqualified) name of XML document root element.

getNamespaceURI

public java.net.URI getNamespaceURI()
Returns:
the namespace URI used by event for its XML elements.

setNamespaceURI

public void setNamespaceURI(java.net.URI namespaceURI)
Sets the value of the namespace URI used by event for its XML elements.

Parameters:
namespaceURI - the new namespace URI.

hasNamespace

public boolean hasNamespace()
Returns:
if this ContextEventType has the namespace defined.

getSchemaURL

public java.net.URL getSchemaURL()
Returns:
the URL where XML Schema can be found that defines the XML document structure of this ContextEventType.

setSchemaURL

public void setSchemaURL(java.net.URL schemaURL)
Sets the XML Schema URL that defines the XML document structure of this ContextEventType.

Parameters:
schemaURL - the new XML Schema URL.

hasSchema

public boolean hasSchema()
Returns:
if this ContextEventType has the schema defined.

createEvent

public org.w3c.dom.Document createEvent(javax.xml.parsers.DocumentBuilder builder)
Create a Document for this ContextEventType using specified DocumentBuilder with root element having name equal to getRootElementName() and default namespace set to getNamespaceURI() if there is one.

Parameters:
builder - the DocumentBuilder used for creating Document.
Returns:
the Document that can be used as an event for this ContextEventType.
Throws:
java.lang.NullPointerException - id specified DocumentBuilder is null.

validate

public void validate(org.w3c.dom.Document document)
              throws MalformedDocumentException
Checks if specified Document is valid for this ContextEventType.

Parameters:
document - the Document.
Throws:
MalformedDocumentException - if specified Document is malformed for this ContextEventType.


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