|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jguiraffe.locators.AbstractLocator
net.sf.jguiraffe.locators.AbstractStreamLocator
net.sf.jguiraffe.locators.ByteArrayLocator
public class ByteArrayLocator
A specialized implementation that provides
access to data stored in memory as a byte array.
Locator
This locator can be initialized either with a byte array or with a string. This data is kept in memory. The locator returns a stream or an URL providing access to exactly this data.
This class is especially useful for providing access to small amounts of data to clients that can deal with locators. It can also be of value for unit tests supporting an easy way of defining test data.
Instances are created using one of the static getInstance()
factory methods. This class is thread-safe and can be used concurrently by
multiple threads. Each invocation of getInputStream() returns a
new stream instance initialized with the data of this locator.
| Method Summary | |
|---|---|
protected java.net.URL |
createURL(java.net.URLStreamHandler streamHandler)
Creates a URL representing the data of this locator. |
boolean |
equals(java.lang.Object obj)
Compares this object with another one. |
java.io.InputStream |
getInputStream()
Returns an input stream for the data of this locator. |
static ByteArrayLocator |
getInstance(byte[] data)
Creates an instance of ByteArrayLocator that is initialized
with the specified data. |
static ByteArrayLocator |
getInstance(java.lang.String data)
Creates an instance of ByteArrayLocator that is initialized
with the data of the specified string. |
int |
hashCode()
Returns a hash code for this object. |
java.lang.String |
toString()
Returns a string representation for this object. |
| Methods inherited from class net.sf.jguiraffe.locators.AbstractStreamLocator |
|---|
getURL |
| Methods inherited from class net.sf.jguiraffe.locators.AbstractLocator |
|---|
getFile |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static ByteArrayLocator getInstance(byte[] data)
ByteArrayLocator that is initialized
with the specified data.
data - the data for the locator (must not be null)
java.lang.IllegalArgumentException - if the data is nullpublic static ByteArrayLocator getInstance(java.lang.String data)
ByteArrayLocator that is initialized
with the data of the specified string.
data - the data for the locator (must not be null)
java.lang.IllegalArgumentException - if the data is null
public java.io.InputStream getInputStream()
throws java.io.IOException
getInputStream in interface LocatorgetInputStream in class AbstractLocatorjava.io.IOException - if an error occurspublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to compare to
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
protected java.net.URL createURL(java.net.URLStreamHandler streamHandler)
throws java.net.MalformedURLException
createURL in class AbstractStreamLocatorstreamHandler - the stream handler to use for this URL
java.net.MalformedURLException - if the URL cannot be created
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||