Class URLResourceSource

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

public class URLResourceSource extends Object implements ResourceSource
  • Constructor Details

    • URLResourceSource

      public URLResourceSource()
      Construct a new URLResourceSource. Must set URL separately.
    • URLResourceSource

      public URLResourceSource(URL sourceUrl)
      Construct a new URLResourceSource from a specific URL.
      Parameters:
      sourceUrl - The url to load the resource from. Must not be null. If the URL has a valid URL filename (see URL.getFile()) and an extension (eg. http://url/myFile.png) then the extension (.png in this case) is used as the type.
    • URLResourceSource

      public URLResourceSource(URL sourceUrl, String type)
      Construct a new URLResourceSource from a specific URL and type.
      Parameters:
      sourceUrl - The url to load the resource from. Must not be null.
      type - our type. Usually a file extension such as .png. Required for generic loading when multiple resource handlers could be used.
  • Method Details

    • getRelativeSource

      public ResourceSource getRelativeSource(String name)
      Description copied from interface: ResourceSource
      Generate and return a new ResourceSource pointing to a named resource that is relative to this object's resource.
      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.
    • setURL

      public void setURL(URL url)
    • getURL

      public URL getURL()
    • getName

      public String getName()
      Specified by:
      getName in interface ResourceSource
      Returns:
      the name of this resource.
    • getType

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

      public void setType(String type)
    • openStream

      public InputStream openStream() throws IOException
      Specified by:
      openStream in interface ResourceSource
      Returns:
      an InputStream to this resource's contents.
      Throws:
      IOException - if something wrong occurs while reading
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the string representation of this URLResourceSource.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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