java.io.Serializable
, Resource
, SelfDescribingResource
, SelfDescribingResourceV2
AdminResource
, ApplicationResource
, COMResource
, ControlResource
, EISResource
, EJBResource
, JDBCResource
, JMSResource
, JMXResource
, JNDIResource
, RemoteResource
, ServerResource
, URLResource
, WebServiceResource
, WorkContextResource
public abstract class ResourceBase extends java.lang.Object implements SelfDescribingResourceV2
ResourceBase
class is an abstract base class for all the specific resource types
and facilitates the model for the extending resources. Each resource is represented
by its type and a set of attributes, and each instance is identified by a unique long identifier
that is computed with a hash function from the resource type and the attributes.
The ResourceBase
class contains the BEA-provided implementations of the
getKeys
, getFields
, getID
, and toString
methods.
The ResourceBase
class contains an array of values for which the extending classes are
expected to provide a corresponding array of keys.
(See the getkeys
methods in each extending class for more information).
Modifier and Type | Field | Description |
---|---|---|
protected long |
id |
Resource long hashcode.
|
protected int |
length |
The valid length of the values array.
|
protected static Resource |
NO_PARENT |
|
protected Resource |
parent |
|
protected java.lang.String |
resStr |
|
protected static boolean |
SCOPE_RESOURCE_ACTION |
|
protected java.lang.String[] |
values |
The array of values for which the extending classes are expected to
provide a corresponding array of keys.
|
LIST_FIELD_TYPE, NORMAL_FIELD_TYPE, PATH_FIELD_TYPE, UNDEFINED_FIELD_TYPE
Modifier and Type | Method | Description |
---|---|---|
protected static java.lang.StringBuffer |
appendArrayValue(java.lang.StringBuffer buf,
java.lang.String[] values,
int len) |
Appends the array of values to the buffer as a comma-separated list of values
in curly parentheses.
|
protected static java.lang.StringBuffer |
appendValue(java.lang.StringBuffer buf,
java.lang.String value) |
Appends the value to the buffer, escaping special characters with '\' and
treating
null strings as empty strings. |
boolean |
equals(java.lang.Object obj) |
Compares this resource to the resource in the specified object.
|
int |
getFieldType(java.lang.String fieldName) |
Describe
getFieldType method here. |
long |
getID() |
Gets a 64-bit hashcode for a resource.
|
abstract java.lang.String[] |
getKeys() |
Gets keys for the resource.
|
Resource |
getParentResource() |
Gets a
Resource object that represents the parent of the current
resource. |
int |
getRepeatingFieldIndex() |
getRepeatingFieldIndex returns an index into the
array returned by getKeys() that signifies what part
of the Resource's fields repeat as the hierarchy is traversed. |
int |
getRepeatingFieldTerminatingIndex() |
The field returned by
getRepeatingFieldIndex is
repeated as the Resource is shortened up to and including this
field index. |
java.lang.String[] |
getValues() |
Gets the values corresponding to the keys of this resource's type.
|
int |
hashCode() |
Returns an identifier for the resource as a hash code.
|
protected void |
init(java.lang.String[] values,
int len,
long seed) |
Initializes the resource with the array of values, and
computes the resource ID as a hash function of the resource type and
each of its non-null values.
|
protected void |
init(java.lang.String[] values,
long seed) |
Initializes the resource with the array of values.
|
boolean |
isTransitiveField(java.lang.String fieldName) |
Returns true when the specified field name is a transitive field.
|
protected Resource |
makeParent() |
Creates a
ResourceBase object that represents the parent of the current
resource. |
java.lang.String |
toString() |
Returns a string representation of the resource.
|
protected void |
writeResourceString(java.lang.StringBuffer buf) |
Writes a string representation of the resource to buffer.
|
protected static final boolean SCOPE_RESOURCE_ACTION
protected static final Resource NO_PARENT
protected Resource parent
protected java.lang.String resStr
protected java.lang.String[] values
protected int length
protected long id
public boolean equals(java.lang.Object obj)
public java.lang.String toString()
Each type of resource is first printed in angled brackets. Then, each key is printed, in order, along with it's value. The keys are comma-separated. Values that are lists are comma-separated and delineated by open and close curly braces. Each value is printed as is, except that commas (,), open braces ({), close braces (}), and back slashes (\) are each escaped with a backslash.
For more information about the toString
formats for specific resource types,
see the descriptions in the extending classes.
Note: Because this method produces a result based on the concatenation of strings, it may be expensive in terms of performance.
protected void writeResourceString(java.lang.StringBuffer buf)
Subclasses should override this method if their string representation is different.
buf
- buffer to write to.public Resource getParentResource()
Resource
object that represents the parent of the current
resource. If the resource does not have a parent, the value of
null
must be returned.getParentResource
in interface Resource
Resource
object of the parent resource.protected Resource makeParent()
ResourceBase
object that represents the parent of the current
resource. If the resource does not have a parent, the value of
null
must be returned.Subclasses should override this method.
Resource
object of the parent resource.public long getID()
This method is a hash operation that is calculated and cached within the resource itself.
Note: This method is not guaranteed between service packs or future releases.
Therefore, you should not store getID
values in your database.
public int hashCode()
Resource
public abstract java.lang.String[] getKeys()
public int getFieldType(java.lang.String fieldName)
SelfDescribingResource
getFieldType
method here.getFieldType
in interface SelfDescribingResource
fieldName
- the String
name of the field being queried.int
field type of fieldName
public int getRepeatingFieldIndex()
SelfDescribingResource
getRepeatingFieldIndex
returns an index into the
array returned by getKeys()
that signifies what part
of the Resource's fields repeat as the hierarchy is traversed.
For example, in the URLResource
, the
httpMethod
is repeated as the hierarchy is walked.
A value of -1
indicates that there are no repeating
fields.getRepeatingFieldIndex
in interface SelfDescribingResource
public int getRepeatingFieldTerminatingIndex()
SelfDescribingResource
getRepeatingFieldIndex
is
repeated as the Resource is shortened up to and including this
field index. After this field index the repetition is no longer
applied.getRepeatingFieldTerminatingIndex
in interface SelfDescribingResource
int
describing the terminating index or
getKeys().length
if nonepublic boolean isTransitiveField(java.lang.String fieldName)
SelfDescribingResourceV2
isTransitiveField
in interface SelfDescribingResourceV2
public java.lang.String[] getValues()
getKeys
, because the latter depends
only on the type of the
resource.This returns a copy of the original array so copying and modifying the return value will have no affect on the Resource.
If the Resource has no non-null values then this will return an array of zero lenght.
protected static java.lang.StringBuffer appendValue(java.lang.StringBuffer buf, java.lang.String value)
null
strings as empty strings.buf
- StringBuffer
to which the value should be appended.value
- the string value to append to the StringBuffer
.StringBuffer
with appended values.protected static java.lang.StringBuffer appendArrayValue(java.lang.StringBuffer buf, java.lang.String[] values, int len)
buf
- StringBuffer
to which the value should be appended.values
- the array of string values to append to the StringBuffer
.len
- the number of values from the array that should be appended.StringBuffer
with appended values.protected void init(java.lang.String[] values, long seed)
values
- the array of string values with which the resource should be initialized.seed
- the seed for the hash function.protected void init(java.lang.String[] values, int len, long seed)
values
- the array of string values with which the resource should be initialized.len
- the number of values from the array that apply to this resource.seed
- the seed for the hash function.