1 /* 2 * Copyright 2003, 2004 The Apache Software Foundation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 16 */ 17 package org.apache.ws.jaxme.js; 18 19 /** <p>This interface is an abstract base for fields and similar 20 * objects. It doesn't define many methods, it mainly indicates, that 21 * the implementations value is directly and fast accessible in 22 * the generated code. The use is best demonstrated by an example. 23 * Suggest the following piece of code:</p> 24 * <pre> 25 * Object value; 26 * return new Object[]{"((", value, ") * (", value, "))"}; 27 * </pre> 28 * <p>The example is well suited for the case, where <code>value</code> 29 * is a variable name like "i". It is not suited, if "value" contains 30 * an expensive method call like "sin(x)". It is even wrong in the 31 * case "i++".</p> 32 * <p>By using the interface <code>DirectAccessible</code>, you can 33 * change the implementation of <code>getSquare()</code> to look 34 * like this: 35 * <pre> 36 * Object value; 37 * JavaQName type; 38 * if (!(value instanceof DirectAccessible)) { 39 * LocalJavaField v = pMethod.newJavaField(type); 40 * v.addLine(value); 41 * v.setFinal(true); 42 * value = v; 43 * } 44 * return new Object[]{"((", value, ") * (", value, "))"}; 45 * </pre> 46 * <p>This results in code, which is far more readable and better 47 * optimized.</p> 48 * 49 * @author <a HREF="mailto:jwi@softwareag.com">Jochen Wiedmann</a> 50 */ 51 public interface DirectAccessible extends TypedValue { 52 /** <p>Returns whether the value is possibly null.</p> 53 */ 54 public boolean isNullable(); 55 /** <p>Sets whether the value is possibly null.</p> 56 */ 57 public void setNullable(boolean pNullable); 58 } 59