org.antforge.waqlpp.core
Interface DataPrinter


public interface DataPrinter

A data printer is used to convert content objects into a textual representation during data dependency resolving. There are predefined printers available for the most common object types, but additional ones implementing this interface can be used. Those printers will be chained to form a printer pipeline. The first one able to handle a given object will be called to do the actual conversion. The last printer in the chain should be a default printer which can handle any Object to ensure conversion is possible for all types.

Author:
Michael Starzinger

Method Summary
 boolean canHandle(java.lang.Object object)
          Checks whether the given content object can be handled by this data printer.
 java.lang.String printAsExpression(java.lang.Object object, DataPrinter pipeline)
          Converts the given content object into a textual representation when used as an expression.
 java.lang.String printAsText(java.lang.Object object, DataPrinter pipeline)
          Converts the given content object into a textual representation when used as text.
 

Method Detail

canHandle

boolean canHandle(java.lang.Object object)
Checks whether the given content object can be handled by this data printer. In most cases an instanceof statement will be used to check for a specific object type.

Parameters:
object - The object which should be converted.
Returns:
The boolean value indicating whether the given object can be handled by this data printer.

printAsExpression

java.lang.String printAsExpression(java.lang.Object object,
                                   DataPrinter pipeline)
Converts the given content object into a textual representation when used as an expression. Used when the data dependency is stated as a XQuery expression like in this example:

let $var := ${//anypath} return <test>{$var}</test>

Parameters:
object - The object which should be converted.
pipeline - The top of the printer pipeline. Useful for recursive types like collections or arrays.
Returns:
The textual representation of the given object.

printAsText

java.lang.String printAsText(java.lang.Object object,
                             DataPrinter pipeline)
Converts the given content object into a textual representation when used as text. Used when the data dependency is stated as actual content of a XQuery direct constructor like in this example:

<test>${//anypath}</test>

Parameters:
object - The object which should be converted.
pipeline - The top of the printer pipeline. Useful for recursive types like collections or arrays.
Returns:
The textual representation of the given object.