srcML v1.0.0 Java Documentation

Base Elements XML Element Subelements
comment <comment type="line|block">
<comment type="line" format="doxygen">
<comment type="block" format="doxygen|javadoc">
literal <literal type="boolean|char|null|number|string">
escape <escape char="0xXX">
name <name>
Statements XML Element Subelements
assert statement <assert> <expr>
block <block> <block_content>
break statement <break> <name>
case statement <case> <expr>
continue statement <continue> <name>
default statement <default>
do while statement <do> <block>,<condition>
empty statement <empty_stmt>
expression statement <expr_stmt> <expr>
for statement <for> <control>,<block>
if statement <if_stmt> <if>,<if type="elseif">,<else>
label statement <label> <name>
pseudo block <block type="pseudo"> <block_content>
return statement <return> <expr>
switch statement <switch> <condition>,<block>,<case>,<default>
while statement <while> <condition>,<block>
Statement Subelements XML Element Subelements
block content <block_content>
condition <condition> <expr>
control <control> <init>,<condition>,<incr>
else <else> <block>
else if <if type="elseif"> <condition>,<block>
expression <expr> <name>,<operator>,<call>,<ternary>
if <if> <condition>,<block>
incr <incr> <expr>
then <then> <expr>
type <type> <specifier>,<name>
Specifiers XML Element Subelements
abstract <specifier>abstract</specifier>
default method implementation <specifier>default</specifier>
final <specifier>final</specifier>
native <specifier>native</specifier>
private <specifier>private</specifier>
protected <specifier>protected</specifier>
public <specifier>public</specifier>
static <specifier>static</specifier>
strictfp <specifier>strictfp</specifier>
synchronized <specifier>synchronized</specifier>
transient <specifier>transient</specifier>
volatile <specifier>volatile</specifier>
Declarations, Definitions, and Initializations XML Element Subelements
lambda functions <lambda> <parameter_list>,<block>
method definition <function> <type>,<name>,<parameter_list>,<block>
variable declaration <decl_stmt> <type>,<name>,<init>
Classes, Interfaces, Annotations, and Enums XML Element Subelements
annotation <annotation> <name>,<argument_list>
annotation definition <annotation_defn> <name>,<block>
class <class> <name>,<super_list>,<super>,<block>
constructor <constructor> <name>,<parameter_list>,<specifier>
default annotation property value <default>
enum definition <enum> <block>,<name>
extends <extends> <name>,<super>
implements <implements> <name>,<super>
inheritance list <super_list> <extends>,<implements>,<super>
interface <interface> <name>,<block>
interface_decl <interface_decl> <name>
receiver parameter <name>
static initialization block <static> <block>
Expressions XML Element Subelements
function call <call> <name>,<argument_list>
method reference <name>
super <name>
ternary operator <ternary> <condition>,<then>,<else>
this <name>
Other XML Element Subelements
import <import> <name>
package <package> <name>
synchronized statement <synchronized> <init>,<block>
Exceptions XML Element Subelements
finally <finally> <block>
throw <throw> <expr>
throws <throws> <name>,<argument>
try <try> <init>,<block>,<catch>,<finally>
Generic XML Element Subelements
catch <catch> <parameter_list>,<block>
generic class definition <class> <name>,<parameter_list>,<block>
generic method definition <function> <name>,<parameter_list type="generic">,<block>
generic parameter <extends> <name>
generic variable declaration <decl_stmt> <decl>

line comment


Element

  • <comment type="line">

XPath Queries

  • comments

    //src:comment
  • line comments

    //src:comment[@type='line']

Example

// line
<comment type="line">// line</comment>

block comment


Element

  • <comment type="block">

XPath Queries

  • comments

    //src:comment
  • block comments

    //src:comment[@type='block']

Example

/*
    block
*/
<comment type="block">/*
    block
*/</comment>

doxygen line comment


Element

  • <comment type="line" format="doxygen">

XPath Queries

  • comments

    //src:comment
  • doxygen comments

    //src:comment[@format='doxygen']

doxygen block comment


Element

  • <comment type="block" format="doxygen">

XPath Queries

  • comments

    //src:comment
  • doxygen comments

    //src:comment[@format='doxygen']

Example

/**
 * doxygen comment
 */
/*!
 * text
 */
<comment type="block" format="doxygen">/**
 * doxygen comment
 */</comment>
<comment type="block" format="doxygen">/*!
 * text
 */</comment>

javadoc block comment


Element

  • <comment type="block" format="javadoc">

XPath Queries

  • comments

    //src:comment
  • javadoc comments

    //src:comment[@format='javadoc']

Example

/**
 * javadoc comment
 */
<comment type="block" format="javadoc">/**
 * javadoc comment
 */</comment>

number literal


Element

  • <literal type="number">

XPath Query

  • number literals

    //src:literal[@type='number']

character literal


Element

  • <literal type="char">

XPath Query

  • character literals

    //src:literal[@type='char']

string literal


Element

  • <literal type="string">

XPath Query

  • string literals

    //src:literal[@type='string']

boolean literal


Element

  • <literal type="boolean">

XPath Query

  • boolean literals

    //src:literal[@type='boolean']

null literal


Element

  • <literal type="null">

XPath Query

  • null literals

    //src:literal[@type='null']

if statement


Element

  • <if_stmt>

Subelements

  • <if>
  • <if type="elseif">
  • <else>

XPath Queries

  • if conditions

    //src:if/src:condition
  • then

    //src:if/src:block
  • else

    //src:else/src:block
  • if statements without an else

    //src:if_stmt[not(src:else)]
  • else if

    //src:if[@type='elseif']
  • First if in a nested if statement

    //src:if_stmt/src:if[1]
  • Second if in a nested if statement

    //src:if_stmt/src:if[2]
  • Last if in a nested if statement

    //src:if_stmt/src:if[last()]

Examples

if then

if (A)
    B;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if></if_stmt>

if then else

if (A)
    B;
else
    C;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

if then elseif

if (A)
    B;
else if (A2)
    C;
else
    D:
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<if type="elseif">else if <condition>(<expr><name>A2</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <label><name>D</name>:</label></block_content></block></else></if_stmt>
if(x > 5)
    y+=4;
<if_stmt><if>if<condition>(<expr><name>x</name> <operator>&gt;</operator> <literal type="number">5</literal></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name><operator>+=</operator><literal type="number">4</literal></expr>;</expr_stmt></block_content></block></if></if_stmt>
if ( i > 0 ) {
    y = x / i;
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt>
</block_content>}</block></if></if_stmt>
if ( i > 0 )
    y = x / i;
else {
    x = i;
    y = f( x );
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt></block_content></block></if>
<else>else <block>{<block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <call><name>f</name><argument_list>( <argument><expr><name>x</name></expr></argument> )</argument_list></call></expr>;</expr_stmt>
</block_content>}</block></else></if_stmt>

Without braces

if ( i > 0 )
    if ( j > i )
        x = j;
    else
        x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if>
    <else>else<block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt></block_content></block></if></if_stmt>

With braces

if ( i > 0 ) {
    if ( j > i )
        x = j;
}
else
    x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if></if_stmt>
</block_content>}</block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt>
if ( i > 0 ) {
 	x = i;
}
else if( i < 0)
	x = q;
else
    x = j;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
 	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>
</block_content>}</block></if>
<if type="elseif">else if<condition>( <expr><name>i</name> <operator>&lt;</operator> <literal type="number">0</literal></expr>)</condition><block type="pseudo"><block_content>
	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>q</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

while statement


Element

  • <while>

Subelements

  • <condition>
  • <block>

XPath Queries

  • while loops

    //src:while
  • while-loop conditions

    //src:while/src:condition
  • while loops with a condition containing the variable i

    //src:while[src:condition//src:name='i']

for statement


Element

  • <for>

Subelements

  • <control>
  • <block>

XPath Queries

  • for loops

    //src:for
  • for-loop initialization statements

    //src:for/src:control/src:init
  • for-loop conditions

    //src:for/src:control/src:condition
  • for-loop increments

    //src:for/src:control/src:incr
  • for loops that declare a variable with a single character name (e.g. x, i or y)

    //src:for[string-length(src:control/src:init/src:decl/src:name)=1]
  • for loops with post-increment in the increment expression

    //src:for[src:control/src:incr/src:expr//following-sibling::src:operator='++']

Examples

for( ;; ) { }
<for>for<control>( <init>;</init><condition>;</condition> <incr/>)</control> <block>{<block_content> </block_content>}</block></for>
for (i = 0; i < max; i++ ) {
    if ( line[i] == ' ' ) {
        space++;
    }
    if ( line[i] == '\t' ) {
        tab++;
    }
}
<for>for <control>(<init><expr><name>i</name> <operator>=</operator> <literal type="number">0</literal></expr>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <name>max</name></expr>;</condition> <incr><expr><name>i</name><operator>++</operator></expr></incr> )</control> <block>{<block_content>
    <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">' '</literal></expr> )</condition> <block>{<block_content>
        <expr_stmt><expr><name>space</name><operator>++</operator></expr>;</expr_stmt>
    </block_content>}</block></if></if_stmt>
    <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">'\t'</literal></expr> )</condition> <block>{<block_content>
        <expr_stmt><expr><name>tab</name><operator>++</operator></expr>;</expr_stmt>
    </block_content>}</block></if></if_stmt>
</block_content>}</block></for>
for (int i = 0; i < 10; ++i)
    a += x[i];
<for>for <control>(<init><decl><type><name>int</name></type> <name>i</name> <init>= <expr><literal type="number">0</literal></expr></init></decl>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <literal type="number">10</literal></expr>;</condition> <incr><expr><operator>++</operator><name>i</name></expr></incr>)</control><block type="pseudo"><block_content>
    <expr_stmt><expr><name>a</name> <operator>+=</operator> <name><name>x</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt></block_content></block></for>
for (int item : numbers) {
    System.out.println("Count is: " + item);
}
<for>for <control>(<init><decl><type><name>int</name></type> <name>item</name> <range>: <expr><name>numbers</name></expr></range></decl></init>)</control> <block>{<block_content>
    <expr_stmt><expr><call><name><name>System</name><operator>.</operator><name>out</name><operator>.</operator><name>println</name></name><argument_list>(<argument><expr><literal type="string">"Count is: "</literal> <operator>+</operator> <name>item</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
</block_content>}</block></for>

Empty for statement

for (auto  p = v.begin(); p != v.end() && *p != 0; ++p)
    ;
<for>for <control>(<init><decl><type><name>auto</name></type>  <name>p</name> <init>= <expr><call><name><name>v</name><operator>.</operator><name>begin</name></name><argument_list>()</argument_list></call></expr></init></decl>;</init> <condition><expr><name>p</name> <operator>!=</operator> <call><name><name>v</name><operator>.</operator><name>end</name></name><argument_list>()</argument_list></call> <operator>&amp;&amp;</operator> <operator>*</operator><name>p</name> <operator>!=</operator> <literal type="number">0</literal></expr>;</condition> <incr><expr><operator>++</operator><name>p</name></expr></incr>)</control><block type="pseudo"><block_content>
    <empty_stmt>;</empty_stmt></block_content></block></for>

break statement


Element

  • <break>

Subelement

  • <name>

XPath Queries

  • break statements

    //src:break
  • break statements in for loops

    //src:for//src:break
  • for loops with break statements

    //src:for[.//src:break]
  • break statements that break to the exit label

    //src:break[src:name='exit']

label statement


Element

  • <label>

Subelement

  • <name>

XPath Query

  • labels

    //src:label

Example

stop:
<label><name>stop</name>:</label>

return statement


Element

  • <return>

Subelement

  • <expr>

XPath Queries

  • return statements

    //src:return
  • return expressions

    //src:return/src:expr
  • return statements that return true

    //src:return[src:expr='true']
  • functions with more then one return

    //src:function[count(.//src:return)>1]

switch statement


Element

  • <switch>

Subelements

  • <condition>
  • <block>
  • <case>
  • <default>

XPath Queries

  • switch statements

    //src:switch
  • switch-statement conditions

    //src:switch/src:condition

case statement


Element

  • <case>

Subelement

  • <expr>

XPath Queries

  • case labels

    //src:case
  • case labels that use SATURDAY

    //src:case[.//src:name='SATURDAY']
  • switch statements with a case that uses SATURDAY

    //src:switch[src:block/src:block_content/src:case//src:name='SATURDAY']

Examples

case x:
<case>case <expr><name>x</name></expr>:</case>
case SATURDAY:
<case>case <expr><name>SATURDAY</name></expr>:</case>

default statement


Element

  • <default>

XPath Queries

  • default labels

    //src:default
  • switch statements with a default label

    //src:switch[src:block/src:block_content/src:default]

Example

default case

default:
<default>default:</default>

assert statement


Element

  • <assert>

Subelement

  • <expr>

XPath Queries

  • assert statements

    //src:assert
  • methods with assert statements

    //src:function[.//src:assert]

Example

assert expr1 : expr2 ;
<assert>assert <expr><name>expr1</name> <operator>:</operator> <name>expr2</name></expr> ;</assert>

block


Element

  • <block>

Subelement

  • <block_content>

XPath Queries

  • blocks

    //src:block
  • variable declarations in a block

    //src:block//src:decl_stmt
  • top-level variable declarations in a block

    //src:block/src:block_content/src:decl_stmt

pseudo block


Element

  • <block type="pseudo">

Subelement

  • <block_content>

XPath Queries

  • all pseudo blocks

    //src:block[@type='pseudo']
  • all non pseudo blocks

    //src:block[not(@type='pseudo')]
  • variable declarations in a pseudo block

    //src:block[@type='pseudo']//src:decl_stmt
  • top-level variable declarations in a pseudo block

    //src:block[@type='pseudo']/src:block_content/src:decl_stmt

expression statement


Element

  • <expr_stmt>

Subelement

  • <expr>

XPath Query

  • expression statements

    //src:expr_stmt

empty statement


Element

  • <empty_stmt>

XPath Query

  • empty statements

    //src:empty_stmt

condition


Element

  • <condition>

Subelement

  • <expr>

XPath Queries

  • conditions, including ternary conditions

    //src:condition
  • condition expressions

    //src:condition/src:expr
  • if conditions

    //src:if/src:condition
  • while conditions

    //src:while/src:condition
  • do while conditions

    //src:do/src:condition
  • ternary conditions

    //src:ternary/src:condition

type


Element

  • <type>

Subelements

  • <specifier>
  • <name>

XPath Queries

  • types

    //src:type
  • declaration types

    //src:decl/src:type
  • function types

    //src:function/src:type
  • function declaration types

    //src:function_decl/src:type

block content


Element

  • <block_content>

XPath Queries

  • block contents

    //src:block_content
  • declaration block_contents

    //src:decl/src:block/src:block_content
  • function block_contents

    //src:function/src:block/src:block_content

volatile


Element

  • <specifier>volatile</specifier>

XPath Query

  • volatile variables

    //src:decl[src:type/src:specifier='volatile']

abstract


Element

  • <specifier>abstract</specifier>

XPath Queries

  • abstract classes

    //src:class[src:specifier='abstract']
  • abstract methods

    //src:function[src:type/src:specifier='abstract']

default method implementation


Element

  • <specifier>default</specifier>

XPath Query

  • methods with default implementations

    //src:function[src:type/src:specifier='default']

final


Element

  • <specifier>final</specifier>

XPath Queries

  • final classes

    //src:class[src:specifier='final']
  • final methods

    //src:function[src:type/src:specifier='final']
  • final variable declarations

    //src:decl[src:type/src:specifier='final']

synchronized


Element

  • <specifier>synchronized</specifier>

XPath Query

  • synchronized methods

    //src:function[src:type/src:specifier='synchronized']

transient


Element

  • <specifier>transient</specifier>

XPath Query

  • transient variable declarations

    //src:decl[src:type/src:specifier='transient']

native


Element

  • <specifier>native</specifier>

XPath Query

  • native function declarations

    //src:function_decl[src:type/src:specifier='native']

private


Element

  • <specifier>private</specifier>

XPath Queries

  • private classes

    //src:class[src:specifier='private']
  • private member variables

    //src:class//src:decl_stmt[src:decl/src:type/src:specifier='private']
  • private methods

    //src:function[src:type/src:specifier='private']

protected


Element

  • <specifier>protected</specifier>

XPath Queries

  • protected classes

    //src:class[src:specifier='protected']
  • protected member variables

    //src:class//src:decl_stmt[src:decl/src:type/src:specifier='protected']
  • protected methods

    //src:function[src:type/src:specifier='protected']

public


Element

  • <specifier>public</specifier>

XPath Queries

  • public classes

    //src:class[src:specifier='public']
  • public member variables

    //src:class//src:decl_stmt[src:decl/src:type/src:specifier='public']
  • public methods

    //src:function[src:type/src:specifier='public']

static


Element

  • <specifier>static</specifier>

XPath Queries

  • static methods

    //src:function[src:type/src:specifier='static']
  • static classes

    //src:class[src:specifier='static']
  • static variables

    //src:decl[src:type/src:specifier='static']

strictfp


Element

  • <specifier>strictfp</specifier>

XPath Query

  • strictfp classes

    //src:class[src:specifier='strictfp']

Example

strictfp class FooNum {
}
<class><specifier>strictfp</specifier> class <name>FooNum</name> <block>{
}</block></class>

variable declaration


Element

  • <decl_stmt>

Subelements

  • <type>
  • <name>
  • <init>

XPath Queries

  • variable declaration statements

    //src:decl_stmt
  • variable declarations

    //src:decl
  • variable declarations with an initialization

    //src:decl[src:init]
  • array declarations

    //src:decl[src:name/src:index]

Examples

boolean result = true;
char capitalC = 'C';
<decl_stmt><decl><type><name>boolean</name></type> <name>result</name> <init>= <expr><literal type="boolean">true</literal></expr></init></decl>;</decl_stmt>
<decl_stmt><decl><type><name>char</name></type> <name>capitalC</name> <init>= <expr><literal type="char">'C'</literal></expr></init></decl>;</decl_stmt>
char data[] = {'a', 'b', 'c'};
<decl_stmt><decl><type><name>char</name></type> <name><name>data</name><index>[]</index></name> <init>= <expr><block>{<expr><literal type="char">'a'</literal></expr>, <expr><literal type="char">'b'</literal></expr>, <expr><literal type="char">'c'</literal></expr>}</block></expr></init></decl>;</decl_stmt>
String str = new String(data);
<decl_stmt><decl><type><name>String</name></type> <name>str</name> <init>= <expr><operator>new</operator> <call><name>String</name><argument_list>(<argument><expr><name>data</name></expr></argument>)</argument_list></call></expr></init></decl>;</decl_stmt>
String cde = "cde";
<decl_stmt><decl><type><name>String</name></type> <name>cde</name> <init>= <expr><literal type="string">"cde"</literal></expr></init></decl>;</decl_stmt>
int[][] multi = new int[5][10];
<decl_stmt><decl><type><name><name>int</name><index>[]</index><index>[]</index></name></type> <name>multi</name> <init>= <expr><operator>new</operator> <name><name>int</name><index>[<expr><literal type="number">5</literal></expr>]</index><index>[<expr><literal type="number">10</literal></expr>]</index></name></expr></init></decl>;</decl_stmt>

method definition


Element

  • <function>

Subelements

  • <type>
  • <name>
  • <parameter_list>
  • <block>

XPath Queries

  • method definitions

    //src:function
  • method-definition return types

    //src:function/src:type
  • method-definition parameters

    //src:function/src:parameter_list/src:parameter
  • method definitions with two parameters

    //src:function[count(src:parameter_list/src:parameter)=2]
  • method-definition names

    //src:function/src:name

lambda functions


Element

  • <lambda>

Subelements

  • <parameter_list>
  • <block>

XPath Query

  • lambda functions

    //src:lambda

Examples

(a, b) -> a - b;
<expr_stmt><expr><lambda><parameter_list>(<parameter><decl><name>a</name></decl></parameter>, <parameter><decl><name>b</name></decl></parameter>)</parameter_list> -&gt;<block type="pseudo"><block_content> <expr><name>a</name> <operator>-</operator> <name>b</name></expr></block_content></block></lambda></expr>;</expr_stmt>
(Person p) -> p.getGender() == Person.Sex.MALE
        && p.getAge() >= 18
        && p.getAge() <= 25
<expr><lambda><parameter_list>(<parameter><decl><type><name>Person</name></type> <name>p</name></decl></parameter>)</parameter_list> -&gt;<block type="pseudo"><block_content> <expr><call><name><name>p</name><operator>.</operator><name>getGender</name></name><argument_list>()</argument_list></call> <operator>==</operator> <name><name>Person</name><operator>.</operator><name>Sex</name><operator>.</operator><name>MALE</name></name>
        <operator>&amp;&amp;</operator> <call><name><name>p</name><operator>.</operator><name>getAge</name></name><argument_list>()</argument_list></call> <operator>&gt;=</operator> <literal type="number">18</literal>
        <operator>&amp;&amp;</operator> <call><name><name>p</name><operator>.</operator><name>getAge</name></name><argument_list>()</argument_list></call> <operator>&lt;=</operator> <literal type="number">25</literal></expr></block_content></block></lambda></expr>
(int a, int b) -> {  return a + b; }
<expr_stmt><expr><lambda><parameter_list>(<parameter><decl><type><name>int</name></type> <name>a</name></decl></parameter>, <parameter><decl><type><name>int</name></type> <name>b</name></decl></parameter>)</parameter_list> -&gt; <block>{<block_content>  <return>return <expr><name>a</name> <operator>+</operator> <name>b</name></expr>;</return> </block_content>}</block></lambda></expr></expr_stmt>
() -> System.out.println("Hello World");
<expr_stmt><expr><lambda><parameter_list>()</parameter_list> -&gt;<block type="pseudo"><block_content> <expr><call><name><name>System</name><operator>.</operator><name>out</name><operator>.</operator><name>println</name></name><argument_list>(<argument><expr><literal type="string">"Hello World"</literal></expr></argument>)</argument_list></call></expr></block_content></block></lambda></expr>;</expr_stmt>
() -> 42
<expr><lambda><parameter_list>()</parameter_list> -&gt;<block type="pseudo"><block_content> <expr><literal type="number">42</literal></expr></block_content></block></lambda></expr>

class


Element

  • <class>

Subelements

  • <name>
  • <super_list>
  • <super>
  • <block>

XPath Queries

  • class definitions

    //src:class
  • anonymous class definitions

    //src:class[not(src:name)]

Examples

class Pair {
}
<class>class <name>Pair</name> <block>{
}</block></class>
class DerivedClass extends BaseClass {
}
<class>class <name>DerivedClass</name> <super_list><extends>extends <super><name>BaseClass</name></super></extends></super_list> <block>{
}</block></class>
HelloWorld spanishGreeting = new HelloWorld() {
    String name = "mundo";
    public void greet() {
        greetSomeone("mundo");
    }
    public void greetSomeone(String someone) {
        name = someone;
        System.out.println("Hola, " + name);
    }
};
<decl_stmt><decl><type><name>HelloWorld</name></type> <name>spanishGreeting</name> <init>= <expr><operator>new</operator> <class><super><name>HelloWorld</name></super><argument_list>()</argument_list> <block>{
    <decl_stmt><decl><type><name>String</name></type> <name>name</name> <init>= <expr><literal type="string">"mundo"</literal></expr></init></decl>;</decl_stmt>
    <function><type><specifier>public</specifier> <name>void</name></type> <name>greet</name><parameter_list>()</parameter_list> <block>{<block_content>
        <expr_stmt><expr><call><name>greetSomeone</name><argument_list>(<argument><expr><literal type="string">"mundo"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
    </block_content>}</block></function>
    <function><type><specifier>public</specifier> <name>void</name></type> <name>greetSomeone</name><parameter_list>(<parameter><decl><type><name>String</name></type> <name>someone</name></decl></parameter>)</parameter_list> <block>{<block_content>
        <expr_stmt><expr><name>name</name> <operator>=</operator> <name>someone</name></expr>;</expr_stmt>
        <expr_stmt><expr><call><name><name>System</name><operator>.</operator><name>out</name><operator>.</operator><name>println</name></name><argument_list>(<argument><expr><literal type="string">"Hola, "</literal> <operator>+</operator> <name>name</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
    </block_content>}</block></function>
}</block></class></expr></init></decl>;</decl_stmt>

interface


Element

  • <interface>

Subelements

  • <name>
  • <block>

XPath Query

  • interfaces

    //src:interface

interface_decl


Element

  • <interface_decl>

Subelement

  • <name>

XPath Query

  • interface declarations

    //src:interface_decl

annotation definition


Element

  • <annotation_defn>

Subelements

  • <name>
  • <block>

XPath Query

  • annotation definitions

    //src:annotation_defn

Example

@interface ClassPreambleAnnotation {
}
<annotation_defn>@interface <name>ClassPreambleAnnotation</name> <block>{
}</block></annotation_defn>

annotation


Element

  • <annotation>

Subelements

  • <name>
  • <argument_list>

XPath Queries

  • annotations

    //src:annotation
  • -Deprecated annotations

    //src:annotation[src:name='Deprecated']

inheritance list


Element

  • <super_list>

Subelements

  • <extends>
  • <implements>
  • <super>

XPath Queries

  • classes with at least one super class

    //src:class[src:super_list/src:super]
  • classes that inherit from bar

    //src:class[src:super_list/src:super/src:name='bar']

enum definition


Element

  • <enum>

Subelements

  • <block>
  • <name>

XPath Queries

  • enums

    //src:enum
  • enum names

    //src:enum/src:name

Example

enum Planet {
    MERCURY,
    VENUS,
    EARTH,
    MARS,
    JUPITER,
    SATURN,
    URANUS,
    NEPTUNE;
}
<enum>enum <name>Planet</name> <block>{
    <decl><name>MERCURY</name></decl>,
    <decl><name>VENUS</name></decl>,
    <decl><name>EARTH</name></decl>,
    <decl><name>MARS</name></decl>,
    <decl><name>JUPITER</name></decl>,
    <decl><name>SATURN</name></decl>,
    <decl><name>URANUS</name></decl>,
    <decl><name>NEPTUNE</name></decl>;
}</block></enum>

extends


Element

  • <extends>

Subelements

  • <name>
  • <super>

XPath Queries

  • extends

    //src:extends
  • classes that extend from BaseClass

    //src:class[src:super_list/src:extends/src:name='BaseClass']

Example

class DerivedClass extends BaseClass {
}
<class>class <name>DerivedClass</name> <super_list><extends>extends <super><name>BaseClass</name></super></extends></super_list> <block>{
}</block></class>

implements


Element

  • <implements>

Subelements

  • <name>
  • <super>

XPath Queries

  • implements

    //src:implements
  • classes which implement IVehicle

    //src:class[src:super_list/src:implements/src:name='IVehicle']

receiver parameter


Element

  • <name>

XPath Query

  • constructors with a receiver parameter

    //src:constructor[src:parameter_list/src:parameter/src:decl/src:name/src:name='this']

static initialization block


Element

  • <static>

Subelement

  • <block>

XPath Query

  • static initialization blocks

    //src:static

default annotation property value


Element

  • <default>

XPath Query

  • annotation properties with a default value

    //src:function_decl[src:default]

function call


Element

  • <call>

Subelements

  • <name>
  • <argument_list>

XPath Query

  • function calls

    //src:call

ternary operator


Element

  • <ternary>

Subelements

  • <condition>
  • <then>
  • <else>

XPath Query

  • ternary operators

    //src:ternary

super


Element

  • <name>

XPath Query

  • calls to a super constructor

    //src:call[src:name='super']

import


Element

  • <import>

Subelement

  • <name>

XPath Query

  • import statements

    //src:import

package


Element

  • <package>

Subelement

  • <name>

XPath Query

  • package declarations

    //src:package

Example

package com.mycompany;
<package>package <name><name>com</name><operator>.</operator><name>mycompany</name></name>;</package>

synchronized statement


Element

  • <synchronized>

Subelements

  • <init>
  • <block>

XPath Query

  • synchronization statements

    //src:synchronized

throw


Element

  • <throw>

Subelement

  • <expr>

XPath Query

  • uses of throw

    //src:throw

throws


Element

  • <throws>

Subelements

  • <name>
  • <argument>

XPath Queries

  • uses of throws

    //src:throws
  • functions with a throws specification

    //src:function[src:throws]

try


Element

  • <try>

Subelements

  • <init>
  • <block>
  • <catch>
  • <finally>

XPath Queries

  • try blocks

    //src:try
  • try blocks with a resource list

    //src:try[src:init]
  • try blocks with only a finally block

    //src:try[src:finally][not(src:catch)]
  • try blocks with a catch and a finally block

    //src:try[src:finally][src:catch]

generic class definition


Element

  • <class>

Subelements

  • <name>
  • <parameter_list>
  • <block>

XPath Query

  • generic classes

    //src:class[src:name/src:parameter_list]

generic parameter


Element

  • <extends>

Subelement

  • <name>

XPath Queries

  • bound generic parameters

    //src:argument[src:extends]
  • classes with a bound generic parameter

    //src:class[src:name/src:parameter_list/src:parameter/src:extends]
  • methods with a bound generic parameter

    //src:function[src:type/src:argument_list/src:argument/src:extends]
  • functions with a generic wildcard parameter that has an upper bound

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:name/src:argument_list/src:argument[src:name='?'][src:extends]]
  • functions with a generic wildcard parameter that is unbound

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:name/src:argument_list/src:argument[src:name='?'][not(src:extends)][not(src:super)]]
  • functions with a generic wildcard parameter that has a lower bound

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:name/src:argument_list/src:argument[src:name='?'][src:super]]

Examples

public <U extends Number> void inspect(U u) {
}
<function><type><specifier>public</specifier> <parameter_list type="generic">&lt;<parameter><name>U</name> <extends>extends <name>Number</name></extends></parameter>&gt;</parameter_list> <name>void</name></type> <name>inspect</name><parameter_list>(<parameter><decl><type><name>U</name></type> <name>u</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
<T extends Comparable<T>> int countGreaterThan(T[] anArray, T elem) {
}
<function><type><parameter_list type="generic">&lt;<parameter><name>T</name> <extends>extends <name><name>Comparable</name><argument_list type="generic">&lt;<argument><name>T</name></argument>&gt;</argument_list></name></extends></parameter>&gt;</parameter_list> <name>int</name></type> <name>countGreaterThan</name><parameter_list>(<parameter><decl><type><name><name>T</name><index>[]</index></name></type> <name>anArray</name></decl></parameter>, <parameter><decl><type><name>T</name></type> <name>elem</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
<T extends Foo & Bar> void doSomething(T input) {
}
<function><type><parameter_list type="generic">&lt;<parameter><name>T</name> <extends>extends <name>Foo</name></extends> <operator>&amp;</operator> <name>Bar</name></parameter>&gt;</parameter_list> <name>void</name></type> <name>doSomething</name><parameter_list>(<parameter><decl><type><name>T</name></type> <name>input</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>

upper bound wildcard

public static void process(List<? extends Foo> list) {
}
<function><type><specifier>public</specifier> <specifier>static</specifier> <name>void</name></type> <name>process</name><parameter_list>(<parameter><decl><type><name><name>List</name><argument_list type="generic">&lt;<argument><name>?</name> <extends>extends <name>Foo</name></extends></argument>&gt;</argument_list></name></type> <name>list</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>

unbound wildcard

void printList(List<?> list) {
}
<function><type><name>void</name></type> <name>printList</name><parameter_list>(<parameter><decl><type><name><name>List</name><argument_list type="generic">&lt;<argument><name>?</name></argument>&gt;</argument_list></name></type> <name>list</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>

lower bound wildcard

void addNumbers(List<? super Integer> list) {
}
<function><type><name>void</name></type> <name>addNumbers</name><parameter_list>(<parameter><decl><type><name><name>List</name><argument_list type="generic">&lt;<argument><name>?</name> <super>super <name>Integer</name></super></argument>&gt;</argument_list></name></type> <name>list</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>