## com.saxonica.codegen
Class TreatFnCompiler

    java.lang.Object
      com.saxonica.codegen.ExpressionCompiler
          com.saxonica.codegen.SingletonExpressionCompiler
              com.saxonica.codegen.TreatFnCompiler

    public class TreatFnCompiler

extends SingletonExpressionCompiler

Generate Java code to implement the "treat as" functions exactly-one, etc. These functions essentially do nothing other than returning their operands; the work is all done in checking that the arguments are consistent with the function signature.

Constructor Summary
`TreatFnCompiler()`

Method Summary
`void` `compileAsLoop(CompilerService compiler, Expression expr, LoopAction action)` Compile an XPath expression in the form of a loop.
`void` `compilePush(CompilerService compiler, Expression exp)` Generate Java code to execute the expression in push mode, that is, code to write events to the current output Receiver
`java.lang.String` `compileToItem(CompilerService compiler, Expression expr)` Generate Java code to evaluate the expression as an Item
`java.lang.String` `compileToIterator(CompilerService compiler, Expression exp)` Generate Java code to evaluate the expression as a SequenceIterator
`java.lang.String` `compileToValueRepresentation(CompilerService compiler, Expression expr)` Generate Java code to evaluate the expression as a ValueRepresentation

Methods inherited from class com.saxonica.codegen.SingletonExpressionCompiler
`compileToCharSequence, compileToEffectiveBooleanValue`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TreatFnCompiler

    public TreatFnCompiler()

Method Detail

### compileToItem

    public java.lang.String compileToItem(CompilerService compiler,
                                          Expression expr)

  Description copied from class: `ExpressionCompiler`
  Generate Java code to evaluate the expression as an Item

  Specified by:
    `compileToItem` in class `ExpressionCompiler`
  Parameters:
    `compiler` - the compiler service
    `expr` - the expression to be compiled
  Returns:
    a simple Java expression (usually the name of a variable that has been declared) which will be of class `Item`, and which will hold the value of the expression at run-time (or hold null, representing an empty sequence).

### compilePush

    public void compilePush(CompilerService compiler,
                            Expression exp)

  Description copied from class: `ExpressionCompiler`
  Generate Java code to execute the expression in push mode, that is, code to write events to the current output Receiver

  Overrides:
    `compilePush` in class `SingletonExpressionCompiler`
  Parameters:
    `compiler` - the compiler service
    `exp` - the expression to be compiled

### compileToIterator

    public java.lang.String compileToIterator(CompilerService compiler,
                                              Expression exp)

  Description copied from class: `ExpressionCompiler`
  Generate Java code to evaluate the expression as a SequenceIterator

  Overrides:
    `compileToIterator` in class `SingletonExpressionCompiler`
  Parameters:
    `compiler` - the compiler service
    `exp` - the XPath expression to be compiled
  Returns:
    a simple Java expression (usually the name of a variable that has been declared) which will be of class `SequenceIterator`, and which at run-time will hold an iterator over the the value of the XPath expression

### compileAsLoop

    public void compileAsLoop(CompilerService compiler,
                              Expression expr,
                              LoopAction action)

  Description copied from class: `ExpressionCompiler`
  Compile an XPath expression in the form of a loop. This generates Java code that loops over the items in the result of the expression; the body of the loop is constructed by a callback to the supplied LoopAction (which will handle nested expressions)

  Overrides:
    `compileAsLoop` in class `ExpressionCompiler`
  Parameters:
    `compiler` - the CompilerService
    `expr` - the XPath expression to be compiled
    `action` - the action to be taken to compile code that processes each item in the sequence returned by the XPath expression

### compileToValueRepresentation

    public java.lang.String compileToValueRepresentation(CompilerService compiler,
                                                         Expression expr)

  Description copied from class: `ExpressionCompiler`
  Generate Java code to evaluate the expression as a ValueRepresentation

  Overrides:
    `compileToValueRepresentation` in class `ExpressionCompiler`
  Parameters:
    `compiler` - the compiler service
    `expr` - the expression to be compiled
  Returns:
    a simple Java expression (usually the name of a variable that has been declared) which will be of class `ValueRepresentation`, and which at run-time will hold the value of the expression

Copyright (c) Saxonica Limited. All rights reserved.