View Javadoc

    1   package org.codehaus.xfire.aegis.type.basic;
    2
    3   import org.codehaus.xfire.MessageContext;
    4   import org.codehaus.xfire.aegis.MessageReader;
    5   import org.codehaus.xfire.aegis.MessageWriter;
    6   import org.codehaus.xfire.aegis.type.Type;
    7   import org.codehaus.xfire.fault.XFireFault;
    8   import org.codehaus.xfire.util.Base64;
    9
    10  /***
    11   * Converts back and forth to byte[] objects.
    12   *
    13   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    14   */
    15  public class Base64Type
    16      extends Type
    17  {
    18      public Object readObject(MessageReader reader, MessageContext context)
    19          throws XFireFault
    20      {
    21          return Base64.decode(reader.getValue());
    22      }
    23
    24      public void writeObject(Object object, MessageWriter writer, MessageContext context)
    25          throws XFireFault
    26      {
    27          byte[] data = (byte[]) object;
    28
    29          writer.writeValue( Base64.encode(data, 0, data.length) );
    30      }
    31  }