Package org.codehaus.janino

# Class Unparser

java.lang.Object
org.codehaus.janino.Unparser

All Implemented Interfaces:
  `AutoCloseable`

public class Unparser extends Object implements AutoCloseable
Unparses (un-compiles) an AST to a `Writer`. See `main(String[])` for a usage example.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final PrintWriter`
`pw`
Where the `visit...()` methods print their text.

## Constructor Summary

Constructors
Constructor
Description
`Unparser(Writer w)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Flushes all generated code.
`void`
`flush()`
Flushes all generated code.
`static void`
`main(String[] args)`
Testing of parsing/unparsing.
`static void`
`unparse(Java.AbstractCompilationUnit acu, Writer w)`
Unparses the given `Java.AbstractCompilationUnit` to the given `Writer`.
`void`
`unparseAbstractCompilationUnit(Java.AbstractCompilationUnit cu)`
`void`
`unparseAtom(Java.Atom a)`
`void`
`unparseBlock(Java.Block b)`
Generates Java code from a `Java.Block`.
`void`
`unparseBlockStatement(Java.BlockStatement bs)`
`void`
`unparseClassDeclarationBody(Java.AbstractClassDeclaration cd)`
Generates Java code from a `Java.AbstractClassDeclaration`.
`void`
`unparseImportDeclaration(Java.AbstractCompilationUnit.ImportDeclaration id)`
`void`
`unparseLambdaBody(Java.LambdaBody body)`
`void`
`unparseLambdaParameters(Java.LambdaParameters lp)`
`void`
`unparseLvalue(Java.Lvalue lv)`
`void`
`unparseRvalue(Java.Rvalue rv)`
`void`
`unparseStatements(List<? extends Java.BlockStatement> statements)`
Generates Java code from a sequence of `Java.BlockStatement`s.
`void`
`unparseType(Java.Type t)`
`void`
`unparseTypeDeclaration(Java.TypeDeclaration td)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### pw

protected final PrintWriter pw
Where the `visit...()` methods print their text. Notice that this `PrintWriter` does not print to the output directly, but through an `AutoIndentWriter`.

## Constructor Details

### Unparser

public Unparser(Writer w)

## Method Details

### main

public static void main(String[] args) throws Exception
Testing of parsing/unparsing.

Reads compilation units from the files named on the command line and unparses them to `System.out`.

Throws:
  `Exception`

### unparse

public static void unparse(Java.AbstractCompilationUnit acu, Writer w)
Unparses the given `Java.AbstractCompilationUnit` to the given `Writer`.

### flush

public void flush()
Flushes all generated code.

### close

public void close()
Flushes all generated code.

Specified by:
  `close` in interface `AutoCloseable`

### unparseAbstractCompilationUnit

public void unparseAbstractCompilationUnit(Java.AbstractCompilationUnit cu)

Parameters:
  `cu` - The compilation unit to unparse

### unparseImportDeclaration

public void unparseImportDeclaration(Java.AbstractCompilationUnit.ImportDeclaration id)

### unparseStatements

public void unparseStatements(List<? extends Java.BlockStatement> statements)
Generates Java code from a sequence of `Java.BlockStatement`s.

### unparseLambdaParameters

public void unparseLambdaParameters(Java.LambdaParameters lp)

### unparseLambdaBody

public void unparseLambdaBody(Java.LambdaBody body)

### unparseBlock

public void unparseBlock(Java.Block b)
Generates Java code from a `Java.Block`.

### unparseBlockStatement

public void unparseBlockStatement(Java.BlockStatement bs)

### unparseTypeDeclaration

public void unparseTypeDeclaration(Java.TypeDeclaration td)

### unparseType

public void unparseType(Java.Type t)

### unparseAtom

public void unparseAtom(Java.Atom a)

### unparseRvalue

public void unparseRvalue(Java.Rvalue rv)

### unparseLvalue

public void unparseLvalue(Java.Lvalue lv)

### unparseClassDeclarationBody

public void unparseClassDeclarationBody(Java.AbstractClassDeclaration cd)
Generates Java code from a `Java.AbstractClassDeclaration`.