Class StringResourceSource

java.lang.Object
com.ardor3d.util.resource.StringResourceSource
All Implemented Interfaces:
Savable, ResourceSource

public class StringResourceSource extends Object implements ResourceSource
ResourceSource that pulls its content from a String. This source type does not support relative sources.
  • Constructor Details

    • StringResourceSource

      public StringResourceSource(String data)
      Construct a new StringResourceSource.
      Parameters:
      data - the data this source should return.
    • StringResourceSource

      public StringResourceSource(String data, String type)
      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

      public String getName()
      Returns "string resource" as strings have no name.
      Specified by:
      getName in interface ResourceSource
      Returns:
      the name of this resource.
    • getRelativeSource

      public ResourceSource getRelativeSource(String name)
      Returns null and logs a warning as this is not supported.
      Specified by:
      getRelativeSource in interface ResourceSource
      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

      public String getType()
      Specified by:
      getType in interface ResourceSource
      Returns:
      the "type" of resource we are pointing to. For example ".jpg", ".dae", etc.
    • openStream

      public InputStream openStream() throws IOException
      Grabs our data as a UTF8 byte array and returns it in a ByteArrayInputStream.
      Specified by:
      openStream in interface ResourceSource
      Returns:
      an InputStream to this resource's contents.
      Throws:
      IOException - if something wrong occurs while reading
    • getClassTag

      public Class<?> getClassTag()
      Specified by:
      getClassTag in interface Savable
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException