|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.container.ByteArrayContainer
public class ByteArrayContainer
This class is a simple container to hold a byte array.
It additionally offers some simple methods to load the byte array from different ways.
| Field Summary | |
|---|---|
static String |
ENCODING_UTF8
|
static Class<? extends ByteArrayContainer> |
implementationForByteArrayContainerClass
Used by the factory method. |
| Constructor Summary | |
|---|---|
ByteArrayContainer()
Default ByteArrayContainer creating an instance with no content. |
|
ByteArrayContainer(byte[] content)
Creates an ByteArrayContainer with a copied byte array content. |
|
ByteArrayContainer(CharSequence charsequence)
|
|
ByteArrayContainer(CharSequence charsequence,
String encoding)
|
|
ByteArrayContainer(String content)
|
|
ByteArrayContainer(String content,
String encoding)
|
|
| Method Summary | |
|---|---|
void |
clear()
Clears the content. |
ByteArrayContainer |
copyFrom(byte[] source)
Copies the content from a byte array into the container. |
ByteArrayContainer |
copyFrom(ByteArrayContainer sourceByteArrayContainer)
Copies the content from another container into this one. |
ByteArrayContainer |
copyFrom(CharSequence charSequence)
Copies the content of a CharSequence into the ByteArrayContainer using the DEFAULTENCODING. |
ByteArrayContainer |
copyFrom(CharSequence charSequence,
String encoding)
Copies the content of a CharSequence into the ByteArrayContainer. |
ByteArrayContainer |
copyFrom(InputStream sourceInputStream)
Copies the content from an InputStream into the ByteArrayContainer without closing the InputStream If the copy operation fails the content of the ByteArrayContainer is set to invalid. |
ByteArrayContainer |
copyFrom(String string)
Copies the content of a String into the container. |
ByteArrayContainer |
copyFrom(String string,
String encoding)
Copies the content of a String into the ByteArrayContainer. |
static ByteArrayContainer |
createNewInstance()
Creates a new instance of this class. |
void |
download(String urlStr)
Downloads the content from the given url resource. |
void |
download(URI uri)
|
void |
download(URL url)
Downloads the content from the given url resource. |
byte[] |
getContent()
|
InputStream |
getInputStream()
|
OutputStream |
getOutputStream()
Returns an outputstream, that allows to write the byte array content directly. |
boolean |
isContentInvalid()
Returns true if a previous operation on the ByteArrayContainer has put the content into a malformed state. |
boolean |
isEmpty()
|
boolean |
isNotEmpty()
|
void |
load(File file)
Loads the content of the given file into the container. |
void |
save(File file)
Saves the content of the ByteArrayContainer to a given File |
ByteArrayContainer |
setContent(byte[] content)
|
void |
setContentInvalid(boolean isContentInvalid)
Sets the content of the ByteArrayContainer to be marked as invalid |
String |
toString()
Transforms the content into a String. |
String |
toString(String encoding)
Transforms the content into a String. |
List<String> |
toStringList()
Returns the content as a list of strings, separated by line feed and/or carriage return. |
List<String> |
toStringList(String encoding)
Returns the content as a list of strings, separated by line feed and/or carriage return. |
List<String> |
toStringList(String encoding,
String regExDelimiter)
Returns the content as a list of strings, separated by an arbitrary regular expression. |
Map<String,ByteArrayContainer> |
unzip()
Converts a zip file content into unzipped content. |
static Map<String,ByteArrayContainer> |
unzipIntoFilenameByteArrayContainerMap(ByteArrayContainer byteArrayContainer)
Unzipps the given ByteArrayContainer object into a map containing the filenames and unzipped ByteArrayContainer objects for each file. |
boolean |
writeTo(Appendable appendable,
String encoding)
Writes the content of the ByteArrayContainer to an Appendable e.g. a StringBuilder or
StringBuffer |
boolean |
writeTo(OutputStream outputStream)
Writes the content of the ByteArrayContainer to a given OutputStream without closing the OutputStream
but flushing the content to it. |
void |
zip()
|
void |
zip(String zipFileName)
Converts the content into a zip file content. |
static ByteArrayContainer |
zipFilenameByteArrayContainerMap(Map<String,ByteArrayContainer> byteArrayContainerMap)
Zipps all ByteArrayContainers of a given map, which contains filenames with corresponding unzipped ByteArrayContainer objects. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String ENCODING_UTF8
public static Class<? extends ByteArrayContainer> implementationForByteArrayContainerClass
createNewInstance()| Constructor Detail |
|---|
public ByteArrayContainer()
ByteArrayContainer creating an instance with no content.
public ByteArrayContainer(byte[] content)
ByteArrayContainer with a copied byte array content.
content - copyFrom(byte[])public ByteArrayContainer(String content)
content - copyFrom(String)
public ByteArrayContainer(String content,
String encoding)
content - copyFrom(String, String)
public ByteArrayContainer(CharSequence charsequence,
String encoding)
charsequence - copyFrom(CharSequence)public ByteArrayContainer(CharSequence charsequence)
charsequence - copyFrom(CharSequence)| Method Detail |
|---|
public boolean isEmpty()
isNotEmpty()public boolean isNotEmpty()
isEmpty()public void download(URI uri)
uri - download(URL)public void download(URL url)
url - download(URI),
#download(String))public void download(String urlStr)
urlStr - download(URI),
download(URL)
public void load(File file)
throws IOException
file -
IOException
public void save(File file)
throws IOException
ByteArrayContainer to a given File
file -
IOExceptionpublic ByteArrayContainer copyFrom(ByteArrayContainer sourceByteArrayContainer)
sourceByteArrayContainer -
public ByteArrayContainer copyFrom(InputStream sourceInputStream)
InputStream into the ByteArrayContainer without closing the InputStream ByteArrayContainer is set to invalid.
sourceInputStream -
isContentInvalid()
public ByteArrayContainer copyFrom(String string,
String encoding)
String into the ByteArrayContainer. ByteArrayContainer is set to invalid.
string - encoding -
isContentInvalid()public ByteArrayContainer copyFrom(String string)
string -
public ByteArrayContainer copyFrom(CharSequence charSequence)
CharSequence into the ByteArrayContainer using the DEFAULTENCODING.
charSequence -
public ByteArrayContainer copyFrom(CharSequence charSequence,
String encoding)
CharSequence into the ByteArrayContainer.
charSequence - encoding -
public ByteArrayContainer copyFrom(byte[] source)
source -
public String toString()
toString in class ObjecttoString(String)public String toString(String encoding)
encoding - specifies the encoding of the binary data. Example: "utf-8"
toString()public List<String> toStringList()
public List<String> toStringList(String encoding)
encoding - : for example = "utf-8"
public List<String> toStringList(String encoding,
String regExDelimiter)
encoding - : for example = "utf-8"
ENCODING_UTF8
public boolean writeTo(Appendable appendable,
String encoding)
ByteArrayContainer to an Appendable e.g. a StringBuilder or
StringBuffer
appendable - encoding -
public boolean writeTo(OutputStream outputStream)
ByteArrayContainer to a given OutputStream without closing the OutputStream
but flushing the content to it.
outputStream -
public void clear()
public byte[] getContent()
public ByteArrayContainer setContent(byte[] content)
public InputStream getInputStream()
public OutputStream getOutputStream()
public void zip(String zipFileName)
public void zip()
zip(String)public static ByteArrayContainer zipFilenameByteArrayContainerMap(Map<String,ByteArrayContainer> byteArrayContainerMap)
byteArrayContainerMap - public Map<String,ByteArrayContainer> unzip()
unzipIntoFilenameByteArrayContainerMap(ByteArrayContainer)public static Map<String,ByteArrayContainer> unzipIntoFilenameByteArrayContainerMap(ByteArrayContainer byteArrayContainer)
byteArrayContainer -
public static ByteArrayContainer createNewInstance()
implementationForByteArrayContainerClasspublic boolean isContentInvalid()
ByteArrayContainer has put the content into a malformed state.
copyFrom(InputStream),
copyFrom(String)public void setContentInvalid(boolean isContentInvalid)
ByteArrayContainer to be marked as invalid
isContentInvalid -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||