KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > sql > filters > AbstractBlobFilter


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk
22  * Contributor(s): Emmanuel Cecchet.
23  */

24
25 package org.objectweb.cjdbc.common.sql.filters;
26
27 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags;
28
29 /**
30  * This class defines a BlobFilterInterface. All implementing interface should
31  * satisfy the following: - Implementation is not dependant of the database -
32  * decode(encode(data)) = data
33  *
34  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
35  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.fr">Emmanuel Cecchet
36  * </a>
37  * @version 1.0
38  */

39 public abstract class AbstractBlobFilter
40 {
41
42   /**
43    * Get an instance of an <code>AbstractBlobFilter</code> given the
44    * blobEndodingMethod description. Currently supported are: <br>
45    * <code>hexa</code><br>
46    * <code>none</code><br>
47    * <code>escaped</code><br>
48    * If the parameter specified is not appropriate then a
49    * <code>NoneBlobFilter</code> instance is returned.
50    *
51    * @param blobEncodingMethod the string description
52    * @return <code>AbstractBlobFilter</code> instance
53    */

54   public static AbstractBlobFilter getBlobFilterInstance(
55       String JavaDoc blobEncodingMethod)
56   {
57     if (blobEncodingMethod.equals(DatabasesXmlTags.VAL_hexa))
58       return new HexaBlobFilter();
59     else if (blobEncodingMethod.equals(DatabasesXmlTags.VAL_escaped))
60       return new BlobEscapedFilter();
61     else if (blobEncodingMethod.equals(DatabasesXmlTags.VAL_base64))
62       return new Base64Filter();
63     else
64       return new NoneBlobFilter();
65   }
66
67   /**
68    * Encode the blob data in a form that is independant of the database.
69    *
70    * @param data the byte array to convert
71    * @return <code>String</code> object is returned for convenience as this is
72    * the way it is going to be handled afterwards.
73    */

74   public abstract String JavaDoc encode(byte[] data);
75
76   /**
77    * Encode the blob data in a form that is independant of the database.
78    *
79    * @param data the byte array to convert
80    * @return <code>String</code> object is returned for convenience as this is
81    * the way it is going to be handled afterwards.
82    */

83   public abstract String JavaDoc encode(String JavaDoc data);
84
85   /**
86    * Decode the blob data from the database. This must done in a database
87    * independant manner.
88    *
89    * @param data the data to decode
90    * @return <code>byte[]</code> decoded byte array of data
91    */

92   public abstract byte[] decode(byte[] data);
93
94   /**
95    * Decode the blob data from the database. This must done in a database
96    * independant manner.
97    *
98    * @param data the data to decode
99    * @return <code>byte[]</code> decoded byte array of data
100    */

101   public abstract byte[] decode(String JavaDoc data);
102
103   /**
104    * Get the XML attribute value of the filter as defined in the DTD.
105    *
106    * @return XML attribute value
107    */

108   public abstract String JavaDoc getXml();
109 }
Popular Tags