com.spinn3r.api.util
Class CompressedBLOB

java.lang.Object
  extended by com.spinn3r.api.util.CompressedBLOB

public class CompressedBLOB
extends java.lang.Object

Facade which allows us to compress and decompress text easily and efficiently from a central location with the correctly library and encodign support.

Version:
$Id: SHA1.java,v 1.9 2005/06/17 18:04:04 burton Exp $
Author:
Kevin Burton

Field Summary
protected  byte[] b
          compressed form of this content.
static int BUFFER_SIZE
           
static int COMPRESSION_RATIO
           
protected  java.lang.String content
          The internal content...
static int DECOMPRESSION_RATIO
           
static int DEFAULT_LEVEL
          Specify the default compression level.
static boolean ENABLE_CACHED_BYTES
           
static java.lang.String ENCODING
          Specifies the type of string encoding to use regardless of whether it's compressed or not.
protected  int external_format
          Specify the default external format used for this content.
static int EXTERNAL_FORMAT
          Specifies the default external format to use for new compressed data.
static int FORMAT_BASE64_ZLIB
           
static int FORMAT_UNKNOWN
           
static int FORMAT_UTF8
           
static int FORMAT_ZLIB
          UTF+ZLIB compression.
protected  java.lang.String lang
           
protected  int level
          Compression level to be used.
 
Constructor Summary
CompressedBLOB(byte[] b)
           
CompressedBLOB(int external_format, java.lang.String v)
           
CompressedBLOB(java.lang.String v)
           
 
Method Summary
 java.lang.String decompress()
          Given the binary data, determine the external form, correctly parse it and return the value as a String.
 byte[] getBytes()
          Take the content we've been given and store it in the correct output format.
static java.io.InputStream getCompressedInputStream(java.io.InputStream is)
          Get the correct stream from the correctly underlying compression library.
 java.io.OutputStream getCompressedOutputStream(java.io.OutputStream os)
          Get the correct stream from the correctly underlying compression library.
 java.lang.String getContent()
           
static int getExternalFormatIdentifier(byte[] b)
          From a byte output stream return the external format revision it's using.
 void setLang(java.lang.String lang)
          Set the lang of the target blog.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENABLE_CACHED_BYTES

public static boolean ENABLE_CACHED_BYTES

FORMAT_UNKNOWN

public static final int FORMAT_UNKNOWN
See Also:
Constant Field Values

FORMAT_UTF8

public static final int FORMAT_UTF8
See Also:
Constant Field Values

FORMAT_BASE64_ZLIB

public static final int FORMAT_BASE64_ZLIB
See Also:
Constant Field Values

FORMAT_ZLIB

public static final int FORMAT_ZLIB
UTF+ZLIB compression.

See Also:
Constant Field Values

EXTERNAL_FORMAT

public static int EXTERNAL_FORMAT
Specifies the default external format to use for new compressed data.


DEFAULT_LEVEL

public static int DEFAULT_LEVEL
Specify the default compression level. See `level` for more information.


ENCODING

public static java.lang.String ENCODING
Specifies the type of string encoding to use regardless of whether it's compressed or not. NOTE. This has to be language specific encoding to use UTF-16 where appropriate.


DECOMPRESSION_RATIO

public static int DECOMPRESSION_RATIO

COMPRESSION_RATIO

public static int COMPRESSION_RATIO

BUFFER_SIZE

public static int BUFFER_SIZE

content

protected java.lang.String content
The internal content...


b

protected byte[] b
compressed form of this content.


lang

protected java.lang.String lang

external_format

protected int external_format
Specify the default external format used for this content.


level

protected int level
Compression level to be used. Levels range from 0 (no compression) to 9 (best compression).

Constructor Detail

CompressedBLOB

public CompressedBLOB(java.lang.String v)

CompressedBLOB

public CompressedBLOB(int external_format,
                      java.lang.String v)

CompressedBLOB

public CompressedBLOB(byte[] b)
Method Detail

setLang

public void setLang(java.lang.String lang)
Set the lang of the target blog. This is used as a hint to enable UTF-16 and potentially UTF-32 for language that are multi-byte. This is a future feature as we can't support this just yet.


getContent

public java.lang.String getContent()
                            throws java.lang.Exception
Throws:
java.lang.Exception

decompress

public java.lang.String decompress()
                            throws java.lang.Exception
Given the binary data, determine the external form, correctly parse it and return the value as a String.

Throws:
java.lang.Exception

getBytes

public byte[] getBytes()
                throws java.lang.Exception
Take the content we've been given and store it in the correct output format.

Throws:
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getCompressedOutputStream

public java.io.OutputStream getCompressedOutputStream(java.io.OutputStream os)
Get the correct stream from the correctly underlying compression library.


getCompressedInputStream

public static java.io.InputStream getCompressedInputStream(java.io.InputStream is)
Get the correct stream from the correctly underlying compression library.


getExternalFormatIdentifier

public static int getExternalFormatIdentifier(byte[] b)
From a byte output stream return the external format revision it's using.



Copyright © Tailrank Inc. All Rights Reserved.