1 24 25 package org.objectweb.cjdbc.common.sql.filters; 26 27 import org.objectweb.cjdbc.common.stream.encoding.Base64; 28 import org.objectweb.cjdbc.common.stream.encoding.ZipEncoding; 29 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 30 31 38 public class Base64Filter extends AbstractBlobFilter 39 { 40 41 44 public String encode(byte[] data) 45 { 46 try 47 { 48 return Base64.encode(ZipEncoding.encode(data)); 49 } 50 catch (Exception e) 51 { 52 e.printStackTrace(); 53 return ""; 54 } 55 } 56 57 60 public String encode(String data) 61 { 62 63 return encode(data.getBytes()); 64 } 65 66 69 public byte[] decode(byte[] data) 70 { 71 try 72 { 73 return ZipEncoding.decode(Base64.decode(new String (data))); 74 } 75 catch (Exception e) 76 { 77 e.printStackTrace(); 78 return null; 79 } 80 } 81 82 85 public byte[] decode(String data) 86 { 87 return decode(data.getBytes()); 88 } 89 90 93 public String getXml() 94 { 95 return DatabasesXmlTags.VAL_base64; 96 } 97 98 } | Popular Tags |