Package com.ardor3d.util.resource
Class StringResourceSource
java.lang.Object
com.ardor3d.util.resource.StringResourceSource
- All Implemented Interfaces:
Savable
,ResourceSource
ResourceSource that pulls its content from a String. This source type does not support relative sources.
-
Field Summary
Fields inherited from interface com.ardor3d.util.resource.ResourceSource
UNKNOWN_TYPE
-
Constructor Summary
ConstructorDescriptionStringResourceSource
(String data) Construct a new StringResourceSource.StringResourceSource
(String data, String type) Construct a new StringResourceSource. -
Method Summary
Modifier and TypeMethodDescriptionClass
<?> getName()
Returns "string resource" as strings have no name.getRelativeSource
(String name) Returns null and logs a warning as this is not supported.getType()
Grabs our data as a UTF8 byte array and returns it in a ByteArrayInputStream.void
read
(InputCapsule capsule) void
write
(OutputCapsule capsule)
-
Constructor Details
-
StringResourceSource
Construct a new StringResourceSource.- Parameters:
data
- the data this source should return.
-
StringResourceSource
Construct a new StringResourceSource.- Parameters:
data
- the data this source should return.type
- the type for this source. Usually a file extension such as .txt or .js. Required for generic loading when multiple resource handlers could be used.
-
-
Method Details
-
getName
Returns "string resource" as strings have no name.- Specified by:
getName
in interfaceResourceSource
- Returns:
- the name of this resource.
-
getRelativeSource
Returns null and logs a warning as this is not supported.- Specified by:
getRelativeSource
in interfaceResourceSource
- Parameters:
name
- the name of the resource we want. eg. "./mypic.jpg" etc.- Returns:
- the relative resource, or null if none is found. Will also return null if this ResourceSource type does not support relative source.
-
getType
- Specified by:
getType
in interfaceResourceSource
- Returns:
- the "type" of resource we are pointing to. For example ".jpg", ".dae", etc.
-
openStream
Grabs our data as a UTF8 byte array and returns it in a ByteArrayInputStream.- Specified by:
openStream
in interfaceResourceSource
- Returns:
- an InputStream to this resource's contents.
- Throws:
IOException
- if something wrong occurs while reading
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-