public String getDefaultValueExpression() { return p.getDefaultValueExpression(); }
protected String getConstructorDefensiveCopyExpression( Property prop, Class propType ) { return prop.getDefensiveCopyExpression(); }
public int getGetterModifiers() { return p.getGetterModifiers(); }
private static boolean changeMarked( Property prop ) { return prop.isBound() || prop.isConstrained(); }
iw.print( CodegenUtils.getModifierString( prop.getSetterModifiers() ) ); iw.print(" void set" + BeangenUtils.capitalize( prop.getName() ) + "( " + prop.getSimpleTypeName() + ' ' + prop.getName() + " )"); if ( prop.isConstrained() ) iw.println(" throws PropertyVetoException"); else iw.println( prop.getSimpleTypeName() + " oldVal = " + getExpression + ';'); String newValExpr = prop.getName(); String changeCheck; String simpleTypeName = prop.getSimpleTypeName(); if ( ClassUtils.isPrimitive( simpleTypeName ) ) changeCheck = "oldVal != " + prop.getName(); changeCheck = "! eqOrBothNull( oldVal, " + prop.getName() + " )"; if ( prop.isConstrained() ) iw.println("vcs.fireVetoableChange( \"" + prop.getName() + "\", " + oldValExpr + ", " + newValExpr + " );"); iw.downIndent(); if ( prop.isBound() ) iw.println("pcs.firePropertyChange( \"" + prop.getName() + "\", " + oldValExpr + ", " + newValExpr + " );"); iw.downIndent();
public static void writePropertyGetter( Property prop, String defensiveCopyExpression, IndentedWriter iw ) throws IOException { String pfx = ("boolean".equals( prop.getSimpleTypeName() ) ? "is" : "get" ); iw.print( CodegenUtils.getModifierString( prop.getGetterModifiers() ) ); iw.println(' ' + prop.getSimpleTypeName() + ' ' + pfx + BeangenUtils.capitalize( prop.getName() ) + "()"); String retVal = defensiveCopyExpression; if (retVal == null) retVal = prop.getName(); iw.println("{ return " + retVal + "; }"); }
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") ois.readObject();"); }
public static void writePropertySetter( Property prop, String setterDefensiveCopyExpression, IndentedWriter iw ) throws IOException { String setVal = setterDefensiveCopyExpression; if (setVal == null) setVal = prop.getName(); String usualGetExpression = ("this." + prop.getName()); String usualSetStatement = ("this." + prop.getName() + " = " + setVal + ';'); writePropertySetterWithGetExpressionSetStatement(prop, usualGetExpression, usualSetStatement, iw); }
public static void writePropertyVariable( Property prop, String defaultValueExpression, IndentedWriter iw ) throws IOException { iw.print( CodegenUtils.getModifierString( prop.getVariableModifiers() ) ); iw.print( ' ' + prop.getSimpleTypeName() + ' ' + prop.getName()); String dflt = defaultValueExpression; if (dflt != null) iw.print( " = " + dflt ); iw.println(';'); }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { iw.print( CodegenUtils.getModifierString( ctor_modifiers ) ); iw.print(" " + info.getClassName() + "( "); iw.print( info.getClassName() + " copyMe" ); iw.println(" )"); iw.println("{"); iw.upIndent(); for (int i = 0, len = props.length; i < len; ++i) { String propGetterMethodCall; if (propTypes[i] == boolean.class) propGetterMethodCall = "is" + BeangenUtils.capitalize( props[i].getName() ) + "()"; else propGetterMethodCall = "get" + BeangenUtils.capitalize( props[i].getName() ) + "()"; iw.println(props[i].getSimpleTypeName() + ' ' + props[i].getName() + " = copyMe." + propGetterMethodCall + ';'); iw.print("this." + props[i].getName() + " = "); String setExp = props[i].getDefensiveCopyExpression(); if (setExp == null) setExp = props[i].getName(); iw.println(setExp + ';'); } iw.downIndent(); iw.println("}"); } }
public static boolean hasConstrainedProperties(Property[] props) { for (int i = 0, len = props.length; i < len; ++i) if (props[i].isConstrained()) return true; return false; }
public static boolean hasBoundProperties(Property[] props) { for (int i = 0, len = props.length; i < len; ++i) if (props[i].isBound()) return true; return false; }
public boolean isReadOnly() { return p.isReadOnly(); }
public String getSimpleTypeName() { return p.getSimpleTypeName(); }
public int getVariableModifiers() { return p.getVariableModifiers(); }
public int getSetterModifiers() { return p.getSetterModifiers(); }
iw.print( CodegenUtils.getModifierString( prop.getSetterModifiers() ) ); iw.print(" void set" + BeangenUtils.capitalize( prop.getName() ) + "( " + prop.getSimpleTypeName() + ' ' + prop.getName() + " )"); if ( prop.isConstrained() ) iw.println(" throws PropertyVetoException"); else iw.println( prop.getSimpleTypeName() + " oldVal = " + getExpression + ';'); String newValExpr = prop.getName(); String changeCheck; String simpleTypeName = prop.getSimpleTypeName(); if ( ClassUtils.isPrimitive( simpleTypeName ) ) changeCheck = "oldVal != " + prop.getName(); changeCheck = "! eqOrBothNull( oldVal, " + prop.getName() + " )"; if ( prop.isConstrained() ) iw.println("vcs.fireVetoableChange( \"" + prop.getName() + "\", " + oldValExpr + ", " + newValExpr + " );"); iw.downIndent(); if ( prop.isBound() ) iw.println("pcs.firePropertyChange( \"" + prop.getName() + "\", " + oldValExpr + ", " + newValExpr + " );"); iw.downIndent();
public static void writePropertyGetter( Property prop, String defensiveCopyExpression, IndentedWriter iw ) throws IOException { String pfx = ("boolean".equals( prop.getSimpleTypeName() ) ? "is" : "get" ); iw.print( CodegenUtils.getModifierString( prop.getGetterModifiers() ) ); iw.println(' ' + prop.getSimpleTypeName() + ' ' + pfx + BeangenUtils.capitalize( prop.getName() ) + "()"); String retVal = defensiveCopyExpression; if (retVal == null) retVal = prop.getName(); iw.println("{ return " + retVal + "; }"); }
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") ois.readObject();"); }