private void writeSetLocation( String key, String objectName, String trackerVariable, JSourceCode sc ) { if ( locationTracker == null ) { return; } String variable = ( trackerVariable != null ) ? trackerVariable : LOCATION_VAR; sc.add( objectName + ".set" + capitalise( singular( locationField ) ) + "( " + key + ", " + variable + " );" ); }
private void writeHelpers( JClass jClass ) { jClass.addMethod(getTrimmedValueMethod()); jClass.addMethod(getInterpolatedTrimmed()); jClass.addMethod(getRequiredAttributeValueMethod()); jClass.addMethod(getBooleanValueMethod()); jClass.addMethod(getBooleanValue2Method()); jClass.addMethod( getCharacterValueMethod() ); jClass.addMethod(convertNumericalType( "getIntegerValue", JType.INT, "Integer.valueOf( s ).intValue()", "an integer" )); jClass.addMethod(convertNumericalType( "getShortValue", JType.SHORT, "Short.valueOf( s ).shortValue()", "a short integer" )); jClass.addMethod(convertNumericalType( "getByteValue", JType.BYTE, "Byte.valueOf( s ).byteValue()", "a byte" )); jClass.addMethod(convertNumericalType( "getLongValue", JType.LONG, "Long.valueOf( s ).longValue()", "a long integer" )); jClass.addMethod(convertNumericalType( "getFloatValue", JType.FLOAT, "Float.valueOf( s ).floatValue()", "a floating point number" )); jClass.addMethod(convertNumericalType( "getDoubleValue", JType.DOUBLE, "Double.valueOf( s ).doubleValue()", "a floating point number" )); jClass.addMethod( getDateValueMethod() ); jClass.addMethod( getDateValue2Method() ); jClass.addMethod( getCheckFieldWithDuplicateMethod() ); jClass.addMethod( getCheckUnknonwElement2Method() ); jClass.addMethod( getCheckUnknownAttributeMethod() ); jClass.addMethod( getNextTagMethod() ); }
public void generate( Model model, Properties parameters ) throws ModelloException initialize( model, parameters ); requiresDomSupport = false; if ( isLocationTracking() ) locationTracker = model.getLocationTracker( getGeneratedVersion() ); if ( locationTracker == null ) ( (ModelClassMetadata) locationTracker.getMetadata( ModelClassMetadata.ID ) ).getLocationTracker(); sourceTracker = model.getSourceTracker( getGeneratedVersion() ); generateXpp3Reader();
private void generateXpp3Reader() throws ModelloException, IOException Model objectModel = getModel(); objectModel.getDefaultPackageName( isPackageWithVersion(), getGeneratedVersion() ) + ".io.xpp3"; String unmarshallerName = getFileName( "Xpp3Reader" + ( isLocationTracking() ? "Ex" : "" ) ); JSourceWriter sourceWriter = newJSourceWriter( packageName, unmarshallerName ); initHeader( jClass ); suppressAllWarnings( objectModel, jClass ); jClass.addImport( "java.text.DateFormat" ); addModelImports( jClass, null ); writeAllClassesParser( objectModel, jClass ); writeAllClassesReaders( objectModel, jClass ); writeHelpers( jClass ); writeBuildDomMethod( jClass );
String capClassName = capitalise( className ); String uncapClassName = uncapitalise( className ); addTrackingParameters( unmarshall ); writeNewSetLocation( "\"\"", uncapClassName, null, sc ); List<ModelField> modelFields = getFieldsForXml( modelClass, getGeneratedVersion() ); contentField = writeClassAttributesParser( modelFields, uncapClassName, rootElement, sc, jClass ); writePrimitiveField( contentField, contentField.getType(), uncapClassName, uncapClassName, "\"\"", "set" + capitalise( contentField.getName() ), sc ); processField( field, xmlFieldMetadata, addElse, sc, uncapClassName, jClass );
String fieldTagName = resolveTagName( field, xmlFieldMetadata ); String capFieldName = capitalise( field.getName() ); String singularName = singular( field.getName() ); writePrimitiveField( field, field.getType(), objectName, objectName, "\"" + field.getName() + "\"", "set" + capFieldName, sc ); String valuesTagName = resolveTagName( fieldTagName, xmlAssociationMetadata ); boolean inModel = isClassInModel( association.getTo(), field.getModelClass().getModel() ); writeNewSetLocation( field, objectName, LOCATION_VAR + "s", sc ); + capitalise( singular( locationField ) ) + "( \"" + field.getName() + "\" );" ); sc.add( "if ( " + LOCATION_VAR + "s == null )" ); sc.add( "{" ); sc.indent(); writeNewSetLocation( field, objectName, LOCATION_VAR + "s", sc ); sc.unindent(); sc.add( "}" ); writePrimitiveField( association, association.getTo(), associationName, LOCATION_VAR + "s", key, "add", sc ); writeNewSetLocation( field, objectName, LOCATION_VAR + "s", sc );
String capClassName = capitalise( className ); addTrackingParameters( unmarshall ); String tagName = resolveTagName( modelClass ); String variableName = uncapitalise( className ); addTrackingParameters( unmarshall ); addTrackingParameters( unmarshall );
String tagName = resolveTagName( field, xmlFieldMetadata ); sc.indent(); writePrimitiveField( field, field.getType(), objectName, objectName, "\"" + field.getName() + "\"", "set" + capitalise( field.getName() ), sc );