edu.sdsc.inca
Class WrapResource

java.lang.Object
  extended by edu.sdsc.inca.WrapResource

public class WrapResource
extends java.lang.Object

A class that wraps a resource or resource group, represented by an Inca XmlBean, with some convenience methods.


Field Summary
static int COMPUTE_SERVER
          An enumeration of server types for get/setServerSpec.
static int FILE_SERVER
           
protected  java.util.Hashtable inheritedMacros
           
protected  java.util.Hashtable localMacros
           
static int PROXY_SERVER
           
protected  edu.sdsc.inca.dataModel.util.Resource resource
           
 
Constructor Summary
WrapResource()
          Constructs a new WrapResource.
WrapResource(edu.sdsc.inca.dataModel.util.Resource resource)
          Constructs a new WrapResource to wrap an existing Resource.
 
Method Summary
 void copy(WrapResource original)
          Copies all information from another resouce into this one.
 boolean equals(java.lang.Object o)
          Override of the default equals method.
 java.lang.String[] expandHostPattern()
          Returns the set of strings matched by the resource's host pattern.
 java.lang.String[] getInheritedMacroNames()
          Returns the names of all inherited macros defined for the resource.
 java.lang.String[] getLocalMacroNames()
          Returns the names of all local macros defined for the resource.
 java.lang.String getMacroValue(java.lang.String name)
          Returns the first value of an existing resource macro with a given name, or null if none.
 java.lang.String[] getMacroValues(java.lang.String name)
          Returns all values of an existing resource macro with a given name, or null if none.
 java.lang.String getName()
          Returns the name of the resource.
 edu.sdsc.inca.dataModel.util.Resource getResource()
          Returns the underlying Resource of this resource.
 java.lang.String getServer(int which)
          Retrieves the macros related to one of the resource servers and composes their values into a String of the form host[:port][/dn].
 java.lang.String getXpath()
          Returns the xpath of the resource.
 boolean isLocalMacro(java.lang.String name)
          Indicates whether a macro is defined locally to this resource.
 void removeAllInheritedMacros()
          Deletes any inherited macros defined in the resource.
 void removeMacro(java.lang.String name)
          Removes any macro with a specified name from the resource.
 void setInheritedMacroValue(java.lang.String name, java.lang.String value)
          Adds an inherited macro with a single value to the resource, replacing any other with the same name.
 void setInheritedMacroValues(java.lang.String name, java.lang.String[] values)
          Adds an inherited macro with multiple values to the resource, replacing any other with the same name.
 void setMacroValue(java.lang.String name, java.lang.String value)
          Adds a macro with a single value to the resource, replacing any other with the same name.
 void setMacroValue(java.lang.String name, java.lang.String value, java.lang.String defaultValue)
          A convenience that removes a macro from the resource, then sets it to a new single value unless that value is equal to a default value.
 void setMacroValues(java.lang.String name, java.lang.String[] values)
          Adds a macro with multiple values to the resource, replacing any other with the same name.
 void setName(java.lang.String name)
          Sets the name of the resource to a specified value.
 void setServer(int which, java.lang.String server)
          Splits a server string of the form host[:port][/dn] and stores its component parts into appropriate macros.
 void setXpath(java.lang.String xpath)
          Sets the xpath of the resource to a specified value.
 java.lang.String toString()
          An override of the default toString function.
 java.lang.String toXml()
          Returns XML for the resource.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPUTE_SERVER

public static final int COMPUTE_SERVER
An enumeration of server types for get/setServerSpec.

See Also:
Constant Field Values

FILE_SERVER

public static final int FILE_SERVER
See Also:
Constant Field Values

PROXY_SERVER

public static final int PROXY_SERVER
See Also:
Constant Field Values

resource

protected edu.sdsc.inca.dataModel.util.Resource resource

inheritedMacros

protected java.util.Hashtable inheritedMacros

localMacros

protected java.util.Hashtable localMacros
Constructor Detail

WrapResource

public WrapResource()
Constructs a new WrapResource.


WrapResource

public WrapResource(edu.sdsc.inca.dataModel.util.Resource resource)
Constructs a new WrapResource to wrap an existing Resource.

Parameters:
resource - the resource to wrap
Method Detail

copy

public void copy(WrapResource original)
Copies all information from another resouce into this one.

Parameters:
original - the WrapResource to duplicate

equals

public boolean equals(java.lang.Object o)
Override of the default equals method.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare to this one
Returns:
true iff o specifies the same resource

expandHostPattern

public java.lang.String[] expandHostPattern()
Returns the set of strings matched by the resource's host pattern.

Returns:
the set of string matched by the resource's host pattern

getInheritedMacroNames

public java.lang.String[] getInheritedMacroNames()
Returns the names of all inherited macros defined for the resource.

Returns:
the set of macro names

getLocalMacroNames

public java.lang.String[] getLocalMacroNames()
Returns the names of all local macros defined for the resource.

Returns:
the set of macro names

getMacroValue

public java.lang.String getMacroValue(java.lang.String name)
Returns the first value of an existing resource macro with a given name, or null if none.

Parameters:
name - the specified macro name
Returns:
the first value of the macro with the given name, null if none

getMacroValues

public java.lang.String[] getMacroValues(java.lang.String name)
Returns all values of an existing resource macro with a given name, or null if none.

Parameters:
name - the specified macro name
Returns:
the values of the macro with the given name, null if none

getName

public java.lang.String getName()
Returns the name of the resource.

Returns:
the resource name

getResource

public edu.sdsc.inca.dataModel.util.Resource getResource()
Returns the underlying Resource of this resource.

Returns:
the Resource

getServer

public java.lang.String getServer(int which)
Retrieves the macros related to one of the resource servers and composes their values into a String of the form host[:port][/dn].

Parameters:
which - one of the server types indicated by the constants above
Returns:
a string that contains the host, optional port and option dn

getXpath

public java.lang.String getXpath()
Returns the xpath of the resource.

Returns:
the resource xpath

isLocalMacro

public boolean isLocalMacro(java.lang.String name)
Indicates whether a macro is defined locally to this resource.

Parameters:
name - the macro name
Returns:
whether the macro is defined locally

removeAllInheritedMacros

public void removeAllInheritedMacros()
Deletes any inherited macros defined in the resource.


removeMacro

public void removeMacro(java.lang.String name)
Removes any macro with a specified name from the resource.

Parameters:
name - the specified macro name

setInheritedMacroValue

public void setInheritedMacroValue(java.lang.String name,
                                   java.lang.String value)
Adds an inherited macro with a single value to the resource, replacing any other with the same name.

Parameters:
name - the name of the macro
value - the value of the macro

setInheritedMacroValues

public void setInheritedMacroValues(java.lang.String name,
                                    java.lang.String[] values)
Adds an inherited macro with multiple values to the resource, replacing any other with the same name.

Parameters:
name - the name of the macro
values - the values of the macro

setMacroValue

public void setMacroValue(java.lang.String name,
                          java.lang.String value)
Adds a macro with a single value to the resource, replacing any other with the same name.

Parameters:
name - the name of the macro
value - the value of the macro

setMacroValue

public void setMacroValue(java.lang.String name,
                          java.lang.String value,
                          java.lang.String defaultValue)
A convenience that removes a macro from the resource, then sets it to a new single value unless that value is equal to a default value. Also ignores values that are equivalent to an inherited macro of the same name.

Parameters:
name - the name of the macro
value - the value of the macro
defaultValue - the default value for the macro if it isn't set

setMacroValues

public void setMacroValues(java.lang.String name,
                           java.lang.String[] values)
Adds a macro with multiple values to the resource, replacing any other with the same name.

Parameters:
name - the name of the macro
values - the values of the macro

setName

public void setName(java.lang.String name)
Sets the name of the resource to a specified value.

Parameters:
name - the resource name

setServer

public void setServer(int which,
                      java.lang.String server)
Splits a server string of the form host[:port][/dn] and stores its component parts into appropriate macros.

Parameters:
which - one of the server types indicated by the constants above
server - the server specification string

setXpath

public void setXpath(java.lang.String xpath)
Sets the xpath of the resource to a specified value.

Parameters:
xpath - the resource xpath

toString

public java.lang.String toString()
An override of the default toString function.

Overrides:
toString in class java.lang.Object

toXml

public java.lang.String toXml()
Returns XML for the resource.

Returns:
the configuration, as an XML string