CPD Results
The following document contains the results of PMD's CPD 6.55.0.
Duplications
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 909 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 1021 |
jClass.addMethod(method); } private void addTrackingParameters(JMethod method) { if (sourceTracker != null) { method.addParameter(new JParameter(new JClass(sourceTracker.getName()), SOURCE_PARAM)); } } private void writeNewSetLocation(ModelField field, String objectName, String trackerVariable, JSourceCode sc) { writeNewSetLocation("\"" + field.getName() + "\"", objectName, trackerVariable, sc); } private void writeNewSetLocation(String key, String objectName, String trackerVariable, JSourceCode sc) { writeNewLocation(trackerVariable, sc); writeSetLocation(key, objectName, trackerVariable, sc); } private void writeNewLocation(String trackerVariable, JSourceCode sc) { if (locationTracker == null) { return; } String constr = "new " + locationTracker.getName() + "( parser.getLineNumber(), parser.getColumnNumber()"; constr += (sourceTracker != null) ? ", " + SOURCE_PARAM : ""; constr += " )"; sc.add(((trackerVariable != null) ? trackerVariable : LOCATION_VAR) + " = " + constr + ";"); } 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 + " );"); } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 500 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 565 |
+ "' data to start with an Array\", parser.getCurrentLocation() );"); sc.add("}"); JavaFieldMetadata javaFieldMetadata = (JavaFieldMetadata) association.getMetadata(JavaFieldMetadata.ID); String adder; if (javaFieldMetadata.isGetter() && javaFieldMetadata.isSetter()) { sc.add(type + " " + associationName + " = " + objectName + ".get" + capFieldName + "();"); sc.add("if ( " + associationName + " == null )"); sc.add("{"); sc.indent(); sc.add(associationName + " = " + association.getDefaultValue() + ";"); sc.add(objectName + ".set" + capFieldName + "( " + associationName + " );"); sc.unindent(); sc.add("}"); adder = associationName + ".add"; } else { adder = objectName + ".add" + association.getTo(); } if (!inModel && locationTracker != null) { sc.add(locationTracker.getName() + " " + LOCATION_VAR + "s = " + objectName + ".get" + 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("}"); } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 186 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 212 |
sc.add("JsonParser parser = factory.createParser( reader );"); sc.add("return " + readerMethodName + "( parser, strict );"); jClass.addMethod(unmarshall); unmarshall = new JMethod(readerMethodName, new JClass(className), null); unmarshall.addParameter(new JParameter(new JClass("Reader"), "reader")); unmarshall.addException(new JClass("IOException")); sc = unmarshall.getSourceCode(); sc.add("return " + readerMethodName + "( reader, true );"); jClass.addMethod(unmarshall); // ---------------------------------------------------------------------- // Write the read(InputStream[,boolean]) methods which will do the unmarshalling. // ---------------------------------------------------------------------- unmarshall = new JMethod(readerMethodName, new JClass(className), null); unmarshall.addParameter(new JParameter(new JClass("InputStream"), "in")); unmarshall.addParameter(new JParameter(JClass.BOOLEAN, "strict")); addTrackingParameters(unmarshall); unmarshall.addException(new JClass("IOException")); sc = unmarshall.getSourceCode(); sc.add("return " + readerMethodName + "( new InputStreamReader( in ), strict" + trackingArgs + " );"); jClass.addMethod(unmarshall); unmarshall = new JMethod(readerMethodName, new JClass(className), null); unmarshall.addParameter(new JParameter(new JClass("InputStream"), "in")); unmarshall.addException(new JClass("IOException")); sc = unmarshall.getSourceCode(); sc.add("return " + readerMethodName + "( in, true );"); jClass.addMethod(unmarshall); // -------------------------------------------------------------------- } private void generateJacksonReader() throws ModelloException, IOException { |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jReaderGenerator.java | Modello Dom4J Plugin | 857 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 935 |
method.addParameter(new JParameter(new JClass("String"), "attribute")); sc = method.getSourceCode(); sc.add("if ( s != null )"); sc.add("{"); sc.addIndented("return s.charAt( 0 );"); sc.add("}"); sc.add("return 0;"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType("getIntegerValue", JType.INT, "Integer.valueOf( s ).intValue()", "an integer"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType( "getShortValue", JType.SHORT, "Short.valueOf( s ).shortValue()", "a short integer"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType("getByteValue", JType.BYTE, "Byte.valueOf( s ).byteValue()", "a byte"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType("getLongValue", JType.LONG, "Long.valueOf( s ).longValue()", "a long integer"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType( "getFloatValue", JType.FLOAT, "Float.valueOf( s ).floatValue()", "a floating point number"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType( "getDoubleValue", JType.DOUBLE, "Double.valueOf( s ).doubleValue()", "a floating point number"); jClass.addMethod(method); // -------------------------------------------------------------------- method = new JMethod("getDateValue", new JClass("java.util.Date"), null); method.getModifiers().makePrivate(); method.addParameter(new JParameter(new JClass("String"), "s")); method.addParameter(new JParameter(new JClass("String"), "attribute")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 105 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 100 |
throw new ModelloException("Exception while generating Jackson Reader.", ex); } } private void writeAllClassesReaders(Model objectModel, JClass jClass) { ModelClass root = objectModel.getClass(objectModel.getRoot(getGeneratedVersion()), getGeneratedVersion()); for (ModelClass clazz : getClasses(objectModel)) { if (isTrackingSupport(clazz)) { continue; } writeClassReaders(clazz, jClass, root.getName().equals(clazz.getName())); } } private void writeClassReaders(ModelClass modelClass, JClass jClass, boolean rootElement) { JavaClassMetadata javaClassMetadata = (JavaClassMetadata) modelClass.getMetadata(JavaClassMetadata.class.getName()); // Skip abstract classes, no way to parse them out into objects if (javaClassMetadata.isAbstract()) { return; } XmlClassMetadata xmlClassMetadata = (XmlClassMetadata) modelClass.getMetadata(XmlClassMetadata.ID); if (!rootElement && !xmlClassMetadata.isStandaloneRead()) { return; } String className = modelClass.getName(); String capClassName = capitalise(className); String readerMethodName = "read"; if (!rootElement) { readerMethodName += capClassName; } // ---------------------------------------------------------------------- // Write the read(JsonParser) method which will do the unmarshalling. // ---------------------------------------------------------------------- JMethod unmarshall = new JMethod(readerMethodName, new JClass(className), null); unmarshall.getModifiers().makePrivate(); unmarshall.addParameter(new JParameter(new JClass("JsonParser"), "parser")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/java/JavaModelloGenerator.java | Modello Java Plugin | 1023 |
org/codehaus/modello/plugin/java/JavaModelloGenerator.java | Modello Java Plugin | 1067 |
sc = jMethod.getSourceCode(); sc.add("if ( source == null )"); sc.add("{"); sc.addIndented("return target;"); sc.add("}"); sc.add("else if ( target == null )"); sc.add("{"); sc.addIndented("return source;"); sc.add("}"); sc.add(""); sc.add(locationClass.getName() + " result ="); sc.add(" new " + locationClass.getName() + "( target.getLineNumber(), target.getColumnNumber()" + (sourceClass != null ? ", target.get" + capitalise(source.getName()) + "()" : "") + " );"); sc.add(""); sc.add(fieldType + " locations;"); sc.add(fieldType + " sourceLocations = source.get" + capitalise(locationsField) + "();"); sc.add(fieldType + " targetLocations = target.get" + capitalise(locationsField) + "();"); sc.add("if ( sourceLocations == null )"); sc.add("{"); sc.addIndented("locations = targetLocations;"); sc.add("}"); sc.add("else if ( targetLocations == null )"); sc.add("{"); sc.addIndented("locations = sourceLocations;"); sc.add("}"); sc.add("else"); sc.add("{"); sc.addIndented("locations = new " + fieldImpl.getName() + "();"); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 105 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 100 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 92 |
throw new ModelloException("Exception while generating Jackson Reader.", ex); } } private void writeAllClassesReaders(Model objectModel, JClass jClass) { ModelClass root = objectModel.getClass(objectModel.getRoot(getGeneratedVersion()), getGeneratedVersion()); for (ModelClass clazz : getClasses(objectModel)) { if (isTrackingSupport(clazz)) { continue; } writeClassReaders(clazz, jClass, root.getName().equals(clazz.getName())); } } private void writeClassReaders(ModelClass modelClass, JClass jClass, boolean rootElement) { JavaClassMetadata javaClassMetadata = (JavaClassMetadata) modelClass.getMetadata(JavaClassMetadata.class.getName()); // Skip abstract classes, no way to parse them out into objects if (javaClassMetadata.isAbstract()) { return; } XmlClassMetadata xmlClassMetadata = (XmlClassMetadata) modelClass.getMetadata(XmlClassMetadata.ID); if (!rootElement && !xmlClassMetadata.isStandaloneRead()) { return; } String className = modelClass.getName(); String capClassName = capitalise(className); String readerMethodName = "read"; if (!rootElement) { readerMethodName += capClassName; } // ---------------------------------------------------------------------- // Write the read(JsonParser) method which will do the unmarshalling. // ---------------------------------------------------------------------- JMethod unmarshall = new JMethod(readerMethodName, new JClass(className), null); unmarshall.getModifiers().makePrivate(); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 306 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 423 |
} jClass.print(sourceWriter); sourceWriter.close(); } private void writeAllClassesParser(Model objectModel, JClass jClass) { ModelClass root = objectModel.getClass(objectModel.getRoot(getGeneratedVersion()), getGeneratedVersion()); for (ModelClass clazz : getClasses(objectModel)) { if (isTrackingSupport(clazz)) { continue; } writeClassParser(clazz, jClass, root.getName().equals(clazz.getName())); } } private void writeClassParser(ModelClass modelClass, JClass jClass, boolean rootElement) { JavaClassMetadata javaClassMetadata = (JavaClassMetadata) modelClass.getMetadata(JavaClassMetadata.class.getName()); // Skip abstract classes, no way to parse them out into objects if (javaClassMetadata.isAbstract()) { return; } String className = modelClass.getName(); String capClassName = capitalise(className); String uncapClassName = uncapitalise(className); JMethod unmarshall = new JMethod("parse" + capClassName, new JClass(className), null); unmarshall.getModifiers().makePrivate(); unmarshall.addParameter(new JParameter(new JClass("JsonParser"), "parser")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 308 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 322 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 429 |
jClass.print(sourceWriter); sourceWriter.close(); } private void writeAllClassesParser(Model objectModel, JClass jClass) { ModelClass root = objectModel.getClass(objectModel.getRoot(getGeneratedVersion()), getGeneratedVersion()); for (ModelClass clazz : getClasses(objectModel)) { if (isTrackingSupport(clazz)) { continue; } writeClassParser(clazz, jClass, root.getName().equals(clazz.getName())); } } private void writeClassParser(ModelClass modelClass, JClass jClass, boolean rootElement) { JavaClassMetadata javaClassMetadata = (JavaClassMetadata) modelClass.getMetadata(JavaClassMetadata.class.getName()); // Skip abstract classes, no way to parse them out into objects if (javaClassMetadata.isAbstract()) { return; } String className = modelClass.getName(); String capClassName = capitalise(className); String uncapClassName = uncapitalise(className); JMethod unmarshall = new JMethod("parse" + capClassName, new JClass(className), null); unmarshall.getModifiers().makePrivate(); unmarshall.addParameter(new JParameter(new JClass("JsonParser"), "parser")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jReaderGenerator.java | Modello Dom4J Plugin | 857 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 935 |
org/codehaus/modello/plugin/stax/StaxReaderGenerator.java | Modello StAX Plugin | 1589 |
method.addParameter(new JParameter(new JClass("String"), "attribute")); sc = method.getSourceCode(); sc.add("if ( s != null )"); sc.add("{"); sc.addIndented("return s.charAt( 0 );"); sc.add("}"); sc.add("return 0;"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType("getIntegerValue", JType.INT, "Integer.valueOf( s ).intValue()", "an integer"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType( "getShortValue", JType.SHORT, "Short.valueOf( s ).shortValue()", "a short integer"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType("getByteValue", JType.BYTE, "Byte.valueOf( s ).byteValue()", "a byte"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType("getLongValue", JType.LONG, "Long.valueOf( s ).longValue()", "a long integer"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType( "getFloatValue", JType.FLOAT, "Float.valueOf( s ).floatValue()", "a floating point number"); jClass.addMethod(method); // -------------------------------------------------------------------- method = convertNumericalType( "getDoubleValue", JType.DOUBLE, "Double.valueOf( s ).doubleValue()", "a floating point number"); jClass.addMethod(method); // -------------------------------------------------------------------- method = new JMethod("getDateValue", new JClass("java.util.Date"), null); method.getModifiers().makePrivate(); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 361 |
org/codehaus/modello/plugin/xpp3/Xpp3WriterGenerator.java | Modello XPP3 Plugin | 301 |
+ ", contentHandler );"); } // XML tags for (ModelField field : modelFields) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID); if (xmlFieldMetadata.isContent()) { // skip field with type Content continue; } JavaFieldMetadata javaFieldMetadata = (JavaFieldMetadata) field.getMetadata(JavaFieldMetadata.ID); String fieldTagName = resolveTagName(field, xmlFieldMetadata); String type = field.getType(); String value = uncapClassName + "." + getPrefix(javaFieldMetadata) + capitalise(field.getName()) + "()"; if (xmlFieldMetadata.isAttribute()) { continue; } if (field instanceof ModelAssociation) { ModelAssociation association = (ModelAssociation) field; String associationName = association.getName(); if (association.isOneMultiplicity()) { sc.add(getValueChecker(type, value, association)); sc.add("{"); sc.addIndented("write" + association.getTo() + "( (" + association.getTo() + ") " + value + ", \"" + fieldTagName + "\", contentHandler, attributes );"); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 409 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 606 |
} /** * Generate code to process a field represented as an XML element. * * @param field the field to process * @param xmlFieldMetadata its XML metadata * @param addElse add an <code>else</code> statement before generating a new <code>if</code> * @param sc the method source code to add to * @param objectName the object name in the source * @param jClass the generated class source file */ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata, boolean addElse, JSourceCode sc, String objectName, JClass jClass) { String fieldTagName = resolveTagName(field, xmlFieldMetadata); String capFieldName = capitalise(field.getName()); String singularName = singular(field.getName()); String alias; if (StringUtils.isEmpty(field.getAlias())) { alias = "null"; } else { alias = "\"" + field.getAlias() + "\""; } String tagComparison = (addElse ? "else " : "") + "if ( checkFieldWithDuplicate( parser, \"" + fieldTagName + "\", " + alias + ", parsed ) )"; if (!(field instanceof ModelAssociation)) { // model field sc.add(tagComparison); sc.add("{"); sc.indent(); writePrimitiveField( field, field.getType(), objectName, objectName, "\"" + field.getName() + "\"", "set" + capFieldName, sc, |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/velocity/Helper.java | Modello Velocity Plugin | 139 |
org/codehaus/modello/plugins/xml/XmlModelHelpers.java | Modello XML Plugin | 170 |
fields = new ArrayList<>(); for (ModelField field : modelClass.getFields(version)) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID); if (xmlFieldMetadata.isTransient()) { // just ignore xml.transient fields continue; } if (xmlFieldMetadata.getInsertParentFieldsUpTo() != null) { // insert fields from parent up to the specified field boolean found = false; while (!found && parentIter.hasNext()) { ModelField parentField = parentIter.next(); fields.add(parentField); found = parentField.getName().equals(xmlFieldMetadata.getInsertParentFieldsUpTo()); } if (!found) { // interParentFieldsUpTo not found throw new ModelloRuntimeException("parent field not found: class " + modelClass.getName() + " xml.insertParentFieldUpTo='" + xmlFieldMetadata.getInsertParentFieldsUpTo() + "'"); } } fields.add(field); } // add every remaining fields from parent class while (parentIter.hasNext()) { fields.add(parentIter.next()); } } return fields; } } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonWriterGenerator.java | Modello Jackson Plugin | 277 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlWriterGenerator.java | Modello SnakeYaml Plugin | 336 |
sc.add("generator.writeObjectFieldStart( \"" + fieldTagName + "\" );"); } StringBuilder entryTypeBuilder = new StringBuilder("java.util.Map.Entry"); if (useJava5) { entryTypeBuilder.append('<'); if (association.getType().equals(ModelDefault.PROPERTIES)) { entryTypeBuilder.append("Object, Object"); } else { entryTypeBuilder.append("String, ").append(association.getTo()); } entryTypeBuilder.append('>'); } if (useJava5) { sc.add("for ( " + entryTypeBuilder + " entry : " + value + ".entrySet() )"); } else { sc.add("for ( java.util.Iterator it = " + value + ".entrySet().iterator(); it.hasNext(); )"); } sc.add("{"); sc.indent(); if (!useJava5) { sc.add(entryTypeBuilder + " entry = (" + entryTypeBuilder + ") it.next();"); } sc.add("final String key = String.valueOf( entry.getKey() );"); sc.add("final String value = String.valueOf( entry.getValue() );"); if (xmlAssociationMetadata.isMapExplode()) { sc.add("generator.writeStartObject();"); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jWriterGenerator.java | Modello Dom4J Plugin | 220 |
org/codehaus/modello/plugin/xpp3/Xpp3WriterGenerator.java | Modello XPP3 Plugin | 262 |
sc.add("Element element = parentElement.addElement( tagName );"); } ModelField contentField = null; String contentValue = null; List<ModelField> modelFields = getFieldsForXml(modelClass, getGeneratedVersion()); // XML attributes for (ModelField field : modelFields) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID); JavaFieldMetadata javaFieldMetadata = (JavaFieldMetadata) field.getMetadata(JavaFieldMetadata.ID); String fieldTagName = resolveTagName(field, xmlFieldMetadata); String type = field.getType(); String value = uncapClassName + "." + getPrefix(javaFieldMetadata) + capitalise(field.getName()) + "()"; if (xmlFieldMetadata.isContent()) { contentField = field; contentValue = value; continue; } if (xmlFieldMetadata.isAttribute()) { sc.add(getValueChecker(type, value, field)); sc.add("{"); sc.addIndented("element.addAttribute( \"" + fieldTagName + "\", " |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jWriterGenerator.java | Modello Dom4J Plugin | 223 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlWriterGenerator.java | Modello SnakeYaml Plugin | 197 |
org/codehaus/modello/plugin/xpp3/Xpp3WriterGenerator.java | Modello XPP3 Plugin | 265 |
ModelField contentField = null; String contentValue = null; List<ModelField> modelFields = getFieldsForXml(modelClass, getGeneratedVersion()); // XML attributes for (ModelField field : modelFields) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID); JavaFieldMetadata javaFieldMetadata = (JavaFieldMetadata) field.getMetadata(JavaFieldMetadata.ID); String fieldTagName = resolveTagName(field, xmlFieldMetadata); String type = field.getType(); String value = uncapClassName + "." + getPrefix(javaFieldMetadata) + capitalise(field.getName()) + "()"; if (xmlFieldMetadata.isContent()) { contentField = field; contentValue = value; continue; } if (xmlFieldMetadata.isAttribute()) { sc.add(getValueChecker(type, value, field)); sc.add("{"); sc.addIndented("element.addAttribute( \"" + fieldTagName + "\", " |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jReaderGenerator.java | Modello Dom4J Plugin | 408 |
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 402 |
sc.unindent(); sc.add("}"); } sc.add("return " + uncapClassName + ";"); jClass.addMethod(unmarshall); } /** * Generate code to process a field represented as an XML element. * * @param field the field to process * @param xmlFieldMetadata its XML metadata * @param addElse add an <code>else</code> statement before generating a new <code>if</code> * @param sc the method source code to add to * @param objectName the object name in the source * @param jClass the generated class source file */ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata, boolean addElse, JSourceCode sc, String objectName, JClass jClass) { String fieldTagName = resolveTagName(field, xmlFieldMetadata); String capFieldName = capitalise(field.getName()); String singularName = singular(field.getName()); String alias; if (StringUtils.isEmpty(field.getAlias())) { alias = "null"; } else { alias = "\"" + field.getAlias() + "\""; } String tagComparison = (addElse ? "else " : "") + "if ( checkFieldWithDuplicate( childElement, \"" |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 910 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 1022 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 1530 |
} private void addTrackingParameters(JMethod method) { if (sourceTracker != null) { method.addParameter(new JParameter(new JClass(sourceTracker.getName()), SOURCE_PARAM)); } } private void writeNewSetLocation(ModelField field, String objectName, String trackerVariable, JSourceCode sc) { writeNewSetLocation("\"" + field.getName() + "\"", objectName, trackerVariable, sc); } private void writeNewSetLocation(String key, String objectName, String trackerVariable, JSourceCode sc) { writeNewLocation(trackerVariable, sc); writeSetLocation(key, objectName, trackerVariable, sc); } private void writeNewLocation(String trackerVariable, JSourceCode sc) { if (locationTracker == null) { return; } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 255 |
org/codehaus/modello/plugin/xpp3/Xpp3WriterGenerator.java | Modello XPP3 Plugin | 205 |
createXpp3DomMethod(jClass); } jClass.print(sourceWriter); sourceWriter.close(); } private void writeAllClasses(Model objectModel, JClass jClass) throws ModelloException { for (ModelClass clazz : getClasses(objectModel)) { writeClass(clazz, jClass); } } private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloException { String className = modelClass.getName(); String uncapClassName = uncapitalise(className); JMethod marshall = new JMethod("write" + className); marshall.addParameter(new JParameter(new JClass(className), uncapClassName)); marshall.addParameter(new JParameter(new JClass("String"), "tagName")); marshall.addParameter(new JParameter(new JClass("ContentHandler"), "contentHandler")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jWriterGenerator.java | Modello Dom4J Plugin | 167 |
org/codehaus/modello/plugin/stax/StaxWriterGenerator.java | Modello StAX Plugin | 217 |
writeDomHelpers(jClass); } jClass.print(sourceWriter); sourceWriter.close(); } private void writeAllClasses(Model objectModel, JClass jClass) throws ModelloException { for (ModelClass clazz : getClasses(objectModel)) { writeClass(clazz, jClass); } } private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloException { String className = modelClass.getName(); String uncapClassName = uncapitalise(className); JMethod marshall = new JMethod("write" + className); marshall.getModifiers().makePrivate(); marshall.addParameter(new JParameter(new JClass(className), uncapClassName)); marshall.addParameter(new JParameter(new JClass("String"), "tagName")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jWriterGenerator.java | Modello Dom4J Plugin | 230 |
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 302 |
org/codehaus/modello/plugin/xpp3/Xpp3WriterGenerator.java | Modello XPP3 Plugin | 272 |
for (ModelField field : modelFields) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID); JavaFieldMetadata javaFieldMetadata = (JavaFieldMetadata) field.getMetadata(JavaFieldMetadata.ID); String fieldTagName = resolveTagName(field, xmlFieldMetadata); String type = field.getType(); String value = uncapClassName + "." + getPrefix(javaFieldMetadata) + capitalise(field.getName()) + "()"; if (xmlFieldMetadata.isContent()) { contentField = field; contentValue = value; continue; } if (xmlFieldMetadata.isAttribute()) { sc.add(getValueChecker(type, value, field)); sc.add("{"); sc.addIndented("element.addAttribute( \"" + fieldTagName + "\", " |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 520 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 585 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 763 |
sc.unindent(); sc.add("}"); adder = associationName + ".add"; } else { adder = objectName + ".add" + association.getTo(); } if (!inModel && locationTracker != null) { sc.add(locationTracker.getName() + " " + LOCATION_VAR + "s = " + objectName + ".get" + 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("}"); } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/java/javasource/JClass.java | Modello Java Plugin | 578 |
org/codehaus/modello/plugin/java/javasource/JInterface.java | Modello Java Plugin | 388 |
if (fieldAnnotations != null) fieldAnnotations.print(jsw); // -- print member jsw.write(jField.getModifiers().toString()); jsw.write(' '); JType type = jField.getType(); String typeName = type.toString(); // -- for esthetics use short name in some cases if (typeName.equals(toString())) { typeName = type.getLocalName(); } jsw.write(typeName); jsw.write(' '); jsw.write(jField.getName()); String init = jField.getInitString(); if (init != null) { jsw.write(" = "); jsw.write(init); } jsw.writeln(';'); jsw.writeln(); } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 302 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlWriterGenerator.java | Modello SnakeYaml Plugin | 204 |
for (ModelField field : modelFields) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID); JavaFieldMetadata javaFieldMetadata = (JavaFieldMetadata) field.getMetadata(JavaFieldMetadata.ID); String fieldTagName = resolveTagName(field, xmlFieldMetadata); String type = field.getType(); String value = uncapClassName + "." + getPrefix(javaFieldMetadata) + capitalise(field.getName()) + "()"; if (xmlFieldMetadata.isContent()) { contentField = field; contentValue = value; continue; } if (xmlFieldMetadata.isAttribute()) { sc.add(getValueChecker(type, value, field)); sc.add("{"); sc.addIndented("attributes.addAttribute( NAMESPACE, \"" |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 441 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 494 |
String tagComparison = (addElse ? "else " : "") + "if ( checkFieldWithDuplicate( parser, \"" + fieldTagName + "\", " + alias + ", parsed ) )"; if (!(field instanceof ModelAssociation)) { // model field sc.add(tagComparison); sc.add("{"); sc.indent(); writePrimitiveField( field, field.getType(), objectName, objectName, "\"" + field.getName() + "\"", "set" + capFieldName, sc, false); sc.unindent(); sc.add("}"); } else { // model association ModelAssociation association = (ModelAssociation) field; String associationName = association.getName(); if (association.isOneMultiplicity()) { sc.add(tagComparison); sc.add("{"); sc.addIndented(objectName + ".set" + capFieldName + "( parse" + association.getTo() + "( parser, strict" |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 508 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 573 |
org/codehaus/modello/plugin/stax/StaxReaderGenerator.java | Modello StAX Plugin | 1064 |
if (javaFieldMetadata.isGetter() && javaFieldMetadata.isSetter()) { sc.add(type + " " + associationName + " = " + objectName + ".get" + capFieldName + "();"); sc.add("if ( " + associationName + " == null )"); sc.add("{"); sc.indent(); sc.add(associationName + " = " + association.getDefaultValue() + ";"); sc.add(objectName + ".set" + capFieldName + "( " + associationName + " );"); sc.unindent(); sc.add("}"); adder = associationName + ".add"; } else { adder = objectName + ".add" + association.getTo(); } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 758 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 757 |
} } private void writeHelpers(JClass jClass) { JMethod method = new JMethod("getTrimmedValue", new JClass("String"), null); method.getModifiers().makePrivate(); method.addParameter(new JParameter(new JClass("String"), "s")); JSourceCode sc = method.getSourceCode(); sc.add("if ( s != null )"); sc.add("{"); sc.addIndented("s = s.trim();"); sc.add("}"); sc.add("return s;"); jClass.addMethod(method); // -------------------------------------------------------------------- method = new JMethod("getRequiredAttributeValue", new JClass("String"), null); method.addException(new JClass("JsonParseException")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/java/JavaModelloGenerator.java | Modello Java Plugin | 1440 |
org/codehaus/modello/plugin/java/JavaModelloGenerator.java | Modello Java Plugin | 2036 |
JType componentType = getComponentType(modelAssociation, javaAssociationMetadata); String defaultValue = getDefaultValue(modelAssociation, componentType); JType type; if (modelAssociation.isGenericType()) { type = new JCollectionType(modelAssociation.getType(), componentType, useJava5); } else if (ModelDefault.MAP.equals(modelAssociation.getType())) { JMapType mapType = new JMapType(modelAssociation.getType(), defaultValue, componentType, useJava5); defaultValue = mapType.getInstanceName(); type = mapType; } else { type = new JClass(modelAssociation.getType()); } JField jField = new JField(type, modelAssociation.getName()); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 365 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlWriterGenerator.java | Modello SnakeYaml Plugin | 243 |
org/codehaus/modello/plugin/xpp3/Xpp3WriterGenerator.java | Modello XPP3 Plugin | 305 |
for (ModelField field : modelFields) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID); if (xmlFieldMetadata.isContent()) { // skip field with type Content continue; } JavaFieldMetadata javaFieldMetadata = (JavaFieldMetadata) field.getMetadata(JavaFieldMetadata.ID); String fieldTagName = resolveTagName(field, xmlFieldMetadata); String type = field.getType(); String value = uncapClassName + "." + getPrefix(javaFieldMetadata) + capitalise(field.getName()) + "()"; if (xmlFieldMetadata.isAttribute()) { continue; } if (field instanceof ModelAssociation) { ModelAssociation association = (ModelAssociation) field; |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 395 |
org/codehaus/modello/plugin/stax/StaxWriterGenerator.java | Modello StAX Plugin | 369 |
+ fieldTagName + "\", contentHandler, attributes );"); sc.add("}"); } else { // MANY_MULTIPLICITY XmlAssociationMetadata xmlAssociationMetadata = (XmlAssociationMetadata) association.getAssociationMetadata(XmlAssociationMetadata.ID); String valuesTagName = resolveTagName(fieldTagName, xmlAssociationMetadata); type = association.getType(); String toType = association.getTo(); boolean wrappedItems = xmlAssociationMetadata.isWrappedItems(); if (ModelDefault.LIST.equals(type) || ModelDefault.SET.equals(type)) { sc.add(getValueChecker(type, value, association)); sc.add("{"); sc.indent(); if (wrappedItems) { sc.add("contentHandler.startElement( NAMESPACE, \"" + fieldTagName + "\", \"" + fieldTagName |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonWriterGenerator.java | Modello Jackson Plugin | 165 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlWriterGenerator.java | Modello SnakeYaml Plugin | 166 |
jClass.addMethod(marshall); jClass.print(sourceWriter); sourceWriter.close(); } private void writeAllClasses(Model objectModel, JClass jClass) throws ModelloException { for (ModelClass clazz : getClasses(objectModel)) { writeClass(clazz, jClass); } } private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloException { String className = modelClass.getName(); String uncapClassName = uncapitalise(className); JMethod marshall = new JMethod("write" + className); marshall.addParameter(new JParameter(new JClass(className), uncapClassName)); marshall.addParameter(new JParameter(new JClass("JsonGenerator"), "generator")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/jackson/JacksonWriterGenerator.java | Modello Jackson Plugin | 167 |
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 258 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlWriterGenerator.java | Modello SnakeYaml Plugin | 168 |
org/codehaus/modello/plugin/xpp3/Xpp3WriterGenerator.java | Modello XPP3 Plugin | 208 |
jClass.print(sourceWriter); sourceWriter.close(); } private void writeAllClasses(Model objectModel, JClass jClass) throws ModelloException { for (ModelClass clazz : getClasses(objectModel)) { writeClass(clazz, jClass); } } private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloException { String className = modelClass.getName(); String uncapClassName = uncapitalise(className); JMethod marshall = new JMethod("write" + className); marshall.addParameter(new JParameter(new JClass(className), uncapClassName)); marshall.addParameter(new JParameter(new JClass("JsonGenerator"), "generator")); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/java/javasource/JCompUnit.java | Modello Java Plugin | 269 |
org/codehaus/modello/plugin/java/javasource/JStructure.java | Modello Java Plugin | 355 |
String javaPackagePath = ""; if ((packageName != null) && (packageName.length() > 0)) { javaPackagePath = packageName.replace('.', File.separatorChar); } // -- Create fully qualified path (including 'destDir') to file File pathFile; if (destDir == null) pathFile = new File(javaPackagePath); else pathFile = new File(destDir, javaPackagePath); if (!pathFile.exists()) { pathFile.mkdirs(); } // -- Prefix filename with path if (pathFile.toString().length() > 0) filename = pathFile.toString() + File.separator + filename; return filename; } // -- getFilename /** * Returns the name of the package that this JCompUnit is a member of * @return the name of the package that this JCompUnit is a member of, * or null if there is no current package name defined **/ public String getPackageName() { |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 999 |
org/codehaus/modello/plugin/stax/StaxReaderGenerator.java | Modello StAX Plugin | 1503 |
"new ParserException( \"\", event.getStartMark(), e.getMessage(), event.getEndMark() )"); jClass.addMethod(method); // -------------------------------------------------------------------- method = new JMethod("getDefaultValue", new JClass("String"), null); method.getModifiers().makePrivate(); method.addParameter(new JParameter(new JClass("String"), "s")); method.addParameter(new JParameter(new JClass("String"), "v")); sc = method.getSourceCode(); sc.add("if ( s == null )"); sc.add("{"); sc.addIndented("s = v;"); sc.add("}"); sc.add("return s;"); jClass.addMethod(method); |
File | Project | Line |
---|---|---|
org/codehaus/modello/core/io/ModelReader.java | Modello Core | 342 |
org/codehaus/modello/core/io/ModelReader.java | Modello Core | 364 |
private void parseCodeSegment(ModelClass modelClass, XmlPullParser parser) throws XmlPullParserException, IOException { while (parser.nextTag() == XmlPullParser.START_TAG) { if ("codeSegment".equals(parser.getName())) { CodeSegment codeSegment = new CodeSegment(); while (parser.nextTag() == XmlPullParser.START_TAG) { if (parseBaseElement(codeSegment, parser)) { } else if ("code".equals(parser.getName())) { codeSegment.setCode(parser.nextText()); } else { parser.nextText(); } } |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jReaderGenerator.java | Modello Dom4J Plugin | 1021 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 1493 |
method.addParameter(new JParameter(new JClass("String"), "attribute")); method.addParameter(new JParameter(JClass.BOOLEAN, "strict")); JSourceCode sc = method.getSourceCode(); sc.add("if ( s != null )"); sc.add("{"); sc.indent(); sc.add("try"); sc.add("{"); sc.addIndented("return " + expression + ";"); sc.add("}"); sc.add("catch ( NumberFormatException nfe )"); sc.add("{"); sc.indent(); sc.add("if ( strict )"); sc.add("{"); sc.addIndented("throw new DocumentException( \"Unable to parse element '\" + attribute + \"', must be " |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 461 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 605 |
return contentField; } /** * Generate code to process a field represented as an XML element. * * @param field the field to process * @param xmlFieldMetadata its XML metadata * @param addElse add an <code>else</code> statement before generating a new <code>if</code> * @param sc the method source code to add to * @param objectName the object name in the source * @param jClass the generated class source file */ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata, boolean addElse, JSourceCode sc, String objectName, JClass jClass) { String fieldTagName = resolveTagName(field, xmlFieldMetadata); String capFieldName = capitalise(field.getName()); String singularName = singular(field.getName()); String alias; if (StringUtils.isEmpty(field.getAlias())) { alias = "null"; } else { alias = "\"" + field.getAlias() + "\""; } String tagComparison = (addElse ? "else " : "") + "if ( checkFieldWithDuplicate( event, \"" + fieldTagName |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 1148 |
org/codehaus/modello/plugin/stax/StaxReaderGenerator.java | Modello StAX Plugin | 1774 |
method.addParameter(new JParameter(new JClass("Event"), "event")); method.addParameter(new JParameter(JType.BOOLEAN, "strict")); JSourceCode sc = method.getSourceCode(); sc.add("if ( s != null )"); sc.add("{"); sc.indent(); sc.add("try"); sc.add("{"); sc.addIndented("return " + expression + ";"); sc.add("}"); sc.add("catch ( NumberFormatException nfe )"); sc.add("{"); sc.indent(); sc.add("if ( strict )"); sc.add("{"); sc.addIndented( |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jReaderGenerator.java | Modello Dom4J Plugin | 776 |
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 757 |
throw new IllegalArgumentException("Unknown type: " + type); } } private void writeHelpers(JClass jClass) { JMethod method = new JMethod("getTrimmedValue", new JClass("String"), null); method.getModifiers().makePrivate(); method.addParameter(new JParameter(new JClass("String"), "s")); JSourceCode sc = method.getSourceCode(); sc.add("if ( s != null )"); sc.add("{"); sc.addIndented("s = s.trim();"); sc.add("}"); sc.add("return s;"); jClass.addMethod(method); // -------------------------------------------------------------------- /* TODO method = new JMethod( new JClass( "String" ), "getRequiredAttributeValue" ); method.addException( new JClass( "XmlPullParserException" ) ); method.getModifiers().makePrivate(); method.addParameter( new JParameter( new JClass( "String" ), "s" ) ); method.addParameter( new JParameter( new JClass( "String" ), "attribute" ) ); method.addParameter( new JParameter( new JClass( "XmlPullParser" ), "parser" ) ); method.addParameter( new JParameter( JClass.Boolean, "strict" ) ); sc = method.getSourceCode(); sc.add( "if ( s == null )" ); sc.add( "{" ); sc.indent(); sc.add( "if ( strict )" ); sc.add( "{" ); sc.addIndented( "throw new XmlPullParserException( \"Missing required value for attribute '\" + attribute + \"'\", parser, null );" ); sc.add( "}" ); sc.unindent(); sc.add( "}" ); sc.add( "return s;" ); jClass.addMethod( method ); */ // -------------------------------------------------------------------- method = new JMethod("getBooleanValue", JType.BOOLEAN, null); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jWriterGenerator.java | Modello Dom4J Plugin | 307 |
org/codehaus/modello/plugin/sax/SaxWriterGenerator.java | Modello SAX Plugin | 395 |
org/codehaus/modello/plugin/stax/StaxWriterGenerator.java | Modello StAX Plugin | 369 |
sc.addIndented("write" + association.getTo() + "( " + value + ", \"" + fieldTagName + "\", element );"); sc.add("}"); } else { // MANY_MULTIPLICITY XmlAssociationMetadata xmlAssociationMetadata = (XmlAssociationMetadata) association.getAssociationMetadata(XmlAssociationMetadata.ID); String valuesTagName = resolveTagName(fieldTagName, xmlAssociationMetadata); type = association.getType(); String toType = association.getTo(); boolean wrappedItems = xmlAssociationMetadata.isWrappedItems(); if (ModelDefault.LIST.equals(type) || ModelDefault.SET.equals(type)) { sc.add(getValueChecker(type, value, association)); sc.add("{"); sc.indent(); |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jReaderGenerator.java | Modello Dom4J Plugin | 415 |
org/codehaus/modello/plugin/jackson/JacksonReaderGenerator.java | Modello Jackson Plugin | 409 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 462 |
org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java | Modello XPP3 Plugin | 606 |
} /** * Generate code to process a field represented as an XML element. * * @param field the field to process * @param xmlFieldMetadata its XML metadata * @param addElse add an <code>else</code> statement before generating a new <code>if</code> * @param sc the method source code to add to * @param objectName the object name in the source * @param jClass the generated class source file */ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata, boolean addElse, JSourceCode sc, String objectName, JClass jClass) { String fieldTagName = resolveTagName(field, xmlFieldMetadata); String capFieldName = capitalise(field.getName()); String singularName = singular(field.getName()); String alias; if (StringUtils.isEmpty(field.getAlias())) { alias = "null"; } else { alias = "\"" + field.getAlias() + "\""; } String tagComparison = (addElse ? "else " : "") + "if ( checkFieldWithDuplicate( childElement, \"" |
File | Project | Line |
---|---|---|
org/codehaus/modello/plugin/dom4j/Dom4jReaderGenerator.java | Modello Dom4J Plugin | 777 |
org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java | Modello SnakeYaml Plugin | 757 |
} } private void writeHelpers(JClass jClass) { JMethod method = new JMethod("getTrimmedValue", new JClass("String"), null); method.getModifiers().makePrivate(); method.addParameter(new JParameter(new JClass("String"), "s")); JSourceCode sc = method.getSourceCode(); sc.add("if ( s != null )"); sc.add("{"); sc.addIndented("s = s.trim();"); sc.add("}"); sc.add("return s;"); jClass.addMethod(method); // -------------------------------------------------------------------- /* TODO method = new JMethod( new JClass( "String" ), "getRequiredAttributeValue" ); method.addException( new JClass( "XmlPullParserException" ) ); method.getModifiers().makePrivate(); method.addParameter( new JParameter( new JClass( "String" ), "s" ) ); method.addParameter( new JParameter( new JClass( "String" ), "attribute" ) ); method.addParameter( new JParameter( new JClass( "XmlPullParser" ), "parser" ) ); method.addParameter( new JParameter( JClass.Boolean, "strict" ) ); sc = method.getSourceCode(); sc.add( "if ( s == null )" ); sc.add( "{" ); sc.indent(); sc.add( "if ( strict )" ); sc.add( "{" ); sc.addIndented( "throw new XmlPullParserException( \"Missing required value for attribute '\" + attribute + \"'\", parser, null );" ); sc.add( "}" ); sc.unindent(); sc.add( "}" ); sc.add( "return s;" ); jClass.addMethod( method ); */ // -------------------------------------------------------------------- method = new JMethod("getBooleanValue", JType.BOOLEAN, null); |