edu.wisc.trace.urcsdk.client.resources
Class AbstractResource

java.lang.Object
  extended by edu.wisc.trace.urcsdk.client.resources.AbstractResource
All Implemented Interfaces:
IResource
Direct Known Subclasses:
EmptyResource, ImageResource, ListResource, TextResource

public abstract class AbstractResource
extends java.lang.Object
implements IResource

AbstractResource is the abstract implementation of IResource that all of the SDK resource types extend from. It provides the common functionality that all resources require and would be tedious to re-implement for every resource type.

Version:
$Revision: 1.21 $
Author:
Andrew Martin, Trace R&D Center Created on: Apr 26, 2005

Field Summary
protected  ElementRef elementRef
           
protected  java.lang.String operationRef
           
protected  java.util.Map<java.lang.String,java.util.List<java.lang.Object>> properties
           
protected  java.lang.Object value
           
protected  java.lang.String valueRef
           
 
Fields inherited from interface edu.wisc.trace.urcsdk.client.resources.IResource
EMPTY_RESOURCE
 
Constructor Summary
AbstractResource()
           
AbstractResource(java.lang.Object value, ElementRef elementRef, java.lang.String valueRef, java.lang.String operationRef, Constants.ResourceRole role, java.util.List<java.lang.String> langs)
          Creates a new instance of AbtractResource.
 
Method Summary
 void addProperty(java.lang.String name, java.util.List<java.lang.Object> list)
          Adds a property to this Resource.
 void addProperty(java.lang.String name, java.lang.Object value)
          Adds a property to this Resource.
 boolean equals(IResource r)
          Returns true if this and the given Resource are the same.
 ElementRef getElementRef()
           
 java.lang.String getFormat()
          Return the DCMI format property of resource (MIME type).
 java.util.List<java.lang.String> getLangs()
          Returns a List of language contexts.
 java.lang.String getOperationRef()
           
 java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getPropertiesMap()
          Returns a Map of properties for this resource.
 java.lang.Object getProperty(java.lang.String property)
          Returns the value of the property with the given name.
 Constants.ResourceRole getRole()
          Returns the role associated with this Resource
 Constants.ResourceType getType()
          Returns the type of the resource.
 java.lang.Object getValue()
          Returns the value of this Resource
 java.lang.String getValueRef()
           
abstract  java.lang.String toString()
          String representation of this Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected java.lang.Object value

properties

protected java.util.Map<java.lang.String,java.util.List<java.lang.Object>> properties

elementRef

protected ElementRef elementRef

valueRef

protected java.lang.String valueRef

operationRef

protected java.lang.String operationRef
Constructor Detail

AbstractResource

public AbstractResource()

AbstractResource

public AbstractResource(java.lang.Object value,
                        ElementRef elementRef,
                        java.lang.String valueRef,
                        java.lang.String operationRef,
                        Constants.ResourceRole role,
                        java.util.List<java.lang.String> langs)
Creates a new instance of AbtractResource.

Parameters:
value - The value of the resource.
elementRef - The element reference of the resource.
valueRef - The value reference of the resource.
operationRef - The operation reference of the resource.
role - The role of the resource.
langs - A List of languages contexts.
Method Detail

addProperty

public void addProperty(java.lang.String name,
                        java.lang.Object value)
Adds a property to this Resource.

Parameters:
name - The name of the new Property.
value - The value of the new Property.

addProperty

public void addProperty(java.lang.String name,
                        java.util.List<java.lang.Object> list)
Adds a property to this Resource.

Parameters:
name - The name of the property.
list - A List of values for this property.

getValue

public java.lang.Object getValue()
Description copied from interface: IResource
Returns the value of this Resource

Specified by:
getValue in interface IResource
Returns:
value of the resource.
See Also:
IResource.getValue()

getFormat

public java.lang.String getFormat()
Description copied from interface: IResource
Return the DCMI format property of resource (MIME type).

Specified by:
getFormat in interface IResource
Returns:
the format for the resource.
See Also:
IResource.getFormat()

getType

public Constants.ResourceType getType()
Returns the type of the resource.

Specified by:
getType in interface IResource
Returns:
Constants.ResourceType
See Also:
IResource.getType()

getElementRef

public ElementRef getElementRef()
Specified by:
getElementRef in interface IResource
Returns:
ElementRef object for the resource.
See Also:
IResource.getElementRef()

getValueRef

public java.lang.String getValueRef()
Specified by:
getValueRef in interface IResource
Returns:
the valueRef string for the resource.
See Also:
IResource.getValueRef()

getOperationRef

public java.lang.String getOperationRef()
Specified by:
getOperationRef in interface IResource
Returns:
String representing the operator reference for the socket element for this resource.

getLangs

public java.util.List<java.lang.String> getLangs()
Returns a List of language contexts.

Specified by:
getLangs in interface IResource
Returns:
List of languages for this Resource

getRole

public Constants.ResourceRole getRole()
Returns the role associated with this Resource

Specified by:
getRole in interface IResource
Returns:
ResourceRole for this Resource

equals

public boolean equals(IResource r)
Returns true if this and the given Resource are the same.

Specified by:
equals in interface IResource

getPropertiesMap

public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getPropertiesMap()
Returns a Map of properties for this resource.

Specified by:
getPropertiesMap in interface IResource
Returns:
Map of Properties of this Resource

getProperty

public java.lang.Object getProperty(java.lang.String property)
Returns the value of the property with the given name. Returns null if the property is empty.

Specified by:
getProperty in interface IResource
Parameters:
property - The property for which the value is needed
Returns:
The value for the requested property

toString

public abstract java.lang.String toString()
Description copied from interface: IResource
String representation of this Object.

Specified by:
toString in interface IResource
Overrides:
toString in class java.lang.Object
Returns:
a String value


Copyright © 2006 Trace R&D Center, University of Wisconsin-Madison. All Rights Reserved.