org.objectweb.cjdbc.common.sql.filters
Class BlobEscapedFilter

java.lang.Object
  extended byorg.objectweb.cjdbc.common.sql.filters.AbstractBlobFilter
      extended byorg.objectweb.cjdbc.common.sql.filters.BlobEscapedFilter

public class BlobEscapedFilter
extends AbstractBlobFilter

This class defines a BlobEscapedFilter. It acts just the same as the NoneBlobFilter except that the content is escaped to prevent strange characters for disturbing the data. This has been adapted mainly for PostgreSQL bytea data, but it should be usable for any other database.

Version:
1.0
Author:
Silvan Eugen Lincan

Constructor Summary
BlobEscapedFilter()
           
 
Method Summary
 byte[] decode(byte[] data)
          Decode the blob data from the database.
 byte[] decode(java.lang.String data)
          Decode the blob data from the database.
 java.lang.String encode(byte[] data)
          Encode the blob data in a form that is independant of the database.
 java.lang.String encode(java.lang.String data)
          Encode the blob data in a form that is independant of the database.
 java.lang.String getXml()
          Get the XML attribute value of the filter as defined in the DTD.
static byte[] toBytes(byte[] s)
          Converts a PG bytea raw value (i.e. the raw binary representation of the bytea data type) into a java byte[].
static java.lang.String toPGString(byte[] postgresBuf)
          Converts a java byte[] into a PG bytea string (i.e. the text representation of the bytea data type).
 
Methods inherited from class org.objectweb.cjdbc.common.sql.filters.AbstractBlobFilter
getBlobFilterInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlobEscapedFilter

public BlobEscapedFilter()
Method Detail

encode

public java.lang.String encode(byte[] data)
Description copied from class: AbstractBlobFilter
Encode the blob data in a form that is independant of the database.

Specified by:
encode in class AbstractBlobFilter
Parameters:
data - the byte array to convert
Returns:
String object is returned for convenience as this is the way it is going to be handled afterwards.
See Also:
AbstractBlobFilter.encode(byte[])

encode

public java.lang.String encode(java.lang.String data)
Description copied from class: AbstractBlobFilter
Encode the blob data in a form that is independant of the database.

Specified by:
encode in class AbstractBlobFilter
Parameters:
data - the byte array to convert
Returns:
String object is returned for convenience as this is the way it is going to be handled afterwards.
See Also:
AbstractBlobFilter.encode(java.lang.String)

decode

public byte[] decode(byte[] data)
Description copied from class: AbstractBlobFilter
Decode the blob data from the database. This must done in a database independant manner.

Specified by:
decode in class AbstractBlobFilter
Parameters:
data - the data to decode
Returns:
byte[] decoded byte array of data
See Also:
AbstractBlobFilter.decode(byte[])

decode

public byte[] decode(java.lang.String data)
Description copied from class: AbstractBlobFilter
Decode the blob data from the database. This must done in a database independant manner.

Specified by:
decode in class AbstractBlobFilter
Parameters:
data - the data to decode
Returns:
byte[] decoded byte array of data
See Also:
AbstractBlobFilter.decode(java.lang.String)

getXml

public java.lang.String getXml()
Description copied from class: AbstractBlobFilter
Get the XML attribute value of the filter as defined in the DTD.

Specified by:
getXml in class AbstractBlobFilter
Returns:
XML attribute value
See Also:
AbstractBlobFilter.getXml()

toPGString

public static java.lang.String toPGString(byte[] postgresBuf)
Converts a java byte[] into a PG bytea string (i.e. the text representation of the bytea data type). Escape characters between 32 and 126.

Parameters:
postgresBuf - The byte array to be converted
Returns:
the string representation

toBytes

public static byte[] toBytes(byte[] s)
Converts a PG bytea raw value (i.e. the raw binary representation of the bytea data type) into a java byte[].

Parameters:
s - The byte array to be converted.
Returns:
an java byte[]


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.