com.legstar.coxb.transform
Class AbstractJsonTransformers

java.lang.Object
  extended by com.legstar.coxb.transform.AbstractJsonTransformers
All Implemented Interfaces:
IHostJsonTransformers

public abstract class AbstractJsonTransformers
extends Object
implements IHostJsonTransformers

A generic class that provides transformer capabilities for a given structure.

A structure maps to an XSD and a COBOL structure. This class does not implement the transformers, it acts as a container.

Classes derived from this one will typically implement a constructor that creates the directional transformers, JSON to host and host to JSON.


Constructor Summary
AbstractJsonTransformers()
          No arg constructor.
AbstractJsonTransformers(IJsonToHostTransformer jsonToHost, IHostToJsonTransformer hostToJson)
          Creates a provider with its directional transformers.
 
Method Summary
 IHostToJsonTransformer getHostToJson()
           
 IJsonToHostTransformer getJsonToHost()
           
 void setHostToJson(IHostToJsonTransformer hostToJson)
           
 void setJsonToHost(IJsonToHostTransformer jsonToHost)
           
 byte[] toHost(Reader reader)
          Transforms JSON to host data.
 byte[] toHost(Reader reader, HostTransformStatus status)
          Transforms JSON source to host data.
 byte[] toHost(Reader reader, String hostCharset)
          Transforms JSON to host data with a specific host character set.
 byte[] toHost(Reader reader, String hostCharset, HostTransformStatus status)
          Transforms JSON source to host data with a specific host character set.
 void toJson(byte[] hostData, Writer writer)
          Transforms host data to JSON.
 void toJson(byte[] hostData, Writer writer, HostTransformStatus status)
          Transforms host data to JSON.
 void toJson(byte[] hostData, Writer writer, String hostCharset)
          Transforms host data to JSON with a specific host character set.
 void toJson(byte[] hostData, Writer writer, String hostCharset, HostTransformStatus status)
          Transforms host data to JSON using 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

AbstractJsonTransformers

public AbstractJsonTransformers()
No arg constructor. Caller is responsible for setting the internal transformers.


AbstractJsonTransformers

public AbstractJsonTransformers(IJsonToHostTransformer jsonToHost,
                                IHostToJsonTransformer hostToJson)
Creates a provider with its directional transformers.

Parameters:
jsonToHost - JSON to host transformer
hostToJson - host to JSON transformer
Method Detail

getJsonToHost

public IJsonToHostTransformer getJsonToHost()
Returns:
the transformer that turns a JSON into host data

setJsonToHost

public void setJsonToHost(IJsonToHostTransformer jsonToHost)
Parameters:
jsonToHost - the transformer that turns an JSON into host data to set

getHostToJson

public IHostToJsonTransformer getHostToJson()
Returns:
the transformer that turns host data into an JSON

setHostToJson

public void setHostToJson(IHostToJsonTransformer hostToJson)
Parameters:
hostToJson - the transformer that turns host data into an JSON to set

toHost

public byte[] toHost(Reader reader,
                     String hostCharset)
              throws HostTransformException
Transforms JSON to host data with a specific host character set.

Specified by:
toHost in interface IHostJsonTransformers
Parameters:
reader - the JSON Reader to unmarshal JSON data from
hostCharset - the host character set
Returns:
a byte array with host data
Throws:
HostTransformException - if transformation fails

toHost

public byte[] toHost(Reader reader)
              throws HostTransformException
Transforms JSON to host data.

Specified by:
toHost in interface IHostJsonTransformers
Parameters:
reader - the JSON reader to unmarshal JSON data from
Returns:
a byte array with host data
Throws:
HostTransformException - if transformation fails

toJson

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

Specified by:
toJson in interface IHostJsonTransformers
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

toJson

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

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

toHost

public byte[] toHost(Reader reader,
                     String hostCharset,
                     HostTransformStatus status)
              throws HostTransformException
Transforms JSON source to host data with a specific host character set.

Specified by:
toHost in interface IHostJsonTransformers
Parameters:
reader - the JSON Reader to unmarshal JSON data from
hostCharset - the host character set
status - will contain information on the transformation after it is executed
Returns:
a byte array with host data
Throws:
HostTransformException - if transformation fails

toHost

public byte[] toHost(Reader reader,
                     HostTransformStatus status)
              throws HostTransformException
Transforms JSON source to host data.

Specified by:
toHost in interface IHostJsonTransformers
Parameters:
reader - the JSON Reader to unmarshal JSON data from
status - will contain information on the transformation after it is executed
Returns:
a byte array with host data
Throws:
HostTransformException - if transformation fails

toJson

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

Specified by:
toJson in interface IHostJsonTransformers
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

toJson

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

Specified by:
toJson in interface IHostJsonTransformers
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


Copyright © 2015 LegSem. All Rights Reserved.