CanonicizerDoclet 

HOME INDEX SEARCH GO  

 <<O>>  Difference Topic CanonicizerDoclet (r1.13 - 09 Sep 2002 - GwynEvans)
Added:
>
>

How about a slight tweak to toString(), to add a super.toString() call if the super class isn't Object?

e.g. return "[Wrapper: " + super.toString() ...

-- GwynEvans - 09 Sep 2002



 <<O>>  Difference Topic CanonicizerDoclet (r1.12 - 28 Jun 2002 - AlainRavet)
Changed:
<
<

CanonicizerDoclet - version 0.3

>
>

CanonicizerDoclet - version 0.3b - (28 Jun 2002)

Changed:
<
<

-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet03.jar

>
>

-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet03b.jar

Added:
>
>

  • v 0.3b - (28 Jun 2002)
    • bug fix only.
Changed:
<
<

%META:FILEATTACHMENT{name="canonicizerDoclet03.jar" attr="" comment="doclet jar v0.3" date="1024432139" path="C:\canonicizerDoclet03.jar" size="14709" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet03.zip" attr="" comment="project source v0.3" date="1024432362" path="C:\canonicizerDoclet03.zip" size="153266" user="AlainRavet" version="1.1"}%

>
>

%META:FILEATTACHMENT{name="canonicizerDoclet03.jar" attr="h" comment="doclet jar v0.3" date="1024432139" path="C:\canonicizerDoclet03.jar" size="14709" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet03.zip" attr="h" comment="project source v0.3" date="1024432362" path="C:\canonicizerDoclet03.zip" size="153266" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet03b.jar" attr="" comment="doclet jar v0.3b" date="1025279244" path="C:\dev\Tool\idea629\lib\canonicizerDoclet03b.jar" size="21619" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet3b.zip" attr="" comment="project source v0.3b" date="1025279355" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet3b.zip" size="242146" user="AlainRavet" version="1.1"}%


 <<O>>  Difference Topic CanonicizerDoclet (r1.11 - 18 Jun 2002 - AlainRavet)
Changed:
<
<

CanonicizerDoclet - version 0.2

>
>

CanonicizerDoclet - version 0.3

Changed:
<
<

result = 37 * result + oneString.hashCode() ;

>
>

result = 37 * result + hashCodeOrZeroIfNull(oneString) ;

Changed:
<
<

-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet.jar

>
>

-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet03.jar

Added:
>
>

  • v 0.3
    • added : null handling in hashCode()
    • test code refactored
Changed:
<
<

  • add a GUI to select/exclude members. (v 0.3)
  • make into a plugin (v0.4 : will require JDK 1.4)
  • improve handling of null values for objects, and strings.
>
>

  • add a GUI to select/exclude members. (v 0.4)
  • make into a plugin (v0.5 : will require JDK 1.4)
Changed:
<
<

I could easily change it the same way I added null handling in equals()
(replacing this.equals(o) by areEqualsOrBothNull(this,o))
But I'm not convinced it's going in the right direction; I tend to prefer letting NPE go the surface.
I almost regret the equals improvment.<grin>
I'm open to suggestions.

>
>

done

Deleted:
<
<

Changed:
<
<

%META:FILEATTACHMENT{name="canonicizerDoclet02.jar" attr="" comment="doclet jar v0.2" date="1023483643" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.jar" size="14738" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet02.zip" attr="" comment="project source v0.2" date="1023484036" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.zip" size="152650" user="AlainRavet" version="1.1"}%

>
>

%META:FILEATTACHMENT{name="canonicizerDoclet02.jar" attr="h" comment="doclet jar v0.2" date="1023483643" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.jar" size="14738" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet02.zip" attr="h" comment="project source v0.2" date="1023484036" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.zip" size="152650" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet03.jar" attr="" comment="doclet jar v0.3" date="1024432139" path="C:\canonicizerDoclet03.jar" size="14709" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet03.zip" attr="" comment="project source v0.3" date="1024432362" path="C:\canonicizerDoclet03.zip" size="153266" user="AlainRavet" version="1.1"}%


 <<O>>  Difference Topic CanonicizerDoclet (r1.10 - 18 Jun 2002 - AlainRavet)
Changed:
<
<

&& areEqualsOrBothNull (obj.oneString, this.oneString) ;

>
>

&& areEqualsOrBothNull (obj.oneString, this.oneString) ;

Changed:
<
<

result = 37 * result + oneString.hashCode() ;

>
>

result = 37 * result + oneString.hashCode() ;

Changed:
<
<

  • improve handling of null values for objects, and strings. (added in v 0.2)
>
>

  • add a GUI to select/exclude members. (v 0.3)
  • make into a plugin (v0.4 : will require JDK 1.4)
  • improve handling of null values for objects, and strings.
Deleted:
<
<

Added:
>
>

I could easily change it the same way I added null handling in equals()
(replacing this.equals(o) by areEqualsOrBothNull(this,o))
But I'm not convinced it's going in the right direction; I tend to prefer letting NPE go the surface.
I almost regret the equals improvment.<grin>
I'm open to suggestions. -- AlainRavet - 18 Jun 2002



 <<O>>  Difference Topic CanonicizerDoclet (r1.9 - 18 Jun 2002 - GlenStampoultzis)
Changed:
<
<

This rules! Thanks Alain!

>
>

Null handling for hashCode would be nice.

Changed:
<
<

-- GlenStampoultzis - 04 Jun 2002

>
>

-- GlenStampoultzis - 18 Jun 2002


 <<O>>  Difference Topic CanonicizerDoclet (r1.8 - 10 Jun 2002 - GlenStampoultzis)
Changed:
<
<

This rules! Thanks Alain! Aside from not handling nulls (added in v 0.2) it works rather nicely.

>
>

This rules! Thanks Alain!


 <<O>>  Difference Topic CanonicizerDoclet (r1.7 - 07 Jun 2002 - AlainRavet)
Changed:
<
<

CanonicizerDoclet - version 0.1

>
>

CanonicizerDoclet - version 0.2

Changed:
<
<



>
>



Changed:
<
<

&& obj.oneString .equals( this.oneString ) ;

>
>

&& areEqualsOrBothNull (obj.oneString, this.oneString) ;

Changed:
<
<

>
>

.. ..

Changed:
<
<

>
>

Added:
>
>

Releases :

  • v 0.2
    • added : null handling in equals()
  • v 0.1
    • initial release
Changed:
<
<

  • improve handling of null values for objects, and strings.
>
>

  • improve handling of null values for objects, and strings. (added in v 0.2)
Changed:
<
<

This rules! Thanks Alain! Aside from not handling nulls it works rather nicely.

>
>

This rules! Thanks Alain! Aside from not handling nulls (added in v 0.2) it works rather nicely.

Changed:
<
<

%META:FILEATTACHMENT{name="canonicizerDoclet.jar" attr="" comment="doclet jar v0.1" date="1023138160" path="C:\canonicizerDoclet.jar" size="13518" user="AlainRavet" version="1.1"}%

>
>

%META:FILEATTACHMENT{name="canonicizerDoclet.jar" attr="h" comment="doclet jar v0.1" date="1023138160" path="C:\canonicizerDoclet.jar" size="13518" user="AlainRavet" version="1.1"}%

Changed:
<
<

%META:FILEATTACHMENT{name="canonicizerDoclet.zip" attr="" comment="project source v0.1 " date="1023138490" path="C:\canonicizerDoclet.zip" size="37591" user="AlainRavet" version="1.1"}%

>
>

%META:FILEATTACHMENT{name="canonicizerDoclet.zip" attr="h" comment="project source v0.2" date="1023138490" path="C:\canonicizerDoclet.zip" size="37591" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet02.jar" attr="" comment="doclet jar v0.2" date="1023483643" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.jar" size="14738" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet02.zip" attr="" comment="project source v0.2" date="1023484036" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.zip" size="152650" user="AlainRavet" version="1.1"}%


 <<O>>  Difference Topic CanonicizerDoclet (r1.6 - 04 Jun 2002 - WalterMundt)
Added:
>
>

Why only private members? Just because an instance variable is non-private doesn't mean it's not part of the definition of the object. And just because Java purists don't like non-private instance variables doesn't mean they don't serve a purpose. (I, for one, see little reason for getters and setters in classes whose only use is within the scope of a single project or even a single multi-project codebase - you can just use "Encapsulate field(s)" later if you find you need to change the way a "property" is stored.)

Also, a suggestion: have some kind of extra Javadoc tag for telling this thing to ignore a variable when making up its methods.

-- WalterMundt - 04 Jun 2002


 <<O>>  Difference Topic CanonicizerDoclet (r1.5 - 04 Jun 2002 - AlainRavet)
Changed:
<
<

See Also: LiveTemplateContribs#Canonical_class

>
>

See Also: LiveTemplateContribs#Canonical_class, TheCanonicalObjectIdiom


 <<O>>  Difference Topic CanonicizerDoclet (r1.4 - 04 Jun 2002 - AlainRavet)
Changed:
<
<

  • hashCode() implements Joshua Bloch's 'Effective Java' recipe.
>
>


 <<O>>  Difference Topic CanonicizerDoclet (r1.3 - 04 Jun 2002 - GlenStampoultzis)
Added:
>
>

This rules! Thanks Alain! Aside from not handling nulls it works rather nicely.

-- GlenStampoultzis - 04 Jun 2002


 <<O>>  Difference Topic CanonicizerDoclet (r1.2 - 03 Jun 2002 - GlenStampoultzis)
Added:
>
>

See Also: LiveTemplateContribs#Canonical_class


 <<O>>  Difference Topic CanonicizerDoclet (r1.1 - 03 Jun 2002 - AlainRavet)
Added:
>
>

%META:TOPICINFO{author="AlainRavet" date="1023138780" format="1.0" version="1.1"}% %META:TOPICPARENT{name="AlainRavet"}% CanonicizerDoclet - version 0.1


(please send comments and bug reports to alain_ravet@yahooNOSPAM321.com)
You can add your comments and suggestions here.

What it does :
For a given class, this doclet generates :

  • toString()
  • hashCode()
  • equals ()
based on the class private non static members.
The generated code for those 3 methods is sent to the console, and copied into the clipboard.


Notes :

  • hashCode() implements Joshua Bloch's 'Effective Java' recipe.
  • toString() format : "[ClassName: valueField1, valueField2, ..]"
    • ex: "[Name: John, Smith]"
  • arrays are not handled, just signaled (code can't compile).
  • If there is no array member in the class, the skeleton should be functional, and can be used as-is.


More :

How to use :

  1. open the class in the editor
  2. call the doclet external tool
  3. the generated code is in the clipboard, and
    the generated code is displayed in the console.

Example :

Class to "canonicize" :


   public class SampleClass
   {
       private byte        aByte       ;
       private String      oneString   ;
   }

Generated code :

   public boolean equals (Object o)
    {
        if (this == o)                    return true  ;
        if (! (o instanceof SampleClass ))  return false ;
        final SampleClass obj = (SampleClass) o;
        return
                   obj.aByte  ==  aByte
                && obj.oneString  .equals(  this.oneString )
          ;
    }

    public String toString ()
    {
        return "[SampleClass: "
                  +          aByte
                  +  ","  +  oneString
          +  "]"  ;
    }

    public int hashCode ()
    {
        int result = 17;
        result   = 37 * result + (int)aByte ;
        result   = 37 * result + oneString.hashCode() ;
        return result  ;
    }
}

How to install :

  1. create a new external tool
  2. edit the new tool :
        Edit Tool :
        ------------------------------------------------------------------------------------
        Name              :     Canonicizer doclet

        Open Console      :     checked

        Program           : $JDKPath$\bin\javadoc.exe
        Parameters        : -private
                            -doclet com.intellij.contrib.canonicizer.Canonicizer
                            -docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet.jar
                            $FilePath$
        Working directory : $JDKPath$\bin
        ------------------------------------------------------------------------------------

Todo :

  • improve handling of null values for objects, and strings.
  • add handling for arrays members
  • generates the corresponding tester class.

Your comments :


%META:FILEATTACHMENT{name="canonicizerDoclet.jar" attr="" comment="doclet jar v0.1" date="1023138160" path="C:\canonicizerDoclet.jar" size="13518" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet.dir" attr="h" comment="project source v0.1" date="1023138214" path="C:\canonicizerDoclet.dir" size="37591" user="AlainRavet" version="1.1"}% %META:FILEATTACHMENT{name="canonicizerDoclet.zip" attr="" comment="project source v0.1 " date="1023138490" path="C:\canonicizerDoclet.zip" size="37591" user="AlainRavet" version="1.1"}%


View | Diffs | r1.13 | > | r1.12 | > | r1.11 | More

e d i t a t t a c h r e f - b y d i f f s
Ideas,requests,problems regarding this site? Send feedback.
Copyright @ 2000-2003 by the contribution authors. All material on this collaboration tool is the property of the contributing authors.

Revision r1.1 - 03 Jun 2002 - 21:13 GMT - AlainRavet
Revision r1.13 - 09 Sep 2002 - 14:13 GMT - GwynEvans
Copyright © 2001 by the contributing authors. All material on this collaboration tool is the property of the contributing authors.
Ideas, requests, problems regarding this site? Send feedback.