# Class: com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink

This output sink is the recipient for the generation of a decompiled Java Abstract Syntax Tree \(AST\). The sink also contains configuration elements that will guide how certain AST elements are generated. Typically, a sink receives the output for a class or a method element. 

 Generating an AST yields a special type of elements, called items, that a client \(such as the decompiler UI\) may want to track to achieve higher level purpose such as xrefs building, renaming, easy syntax coloring, etc. Items include keywords, class/field/method/variable names, labels, etc. The type of items generated depends on the item factory provided to JavaOutputSink constructors.

## Constructor: JavaOutputSink
- parameter: `baseAnchorId`, type: `int`

Description: Create an output sink.
parameter: baseAnchorId: base anchor identifier

## Constructor: JavaOutputSink
- parameter: `baseAnchorId`, type: `int`
- parameter: `doc`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaDocument`
- parameter: `dexdec`, type: `com.pnfsoftware.jeb.core.units.code.android.IDexDecompilerUnit`

Description: Create an output sink for a Java document.
parameter: baseAnchorId: base anchor identifier
parameter: doc: Java document, or null
parameter: dexdec: dex decompiler, or null

## Method: addGeneratedAnon
- parameter: `container`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- parameter: `c`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaClass`

Description: Register an anonymous type \(most likely a class\) that's about to be rendered as inline code, inside a method or another class. We use this multi\-map to track anonymous types that were actually rendered, and those that were not. That can happen in obfuscated files where anonymous inner classes are used by third\-party \(not the container\) classes only.
parameter: container: method or class
parameter: c: an anonymous that's about to be generated \(recorded to avoid generated it later\)

## Method: appendAnnotationsList
- parameter: `annotations`, type: `java.util.List<com.pnfsoftware.jeb.core.units.code.java.IJavaAnnotation>`
- parameter: `charAfterAnno`, type: `char`

Description: Append annotations.
parameter: annotations: annotations to append
parameter: charAfterAnno: character to append after each annotation

## Method: appendAnnotationsList
- parameter: `annotations`, type: `java.util.List<com.pnfsoftware.jeb.core.units.code.java.IJavaAnnotation>`
- parameter: `charAfterAnno`, type: `char`
- parameter: `skiplist`, type: `java.util.Set<java.lang.String>`

Description: Append annotations, skipping selected annotation types.
parameter: annotations: annotations to append
parameter: charAfterAnno: character to append after each annotation
parameter: skiplist: type signatures to skip, or null

## Method: appendKeyword
- parameter: `keyword`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaKeyword`

Description: Append a Java keyword.
parameter: keyword: keyword to append

## Method: appendKeyword
- parameter: `keyword`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaKeyword`
- parameter: `itemId`, type: `long`

Description: Append a Java keyword with an item identifier.
parameter: keyword: keyword to append
parameter: itemId: item identifier

## Method: astDepth
- return type: `int`

Description: Retrieve the current AST generation depth.
return: AST stack depth

## Method: astParent
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`

Description: Make sure to call before `generateEnter`.
return: the parent of the element AST about to be rendered or null if there is none or none         can be found

## Method: astPop
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`

Description: Pop the current AST element from the generation stack.
return: popped AST element

## Method: astPush
- parameter: `elt`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`

Description: Push an AST element on the generation stack.
parameter: elt: AST element
return: previous parent element, or null

## Method: doneGeneratingReplacement

Description: Mark replacement generation as complete.

## Method: getContainingMethods
- return type: `java.util.Collection<com.pnfsoftware.jeb.core.units.code.java.IJavaMethod>`

Description: Retrieve the containing method stack.
return: read\-only containing methods

## Method: getCurrentAnonymousBaseType
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaType`

Description: Retrieve the current anonymous\-class base type.
return: current base type, or null

## Method: getCurrentAnonymousCaptureInfo
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink.CaptureInfo`

Description: Retrieve current anonymous\-class capture information.
return: capture information, or null

## Method: getCurrentContainingClass
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaClass`

Description: Retrieve the current containing class.
return: current containing class, or null

## Method: getCurrentContainingMethod
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaMethod`

Description: Retrieve the current containing method.
return: current containing method, or null

## Method: getCurrentMethodIndex
- return type: `int`

Description: Get the method index of the method being generated
return: a negative value if the index cannot be determined or is invalid

## Method: getDecompilables
- return type: `java.util.List<java.lang.String>`

Description: Retrieve the list of addresses of the decompilable \(classes, fields, methods\) items generated in this part.
return: a list of items, ordered as they appear in the decompiled output

## Method: getDecompilerUnit
- return type: `com.pnfsoftware.jeb.core.units.code.android.IDexDecompilerUnit`

Description: Retrieve the owning dex decompiler.
return: dex decompiler, or null

## Method: getDisplayMethodInternalsAsComment
- return type: `int`

Description: Retrieve the method\-internals comment rendering mode.
return: method\-internals rendering mode

## Method: getDisplayPrivateMethodsLast
- return type: `boolean`

Description: Determine whether private methods should be rendered last.
return: true if private methods should be rendered last

## Method: getDisregardCollapse
- return type: `boolean`

Description: Determine whether collapse metadata should be ignored.
return: true if collapse metadata should be ignored

## Method: getDoNotGenerateThisIfPossible
- return type: `boolean`

Description: Determine whether `this` should be omitted when possible.
return: true if `this` should be omitted when possible

## Method: getDocument
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaDocument`

Description: Retrieve the owning Java document.
return: Java document, or null

## Method: getDynamicContentManager
- return type: `com.pnfsoftware.jeb.core.units.code.java.IDynamicContentManager`

Description: Retrieve the dynamic content manager.
return: dynamic content manager, or null

## Method: getGenerateAnnotations
- return type: `boolean`

Description: Determine whether annotations should be rendered.
return: true if annotations should be rendered

## Method: getGenerateLambdas
- return type: `boolean`

Description: Determine whether lambdas should be rendered when possible.
return: true if lambdas should be rendered

## Method: getGenerateOverrideAnnotations
- return type: `boolean`

Description: Determine whether additional `@Override` annotations should be rendered.
return: true if override annotations should be rendered

## Method: getGenerateSyntheticFields
- return type: `boolean`

Description: Determine whether synthetic fields should be rendered.
return: true if synthetic fields should be rendered

## Method: getGenerateSyntheticMethods
- return type: `boolean`

Description: Determine whether synthetic methods should be rendered.
return: true if synthetic methods should be rendered

## Method: getGeneratedAnon
- parameter: `container`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.java.IJavaClass>`

Description: Retrieve anonymous classes generated in a container.
parameter: container: method or class container
return: generated anonymous classes, possibly empty

## Method: getIdentifierCoordinates
- return type: `java.util.Map<java.lang.Long,java.util.List<com.pnfsoftware.jeb.core.output.code.coordinates.ICodeCoordinates>>`

Description: Retrieve recorded identifier coordinates.
return: identifier coordinates keyed by item id

## Method: getInsertBlankLinesAfterCompounds
- return type: `boolean`

Description: Determine whether blank lines should be inserted after compound statements.
return: true if blank lines should be inserted

## Method: getReplacementFor
- parameter: `ident`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaIdentifier`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaExpression`

Description: Retrieve a replacement expression for an identifier.
parameter: ident: identifier
return: replacement expression, or null

## Method: getResolveFieldAccessTargets
- return type: `boolean`

Description: Determine whether field\-access targets should be resolved.
return: true if field\-access targets should be resolved

## Method: getResolveMethodCallTargets
- return type: `boolean`

Description: Determine whether method\-call targets should be resolved.
return: true if method\-call targets should be resolved

## Method: getSortItemsForRendering
- return type: `int`

Description: Retrieve the source\-item sorting mode.
return: sorting mode

## Method: getSplitCallArgThreshold
- return type: `int`

Description: Retrieve the argument\-count threshold for split call rendering.
return: split\-call argument threshold

## Method: getTopLevelClass
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaClass`

Description: Retrieve the top\-level containing class.
return: top\-level class, or null

## Method: getUseDebugInfoNames
- return type: `boolean`

Description: Determine whether dex debug\-information names should be used.
return: true if debug\-information names should be used

## Method: getUseVarReservedType
- return type: `boolean`

Description: Determine whether `var` should be rendered when possible.
return: true if `var` should be used when possible

## Method: isBeingGenerated
- parameter: `elt`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- return type: `boolean`

Description: Determine whether an AST element is currently being generated.
parameter: elt: AST element
return: true if the element is on the generation stack

## Method: loadCommentInline
- parameter: `insnCoord`, type: `com.pnfsoftware.jeb.core.output.code.coordinates.ICodeCoordinates`

Description: Load an inline comment as the current end\-of\-line comment.
parameter: insnCoord: instruction coordinates

## Method: popAnonymousBaseType
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaType`

Description: Pop the current anonymous\-class base type.
return: popped base type, possibly null

## Method: popAnonymousCaptureInfo
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink.CaptureInfo`

Description: Pop anonymous\-class capture information.
return: popped capture information

## Method: popContainingClass
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaClass`

Description: Pop the current containing class.
return: popped containing class

## Method: popContainingMethod
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaMethod`

Description: Pop the current containing method.
return: popped containing method

## Method: popReplacements
- return type: `java.util.Map<com.pnfsoftware.jeb.core.units.code.java.IJavaIdentifier,com.pnfsoftware.jeb.core.units.code.java.IJavaExpression>`

Description: Pop the current identifier replacement map.
return: replacement map

## Method: pushAnonymousBaseType
- parameter: `type`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaType`

Description: Push an anonymous\-class base type.
parameter: type: base type, possibly null

## Method: pushAnonymousCaptureInfo
- parameter: `info`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink.CaptureInfo`

Description: Push anonymous\-class capture information.
parameter: info: capture information

## Method: pushContainingClass
- parameter: `c`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaClass`

Description: Push a containing class on the generation stack.
parameter: c: containing class

## Method: pushContainingMethod
- parameter: `m`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaMethod`

Description: Push a containing method on the generation stack.
parameter: m: containing method

## Method: pushReplacements
- parameter: `replmap`, type: `java.util.Map<com.pnfsoftware.jeb.core.units.code.java.IJavaIdentifier,com.pnfsoftware.jeb.core.units.code.java.IJavaExpression>`

Description: Push an identifier replacement map.
parameter: replmap: replacement map

## Method: recordGeneratedDecompilable
- parameter: `signature`, type: `java.lang.String`

Description: Record a generated decompilable item.
parameter: signature: decompilable item signature

## Method: recordIdentifierCoordinates
- parameter: `objectId`, type: `long`
- parameter: `coordinates`, type: `com.pnfsoftware.jeb.core.output.code.coordinates.ICodeCoordinates`

Description: Record coordinates for an identifier item.
parameter: objectId: identifier item id
parameter: coordinates: code coordinates

## Method: renderInlineComment
- parameter: `coord`, type: `com.pnfsoftware.jeb.core.output.code.coordinates.ICodeCoordinates`
- parameter: `appendEOL`, type: `boolean`

Description: Render an inline comment for code coordinates.
parameter: coord: code coordinates
parameter: appendEOL: true to append an end\-of\-line marker

## Method: renderPreComment
- parameter: `coord`, type: `com.pnfsoftware.jeb.core.output.code.coordinates.ICodeCoordinates`

Description: Render a pre\-comment for code coordinates. 

 An end\-of\-line marker is always appended.
parameter: coord: code coordinates

## Method: requestGeneratingReplacement
- return type: `boolean`

Description: Request entry into replacement generation.
return: true if replacement generation may proceed

## Method: setCurrentMethodIndex
- parameter: `index`, type: `int`
- return type: `int`

Description: Set the method index of the method being generated
parameter: index: the current method index
return: the previous index

## Method: setDynamicContentManager
- parameter: `dcm`, type: `com.pnfsoftware.jeb.core.units.code.java.IDynamicContentManager`

Description: Set the dynamic content manager.
parameter: dcm: dynamic content manager, or null

## Method: setGeneratingReplacement
- parameter: `generatingReplacement`, type: `boolean`

Description: Set the replacement\-generation state.
parameter: generatingReplacement: true if a replacement is being generated

## Method: validate


