org.weborganic.aeson
Class JSONResult

java.lang.Object
  extended by javax.xml.transform.sax.SAXResult
      extended by org.weborganic.aeson.JSONResult
All Implemented Interfaces:
Result

public class JSONResult
extends SAXResult
implements Result

A Result implementation automatically writing out JSON.

Version:
17 November 2013
Author:
Christophe Lauret
See Also:
The application/json Media Type for JavaScript Object Notation (JSON)

Field Summary
 
Fields inherited from class javax.xml.transform.sax.SAXResult
FEATURE
 
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
 
Constructor Summary
JSONResult()
          Zero-argument default constructor.
JSONResult(OutputStream out)
          Construct a JSONResult from a byte stream.
JSONResult(Writer writer)
          Construct a JSONResult from a character stream.
 
Method Summary
static JSONResult newInstance(StreamResult result)
          Returns a new instance from the specified stream result.
static Result newInstanceIfSupported(Transformer t, StreamResult result)
          Returns a new instance of the
static boolean supports(Transformer t)
          Indicates whether the specified transformer based on its output properties.
 
Methods inherited from class javax.xml.transform.sax.SAXResult
getHandler, getLexicalHandler, getSystemId, setHandler, setLexicalHandler, setSystemId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.transform.Result
getSystemId, setSystemId
 

Constructor Detail

JSONResult

public JSONResult()
Zero-argument default constructor.

transformation results will go to System.out.


JSONResult

public JSONResult(OutputStream out)
Construct a JSONResult from a byte stream.

Parameters:
out - A valid OutputStream.

JSONResult

public JSONResult(Writer writer)
Construct a JSONResult from a character stream.

It is generally preferable to use a byte stream so that the encoding can controlled by the xsl:output declaration; but can be convenient when using StringWriter

Parameters:
writer - A valid character stream.
Method Detail

newInstanceIfSupported

public static Result newInstanceIfSupported(Transformer t,
                                            StreamResult result)
Returns a new instance of the

Parameters:
t -
Returns:

newInstance

public static JSONResult newInstance(StreamResult result)
Returns a new instance from the specified stream result.

Parameters:
result - a non-null stream result instance.
Returns:
a new JSONResult instance using the same properties as the stream result.

supports

public static boolean supports(Transformer t)
Indicates whether the specified transformer based on its output properties.

the transformer is considered to support this Result type if it uses the "xml" method and specifies the media type as "application/json".

Parameters:
t - the XSLT transformer implementation
Returns:
true if it matches the conditions above; false otherwise.