jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Modello
  • MODELLO-97

Add constants for tags and attributes in xpp3

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.0-alpha-16
  • Fix Version/s: 1.6
  • Component/s: modello-plugin-xpp3
  • Labels:
    None
  • Complexity:
    Intermediate
  • Testcase included:
    yes
  • Patch Submitted:
    Yes

Description

I proposed to add constants for tags and attributes, i.e.:

MyGeneratedXpp3Reader.java
public class MavenXpp3Reader {
...
    /**
     * Tag name for <code>myTag</code>.
     */
    public static final java.lang.String TAG_MYTAG = "myTag";

    /**
     * Attribute name for <code>myAttribute</code>.
     */
    public static final java.lang.String ATTRIBUTE_MYATTRIBUTE = "myAttribute";
...
}

The patch includes:

  • added new methods in Xpp3ReaderGenerator class to handle that: addConstantField(...) and getConstantName(...)
  • replaces all tagName/singularTagName by getConstantName(...)
  • removed unused import
  • updated Xpp3WriterGenerator to use the constants defined in the generated Xpp3Reader class
  • added a test case

Note: in src/test/java, the package org.codehaus.modello.generator.xml.xpp3 was moved to org.codehaus.modello.plugin.xpp3 like defined in src/main/java

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. File
    added_public_static_final_fields.diff
    14/Aug/07 5:04 PM
    45 kB
    Vincent Siveton

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Herve Boutemy added a comment - 16/Aug/09 4:36 PM

The idea is interesting: constants should improve generated code (yes, code is generated, there won't be any copy/paste error, but copying/pasting String values is not a good practice).

I have a few concerns about how to implement this idea: why constants in XPP3 only, and not other XML readers/writers? Why constants in reader instead of writer?

Idea: what if modello-plugin-xml generates constants in a separate MavenXmlTags class or interface in io package?

Another concern is about conflicting tag names between multiple classes of the model, or recognizing which tag is for which class.
Shouldn't the constants names contain the class name as a prefix?

Show
Herve Boutemy added a comment - 16/Aug/09 4:36 PM The idea is interesting: constants should improve generated code (yes, code is generated, there won't be any copy/paste error, but copying/pasting String values is not a good practice). I have a few concerns about how to implement this idea: why constants in XPP3 only, and not other XML readers/writers? Why constants in reader instead of writer? Idea: what if modello-plugin-xml generates constants in a separate MavenXmlTags class or interface in io package? Another concern is about conflicting tag names between multiple classes of the model, or recognizing which tag is for which class. Shouldn't the constants names contain the class name as a prefix?
Hide
Permalink
Vincent Siveton added a comment - 17/Aug/09 7:10 AM

We could add these constants in the reader and the writer (similar to WriterFactory.UTF_8 ReaderFactory.UTF_8 from p-u)
The interface idea could be also a good idea.

Show
Vincent Siveton added a comment - 17/Aug/09 7:10 AM We could add these constants in the reader and the writer (similar to WriterFactory.UTF_8 ReaderFactory.UTF_8 from p-u) The interface idea could be also a good idea.

People

  • Assignee:
    Unassigned
    Reporter:
    Vincent Siveton
Vote (0)
Watch (1)

Dates

  • Created:
    14/Aug/07 5:04 PM
    Updated:
    19/Oct/11 12:20 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.