# Interface: com.pnfsoftware.jeb.core.units.code.java.IJavaElement

Top\-level interface for all elements of a Java Abstract Syntax Tree. 

 Each AST element implements this interface or one of the sub\-interfaces.

## Static Field: FLAG_BUILT
Type: `int`

Constant value: `1`
Description: Flag indicating that the element was built.

## Static Field: FLAG_FIELD_REFERENCES_OUTERCLASS
Type: `int`

Constant value: `64`
Description: Flag indicating that a field references an outer class.

## Static Field: FLAG_LAMBDA_CLASS
Type: `int`

Constant value: `32`
Description: Flag indicating a lambda class artifact.

## Static Field: FLAG_LAMBDA_IMPL
Type: `int`

Constant value: `16`
Description: Flag indicating a lambda implementation artifact.

## Static Field: FLAG_OPTIONAL_RENDERING
Type: `int`

Constant value: `4`
Description: Flag indicating that rendering of the element is optional.

## Static Field: FLAG_SECOND_PARAMETER_IS_OUTER_REF
Type: `int`

Constant value: `2`
Description: Flag indicating that the second parameter is an outer\-class reference.

## Static Field: FLAG_STICKY
Type: `int`

Constant value: `256`
Description: Flag reserved for sticky element state.

## Method: addFlags
- parameter: `f`, type: `int`

Description: Add flags to the current list of flags on this element. See `FLAG_xxx` for a list of legal flags.
parameter: f: 

## Method: addTag
- parameter: `key`, type: `java.lang.String`
- parameter: `value`, type: `java.lang.Object`
- return type: `java.lang.Object`

Description: Add a tag. See [#getTags()](#getTags()).
parameter: key: 
parameter: value: 
return: 

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

Description: This non\-recursive method indicates whether or not this element may be the cause of an exception. In order to recursively check if the element throws \(e.g., for a statement\), use [JUtil#canThrow(IStatement)](JUtil#canThrow(IStatement)).
return: 

## Method: collectAllPhysicalOffsets
- parameter: `physicalOffsets`, type: `java.util.Collection<java.lang.Integer>`

Description: Collect physical offsets for this element and all its constituents. The first element [added](Collection#add(Object)) is for this one, followed by the [sub\-elements's](#getSubElements()).
parameter: physicalOffsets: output collection

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

Description: Duplicate this element.
return: a \(possibly\) duplicated object of the same type

## Method: generate
- parameter: `out`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink`

Description: Generate this AST element recursively into a sink.
parameter: out: 

## Method: getData
- parameter: `key`, type: `java.lang.Object`
- return type: `java.lang.Object`

Description: Retrieve a piece of data attached to this AST element.
parameter: key: 
return: 

## Method: getElementType
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaElementType`

Description: This method returns the type of Java AST element held by this object.
return: 

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

Description: Retrieve the flags set on this element. See `FLAG_xxx` for a list of legal flags.
return: 

## Method: getOrigin
- return type: `java.lang.String`

Description: Retrieve origin metadata for this element.
return: origin metadata, or null

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

Description: Retrieve the explicit low\-level dex method index of this AST element. 

 For code located in a method, the default method attached to an AST element is the method containing the element.
return: a lower\-level dex method index, or \-1 to signify none or the default

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

Description: Retrieve the low\-level offset that map to this AST element.
return: a physical method offset, \-1 if none is available

## Method: getReconAnon
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconAnon`

Description: Retrieve anonymous\-class reconstruction metadata.
return: anonymous\-class reconstruction metadata, or null

## Method: getReconEnum
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconEnum`

Description: Retrieve enum reconstruction metadata.
return: enum reconstruction metadata, or null

## Method: getReconEnummap
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconEnummap`

Description: Retrieve enum\-switch\-map reconstruction metadata.
return: enum\-switch\-map reconstruction metadata, or null

## Method: getReconLambda
- return type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconLambda`

Description: Retrieve lambda reconstruction metadata.
return: lambda reconstruction metadata, or null

## Method: getSubElements
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.java.IJavaElement>`

Description: Get the list of AST elements that constitute this AST element. Typically, for simple statements, it may be expression. For complex expressions, it may be simpler expressions. For compound statements, it may more statements and expressions. 

 Note that [type](IJavaType) and [annotation](IJavaAnnotation) elements are not returned by this method.
return: the list of constituting elements, may be empty but never null

## Method: getTags
- return type: `java.util.Map<java.lang.String,java.lang.Object>`

Description: Get a read\-only collection of the current tag map. Tags are special key\-value pairs that can be attached to AST elements and rendered during AST generation.
return: 

## Method: hasFlags
- parameter: `f`, type: `int`
- return type: `boolean`

Description: Determine whether any flags have been set on this element. See `FLAG_xxx` for a list of legal flags.
parameter: f: 
return: 

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

Description: Determine whether an explicit physical method index is attached to this element. 

 For code located in a method, the default method attached to an AST element is the method containing the element.
return: 

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

Description: Determine whether a physical offset is attached to this element.
return: 

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

Description: Determine whether this element was created by a Java reconstruction pass.
return: true if this element is a reconstruction artifact

## Method: removeFlags
- parameter: `f`, type: `int`

Description: Remove some flags from this element. See `FLAG_xxx` for a list of legal flags.
parameter: f: 

## Method: removeTag
- parameter: `key`, type: `java.lang.String`
- return type: `java.lang.Object`

Description: Remove a tag. See [#getTags()](#getTags()).
parameter: key: 
return: 

## Method: replaceSubElement
- parameter: `target`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- parameter: `repl`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- return type: `boolean`

Description: Replace one element by another one. Only the references are compared, no equals/deep compare. At most one element is replaced. 

 Note that [type](IJavaType) and [annotation](IJavaAnnotation) elements cannot be replaced using this method.
parameter: target: the element to be replaced
parameter: repl: the new element
return: 

## Method: setData
- parameter: `key`, type: `java.lang.String`
- parameter: `value`, type: `java.lang.Object`

Description: Attach a piece of arbitrary data to this AST element.
parameter: key: 
parameter: value: 

## Method: setFlags
- parameter: `f`, type: `int`

Description: Set flags on this element. See `FLAG_xxx` for a list of legal flags.
parameter: f: 

## Method: setLambdaRecon
- parameter: `recon`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconLambda`

Description: Attach lambda reconstruction metadata.
parameter: recon: lambda reconstruction metadata, or null

## Method: setOrigin
- parameter: `origin`, type: `java.lang.String`

Description: Set origin metadata for this element.
parameter: origin: origin metadata, or null

## Method: setPhysicalMethodIndex
- parameter: `midx`, type: `int`

Description: Set an explicit low\-level dex method index of this AST element. This method is useful to override the default \(owner method\), such as when a method contains inlined code from another method. 

 For code located in a method, the default method attached to an AST element is the method containing the element.
parameter: midx: a lower\-level dex method index, or \-1 to signify none or the default

## Method: setPhysicalOffset
- parameter: `offset`, type: `int`

Description: Set a low\-level physical offset to this AST element.
parameter: offset: 

## Method: setReconAnon
- parameter: `recon`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconAnon`

Description: Attach anonymous\-class reconstruction metadata.
parameter: recon: anonymous\-class reconstruction metadata, or null

## Method: setReconEnum
- parameter: `recon`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconEnum`

Description: Attach enum reconstruction metadata.
parameter: recon: enum reconstruction metadata, or null

## Method: setReconEnummap
- parameter: `recon`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaReconEnummap`

Description: Attach enum\-switch\-map reconstruction metadata.
parameter: recon: enum\-switch\-map reconstruction metadata, or null

## Method: toShortString
- return type: `java.lang.String`

Description: Generate a short\-string version of this element.
return: 

## Method: visitDepthPost
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.java.IJVisitor`
- return type: `boolean`

Description: Depth\-first search, post\-order visit of an expression tree or sub\-tree. The node being visited may be replaced without notifying the visitor.
parameter: visitor: the visitor object
return: true if the visit was successful

## Method: visitDepthPost
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.java.IJVisitor`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- return type: `boolean`

Description: Depth\-first search, post\-order visit of an expression tree or sub\-tree. The node being visited may be replaced without notifying the visitor.
parameter: visitor: the visitor object
parameter: parent: 
return: true if the visit was successful

## Method: visitDepthPost
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.java.IJVisitor`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- parameter: `results`, type: `com.pnfsoftware.jeb.core.units.code.java.JVisitResults`
- return type: `boolean`

Description: Depth\-first search, post\-order visit of an expression tree or sub\-tree. The node being visited may be replaced without notifying the visitor.
parameter: visitor: the visitor object
parameter: parent: 
parameter: results: 
return: true if the visit was successful

## Method: visitDepthPost
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.java.IJVisitor`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- parameter: `results`, type: `com.pnfsoftware.jeb.core.units.code.java.JVisitResults`
- parameter: `doNotVisitBlocksInsideCompounds`, type: `boolean`
- return type: `boolean`

Description: Depth\-first search, post\-order visit of an expression tree or sub\-tree. The node being visited may be replaced without notifying the visitor.
parameter: visitor: the visitor object
parameter: parent: 
parameter: results: 
parameter: doNotVisitBlocksInsideCompounds: true to avoid exploring the sub\-blocks of            [compound](IJavaCompound) statements \(e.g., if true, when visiting an            if\-statements, the predicate expressions will be visited, but the if\-blocks will            not\)
return: true if the visit was successful

## Method: visitDepthPre
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.java.IJVisitor`
- return type: `boolean`

Description: Visit this AST tree. Processing of a node is done before visiting the children.
parameter: visitor: 
return: 

## Method: visitDepthPre
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.java.IJVisitor`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- return type: `boolean`

Description: Visit this AST tree. Processing of a node is done before visiting the children.
parameter: visitor: 
parameter: parent: 
return: 

## Method: visitDepthPre
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.java.IJVisitor`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- parameter: `results`, type: `com.pnfsoftware.jeb.core.units.code.java.JVisitResults`
- return type: `boolean`

Description: Visit this AST tree. Processing of a node is done before visiting the children.
parameter: visitor: 
parameter: parent: 
parameter: results: 
return: 

