Class PreferredResources
java.lang.Object
com.sun.jini.loader.pref.internal.PreferredResources
Internal data structure which holds preference information for a preferred class loader. This
utility is used only by the preferred class loader provider and is not intended to be a public
API.
A preferred resources object is created from an input stream which is formatted according to the
Preferred List Syntax which is defined in the specification for
net.jini.loader.pref.PreferredClassProvider
Preferred resources instances hold preferred list expression data and the preferred state for the
resources contained in a given preferred class loader.- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant value that indicates that there is no preference value for a given name.static final intConstant value that indicates that the resource for a given name is known to be not preferred.static final intConstant value that indicates that a given name is preferred.static final intConstant value that indicates that a given resource is preferred. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a preference object from a stream of formatted preference syntax. -
Method Summary
Modifier and TypeMethodDescriptionReturns the preference setting that will be applied to names which have no explicit preference setting in contained preference settings.intgetNameState(String name, boolean isClass) Searches the preference maps to determine the preference state of the named resource.getWildcardPreference(String name) Return the boolean value of the most specific wild card (package and namespace) expression which matchesname.voidsetNameState(String name, int prefState) Enable MarshalInputStream to optimize preference information: permits complete name expressions to be added for names that only match wild-card expressions.voidwrite(OutputStream out) Write the preferences to the specified OutputStream using the preference list syntax.
-
Field Details
-
NAME_NO_PREFERENCE
public static final int NAME_NO_PREFERENCEConstant value that indicates that there is no preference value for a given name.- See Also:
-
NAME_NOT_PREFERRED
public static final int NAME_NOT_PREFERREDConstant value that indicates that the resource for a given name is known to be not preferred. This state is applicable when a preference expression declared that the name is not preferred or when the resource for the name (preferred or not) is known to not exist.- See Also:
-
NAME_PREFERRED
public static final int NAME_PREFERREDConstant value that indicates that a given name is preferred. This state is applicable when a preference expression declares the name to be preferred but it is uncertain whether the resource for the name the exists.- See Also:
-
NAME_PREFERRED_RESOURCE_EXISTS
public static final int NAME_PREFERRED_RESOURCE_EXISTSConstant value that indicates that a given resource is preferred. This state is applicable when a preference expression declares the name to be preferred and the resource for the name is known to exist.- See Also:
-
-
Constructor Details
-
PreferredResources
Create a preference object from a stream of formatted preference syntax.- Throws:
IOException- See Also:
-
-
Method Details
-
write
Write the preferences to the specified OutputStream using the preference list syntax. Preference expressions are written in the following order: Complete name expressions Package expressions Namespace expressions- Parameters:
out- the stream to which formatted preference information will be written- Throws:
IOException- if an error occurs while writing to the stream
-
getDefaultPreference
Returns the preference setting that will be applied to names which have no explicit preference setting in contained preference settings. The default preference is set by the first preference setting with no associated name in a preferences list file.- Returns:
- default boolean preference value for these preferences
-
setNameState
Enable MarshalInputStream to optimize preference information: permits complete name expressions to be added for names that only match wild-card expressions. These added expressions hold data that tells if a resource has been loaded. This method makes this object mutable. Synchronization must be used to ensure consistent preference state when this method is called.- Parameters:
name- the name for which preferred state will be setprefState- the preferred state for the given name- Throws:
IOException- if the name length is zero length
-
getNameState
Searches the preference maps to determine the preference state of the named resource. The preference state for the given resource name is returned. The preference state is an integer that is equal to one of the preference state values defined above. This state integer tells the preference value of name and whether its resource is known to exist.- Parameters:
isClass- whether the givennamerefers to a class resource- Returns:
- the state for the given name which will be set to one of the following values: NAME_NO_PREFERENCE, NAME_NOT_PREFERRED, NAME_PREFERRED, NAME_PREFERRED_RESOURCE_EXISTS
- Throws:
IOException- if an error occurs getting the state for the supplied name
-
getWildcardPreference
Return the boolean value of the most specific wild card (package and namespace) expression which matchesname. Package preferences are always more specific than namespace preferences.- Parameters:
name- the resource name to which the returned boolean value will apply- Returns:
Boolean.TRUE/code> ifnameis preferred.Boolean.FALSEis it is not.nullif there is no wildcard preference for the name.
-