de.enough.polish.android.helper
Class ResourceInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by de.enough.polish.android.helper.ResourceInputStream
All Implemented Interfaces:
Closeable

public class ResourceInputStream
extends InputStream

Wraps input streams opened with getClass().getResourceAsStream(..).

Author:
Robert Virkus

Constructor Summary
ResourceInputStream(String url, int id, InputStream in)
          Creates a new resource input stream
 
Method Summary
 int available()
           
 void close()
           
 boolean equals(Object o)
           
 int getResourceId()
          Retrieves the ID of the resource within R.java
 String getResourceUrl()
          Retrieves the url or the original resource
 int hashCode()
           
 void mark(int pos)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] buf)
           
 int read(byte[] buf, int offset, int len)
           
 void reset()
           
 long skip(long len)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceInputStream

public ResourceInputStream(String url,
                           int id,
                           InputStream in)
Creates a new resource input stream

Parameters:
url - the URL of the resource
id - the ID of the resource (R.java)
in - the actual input stream
Method Detail

getResourceUrl

public String getResourceUrl()
Retrieves the url or the original resource

Returns:
the resource URL, e.g. /image.png

getResourceId

public int getResourceId()
Retrieves the ID of the resource within R.java

Returns:
the ID of the resource

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

mark

public void mark(int pos)
Overrides:
mark in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

read

public int read(byte[] buf,
                int offset,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buf)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStream
Throws:
IOException

skip

public long skip(long len)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object