list of dots

User Manual    [Previous]   [Next]   

Around Statement

An around statement can be used used to inject code around a code block. The original code appears in the middle, wherever the special around_proceed keyword is placed. The first example below surrounds the body of an entire method. The second example injects code between two labels

Example with "in class around injection with no labels" statement

class AroundClass{
  static void doSomeThing()
  { 
    int x; int a;
    boolean flag = false;
    Label1: x = 0;
    Label2: a = 0;
    flag = true;
  }
}

class AroundClass
{
  around custom doSomeThing()
  {
    // code before around.
    if (true) 
    { 
      around_proceed:
    }  
    // code after around.
  }  
}
      

Load the above code into UmpleOnline

 

Example with "top-level around injection with two labels" statement

class AroundClass{
  static void doSomeThing()
  {
    boolean flag = false;
    Label1: int x = 0;
    Label2: 
    flag = true;
  }
}

around {AroundClass} custom Label1-Label2:doSomeThing()
{
  // code before around.
  if (true) 
  {
    around_proceed:
  }  
  // code after around.
}
      

Load the above code into UmpleOnline

 

Syntax


toplevelBeforeCode : ( before | [=around] ) {([className])(, [className])*} [[aspectBody]]