BEA Systems, Inc.

WebLogic Server 8.1 API Reference

weblogic.security.service
Class ResourceBase

java.lang.Object
  |
  +--weblogic.security.service.ResourceBase
Direct Known Subclasses:
AdminResource, ApplicationResource, COMResource, EISResource, EJBResource, JDBCResource, JMSResource, JNDIResource, RealmAdapterAclResource, ServerResource, URLResource, WebResource

public abstract class ResourceBase
extends java.lang.Object
implements SelfDescribingResource

The 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).

Author:
Copyright © 2002 BEA Systems, Inc. All Rights Reserved.
See Also:
Serialized Form

Field Summary
protected  long id
          The unique long identifier computed with a hash function from the resource type and the attributes.
protected  int length
          The valid length of the values array.
protected static boolean SCOPE_RESOURCE_ACTION
           
protected static java.lang.String SCOPE_RESOURCE_ACTION_NAME
           
protected  java.lang.String[] values
          The array of values for which the extending classes are expected to provide a corresponding array of keys.
 
Constructor Summary
ResourceBase()
          Creates an empty ResourceBase.
 
Method Summary
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 o)
          Compares this resource to the resource in the specified object.
 int getFieldType(java.lang.String fieldName)
           
 long getID()
          Gets a unique, 64-bit identifier for a resource.
abstract  java.lang.String[] getKeys()
          Gets keys for the resource.
 int getRepeatingFieldIndex()
           
 int getRepeatingFieldTerminatingIndex()
           
 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.
 void reset()
          Deprecated. As of 04/01/02.

 java.lang.String toString()
          Returns a string representation of the resource.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

values

protected java.lang.String[] values
The array of values for which the extending classes are expected to provide a corresponding array of keys.


length

protected int length
The valid length of the values array. This variable eliminates the need to make copies to shorter arrays.


id

protected long id
The unique long identifier computed with a hash function from the resource type and the attributes.


SCOPE_RESOURCE_ACTION_NAME

protected static final java.lang.String SCOPE_RESOURCE_ACTION_NAME

SCOPE_RESOURCE_ACTION

protected static final boolean SCOPE_RESOURCE_ACTION
Constructor Detail

ResourceBase

public ResourceBase()
Creates an empty ResourceBase.

Method Detail

equals

public boolean equals(java.lang.Object o)
Compares this resource to the resource in the specified object.

Parameters:
o - the other resource with which to compare this resource.

Returns:
TRUE if the resource passed in matches this resource, and FALSE otherwise.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

toString

public java.lang.String toString()
Returns a string representation of the resource.

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.

Returns:
the resource, represented as a String.

Overrides:
toString in class java.lang.Object

getID

public long getID()
Gets a unique, 64-bit identifier for a resource.

This method provides a quick and efficient way of identifying a resource that can be used instead of the toString method.

This method is a hash operation that is calculated and cached within the resource itself. The ID is guaranteed to be unique by a probablistic distribution over 64 bits.

Note: This method is not guaranteed between service packs or future releases. Therefore, you should not store getID values in your database.

Returns:
the ID value for the resource, represented as a long.


hashCode

public int hashCode()
Returns an identifier for the resource as a hash code. Because the hash code is only 32 bits, this identifier is not guaranteed to be unique.

Returns:
the ID value for the resource, represented as an int.

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

reset

public void reset()
Deprecated. As of 04/01/02.

Clears all the values from the resource.


getKeys

public abstract java.lang.String[] getKeys()
Gets keys for the resource.

Returns:
an array of Strings containing the resource's keys.


getFieldType

public int getFieldType(java.lang.String fieldName)
Specified by:
getFieldType in interface SelfDescribingResource


getRepeatingFieldIndex

public int getRepeatingFieldIndex()
Specified by:
getRepeatingFieldIndex in interface SelfDescribingResource


getRepeatingFieldTerminatingIndex

public int getRepeatingFieldTerminatingIndex()
Specified by:
getRepeatingFieldTerminatingIndex in interface SelfDescribingResource


getValues

public java.lang.String[] getValues()
Gets the values corresponding to the keys of this resource's type. This array may be shorter than the array returned by 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.

Returns:
a potentially zero-length array of Strings representing the keys' values for the resource.


appendValue

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.

Parameters:
buf - StringBuffer to which the value should be appended.

value - the string value to append to the StringBuffer.

Returns:
StringBuffer with appended values.


appendArrayValue

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.

Parameters:
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.

Returns:
StringBuffer with appended values.


init

protected void init(java.lang.String[] values,
                    long seed)
Initializes the resource with the array of values.

Parameters:
values - the array of string values with which the resource should be initialized.

seed - the seed for the hash function.


init

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.

Parameters:
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.


Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs81b