net.sf.jaxme.js
Interface DirectAccessible

All Known Subinterfaces:
LocalJavaField
All Known Implementing Classes:
ConditionalIndentationJavaSourceObject.LJFImpl, ConditionalIndentationJavaSourceObject.LoopVariable, JavaField, Parameter

public interface DirectAccessible

This interface is an abstract base for fields and similar objects. It doesn't define many methods, it mainly indicates, that the implementations value is directly and fast accessible in the generated code. The use is best demonstrated by an example. Suggest the following piece of code:

     Object value;
     return new Object[]{"((", value, ") * (", value, "))"};
 

The example is well suited for the case, where value is a variable name like "i". It is not suited, if "value" contains an expensive method call like "sin(x)". It is even wrong in the case "i++".

By using the interface DirectAccessible, you can change the implementation of getSquare() to look like this:

     Object value;
     JavaQName type;
     if (!(value instanceof DirectAccessible)) {
       LocalJavaField v = pMethod.newJavaField(type);
       v.addLine(value);
       v.setFinal(true);
       value = v;
     }
     return new Object[]{"((", value, ") * (", value, "))"};
 

This results in code, which is far more readable and better optimized.

Author:
Jochen Wiedmann

Method Summary
 boolean isNullable()
          Returns whether the value is possibly null.
 void setNullable(boolean pNullable)
          Sets whether the value is possibly null.
 

Method Detail

isNullable

public boolean isNullable()

Returns whether the value is possibly null.


setNullable

public void setNullable(boolean pNullable)

Sets whether the value is possibly null.