|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
java.lang.Object
|
+--com.sas.net.BaseResourceLocator
|
+--com.sas.net.AppletResourceLocator
The AppletResourceLocator is used to locate any type of resources relative to an applet,
whether the resource wanted is an image file or a webEIS document. By default, the applet
the resource is relative to is the applet returned from GlobalInfoTable.getApplet()
and is relative to the code base of the applet. The resource name should be the relative path
and filename of the resource.
Creating a AppletResourceLocator
A valid instance is created by instantiating an object of AppletResourceLocator followed by setting relative resource name.
AppletResourceLocator appletResourceLocator1 = new AppletResourceLocator();
appletResourceLocator1.setResourceName("apple.gif"); //assumes apple.gif is in the applet's direcotry
If the resource is in a sub-directory of from the applet, then you will need to pass in the sub-directory plus the filename name to the setResourceName call
AppletResourceLocator appletResourceLocator1 = new AppletResourceLocator();
appletResourceLocator1.setResourceName("resource\images\apple.gif");
If the resource is relative to the document base of the applet, then you will
need to call setDocumentBaseRelative(true).
AppletResourceLocator appletResourceLocator1 = new AppletResourceLocator();
appletResourceLocator1.setDocumentBaseRelative(true);
appletResourceLocator1.setResourceName("images\apple.gif");
A call to getResource() will return the URL of the resource if it can be found.
try {
java.net.URL url = appletResourceLocator1.getResource();
} catch (java.net.MalformedURLException ex)
{
//an error occurred while forming the URL, handle as needed
}
| Field Summary | |
protected Applet |
_applet
The applet the resource is relative to, null if the applet cannot be found. |
protected boolean |
_isCodeBaseRelative
Whether to find the resource relative to the code base that is set on the applet |
protected boolean |
_isDocumentBaseRelative
Whether to find the resource relative to the document base that is set on the applet |
| Fields inherited from class com.sas.net.BaseResourceLocator |
_pcs, _resource, RUNTIME, WEBAF, WEBEIS |
| Constructor Summary | |
AppletResourceLocator()
Default Constructor. |
|
AppletResourceLocator(String resourceName)
Sets the name of the resource. |
|
| Method Summary | |
protected ResourceLocatorInterface |
createInstance(String resource)
Creates a AppletResourceLocator from the string passed in. |
static ResourceLocatorInterface |
decode(String resource)
Creates a AppletResourceLocator from the string passed in. |
String |
encode()
Returns a string representation of the AppletResourceLocator that can be used with decode(String) to create a new AppletResourceLocator with the same resource name and Applet. |
String |
getAbsolutePath()
Returns the absolute path of the resource. |
Applet |
getApplet()
Returns the applet that the resource is relative to. |
String |
getProjectDirectory()
Returns the directory where the applet is located, so that the resource can be found relative to it. |
String |
getRelativePath()
Convenience method, returns the resource name. |
URL |
getResource()
Returns a URL of the resource. |
boolean |
isCodeBaseRelative()
Whether to locate the resource relative to the code base of the applet. |
boolean |
isDocumentBaseRelative()
Whether to locate the resource relative to the document base of the applet. |
void |
setApplet(Applet newValue)
Sets the applet to locate the resource relative to. |
void |
setCodeBaseRelative(boolean newValue)
Sets whether the AppletResourceLocator should try to locate the resource relative to the code base or not. |
void |
setDocumentBaseRelative(boolean newValue)
Sets whether the AppletResourceLocator should try to locate the resource relative to the document base or not. |
| Methods inherited from class com.sas.net.BaseResourceLocator |
addPropertyChangeListener, addPropertyChangeListener, clone, equals, firePropertyChange, firePropertyChange, getMode, getResourceLocator, getResourceName, removePropertyChangeListener, removePropertyChangeListener, setResourceName, toString |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.sas.net.ResourceLocatorInterface |
getResourceName, setResourceName |
| Field Detail |
protected Applet _applet
protected boolean _isDocumentBaseRelative
protected boolean _isCodeBaseRelative
| Constructor Detail |
public AppletResourceLocator()
public AppletResourceLocator(String resourceName)
resourceName - the relative path and name of the resource to locate| Method Detail |
public Applet getApplet()
GlobalInfoTable.getObject(),
setApplet(Applet)public void setApplet(Applet newValue)
newValue - the applet the resource is relative toGlobalInfoTable.getApplet(),
getApplet()public boolean isDocumentBaseRelative()
setDocumentBaseRelative(boolean),
isCodeBaseRelative()public void setDocumentBaseRelative(boolean newValue)
true - if the resource is relative to the document base of the applet, false otherwiseisDocumentBaseRelative(),
setCodeBaseRelative(boolean)public boolean isCodeBaseRelative()
setCodeBaseRelative(boolean),
isDocumentBaseRelative()public void setCodeBaseRelative(boolean newValue)
true - if the resource is relative to the code base of the applet, false otherwiseisCodeBaseRelative(),
setDocumentBaseRelative(boolean)
public URL getResource()
throws MalformedURLException
URL of the resource. A null URL will be returned if the resource
cannot be found relative to the applet or if an error occurs. A MalformedURLException
will be thrown if the construction of the URL fails.getResource in interface ResourceLocatorInterfacegetResource in class BaseResourceLocatorURL,
MalformedURLExceptionpublic String encode()
encode in class BaseResourceLocator~ ~public static ResourceLocatorInterface decode(String resource)
resource - a string the should be in the format
"Applet: ~~ ~protected ResourceLocatorInterface createInstance(String resource)
createInstance in class BaseResourceLocatorresource - a string the should be in the format
"Applet: ~~ ~public String getRelativePath()
getResource().public String getAbsolutePath()
getProjectDirectory() to determine where the resource
is.getProjectDirectory()public String getProjectDirectory()
getProjectDirectory in class BaseResourceLocator
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||