org.opensourcephysics.tools
Class Resource

java.lang.Object
  extended by org.opensourcephysics.tools.Resource

public class Resource
extends java.lang.Object

This represents a resource obtained from a URL or File.

Version:
1.0
Author:
Douglas Brown

Field Summary
protected static java.lang.String encoding
           
 
Constructor Summary
Resource(java.io.File file)
          Constructs a resource from a file.
Resource(java.net.URL url)
          Constructs a resource from a url.
 
Method Summary
 java.lang.String getAbsolutePath()
          Gets the absolute path.
 java.applet.AudioClip getAudioClip()
          Gets an AudioClip.
 java.awt.image.BufferedImage getBufferedImage()
          Gets a buffered image.
 java.io.File getFile()
          Gets the file associated with this resource.
 javax.swing.ImageIcon getIcon()
          Gets an ImageIcon.
 java.awt.Image getImage()
          Gets an Image.
 java.lang.Object getObject(java.lang.Class<?> type)
          Gets an object of the specified type.
 java.lang.String getString()
          Gets a String.
 java.net.URL getURL()
          Gets the url associated with this resource.
 java.io.InputStream openInputStream()
          Opens an InputStream.
 java.io.BufferedReader openReader()
          Opens a BufferedReader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encoding

protected static java.lang.String encoding
Constructor Detail

Resource

public Resource(java.net.URL url)
Constructs a resource from a url.

Parameters:
url - the URL

Resource

public Resource(java.io.File file)
Constructs a resource from a file.

Parameters:
file - the file
Method Detail

getAbsolutePath

public java.lang.String getAbsolutePath()
Gets the absolute path.

Returns:
the absolute path

getURL

public java.net.URL getURL()
Gets the url associated with this resource.

Returns:
the URL

getFile

public java.io.File getFile()
Gets the file associated with this resource.

Returns:
the File

getObject

public java.lang.Object getObject(java.lang.Class<?> type)
Gets an object of the specified type. Currently the only types recognized are String and ImageIcon.

Parameters:
type - the desired class type
Returns:
the object, or null

openInputStream

public java.io.InputStream openInputStream()
Opens an InputStream.

Returns:
the stream

openReader

public java.io.BufferedReader openReader()
Opens a BufferedReader.

Returns:
the reader

getIcon

public javax.swing.ImageIcon getIcon()
Gets an ImageIcon.

Returns:
the icon

getImage

public java.awt.Image getImage()
Gets an Image.

Returns:
the image

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Gets a buffered image.

Returns:
the image

getString

public java.lang.String getString()
Gets a String.

Returns:
the string

getAudioClip

public java.applet.AudioClip getAudioClip()
Gets an AudioClip.

Returns:
the audio clip