Package org.javarosa.core.reference
Class ResourceReference
java.lang.Object
org.javarosa.core.reference.ResourceReference
- All Implemented Interfaces:
Reference
public class ResourceReference extends Object implements Reference
A Resource Reference is a reference to a file which
is a Java Resource, which is accessible with the
'getResourceAsStream' method from the Java Classloader.
Resource References are read only, and can identify with
certainty whether a binary file is located at them.
- Author:
- ctsims
-
Constructor Summary
Constructors Constructor Description ResourceReference(String URI)Creates a new resource reference with URI in the format of a fully global resource URI, IE: "/path/file.ext". -
Method Summary
Modifier and Type Method Description booleandoesBinaryExist()booleanequals(Object o)StringgetLocalURI()OutputStreamgetOutputStream()InputStreamgetStream()StringgetURI()booleanisReadOnly()Reference[]probeAlternativeReferences()Determines any platform-specific and reference-type specific alternatives versions of this reference which may exist.voidremove()Removes the binary data located by this reference.
-
Constructor Details
-
ResourceReference
Creates a new resource reference with URI in the format of a fully global resource URI, IE: "/path/file.ext".- Parameters:
URI-
-
-
Method Details
-
doesBinaryExist
- Specified by:
doesBinaryExistin interfaceReference- Returns:
- True if the binary does (or might) exist at the remote location. False if the binary definitely does not exist.
- Throws:
IOException- If there is a problem identifying the status of the resource
-
getStream
- Specified by:
getStreamin interfaceReference- Returns:
- A Stream of data which is the binary resource's definition.
- Throws:
IOException- If there is a problem reading the stream.
-
getURI
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceReference- Returns:
- True if the remote data is only available to be read from (using getStream), False if the remote data can also be modified or written to.
-
equals
-
getOutputStream
- Specified by:
getOutputStreamin interfaceReference- Returns:
- A stream which can be written to at the reference location to define the binary content there.
- Throws:
IOException- If there is a problem writing or the reference is read only
-
remove
Description copied from interface:ReferenceRemoves the binary data located by this reference.- Specified by:
removein interfaceReference- Throws:
IOException- If there is a problem deleting or the reference is read only
-
getLocalURI
- Specified by:
getLocalURIin interfaceReference- Returns:
- A URI which may or may not exist in the local context which will resolves to this reference. This method should be used with caution: There is no guarantee that a local URI can be constructed or used in a general way.
-
probeAlternativeReferences
Description copied from interface:ReferenceDetermines any platform-specific and reference-type specific alternatives versions of this reference which may exist. Useful when only certain media or references are available on a platform and you need to figure out whether a platform-specific version might be present. NOTE: There is no guarantee that returned references will exist, they should be tested.- Specified by:
probeAlternativeReferencesin interfaceReference
-