Jtest logo




Contents  Previous  Next  Index

Available Rule Nodes


The nodes that you can use to create your rule are listed below, in the order in which they appear in a fully expanded node tree.

An alphabetical list of all available nodes is included at the end of this section.

Constants

Nodes which represent values which cannot be changed.

boolean Constant

A node which represents a boolean constant.

Example:

     public final boolean isHuman = true;  // boolean constant

char Constant

A node which represents a character constant.

Example:

      private final char FIRST_LETTER = 'A';  // char constant

int Constant

A node which represents an integer constant.

Example:

      private final int MIN_AGE = 21;  // int constant

long Constant

A node which represents a long integer constant.

Example:

      long MAX_TEMP = 451L;  // long constant

float Constant

A node which represents a floating point constant.

Example:

      private final float yourNumber = 2.5f; // float constant

double Constant

A node which represents a double floating point constant.

Example:

      public final double myNumber = 314159e-5d;  // double constant

null

A node which represents the built-in value null.

Example:

      private StringTokenizer tokenizer = null;  // null

String Constant

A node which represents a String constant.

Example:

      public final String name = "Mercury";  // String constant

Declarations

Represents a user-defined data type or method.

The engine uses the IsDecl property to distinguish between the actual declaration and references to the declaration.

Method

A method (function) declaration.

Example:

     public int myMethod() { // Method
         int myValue = 17;
         return myValue;
     } 

Parameter

A declaration which is in the parameter list of a method.

Example:

      public void setNumber(int number) {  // parameter declaration
          this.number = number;
      }

Static Initializer

A declaration using the keyword static. A block of statements can be declared to be static, in which case it is executed when, and only when, the class is initialized.

Example:

      public class Converter {
          public static int factor;  // static initializer
          static {   // static initializer
              factor = 5;
          }
      }

super

A reference to the immediate super class.

Example:

      public void execute() {
          // calling super class
          super.execute();  //  reference to super 
          doMyOwn();
      }

this

A reference to the current object.

Example:

      public void startEngine(int type) {
          this.type = type;  //  reference to this
     }

Variables

Variable declarations.

The engine uses the IsDecl property to distinguish between the actual declaration and references to the declaration.

Local Variable

A variable for which the scope is the current block.

Example:

      public void collect(String name) {
          boolean isGood = false;     // isGood is local to this 
method
          isGood = getHasFunds();
      }

Field

Fields are the declarations of class or instance variables.

Example:

     public class Deck {
          public static int num_decks=0;            // static int field
          public final int NUM_CARDS = 52;          // int field
          private int[] cards = new int[NUM_CARDS]; //  array field
          public Deck() {
              num_decks++;
          }
      }

Expressions

Includes all types of expression nodes.

Assignment

Expressions utilizing assignment operators.

a=b

Direct assignment.

Assigns the value of b to a.

Example:

      int x;
      int y = 5;
      x = y;     // a=b

a+=b

Add-equals assignment.

Assigns the result a+b to a.

Example:

      int x=1;
      x += 5;     // a+=b

a-=b

Subtract-equals assignment.

Assigns the result of a-b to a.

Example:

      int x=5;
      x -= 2;     // a-=b

a/=b

Divide-equals assignment.

Assigns the result of a/b to a.

Example:

      float x = 10.0;
      x /= 2.0;    // a/=b

a*=b

Multiply-equals assignment

Assigns the result of a*b to a.

Example:

      int x = 2;
      x *= 3;     // a*=b

a%=b

Mod-equals assignment.

Assign the remainder of a/b to a.

Example:

      int x = 10;
      x %= 7;     // a%=b

a&=b

Bitwise-And-equals assignment.

Assigns the result of a&b to a.

Example:

      int x = 9;
      x &= 5;     // a&=b

a^=b

Bitwise XOR assignment.

Assigns the result of a^b to a.

Example:

      int x = 2;
      x ^= 3;     // a^=b

a|=b

Bitwise OR assignment.

Assigns the result of a|b to b.

Example:

      int x = 9;
      x |= 8;     // a|=b

a<<=b

Left-shift-equals assignment.

Assigns the result of a<<b to a.

Example:

      int x = 2;
      x <<= 3;     // a<<=b

a>>=b

Right-shift-equals assignment.

Assigns the result of a>>b to a.

Example:

      int x = 16;
      x >>= 3;     // a>>=b

a>>>=b

Unsigned right-shift-equals assignment.

Assigns the result of a>>>b to a.

Example:

      int x = 16;
      a >>>= 3;     // a>>>=b

--a

Pre-decrement operator.

Decrement a before being used in expression.

Example:

      int x = 5;
      --x;         // --a

++a

Pre-increment operator.

Increment a before being used in expression.

Example:

      int x = 5;
      ++x;         // ++x

a--

Post-decrement operator.

Decrement a after being used in expression.

Example:

      int x = 5;
      x--;           // a--

a++

Post-increment operator.

Increment a after being used in expression.

Example:

      int x = 5;
      x++;          // a++

Bitwise

All nodes using Java bitwise non-assignment operators.

~a

Bitwise negate operator.

Example:

      int x = 7;
      int y = ~x;     // ~a

a|b

Bitwise or operator.

Example:

      int x = 3;
      int y = 5;
      int z = x|y;     // a|b

a&b

Bitwise and operator.

Example:

      int x = 16;
      int y = 9;
      int z = x&y;     // a&b

a^b

Bitwise XOR operator.

Example:

      int x = 16;
      int y = 17;
      int z = x^y;     // a^b

Comparison

All nodes using Java comparison operators.

a==b

Logical test for equality.

Example:

      boolean method(int x, int y) {
          return x == y;              // a==b
      }

a!=b

Logical test for inequality.

Example:

      boolean method(int x, int y) {
          return x != y;              // a!=b
      }

a<b

Logical test for less-than.

Example:

      boolean method(int x) {
          return x > 5;              // a>b
      }

a<=b

Logical test for less-than or equal-to.

Example:

      boolean method(int x) {
          return x <= 5;              // a<=b
      }

a>b

Logical test for greater-than.

Example:

      boolean method(int x) {
          return x > 5;              // a>b
      }

a>=b

Logical test for greater-than or equal-to.

Example:

      boolean method(int x) {
          return x >= 5;              // a>=b
      }

Logical

Nodes using logical operators.

!a

Logical negation.

Example:

      boolean method(boolean x) {
          return !x;              // !a 
      }

a&&b

Logical 'and'.

Example:

      boolean x = true;
      boolean y = false;
      boolean z = x && y;     // a&&b

a||b

Logical 'or'.

Example:

      boolean x = true;
      boolean y = false;
      boolean z = x || y;     // a||b

Miscellaneous

Other operators not covered previously.

a.b

Dot operator.

Used to specify methods and fields of a particular class or object.

Example:

      Object o;
      String s = o.toString();     // dot operator

a[b]

Array Notation.

Specifies element with index = b of array a.

Example:

      String[] args = new String[5];
      args[3] = "sample string";     // Array notation.

instanceof

Tests whether or not an object is an instance of a particular class.

Example:

      if (apple instanceof fruit) {   // Use of instanceof
      ...
      }

a(b)

Method invocation.

Example:

     class Foo {
         Foo() {
             setNum(3);             // a(b)
         }
         public void int setNum(int n) {
             num = n;
         }
         private int num;
     }

a?b:c

Ternary operator.

Example:

     int method(boolean ok) {
         return ok ? 0 : -1;   // a?b:c
     }

Cast

Conversion of one data type into another.

Example:

      char a = 'a';
      int b = (int) a;    // Cast 

new

Object instantiation.

Example:

     public class AnyClass {
     ...
     }
     AnyClass aClass = new AnyClass();    // Object instantiation

Numerical

Nodes involving numerical operations.

+a

Represents the positive of a number.

The value of a remains unchanged.

Example:

     int x = -6;
     int y = +x;    // +a

-a

Represents the negative of a number.

Example:

     int x = -6;
     int y = -x;    // -a

a+b

The addition operator.

Example:

      int x = 4;
      int z = x + 3;     // a+b

a-b

The subtraction operator.

Example:

      int x = 4;
      int z = x - 4;     // a-b

a*b

The multiplication operator.

Example:

      int x = 4;
      int z = x * 3;     // a*b

a/b

The division operator.

Example:

      int x = 4;
      int z = x / 3;     // a/b

a%b

Mod operator.

Returns the remainder of a/b.

Example:

      int x = 18;
      int y = x%5;     // a%b

a<<b

Left bit-shift.

Example:

      int x=2;
      int y = x<<2;     // a<<b

a>>b

Right bit-shift.

Example:

      int x=2;
      int y = x>>2;     // right bit-shift

a>>>b

Unsigned right bit-shift.

Example:

      int x = -1;
      int y = y>>>1;    // a>>>b

Javadoc

Java comments.

Tags

Javadoc tags fir the comments (i.e., @author).

Packages

Nodes involving packages and imports.

import

The import statement.

Example:

     import javax.swing.*;           // import statement
     import javax.swing.border.*;    // import statement

package

The package statement.

Example:

     package com.brijac.nn;    // package statement

Statements

Nodes involving various Java statements.

break

The 'break' statement.

Used to break out of a loop structure.

Example:

      for (int t=1; t<5; t++) {
          if (t<2) break;     // break statement
      }

case

The case statement.

Specifies a particular case of the switch statement.

Example:

    int method(int i) {
      int ret = 0;
      switch (i) {
          case 2:          // case
              ret = 3;
              break;
          case 3:          // case
               break;
      }
      return ret;
    }

continue

The continue statement.

Used to skip to the next iterator in a loop.

Example:

     for (int t=0; t<5; ++t) {
         if ((t%2) != 0) continue;    // continue statement
         System.out.println(t);
     }

do while

do while statement.

Example:

      boolean done = false;
      do {     // do while
      } while (!done);

declaration statement

A statement involving the declaration of an object or primitive type.

Example:

      int x = 7;                  // Declaration
      Object o = new Object();    // Declaration

for

The 'for' loop.

Example:

      for (int t = 1; t<5; t++) {    // for statement
      ...
      }

if

The 'if' statement.

Example:

      int x=5;
      if (x==5) {    // The if statement
          System.out.println("x="+x);
      }

return

The return statement.

Example:

      int x = 7;
      public void int getNumber() {
          return x;      // return statement
      }

synchronized

The synchronized statement.

Locks object when in use so that it can be accessed by only one caller at a time.

Example:

 public class Foo
 {
   public static Thread get ()
   {
     final Object resource1 = "resource1";
     return new Thread () {
         public void run () {
            synchronized (resource1) {  // synchronized
            }
         }
     };
   }
 }

switch

The switch statement.

Example:

      int t=2;
      switch(t) {        // switch
          case 1:
              break;
          case 2:
               break;
      }

throw

The throw statement.

Example:

      void method(Object t) {
          if (t == null) {
              throw new Exception();
          }
      }

try

The try statement.

Example:

      try {    // try statement
      } catch (Exception e) {
      }

while

The while statement.

Example:

      boolean here = true;
      while (here) {     // while statement
      }

Block

The code block

Example:

      {   // A block
          // statements within this block
       }

Simple

A simple statement.

A singular code statement which does not fall in any of

the other statement categories.

Example:

      for (int count=1; count<10; count++) {
          System.out.println(count);     // simple statement
      }

Types

Nodes representing complex or primitive types.

Complex

Non-primitives.

Array

The array type.

Example:

      String[] stringArray = new String[5];     // array

Class

The Java class type.

Example:

      public class Foo {     // class
      }

Interface

The Java interface type.

Example:

      public interface Plug {     // interface
      }

Primitive

Nodes representing primitive types.

boolean

The boolean primitive type.

Example:

      boolean bool = true;     // boolean

char

The character primitive type.

Example:

      char a = 'a';     // char

byte

The byte integral type.

Example:

      byte b = 23;     // byte

short

The short integer.

Example:

      short s = 4;     // short

int

The integer type.

Example:

      int t = 5;     // int

long

The long integer.

Example:

      long size = 84578734;     // long

float

The floating point type.

Example:

      float width = 78.3e+12f;     // float

double

The double numeric type.

Example:

      double length = 93.45e+301d;     // double

Alphabetical List of Available Nodes

======

a==b

a=b

a-=b

a>=b

a>>=b

a>>>=b

a>>>b

a>>b

a>b

a-b

Array

Assignment

Bitwise

Block

boolean

boolean Constant

break

byte

case

Cast

char

char Constant

Class

Comparison

Complex

Constants

continue

declaration statement

Declarations

do while

double

double Constant

Expressions

Field

float

float Constant

for

if

import

instanceof

int

int Constant

Interface

Javadoc

Local Variable

Logical

long

long Constant

Method

Miscellaneous

new

null

Numerical

package

Packages

Parameter

Primitive

return

short

Simple

Statements

Static Initializer

String Constant

super

switch

synchronized

Tags

this

throw

try

Types

Variables

while

================


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft