ubiware.util.saplbuilder
Class Resource

java.lang.Object
  extended by ubiware.util.saplbuilder.Resource
All Implemented Interfaces:
Object, Predicate, Subject

public class Resource
extends java.lang.Object
implements Subject, Predicate, Object

Representation of a resource. A resource can be used as an Subject, Predicate and Object.

Since:
17 Aug 2010
Author:
Michael Cochez for Ubiware project

Constructor Summary
Resource(java.lang.String resource)
          Creates a Resource from the given String representation.
Resource(java.lang.String prefix, java.lang.String qname)
          Creates a Resource with the given prefix.
Resource(java.net.URI prefix, java.lang.String qname)
          Creates a Resource with the given prefix.
 
Method Summary
static Resource creatAnonymousNode()
           
static Resource createUncheckedResource(java.lang.String resourceString)
          Creates a Resource without the need to catch checked exceptions.
static Resource createUncheckedResource(java.net.URI prefix, java.lang.String qname)
          Creates a Resource without the need to catch checked exceptions.
 boolean equals(java.lang.Object obj)
           
 void generateSapl(java.lang.StringBuilder builder)
          Generate the s-apl representation for this subject.
 int hashCode()
           
 java.lang.String toString()
          Gives a String representation of this resource.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Resource

public Resource(java.net.URI prefix,
                java.lang.String qname)
         throws MalformedSaplException
Creates a Resource with the given prefix.

Parameters:
prefix - The prefix onto which the qname will be appended
qname - The qname of the resource.
Throws:
MalformedSaplException - In case the concatenation of prefix and qname does not result in a valid URI

Resource

public Resource(java.lang.String prefix,
                java.lang.String qname)
         throws MalformedSaplException
Creates a Resource with the given prefix.

Parameters:
prefix - The prefix onto which the qname will be appended
qname - The qname of the resource.
Throws:
MalformedSaplException - In case the concatenation of prefix and qname does not result in a valid URI

Resource

public Resource(java.lang.String resource)
         throws InvalidResourceException
Creates a Resource from the given String representation. The representation must have opening and closing rectangular braces.

Parameters:
resource - The resource in String form.
Throws:
InvalidResourceException - In case resource is not a valid URL.
Method Detail

creatAnonymousNode

public static Resource creatAnonymousNode()

createUncheckedResource

public static Resource createUncheckedResource(java.lang.String resourceString)
Creates a Resource without the need to catch checked exceptions. An Error is thrown if the resourceString is not a valid Resource representation.

Parameters:
resourceString - A String representing a resource.
Returns:
A Resource.
Throws:
java.lang.Error - If the resourceString does not represent a valid Resource.

createUncheckedResource

public static Resource createUncheckedResource(java.net.URI prefix,
                                               java.lang.String qname)
Creates a Resource without the need to catch checked exceptions. An Error is thrown if the preix and qname don't form a valid Resource together.

Parameters:
prefix - The prefix of the URI
qname - the qname which will be appended to the prefix to form the resource.
Returns:
A Resource.
Throws:
java.lang.Error - If the prefix and qname don't form a valid Resource together.

generateSapl

public void generateSapl(java.lang.StringBuilder builder)
Description copied from interface: Subject
Generate the s-apl representation for this subject.

Specified by:
generateSapl in interface Object
Specified by:
generateSapl in interface Predicate
Specified by:
generateSapl in interface Subject
Parameters:
builder - The StringBuilder on which the representation must be appended.

toString

public java.lang.String toString()
Gives a String representation of this resource. This means including angular brackets.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object