srcML v1.0.0 Java Documentation

Base Elements XML Element Subelements
comment <comment type="block|line" format="javadoc|doxygen">
escape <escape char="0xXX">
literal <literal type="number|char|string|boolean|null">
name <name> <name>, <operator>
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>
expr_stmt <expr_stmt> <expr>
for statement <for> <control> <block>
if statement <if_stmt> <if> <else> <if type="elseif">
label statement <label> <name>
return statement <return> <expr>
switch statement <switch> <condition> <case> <block>
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 <else type="elsif> <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>
default method implementation <specifier>
final <specifier>
native <specifier>
private <specifier>
protected <specifier>
public <specifier>
static <specifier>
strictfp <specifier>
synchronized <specifier>
transient <specifier>
volatile <specifier>
Declarations, Definitions, and Initializations XML Element Subelements
anonymous class <class> <super> <block>
lambda functions <lambda> <parameter_list> <block>
method definition <function> <type> <name> <parameter_list> <block>
variable declaration and initialization <decl_stmt>
Classes, Interfaces, Annotations, and Enums XML Element Subelements
annotation definition <annotation_defn> <name> <block>
annotation use <annotation> <name> <argument_list>
class <class> <name> <super_list> <block>
constructor <constructor> <name> <parameter_list>
default annotation property value <default>
enum definition <enum> <block> <name>
extends <extends> <name>
implements <implements> <name>
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>
try <try> <init> <block> <catch> <finally>
Generic XML Element Subelements
bound generic parameter <extends> <name>
catch <catch> <parameter_list> <block>
generic class definition <class> <name> <argument_list> <block>
generic method definition <function> <name> <argument_list> <parameter_list> <block>
generic variable declaration <decl_stmt> <decl>
generic wildcard <extends> <name>

abstract


Element

  • <specifier>

XPath Queries

  • abstract classes

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

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

Examples

abstract class MyClass
{
}
<class><specifier>abstract</specifier> class <name>MyClass</name>
<block>{
}</block></class>
abstract String myMethod();
<function_decl><type><specifier>abstract</specifier> <name>String</name></type> <name>myMethod</name><parameter_list>()</parameter_list>;</function_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 use


Element

  • <annotation>

Subelements

  • <name>
  • <argument_list>

XPath Queries

  • annotations

    //src:annotation
  • -Deprecated annotations

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

Examples

@Entity
@Author( name = "Benjamin Franklin", date = "3/27/2003")
@Inventor("Benjamin Franklin")
class Cls {
}
<class><annotation>@<name>Entity</name></annotation>
<annotation>@<name>Author</name><argument_list>( <argument><expr><name>name</name> <operator>=</operator> <literal type="string">"Benjamin Franklin"</literal></expr></argument>, <argument><expr><name>date</name> <operator>=</operator> <literal type="string">"3/27/2003"</literal></expr></argument>)</argument_list></annotation>
<annotation>@<name>Inventor</name><argument_list>(<argument><expr><literal type="string">"Benjamin Franklin"</literal></expr></argument>)</argument_list></annotation>
class <name>Cls</name> <block>{
}</block></class>
@Entity
@Author( name = "Benjamin Franklin", date = "3/27/2003")
@Inventor("Benjamin Franklin")
<decl><annotation>@<name>Entity</name></annotation>
<annotation>@<name>Author</name><argument_list>( <argument><expr><name>name</name> <operator>=</operator> <literal type="string">"Benjamin Franklin"</literal></expr></argument>, <argument><expr><name>date</name> <operator>=</operator> <literal type="string">"3/27/2003"</literal></expr></argument>)</argument_list></annotation>
@<name>Inventor</name><argument_list>(<argument><expr><literal type="string">"Benjamin Franklin"</literal></expr></argument>)</argument_list></decl>

anonymous class


Element

  • <class>

Subelements

  • <super>
  • <block>

XPath Query

  • anonymous classes

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

Example

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>

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

Example

 {
    line[i] = x;
    x++;
    i--;
}
 <block>{<block_content>
    <expr_stmt><expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>=</operator> <name>x</name></expr>;</expr_stmt>
    <expr_stmt><expr><name>x</name><operator>++</operator></expr>;</expr_stmt>
    <expr_stmt><expr><name>i</name><operator>--</operator></expr>;</expr_stmt>
</block_content>}</block>

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

bound 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]

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>

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']

Examples

char c;
for(;;) {
    printf_s( "\nPress any key, Q to quit: " );

    // Convert to character value
    scanf_s("%c", &c);
    if (c == 'Q')
        break;
}
<decl_stmt><decl><type><name>char</name></type> <name>c</name></decl>;</decl_stmt>
<for>for<control>(<init>;</init><condition>;</condition><incr/>)</control> <block>{<block_content>
    <expr_stmt><expr><call><name>printf_s</name><argument_list>( <argument><expr><literal type="string">"\nPress any key, Q to quit: "</literal></expr></argument> )</argument_list></call></expr>;</expr_stmt>

    <comment type="line">// Convert to character value</comment>
    <expr_stmt><expr><call><name>scanf_s</name><argument_list>(<argument><expr><literal type="string">"%c"</literal></expr></argument>, <argument><expr><operator>&amp;</operator><name>c</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
    <if_stmt><if>if <condition>(<expr><name>c</name> <operator>==</operator> <literal type="char">'Q'</literal></expr>)</condition><block type="pseudo"><block_content>
        <break>break;</break></block_content></block></if></if_stmt>
</block_content>}</block></for>
break label;
<break>break <name>label</name>;</break>

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']

Example

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

class


Element

  • <class>

Subelements

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

XPath Query

  • classes

    //src:class

Example

class Pair {
}
<class>class <name>Pair</name> <block>{
}</block></class>

comment


Element

  • <comment type="block|line" format="javadoc|doxygen">

XPath Queries

  • comments

    //src:comment
  • block comments

    //src:comment[@type='block']
  • line comments

    //src:comment[@type='line']
  • javadoc comments

    //src:comment[@format='javadoc']
  • doxygen comments

    //src:comment[@format='doxygen']
  • line Javadoc comments

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

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:do/src:condition

constructor


Element

  • <constructor>

Subelements

  • <name>
  • <parameter_list>

XPath Query

  • constructors

    //src:constructor

Example

class MyType {
    MyType() { }
}
<class>class <name>MyType</name> <block>{
    <constructor><name>MyType</name><parameter_list>()</parameter_list> <block>{<block_content> </block_content>}</block></constructor>
}</block></class>

control


Element

  • <control>

Subelements

  • <init>
  • <condition>
  • <incr>

XPath Query

  • initialization, condition, and increment of for loops

    //src:control

default annotation property value


Element

  • <default>

XPath Query

  • annotation properties with a default value

    //src:function_decl[src:default]

Example

   int currentRevision() default 1;
   String lastModified() default "N/A";
   <function_decl><type><name>int</name></type> <name>currentRevision</name><parameter_list>()</parameter_list> <default>default <init><expr><literal type="number">1</literal></expr></init></default>;</function_decl>
   <function_decl><type><name>String</name></type> <name>lastModified</name><parameter_list>()</parameter_list> <default>default <init><expr><literal type="string">"N/A"</literal></expr></init></default>;</function_decl>

default method implementation


Element

  • <specifier>

XPath Query

  • methods with default implementations

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

Example

default ZonedDateTime getZonedDateTime(String zoneString) { return null; } 
<function><type><specifier>default</specifier> <name>ZonedDateTime</name></type> <name>getZonedDateTime</name><parameter_list>(<parameter><decl><type><name>String</name></type> <name>zoneString</name></decl></parameter>)</parameter_list> <block>{<block_content> <return>return <expr><literal type="null">null</literal></expr>;</return> </block_content>}</block></function> 

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>

else


Element

  • <else>

Subelement

  • <block>

XPath Query

  • all elses

    //src:else

else if


Element

  • <else type="elsif>

Subelements

  • <condition>
  • <block>

XPath Query

  • all else ifs

    //src:else[type="elsif"]

empty statement


Element

  • <empty_stmt>

XPath Query

  • empty statements

    //src:empty_stmt

Example

;
<empty_stmt>;</empty_stmt>

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>

escape


Element

  • <escape char="0xXX">

expr_stmt


Element

  • <expr_stmt>

Subelement

  • <expr>

expression


Element

  • <expr>

Subelements

  • <name>
  • <operator>
  • <call>
  • <ternary>

XPath Query

  • expressions

    //src:expr

extends


Element

  • <extends>

Subelement

  • <name>

XPath Queries

  • extends

    //src:extends
  • classes that inherit from BaseClass

    //src:class[src:super/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>

final


Element

  • <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']

Examples

 public final class MyFinalClass
 {
 }
 <class><specifier>public</specifier> <specifier>final</specifier> class <name>MyFinalClass</name>
 <block>{
 }</block></class>
public final String myFinalMethod()
{
}
<function><type><specifier>public</specifier> <specifier>final</specifier> <name>String</name></type> <name>myFinalMethod</name><parameter_list>()</parameter_list>
<block>{<block_content>
</block_content>}</block></function>
final int speedlimit=90;
<decl_stmt><decl><type><specifier>final</specifier> <name>int</name></type> <name>speedlimit</name><init>=<expr><literal type="number">90</literal></expr></init></decl>;</decl_stmt>

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>

function call


Element

  • <call>

Subelements

  • <name>
  • <argument_list>

XPath Query

  • function calls

    //src:call

Example

System.out.println("Hello World!");
<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">"Hello World!"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>

generic class definition


Element

  • <class>

Subelements

  • <name>
  • <argument_list>
  • <block>

XPath Query

  • generic classes

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

Example

class Box<T> {
}
<class>class <name><name>Box</name><parameter_list>&lt;<parameter><name>T</name></parameter>&gt;</parameter_list></name> <block>{
}</block></class>

generic wildcard


Element

  • <extends>

Subelement

  • <name>

XPath Queries

  • 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

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>

if


Element

  • <if>

Subelements

  • <condition>
  • <block>

XPath Query

  • all ifs

    //src:if

if statement


Element

  • <if_stmt>

Subelements

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

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>

implements


Element

  • <implements>

Subelement

  • <name>

XPath Queries

  • implements

    //src:implements
  • classes which implement IVehicle

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

Example

public class Truck implements IVehicle
{
}
<class><specifier>public</specifier> class <name>Truck</name> <super_list><implements>implements <super><name>IVehicle</name></super></implements></super_list>
<block>{
}</block></class>

import


Element

  • <import>

Subelement

  • <name>

XPath Query

  • import statements

    //src:import

Example

import java.io.File;
import java.net.*;
<import>import <name><name>java</name><operator>.</operator><name>io</name><operator>.</operator><name>File</name></name>;</import>
<import>import <name><name>java</name><operator>.</operator><name>net</name><operator>.</operator><name>*</name></name>;</import>

incr


Element

  • <incr>

Subelement

  • <expr>

XPath Query

  • increment of for loops

    //src:incr

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']

interface


Element

  • <interface>

Subelements

  • <name>
  • <block>

XPath Query

  • interfaces

    //src:interface

Example

public interface IPolygon
{
	public float getArea();
	public int getNumberOfSides();
	public int getCircumference();
}
<interface><specifier>public</specifier> interface <name>IPolygon</name>
<block>{
	<function_decl><type><specifier>public</specifier> <name>float</name></type> <name>getArea</name><parameter_list>()</parameter_list>;</function_decl>
	<function_decl><type><specifier>public</specifier> <name>int</name></type> <name>getNumberOfSides</name><parameter_list>()</parameter_list>;</function_decl>
	<function_decl><type><specifier>public</specifier> <name>int</name></type> <name>getCircumference</name><parameter_list>()</parameter_list>;</function_decl>
}</block></interface>

interface_decl


Element

  • <interface_decl>

Subelement

  • <name>

XPath Query

  • interface declarations

    //src:interface_decl

label statement


Element

  • <label>

Subelement

  • <name>

XPath Query

  • labels

    //src:label

Example

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

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>

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

Examples

int getArea() {
    return width * height;
}
<function><type><name>int</name></type> <name>getArea</name><parameter_list>()</parameter_list> <block>{<block_content>
    <return>return <expr><name>width</name> <operator>*</operator> <name>height</name></expr>;</return>
</block_content>}</block></function>
Polygon polygonFrom(Point... corners) { }
<function><type><name>Polygon</name></type> <name>polygonFrom</name><parameter_list>(<parameter><decl><type><name>Point</name><modifier>...</modifier></type> <name>corners</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>

native


Element

  • <specifier>

XPath Query

  • native function declarations

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

Example

 native String getProcessorType();
 <function_decl><type><specifier>native</specifier> <name>String</name></type> <name>getProcessorType</name><parameter_list>()</parameter_list>;</function_decl>

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>

private


Element

  • <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']

Examples

public class MyPublicClass {
    private class Helper
    {
    }
}
<class><specifier>public</specifier> class <name>MyPublicClass</name> <block>{
    <class><specifier>private</specifier> class <name>Helper</name>
    <block>{
    }</block></class>
}</block></class>
private int i;
<decl_stmt><decl><type><specifier>private</specifier> <name>int</name></type> <name>i</name></decl>;</decl_stmt>
private String myMethod()
{ }
<function><type><specifier>private</specifier> <name>String</name></type> <name>myMethod</name><parameter_list>()</parameter_list>
<block>{<block_content> </block_content>}</block></function>

protected


Element

  • <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']

Examples

public class Temp {
    protected class MyProtectedClass
    {
    }
}
<class><specifier>public</specifier> class <name>Temp</name> <block>{
    <class><specifier>protected</specifier> class <name>MyProtectedClass</name>
    <block>{
    }</block></class>
}</block></class>
protected int i;
<decl_stmt><decl><type><specifier>protected</specifier> <name>int</name></type> <name>i</name></decl>;</decl_stmt>
protected String myMethod()
{ }
<function><type><specifier>protected</specifier> <name>String</name></type> <name>myMethod</name><parameter_list>()</parameter_list>
<block>{<block_content> </block_content>}</block></function>

public


Element

  • <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']

Examples

public class MyPrivateClass
{
}
<class><specifier>public</specifier> class <name>MyPrivateClass</name>
<block>{
}</block></class>
public int i = 50;
<decl_stmt><decl><type><specifier>public</specifier> <name>int</name></type> <name>i</name> <init>= <expr><literal type="number">50</literal></expr></init></decl>;</decl_stmt>
public String getName() { }
<function><type><specifier>public</specifier> <name>String</name></type> <name>getName</name><parameter_list>()</parameter_list> <block>{<block_content> </block_content>}</block></function>

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']

Example

public void foo(MyType MyType.this) { }
<function><type><specifier>public</specifier> <name>void</name></type> <name>foo</name><parameter_list>(<parameter><decl><type><name>MyType</name></type> <name><name>MyType</name><operator>.</operator><name>this</name></name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>

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]

Examples

return;
<return>return;</return>
return true;
<return>return <expr><name>true</name></expr>;</return>
return( s * (long long)s );
<return>return<expr><operator>(</operator> <name>s</name> <operator>*</operator> <operator>(</operator><name>long</name> <name>long</name><operator>)</operator><name>s</name> <operator>)</operator></expr>;</return>

static


Element

  • <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']

Examples

public final static int MAX_OBJECTS = 100;
static int _numObjects = 0;
<decl_stmt><decl><type><specifier>public</specifier> <specifier>final</specifier> <specifier>static</specifier> <name>int</name></type> <name>MAX_OBJECTS</name> <init>= <expr><literal type="number">100</literal></expr></init></decl>;</decl_stmt>
<decl_stmt><decl><type><specifier>static</specifier> <name>int</name></type> <name>_numObjects</name> <init>= <expr><literal type="number">0</literal></expr></init></decl>;</decl_stmt>
static class MyStaticClass
{ }
<class><specifier>static</specifier> class <name>MyStaticClass</name>
<block>{ }</block></class>
static int getNumObjects()
{ }
<function><type><specifier>static</specifier> <name>int</name></type> <name>getNumObjects</name><parameter_list>()</parameter_list>
<block>{<block_content> </block_content>}</block></function>

static initialization block


Element

  • <static>

Subelement

  • <block>

XPath Query

  • static initialization blocks

    //src:static

Example

class Cls {
	static {

	}  
}
<class>class <name>Cls</name> <block>{
	<static>static <block>{<block_content>

	</block_content>}</block></static>  
}</block></class>

strictfp


Element

  • <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>

super


Element

  • <name>

XPath Query

  • calls to a super constructor

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

Example

super(args)
<expr><call><name>super</name><argument_list>(<argument><expr><name>args</name></expr></argument>)</argument_list></call></expr>

switch statement


Element

  • <switch>

Subelements

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

XPath Queries

  • switch statements

    //src:switch
  • switch-statement conditions

    //src:switch/src:condition

Examples

switch (c) {

    case 'A':
        ++capa;
    case 'a':
        ++lettera;
    default :
        ++total;
}
<switch>switch <condition>(<expr><name>c</name></expr>)</condition> <block>{<block_content>

    <case>case <expr><literal type="char">'A'</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>capa</name></expr>;</expr_stmt>
    <case>case <expr><literal type="char">'a'</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>lettera</name></expr>;</expr_stmt>
    <default>default :</default>
        <expr_stmt><expr><operator>++</operator><name>total</name></expr>;</expr_stmt>
</block_content>}</block></switch>
switch (i) {

    case -1:
        ++n;
        break;
    case 0 :
        ++z;
        break;
    case 1 :
        ++p;
        break;
}
<switch>switch <condition>(<expr><name>i</name></expr>)</condition> <block>{<block_content>

    <case>case <expr><operator>-</operator><literal type="number">1</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>n</name></expr>;</expr_stmt>
        <break>break;</break>
    <case>case <expr><literal type="number">0</literal></expr> :</case>
        <expr_stmt><expr><operator>++</operator><name>z</name></expr>;</expr_stmt>
        <break>break;</break>
    <case>case <expr><literal type="number">1</literal></expr> :</case>
        <expr_stmt><expr><operator>++</operator><name>p</name></expr>;</expr_stmt>
        <break>break;</break>
</block_content>}</block></switch>

synchronized


Element

  • <specifier>

XPath Query

  • synchronized methods

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

Example

public synchronized String mySyncMethod()
{
}
<function><type><specifier>public</specifier> <specifier>synchronized</specifier> <name>String</name></type> <name>mySyncMethod</name><parameter_list>()</parameter_list>
<block>{<block_content>
</block_content>}</block></function>

synchronized statement


Element

  • <synchronized>

Subelements

  • <init>
  • <block>

XPath Query

  • synchronization statements

    //src:synchronized

Example

synchronized (syncObj) {
}
<synchronized>synchronized <init>(<expr><name>syncObj</name></expr>)</init> <block>{<block_content>
</block_content>}</block></synchronized>

ternary operator


Element

  • <ternary>

Subelements

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

XPath Query

  • ternary operators

    //src:ternary

Example

a ? x : y;
<expr_stmt><expr><ternary><condition><expr><name>a</name></expr> ?</condition><then> <expr><name>x</name></expr> </then><else>: <expr><name>y</name></expr></else></ternary></expr>;</expr_stmt>

then


Element

  • <then>

Subelement

  • <expr>

XPath Query

  • then parts of ternary

    //src:then

throw


Element

  • <throw>

Subelement

  • <expr>

XPath Query

  • uses of throw

    //src:throw

Example

throw new IOException("error reading file");
<throw>throw <expr><operator>new</operator> <call><name>IOException</name><argument_list>(<argument><expr><literal type="string">"error reading file"</literal></expr></argument>)</argument_list></call></expr>;</throw>

throws


Element

  • <throws>

Subelement

  • <name>

XPath Queries

  • uses of throws

    //src:throws
  • functions with a throws specification

    //src:function[src:throws]

Examples

public void readFile(String filename) throws IOException {
}
<function><type><specifier>public</specifier> <name>void</name></type> <name>readFile</name><parameter_list>(<parameter><decl><type><name>String</name></type> <name>filename</name></decl></parameter>)</parameter_list> <throws>throws <argument><expr><name>IOException</name></expr></argument></throws> <block>{<block_content>
</block_content>}</block></function>
public MyOtherType foo() throws MyExceptionType throws MyExceptionType2 { }
<function><type><specifier>public</specifier> <name>MyOtherType</name></type> <name>foo</name><parameter_list>()</parameter_list> <throws>throws <argument><expr><name>MyExceptionType</name> <throws>throws <argument><expr><name>MyExceptionType2</name> <block>{ }</block></expr></argument></throws></expr></argument></throws></function>
public MyOtherType foo() throws MyExceptionType, MyExceptionType2 { }
<function><type><specifier>public</specifier> <name>MyOtherType</name></type> <name>foo</name><parameter_list>()</parameter_list> <throws>throws <argument><expr><name>MyExceptionType</name></expr></argument>, <argument><expr><name>MyExceptionType2</name></expr></argument></throws> <block>{<block_content> </block_content>}</block></function>
throws MyExceptionType, MyExceptionType2
<throws>throws <argument><expr><name>MyExceptionType</name></expr></argument>, <argument><expr><name>MyExceptionType2</name></expr></argument></throws>

transient


Element

  • <specifier>

XPath Query

  • transient variable declarations

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

Example

transient String password;
<decl_stmt><decl><type><specifier>transient</specifier> <name>String</name></type> <name>password</name></decl>;</decl_stmt>

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]

Examples

try {

} finally {
	
} 
<try>try <block>{<block_content>

</block_content>}</block> <finally>finally <block>{<block_content>
	
</block_content>}</block></finally></try> 
try (BufferedReader br = new BufferedReader(new FileReader(path))) {
	return br.readLine();
}
<try>try <init>(<decl><type><name>BufferedReader</name></type> <name>br</name> <init>= <expr><operator>new</operator> <call><name>BufferedReader</name><argument_list>(<argument><expr><operator>new</operator> <call><name>FileReader</name><argument_list>(<argument><expr><name>path</name></expr></argument>)</argument_list></call></expr></argument>)</argument_list></call></expr></init></decl>)</init> <block>{<block_content>
	<return>return <expr><call><name><name>br</name><operator>.</operator><name>readLine</name></name><argument_list>()</argument_list></call></expr>;</return>
</block_content>}</block></try>
try {

} catch(Exception varName) {
	
}
<try>try <block>{<block_content>

</block_content>}</block> <catch>catch<parameter_list>(<parameter><decl><type><name>Exception</name></type> <name>varName</name></decl></parameter>)</parameter_list> <block>{<block_content>
	
</block_content>}</block></catch></try>

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

variable declaration and initialization


Element

  • <decl_stmt>

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>

volatile


Element

  • <specifier>

XPath Query

  • volatile variables

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

Example

volatile int sharedVal;
<decl_stmt><decl><type><specifier>volatile</specifier> <name>int</name></type> <name>sharedVal</name></decl>;</decl_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']

Example

while ( i >= 0 ) 
{
    string1[i] = string2[i];
    i--;
}
<while>while <condition>( <expr><name>i</name> <operator>&gt;=</operator> <literal type="number">0</literal></expr> )</condition> 
<block>{<block_content>
    <expr_stmt><expr><name><name>string1</name><index>[<expr><name>i</name></expr>]</index></name> <operator>=</operator> <name><name>string2</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt>
    <expr_stmt><expr><name>i</name><operator>--</operator></expr>;</expr_stmt>
</block_content>}</block></while>