public Externalizable transform(OMElement source, TransformationContext context) { try { String value = source.getText(); ByteArrayInputStream bis = new ByteArrayInputStream(Base64Binary.decode(value)); ObjectInputStream ois = new ObjectInputStream(bis); Object obj = ois.readObject(); ois.close(); Externalizable aReference = (Externalizable) obj; return aReference; } catch (Exception e) { throw new TransformationException(e); } }
public OMElement transform(Externalizable source, TransformationContext context) { OMElement element = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos); out.writeObject(source); out.close(); OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = AxiomHelper.createOMNamespace(factory, new QName("http://callable")); element = factory.createOMElement("reference",ns); element.setText(Base64Binary.encode(bos.toByteArray())); return element; } catch (Exception e) { throw new TransformationException(e); } }
/** * */ public static byte[] decode(String data) { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[data.length() / 4 * 3 + 3]; int obufcount = 0; for (int i = 0; i < data.length(); i++) { char ch = data.charAt(i); if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; obufcount += decode0(ibuf, obuf, obufcount); } } } if (obufcount == obuf.length) { return obuf; } byte[] ret = new byte[obufcount]; System.arraycopy(obuf, 0, ret, 0, obufcount); return ret; }
/** * */ public static byte[] decode(char[] data, int off, int len) { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[len / 4 * 3 + 3]; int obufcount = 0; for (int i = off; i < off + len; i++) { char ch = data[i]; if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; obufcount += decode0(ibuf, obuf, obufcount); } } } if (obufcount == obuf.length) { return obuf; } byte[] ret = new byte[obufcount]; System.arraycopy(obuf, 0, ret, 0, obufcount); return ret; }
/** * */ public static byte[] decode(char[] data, int off, int len) { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[len / 4 * 3 + 3]; int obufcount = 0; for (int i = off; i < off + len; i++) { char ch = data[i]; if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; obufcount += decode0(ibuf, obuf, obufcount); } } } if (obufcount == obuf.length) { return obuf; } byte[] ret = new byte[obufcount]; System.arraycopy(obuf, 0, ret, 0, obufcount); return ret; }
/** * */ public static byte[] decode(String data) { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[data.length() / 4 * 3 + 3]; int obufcount = 0; for (int i = 0; i < data.length(); i++) { char ch = data.charAt(i); if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; obufcount += decode0(ibuf, obuf, obufcount); } } } if (obufcount == obuf.length) { return obuf; } byte[] ret = new byte[obufcount]; System.arraycopy(obuf, 0, ret, 0, obufcount); return ret; }
/** * */ public static void decode(String data, OutputStream ostream) throws IOException { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[3]; for (int i = 0; i < data.length(); i++) { char ch = data.charAt(i); if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; int obufcount = decode0(ibuf, obuf, 0); ostream.write(obuf, 0, obufcount); } } } }
/** * */ public static void decode(String data, OutputStream ostream) throws IOException { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[3]; for (int i = 0; i < data.length(); i++) { char ch = data.charAt(i); if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; int obufcount = decode0(ibuf, obuf, 0); ostream.write(obuf, 0, obufcount); } } } }
/** * */ public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[3]; for (int i = off; i < off + len; i++) { char ch = data[i]; if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; int obufcount = decode0(ibuf, obuf, 0); ostream.write(obuf, 0, obufcount); } } } }
/** * */ public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException { char[] ibuf = new char[4]; int ibufcount = 0; byte[] obuf = new byte[3]; for (int i = off; i < off + len; i++) { char ch = data[i]; if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { ibuf[ibufcount++] = ch; if (ibufcount == ibuf.length) { ibufcount = 0; int obufcount = decode0(ibuf, obuf, 0); ostream.write(obuf, 0, obufcount); } } } }
public String printBase64Binary(byte[] value) { return Base64Binary.encode(value); }
public byte[] parseBase64Binary(String value) { return Base64Binary.decode(value); }
public byte[] parseBase64Binary(String value) { return Base64Binary.decode(value); }
public String printBase64Binary(byte[] value) { return Base64Binary.encode(value); }
/** * Returns base64 representation of specified byte array. */ public static String encode(byte[] data) { return encode(data, 0, data.length); }
/** * Returns base64 representation of specified byte array. */ public static String encode(byte[] data) { return encode(data, 0, data.length); }