com.legstar.coxb.transform
Class AbstractHostToJsonTransformer

java.lang.Object
  extended by com.legstar.coxb.transform.AbstractHostToJsonTransformer
All Implemented Interfaces:
IHostToJsonTransformer

public abstract class AbstractHostToJsonTransformer
extends Object
implements IHostToJsonTransformer

Generic methods to transform host data to JSON.


Constructor Summary
AbstractHostToJsonTransformer(IHostToJavaTransformer hostToJavaTransformer)
          Create an Host to JSON transformer using a Host to Java transformer.
 
Method Summary
 IHostToJavaTransformer getHostToJavaTransformer()
           
 void getJsonFromObject(Object valueObject, Writer writer)
          Marshal JAXB value object to get the JSON.
 void transform(byte[] hostData, int offset, Writer writer)
          Transforms host data to JSON.
 void transform(byte[] hostData, int offset, Writer writer, HostTransformStatus status)
          Transforms host data to JSON.
 void transform(byte[] hostData, int offset, Writer writer, String hostCharset)
          Transforms host data to JSON with a specific host character set.
 void transform(byte[] hostData, int offset, Writer writer, String hostCharset, HostTransformStatus status)
          Transforms host data to JSON with a specific host character set.
 void transform(byte[] hostData, Writer writer)
          Transforms host data to JSON.
 void transform(byte[] hostData, Writer writer, HostTransformStatus status)
          Transforms host data to JSON.
 void transform(byte[] hostData, Writer writer, String hostCharset)
          Transforms host data to JSON with a specific host character set.
 void transform(byte[] hostData, Writer writer, String hostCharset, HostTransformStatus status)
          Transforms host data to JSON with a specific host character set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHostToJsonTransformer

public AbstractHostToJsonTransformer(IHostToJavaTransformer hostToJavaTransformer)
                              throws HostTransformException
Create an Host to JSON transformer using a Host to Java transformer.

Parameters:
hostToJavaTransformer - the host to java transformer
Throws:
HostTransformException - if transformer cannot be created
Method Detail

transform

public void transform(byte[] hostData,
                      int offset,
                      Writer writer,
                      String hostCharset,
                      HostTransformStatus status)
               throws HostTransformException
Transforms host data to JSON with a specific host character set.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
offset - index of first byte to process in hostData
writer - JSON will be sent to this writer.
hostCharset - the host character set
status - will contain information on the transformation after it is executed
Throws:
HostTransformException - if transformation fails

transform

public void transform(byte[] hostData,
                      int offset,
                      Writer writer,
                      String hostCharset)
               throws HostTransformException
Transforms host data to JSON with a specific host character set.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
offset - index of first byte to process in hostData
writer - JSON will be sent to this writer.
hostCharset - the host character set
Throws:
HostTransformException - if transformation fails

transform

public void transform(byte[] hostData,
                      Writer writer,
                      String hostCharset)
               throws HostTransformException
Transforms host data to JSON with a specific host character set.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
writer - JSON will be sent to this writer.
hostCharset - the host character set
Throws:
HostTransformException - if transformation fails

transform

public void transform(byte[] hostData,
                      Writer writer)
               throws HostTransformException
Transforms host data to JSON.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
writer - JSON will be sent to this writer.
Throws:
HostTransformException - if transformation fails

transform

public void transform(byte[] hostData,
                      int offset,
                      Writer writer)
               throws HostTransformException
Transforms host data to JSON.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
offset - index of first byte to process in hostData
writer - JSON will be sent to this writer.
Throws:
HostTransformException - if transformation fails

transform

public void transform(byte[] hostData,
                      Writer writer,
                      String hostCharset,
                      HostTransformStatus status)
               throws HostTransformException
Transforms host data to JSON with a specific host character set.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
writer - JSON will be sent to this writer.
hostCharset - the host character set
status - will contain information on the transformation after it is executed
Throws:
HostTransformException - if transformation fails

transform

public void transform(byte[] hostData,
                      Writer writer,
                      HostTransformStatus status)
               throws HostTransformException
Transforms host data to JSON.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
writer - JSON will be sent to this writer.
status - will contain information on the transformation after it is executed
Throws:
HostTransformException - if transformation fails

transform

public void transform(byte[] hostData,
                      int offset,
                      Writer writer,
                      HostTransformStatus status)
               throws HostTransformException
Transforms host data to JSON.

Specified by:
transform in interface IHostToJsonTransformer
Parameters:
hostData - a byte array containing host data
offset - index of first byte to process in hostData
writer - JSON will be sent to this writer.
status - will contain information on the transformation after it is executed
Throws:
HostTransformException - if transformation fails

getJsonFromObject

public void getJsonFromObject(Object valueObject,
                              Writer writer)
                       throws HostTransformException
Marshal JAXB value object to get the JSON.

Root elements can be marshalled directly while non-root elements must be encapsulated in a JAXBElement before they can be marshalled.

Parameters:
valueObject - the JAXB value object
writer - JSON will be sent to this writer.
Throws:
HostTransformException - if transformation fails

getHostToJavaTransformer

public IHostToJavaTransformer getHostToJavaTransformer()
Returns:
the Host to Java transformer


Copyright © 2015 LegSem. All Rights Reserved.