[Fb-contrib-commit] SF.net SVN: fb-contrib: [905] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-09-15 18:59:24
|
Revision: 905 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=905&view=rev Author: dbrosius Date: 2007-09-15 11:59:26 -0700 (Sat, 15 Sep 2007) Log Message: ----------- initial checkin - NCS detector Modified Paths: -------------- trunk/fb-contrib/etc/bugdescriptions.xsl trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/samples/ITC_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/NMCS_Sample.java trunk/fb-contrib/samples/NOS_Sample.java trunk/fb-contrib/samples/NRTL_Sample.java trunk/fb-contrib/samples/PIS_Sample.java trunk/fb-contrib/samples/RMC_Sample.java trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/samples/SACM_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SIL_Sample.java trunk/fb-contrib/samples/SJVU_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/TR_Sample.java trunk/fb-contrib/samples/UAA_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/samples/URV_Sample.java trunk/fb-contrib/samples/USS_Sample.java trunk/fb-contrib/samples/UTA_Sample.java Added Paths: ----------- trunk/fb-contrib/samples/NCS_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java Property Changed: ---------------- trunk/fb-contrib/build.properties trunk/fb-contrib/etc/bugdescriptions.xsl trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/samples/ITC_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/NMCS_Sample.java trunk/fb-contrib/samples/NOS_Sample.java trunk/fb-contrib/samples/NRTL_Sample.java trunk/fb-contrib/samples/PIS_Sample.java trunk/fb-contrib/samples/RMC_Sample.java trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/samples/SACM_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SIL_Sample.java trunk/fb-contrib/samples/SJVU_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/TR_Sample.java trunk/fb-contrib/samples/UAA_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/samples/URV_Sample.java trunk/fb-contrib/samples/USS_Sample.java trunk/fb-contrib/samples/UTA_Sample.java trunk/fb-contrib/samples/samples-bugs.xml Property changes on: trunk/fb-contrib/build.properties ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/etc/bugdescriptions.xsl =================================================================== --- trunk/fb-contrib/etc/bugdescriptions.xsl 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/etc/bugdescriptions.xsl 2007-09-15 18:59:26 UTC (rev 905) @@ -1,38 +1,38 @@ -<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - - <xsl:template match="/MessageCollection"> - <html> - <head><title>fb-contrib: Bug Descriptions</title></head> - <body background="true"> - <div style="position:absolute;top:0;left:0;width:256;height:65535;z-index:1;background-image:url(blend.jpg);"> - </div> - - <div style="position:absolute;top:20;left:20;z-index:2;"> - <h1>fb-contrib: Bug Descriptions</h1> - - <table border="1" width="100%"> - <xsl:apply-templates select="BugCode"/> - </table> - </div> - </body> - </html> - </xsl:template> - - <xsl:template match="BugCode"> - <xsl:call-template name="Pattern"> - <xsl:with-param name="abbrev"><xsl:value-of select="@abbrev"/></xsl:with-param> - </xsl:call-template> - </xsl:template> - - <xsl:template name="Pattern"> - <xsl:param name="abbrev"/> - <xsl:for-each select="//BugPattern[starts-with(@type,$abbrev)]"> - <tr><td><b><xsl:value-of select="@type"/></b></td></tr> - <xsl:variable name="desc1"><xsl:value-of select="normalize-space(Details/text())"/></xsl:variable> - <xsl:variable name="desc2"><xsl:value-of select="substring($desc1, 9)"/></xsl:variable> - <xsl:variable name="desc"><xsl:value-of select="substring($desc2, 0, string-length($desc2) - 3)"/></xsl:variable> - <tr><td><xsl:copy-of select="$desc"/></td></tr> - </xsl:for-each> - </xsl:template> - +<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:template match="/MessageCollection"> + <html> + <head><title>fb-contrib: Bug Descriptions</title></head> + <body background="true"> + <div style="position:absolute;top:0;left:0;width:256;height:65535;z-index:1;background-image:url(blend.jpg);"> + </div> + + <div style="position:absolute;top:20;left:20;z-index:2;"> + <h1>fb-contrib: Bug Descriptions</h1> + + <table border="1" width="100%"> + <xsl:apply-templates select="BugCode"/> + </table> + </div> + </body> + </html> + </xsl:template> + + <xsl:template match="BugCode"> + <xsl:call-template name="Pattern"> + <xsl:with-param name="abbrev"><xsl:value-of select="@abbrev"/></xsl:with-param> + </xsl:call-template> + </xsl:template> + + <xsl:template name="Pattern"> + <xsl:param name="abbrev"/> + <xsl:for-each select="//BugPattern[starts-with(@type,$abbrev)]"> + <tr><td><b><xsl:value-of select="@type"/></b></td></tr> + <xsl:variable name="desc1"><xsl:value-of select="normalize-space(Details/text())"/></xsl:variable> + <xsl:variable name="desc2"><xsl:value-of select="substring($desc1, 9)"/></xsl:variable> + <xsl:variable name="desc"><xsl:value-of select="substring($desc2, 0, string-length($desc2) - 3)"/></xsl:variable> + <tr><td><xsl:copy-of select="$desc"/></td></tr> + </xsl:for-each> + </xsl:template> + </xsl:transform> \ No newline at end of file Property changes on: trunk/fb-contrib/etc/bugdescriptions.xsl ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/etc/findbugs.xml 2007-09-15 18:59:26 UTC (rev 905) @@ -287,6 +287,10 @@ speed="fast" reports="MRC_METHOD_RETURNS_CONSTANT" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessCustomSerialization" + speed="fast" + reports="NCS_NEEDLESS_CUSTOM_SERIALIZATION" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -377,4 +381,5 @@ <BugPattern abbrev="SJVU" type="SJVU_SUSPICIOUS_JDK_VERSION_USE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="UAA" type="UAA_USE_ADD_ALL" category="STYLE" experimental="true" /> <BugPattern abbrev="MRC" type="MRC_METHOD_RETURNS_CONSTANT" category="STYLE" experimental="true" /> + <BugPattern abbrev="NCS" type="NCS_NEEDLESS_CUSTOM_SERIALIZATION" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/etc/messages.xml 2007-09-15 18:59:26 UTC (rev 905) @@ -778,7 +778,19 @@ </Details> </Detector> - <!-- BugPattern --> + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessCustomSerialization"> + <Details> + <![CDATA[ + <p>looks for classes that implement the Serializable interface and implement the + standard readObject and writeObject methods by simply deferring to the Stream + parameter's defaultReadObject or defaultWriteObject and nothing else. As this is the + built in behavior, these methods are not needed.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> <ShortDescription>method passes simple concatenating string in StringBuffer or StringBuilder append</ShortDescription> @@ -1946,6 +1958,17 @@ </Details> </BugPattern> + <BugPattern type="NCS_NEEDLESS_CUSTOM_SERIALIZATION"> + <ShortDescription>method needlessly implements what is default streaming behavior</ShortDescription> + <LongDescription>method {1} needlessly implements what is default streaming behavior</LongDescription> + <Details> + <![CDATA[ + <p>This method implements the Serializable interface by performing the same operations that + would be done if this method did not exist. Since this is the case, this method is not needed.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2012,4 +2035,5 @@ <BugCode abbrev="SJVU">Suspicious JDK Version Use</BugCode> <BugCode abbrev="UAA">Use Add All</BugCode> <BugCode abbrev="MRC">Method Returns Constant</BugCode> + <BugCode abbrev="NCS">Needless Custom Serialization</BugCode> </MessageCollection> \ No newline at end of file Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/BAS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,91 +1,91 @@ -import java.util.List; - -public class BAS_Sample -{ - public void testIfScope(String s) - { - Object o = new Object(); - if (s.equals("Foo")) - { - s = o.toString(); - } - } - - public String testFPForScope(String s) - { - Object o = new Object(); - while (s.length() > 0) - { - o = s.substring(0, 1); - s = s.substring(1); - } - return s; - } - - public String testFP2Scopes(String s) - { - Object o = new Object(); - if (s.equals("Boo")) - s = o.toString(); - else if (s.equals("Hoo")) - s = o.toString(); - - return s; - } - - public String test2InnerScopes(String s) - { - Object o = new Object(); - if (s != null) - { - if (s.equals("Boo")) - s = o.toString(); - else if (s.equals("Hoo")) - s = o.toString(); - } - - return s; - } - - public String testFPLoopCond(List<String> in) - { - StringBuilder sb = new StringBuilder(); - for (String s : in) - { - sb.append(s); - } - return sb.toString(); - } - - public List<String> getList() - { - return null; - } - - public String testSwitch(int a) - { - String v = "Test"; - - switch (a) - { - case 1: - v = "Testa"; - break; - - case 2: - v = "Tesseract"; - break; - - case 3: - v = "Testy"; - break; - - default: - v = "Rossa"; - break; - } - - return null; - } - -} +import java.util.List; + +public class BAS_Sample +{ + public void testIfScope(String s) + { + Object o = new Object(); + if (s.equals("Foo")) + { + s = o.toString(); + } + } + + public String testFPForScope(String s) + { + Object o = new Object(); + while (s.length() > 0) + { + o = s.substring(0, 1); + s = s.substring(1); + } + return s; + } + + public String testFP2Scopes(String s) + { + Object o = new Object(); + if (s.equals("Boo")) + s = o.toString(); + else if (s.equals("Hoo")) + s = o.toString(); + + return s; + } + + public String test2InnerScopes(String s) + { + Object o = new Object(); + if (s != null) + { + if (s.equals("Boo")) + s = o.toString(); + else if (s.equals("Hoo")) + s = o.toString(); + } + + return s; + } + + public String testFPLoopCond(List<String> in) + { + StringBuilder sb = new StringBuilder(); + for (String s : in) + { + sb.append(s); + } + return sb.toString(); + } + + public List<String> getList() + { + return null; + } + + public String testSwitch(int a) + { + String v = "Test"; + + switch (a) + { + case 1: + v = "Testa"; + break; + + case 2: + v = "Tesseract"; + break; + + case 3: + v = "Testy"; + break; + + default: + v = "Rossa"; + break; + } + + return null; + } + +} Property changes on: trunk/fb-contrib/samples/BAS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/DWI_Sample.java =================================================================== --- trunk/fb-contrib/samples/DWI_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/DWI_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,39 +1,39 @@ -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -public class DWI_Sample -{ - Set<String> avail; - - public void deleteOdds(Set<Integer> bagOInts) - { - Iterator<Integer> it = bagOInts.iterator(); - while (it.hasNext()) - { - Integer i = it.next(); - if ((i.intValue() & 0x01) == 1) - bagOInts.remove(i); - } - } - - public void addIf(Set<String> s, Collection<String> c) { - for (String ss : s) - { - if (ss.equals("addem")) - s.addAll(c); - } - } - - public void fpUnaliased() - { - Iterator<String> it = avail.iterator(); - avail = new HashSet<String>(); - - while (it.hasNext()) - { - avail.add(it.next() + "booya"); - } - } -} +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class DWI_Sample +{ + Set<String> avail; + + public void deleteOdds(Set<Integer> bagOInts) + { + Iterator<Integer> it = bagOInts.iterator(); + while (it.hasNext()) + { + Integer i = it.next(); + if ((i.intValue() & 0x01) == 1) + bagOInts.remove(i); + } + } + + public void addIf(Set<String> s, Collection<String> c) { + for (String ss : s) + { + if (ss.equals("addem")) + s.addAll(c); + } + } + + public void fpUnaliased() + { + Iterator<String> it = avail.iterator(); + avail = new HashSet<String>(); + + while (it.hasNext()) + { + avail.add(it.next() + "booya"); + } + } +} Property changes on: trunk/fb-contrib/samples/DWI_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/ITC_Sample.java =================================================================== --- trunk/fb-contrib/samples/ITC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/ITC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,19 +1,19 @@ -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Vector; - -public class ITC_Sample -{ - public String test(List<String> l) - { - if (l instanceof ArrayList) - return (String)((ArrayList)l).remove(0); - else if (l instanceof LinkedList) - return (String)((LinkedList) l).removeFirst(); - else if (l instanceof Vector) - return (String)((Vector) l).remove(0); - else - return null; - } -} +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Vector; + +public class ITC_Sample +{ + public String test(List<String> l) + { + if (l instanceof ArrayList) + return (String)((ArrayList)l).remove(0); + else if (l instanceof LinkedList) + return (String)((LinkedList) l).removeFirst(); + else if (l instanceof Vector) + return (String)((Vector) l).remove(0); + else + return null; + } +} Property changes on: trunk/fb-contrib/samples/ITC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/LEST_Sample.java =================================================================== --- trunk/fb-contrib/samples/LEST_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/LEST_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,61 +1,61 @@ -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class LEST_Sample -{ - public Date testLest1(String input) - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - throw new IllegalArgumentException(pe.getMessage()); - } - } - - public Date testLest2(String input) - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - throw new IllegalArgumentException(pe.getMessage(), pe); - } - } - - public Date testLestFP1(String input) throws ParseException - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - throw pe; - } - } - - public Date testLestFP2(String input) - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - IllegalArgumentException iae = new IllegalArgumentException(pe.getMessage()); - iae.initCause(pe); - throw iae; - } - } -} +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class LEST_Sample +{ + public Date testLest1(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw new IllegalArgumentException(pe.getMessage()); + } + } + + public Date testLest2(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw new IllegalArgumentException(pe.getMessage(), pe); + } + } + + public Date testLestFP1(String input) throws ParseException + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw pe; + } + } + + public Date testLestFP2(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + IllegalArgumentException iae = new IllegalArgumentException(pe.getMessage()); + iae.initCause(pe); + throw iae; + } + } +} Property changes on: trunk/fb-contrib/samples/LEST_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/fb-contrib/samples/NCS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NCS_Sample.java (rev 0) +++ trunk/fb-contrib/samples/NCS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -0,0 +1,18 @@ +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + + +public class NCS_Sample implements Serializable +{ + private void writeObject(ObjectOutputStream oos) throws IOException + { + oos.defaultWriteObject(); + } + + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException + { + ois.defaultReadObject(); + } +} Property changes on: trunk/fb-contrib/samples/NCS_Sample.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/NMCS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NMCS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/NMCS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,57 +1,57 @@ -import java.util.HashSet; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -public class NMCS_Sample -{ - private static List<String> test1 = new Vector<String>(); - static { - test1.add("one"); - test1.add("two"); - test1.add("three"); - } - - private Map<String, String> test2 = new Hashtable<String, String>(); - - private Set<String> test3 = new HashSet<String>(); - - private List<String> test4 = new Vector<String>(); - - public String test1() - { - StringBuffer sb = new StringBuffer(); - String comma = ""; - for (String s : test1) - { - sb.append(comma); - comma = ","; - sb.append(s); - } - - return sb.toString(); - } - - public String test2() - { - test2 = new Hashtable<String, String>(); - - return test2.get("foo"); - } - - public Set<String> test3() - { - Set<String> temp = test3; - temp.add("Foo"); - return temp; - } - - public List<String> test4(boolean b1, boolean b2) - { - return b1 ? test4 : - b2 ? new Vector<String>() : test4; - } - -} +import java.util.HashSet; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +public class NMCS_Sample +{ + private static List<String> test1 = new Vector<String>(); + static { + test1.add("one"); + test1.add("two"); + test1.add("three"); + } + + private Map<String, String> test2 = new Hashtable<String, String>(); + + private Set<String> test3 = new HashSet<String>(); + + private List<String> test4 = new Vector<String>(); + + public String test1() + { + StringBuffer sb = new StringBuffer(); + String comma = ""; + for (String s : test1) + { + sb.append(comma); + comma = ","; + sb.append(s); + } + + return sb.toString(); + } + + public String test2() + { + test2 = new Hashtable<String, String>(); + + return test2.get("foo"); + } + + public Set<String> test3() + { + Set<String> temp = test3; + temp.add("Foo"); + return temp; + } + + public List<String> test4(boolean b1, boolean b2) + { + return b1 ? test4 : + b2 ? new Vector<String>() : test4; + } + +} Property changes on: trunk/fb-contrib/samples/NMCS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/NOS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NOS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/NOS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,30 +1,30 @@ -import java.util.Map; - -public class NOS_Sample { - private Object lock = new Object(); - - public String test(Object o) { - synchronized(o) { - return o.toString(); - } - } - - public String test2(Object o) { - synchronized(this) { - return o.toString(); - } - } - - public String test3(Map m) { - String v = (String)m.get("boo"); - synchronized (v) { - return v.substring(0,1); - } - } - - public String test4(Object o) { - synchronized(lock) { - return o.toString(); - } - } -} +import java.util.Map; + +public class NOS_Sample { + private Object lock = new Object(); + + public String test(Object o) { + synchronized(o) { + return o.toString(); + } + } + + public String test2(Object o) { + synchronized(this) { + return o.toString(); + } + } + + public String test3(Map m) { + String v = (String)m.get("boo"); + synchronized (v) { + return v.substring(0,1); + } + } + + public String test4(Object o) { + synchronized(lock) { + return o.toString(); + } + } +} Property changes on: trunk/fb-contrib/samples/NOS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/NRTL_Sample.java =================================================================== --- trunk/fb-contrib/samples/NRTL_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/NRTL_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,34 +1,34 @@ -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspTagException; -import javax.servlet.jsp.tagext.TagSupport; - -public class NRTL_Sample extends TagSupport { - private String sample; - private String sample2; - - public void setSample(String s) { - sample = s; - } - - @Override - public int doStartTag() throws JspException { - try { - sample += Math.random(); - sample2 += sample; - pageContext.getOut().print(sample2); - } catch (Exception ex) { - throw new JspTagException("NRTL_Sample: " + ex.getMessage()); - } - return SKIP_BODY; - } - - public void setSample2(String s) { - sample2 = s; - } - - @Override - public int doEndTag() { - return EVAL_PAGE; - } - -} +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.JspTagException; +import javax.servlet.jsp.tagext.TagSupport; + +public class NRTL_Sample extends TagSupport { + private String sample; + private String sample2; + + public void setSample(String s) { + sample = s; + } + + @Override + public int doStartTag() throws JspException { + try { + sample += Math.random(); + sample2 += sample; + pageContext.getOut().print(sample2); + } catch (Exception ex) { + throw new JspTagException("NRTL_Sample: " + ex.getMessage()); + } + return SKIP_BODY; + } + + public void setSample2(String s) { + sample2 = s; + } + + @Override + public int doEndTag() { + return EVAL_PAGE; + } + +} Property changes on: trunk/fb-contrib/samples/NRTL_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/PIS_Sample.java =================================================================== --- trunk/fb-contrib/samples/PIS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/PIS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,60 +1,60 @@ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -public class PIS_Sample -{ - public static void main(String[] args) - { - try - { - B b = new B(); - b.a = 100; - b.b = 100; - D d = new D(); - d.a = 100; - d.b = 100; - d.c = 100; - d.d = 100; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(b); - oos.writeObject(d); - oos.flush(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream ois = new ObjectInputStream(bais); - B b2 = (B)ois.readObject(); - D d2 = (D)ois.readObject(); - if ((b.a == b2.a) && (b.b == b2.b)) - System.out.println("Equal!"); - if ((d.a == d2.a) && (d.b == d2.b) && (d.c == d2.c) && (d.d == d2.d)) - System.out.println("Equal!"); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public static class A - { - public int a = 0; - } - - public static class B extends A implements Serializable - { - public int b = 1; - } - - public static class C extends B - { - public int c = 2; - } - - public static class D extends C - { - public int d = 3; - } -} +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class PIS_Sample +{ + public static void main(String[] args) + { + try + { + B b = new B(); + b.a = 100; + b.b = 100; + D d = new D(); + d.a = 100; + d.b = 100; + d.c = 100; + d.d = 100; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(b); + oos.writeObject(d); + oos.flush(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(bais); + B b2 = (B)ois.readObject(); + D d2 = (D)ois.readObject(); + if ((b.a == b2.a) && (b.b == b2.b)) + System.out.println("Equal!"); + if ((d.a == d2.a) && (d.b == d2.b) && (d.c == d2.c) && (d.d == d2.d)) + System.out.println("Equal!"); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static class A + { + public int a = 0; + } + + public static class B extends A implements Serializable + { + public int b = 1; + } + + public static class C extends B + { + public int c = 2; + } + + public static class D extends C + { + public int d = 3; + } +} Property changes on: trunk/fb-contrib/samples/PIS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/RMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/RMC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/RMC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,33 +1,33 @@ -import java.nio.ByteBuffer; -import java.util.Calendar; -import java.util.Date; - -public class RMC_Sample -{ - String data; - - public boolean test1(Calendar c) - { - Date d = c.getTime(); - long l = d.getTime(); - Date e = c.getTime(); - long j = e.getTime(); - return l == j; - } - - public void rmcFP(ByteBuffer bb) - { - int i = bb.getInt(); - int j = bb.getInt(); - } - - @Override - public boolean equals(Object o) - { - RMC_Sample rmc = (RMC_Sample)o; - if (data.equals("INF") || rmc.data.equals("INF")) - return false; - - return data.equals(rmc.data); - } -} +import java.nio.ByteBuffer; +import java.util.Calendar; +import java.util.Date; + +public class RMC_Sample +{ + String data; + + public boolean test1(Calendar c) + { + Date d = c.getTime(); + long l = d.getTime(); + Date e = c.getTime(); + long j = e.getTime(); + return l == j; + } + + public void rmcFP(ByteBuffer bb) + { + int i = bb.getInt(); + int j = bb.getInt(); + } + + @Override + public boolean equals(Object o) + { + RMC_Sample rmc = (RMC_Sample)o; + if (data.equals("INF") || rmc.data.equals("INF")) + return false; + + return data.equals(rmc.data); + } +} Property changes on: trunk/fb-contrib/samples/RMC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/S508C_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,36 +1,36 @@ -import java.awt.Color; -import java.awt.Container; - -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; - -public class S508C_Sample extends JFrame -{ - private JLabel fLabel = new JLabel("Hello"); - private JLabel imgLabel = new JLabel(new ImageIcon("/boo.gif")); - private JComponent c = new MyComponent(); - - public S508C_Sample() { - Container cp = getContentPane(); - cp.setLayout(null); - - cp.add(fLabel); - JLabel lLabel = new JLabel("there"); - lLabel.setBackground(new Color(255, 0, 0)); - lLabel.setForeground(new Color(255, 255, 100)); - cp.add(lLabel); - - JLabel picLabel = new JLabel(new ImageIcon("/foo.gif")); - cp.add(picLabel); - cp.add(c); - - setSize(300, 200); - } -} - -class MyComponent extends JComponent -{ - -} +import java.awt.Color; +import java.awt.Container; + +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class S508C_Sample extends JFrame +{ + private JLabel fLabel = new JLabel("Hello"); + private JLabel imgLabel = new JLabel(new ImageIcon("/boo.gif")); + private JComponent c = new MyComponent(); + + public S508C_Sample() { + Container cp = getContentPane(); + cp.setLayout(null); + + cp.add(fLabel); + JLabel lLabel = new JLabel("there"); + lLabel.setBackground(new Color(255, 0, 0)); + lLabel.setForeground(new Color(255, 255, 100)); + cp.add(lLabel); + + JLabel picLabel = new JLabel(new ImageIcon("/foo.gif")); + cp.add(picLabel); + cp.add(c); + + setSize(300, 200); + } +} + +class MyComponent extends JComponent +{ + +} Property changes on: trunk/fb-contrib/samples/S508C_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SACM_Sample.java =================================================================== --- trunk/fb-contrib/samples/SACM_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SACM_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,12 +1,12 @@ - -public class SACM_Sample -{ - public String test(int i) - { - String[] giantSounds = new String[] { "fee", "fi", "fo", "fum", "burp", "fart" }; - if ((i < 0) || (i >= giantSounds.length)) - return ""; - - return giantSounds[i]; - } -} + +public class SACM_Sample +{ + public String test(int i) + { + String[] giantSounds = new String[] { "fee", "fi", "fo", "fum", "burp", "fart" }; + if ((i < 0) || (i >= giantSounds.length)) + return ""; + + return giantSounds[i]; + } +} Property changes on: trunk/fb-contrib/samples/SACM_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SCII_Sample.java =================================================================== --- trunk/fb-contrib/samples/SCII_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SCII_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,71 +1,71 @@ -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -public class SCII_Sample extends OverEndulgentParent implements MouseListener -{ - public void mouseClicked(MouseEvent arg0) { - // TODO Auto-generated method stub - - } -} - -class OverEndulgentParent -{ - public void mousePressed(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - public void mouseReleased(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - public void mouseEntered(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - public void mouseExited(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - interface A - { - public void a(); - - public void b(); - - public void c(); - } - - interface B extends A - { - public void b(); - } - - interface C extends B - { - public void c(); - } - - class AA implements A - { - public void a() {} - - public void b() {} - - public void c() {} - } - - class BB extends AA implements B - { - - } - - class CC extends BB implements C - { - - } -} +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +public class SCII_Sample extends OverEndulgentParent implements MouseListener +{ + public void mouseClicked(MouseEvent arg0) { + // TODO Auto-generated method stub + + } +} + +class OverEndulgentParent +{ + public void mousePressed(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + public void mouseReleased(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + public void mouseEntered(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + public void mouseExited(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + interface A + { + public void a(); + + public void b(); + + public void c(); + } + + interface B extends A + { + public void b(); + } + + interface C extends B + { + public void c(); + } + + class AA implements A + { + public void a() {} + + public void b() {} + + public void c() {} + } + + class BB extends AA implements B + { + + } + + class CC extends BB implements C + { + + } +} Property changes on: trunk/fb-contrib/samples/SCII_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SC_Sample.java =================================================================== --- trunk/fb-contrib/samples/SC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,28 +1,28 @@ -import java.util.Comparator; - -public class SC_Sample -{ - public static final int T1 = 0; - public static final int T2 = 1; - - int t = 0; - class SampleComparator implements Comparator<SC_Sample> - { - public int compare(SC_Sample arg0, SC_Sample arg1) { - if (arg0.t == arg1.t) - return 0; - - return -1; - } - } - - class SampleComparable implements Comparable<SC_Sample> - { - public int compareTo(SC_Sample arg0) { - if (t == arg0.t) - return 0; - - return 1; - } - } -} +import java.util.Comparator; + +public class SC_Sample +{ + public static final int T1 = 0; + public static final int T2 = 1; + + int t = 0; + class SampleComparator implements Comparator<SC_Sample> + { + public int compare(SC_Sample arg0, SC_Sample arg1) { + if (arg0.t == arg1.t) + return 0; + + return -1; + } + } + + class SampleComparable implements Comparable<SC_Sample> + { + public int compareTo(SC_Sample arg0) { + if (t == arg0.t) + return 0; + + return 1; + } + } +} Property changes on: trunk/fb-contrib/samples/SC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SIL_Sample.java =================================================================== --- trunk/fb-contrib/samples/SIL_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SIL_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,20 +1,20 @@ -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class SIL_Sample -{ - public void test(ResultSet rs) throws SQLException - { - Connection c = rs.getStatement().getConnection(); - PreparedStatement ps = c.prepareStatement("select foo from boo where moo = ?"); - - while (rs.next()) - { - int key = rs.getInt(1); - ps.setInt(1, key); - ResultSet mrs = ps.executeQuery(); - } - } -} +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class SIL_Sample +{ + public void test(ResultSet rs) throws SQLException + { + Connection c = rs.getStatement().getConnection(); + PreparedStatement ps = c.prepareStatement("select foo from boo where moo = ?"); + + while (rs.next()) + { + int key = rs.getInt(1); + ps.setInt(1, key); + ResultSet mrs = ps.executeQuery(); + } + } +} Property changes on: trunk/fb-contrib/samples/SIL_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SJVU_Sample.java =================================================================== --- trunk/fb-contrib/samples/SJVU_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SJVU_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,12 +1,12 @@ - -public class SJVU_Sample -{ - public void test14using15(int i) - { - Integer ii = Integer.valueOf(i); - StringBuilder sb = new StringBuilder(); - sb.append(ii.intValue()); - } - - -} + +public class SJVU_Sample +{ + public void test14using15(int i) + { + Integer ii = Integer.valueOf(i); + StringBuilder sb = new StringBuilder(); + sb.append(ii.intValue()); + } + + +} Property changes on: trunk/fb-contrib/samples/SJVU_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SPP_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,81 +1,81 @@ -import java.math.BigDecimal; -import java.util.BitSet; - -public class SPP_Sample -{ - private static final double pi = 3.14; - private static final double e = 2.72; - public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); - - static enum Flap { Smack, Jack }; - - public void testSPPBitSet(BitSet b) - { - b.set(-1); - } - - public String testSPPIntern() - { - return "FOO".intern(); //and yes i've seen this! - } - - public String testSBWithChars() - { - StringBuffer sb = new StringBuffer('v'); - sb.append("ictory"); - return sb.toString(); - } - - public double area(double radius) - { - return pi * radius * radius; - } - - public void testStutter(String s) - { - String a = a = s; - } - - public void testNAN(double d) - { - if (d == Double.NaN) - System.out.println("It's a nan"); - } - - public void testNAN(float f) - { - if (f == Float.NaN) - System.out.println("It's a nan"); - } - - public void testBigDecimal() - { - BigDecimal d = new BigDecimal(2.1); - } - - public void testEmptySB() - { - StringBuffer sb = new StringBuffer(""); - } - - public void equalsOnEnum(Flap f) - { - if (f.equals(Flap.Jack)) - System.out.println("Flap Jacks"); - } - - public void testCPPBoolean(Boolean a, Boolean b, Boolean c, Boolean d, Boolean e) - { - if (b && b.booleanValue()) - System.out.println("Booya"); - if (e && e.booleanValue()) - System.out.println("Booya"); - } - - public char usechatAt(String s) - { - if (s.length() > 0) - return s.toCharArray()[0]; - return ' '; - } -} +import java.math.BigDecimal; +import java.util.BitSet; + +public class SPP_Sample +{ + private static final double pi = 3.14; + private static final double e = 2.72; + public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); + + static enum Flap { Smack, Jack }; + + public void testSPPBitSet(BitSet b) + { + b.set(-1); + } + + public String testSPPIntern() + { + return "FOO".intern(); //and yes i've seen this! + } + + public String testSBWithChars() + { + StringBuffer sb = new StringBuffer('v'); + sb.append("ictory"); + return sb.toString(); + } + + public double area(double radius) + { + return pi * radius * radius; + } + + public void testStutter(String s) + { + String a = a = s; + } + + public void testNAN(double d) + { + if (d == Double.NaN) + System.out.println("It's a nan"); + } + + public void testNAN(float f) + { + if (f == Float.NaN) + System.out.println("It's a nan"); + } + + public void testBigDecimal() + { + BigDecimal d = new BigDecimal(2.1); + } + + public void testEmptySB() + { + StringBuffer sb = new StringBuffer(""); + } + + public void equalsOnEnum(Flap f) + { + if (f.equals(Flap.Jack)) + System.out.println("Flap Jacks"); + } + + public void testCPPBoolean(Boolean a, Boolean b, Boolean c, Boolean d, Boolean e) + { + if (b && b.booleanValue()) + System.out.println("Booya"); + if (e && e.booleanValue()) + System.out.println("Booya"); + } + + public char usechatAt(String s) + { + if (s.length() > 0) + return s.toCharArray()[0]; + return ' '; + } +} Property changes on: trunk/fb-contrib/samples/SPP_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/TR_Sample.java =================================================================== --- trunk/fb-contrib/samples/TR_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/TR_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,11 +1,11 @@ - -public class TR_Sample -{ - public int factorial(int n) - { - if (n == 1) - return 1; - - return n * factorial(n-1); - } -} + +public class TR_Sample +{ + public int factorial(int n) + { + if (n == 1) + return 1; + + return n * factorial(n-1); + } +} Property changes on: trunk/fb-contrib/samples/TR_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UAA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UAA_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UAA_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,54 +1,54 @@ -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - - -public class UAA_Sample { - - private Set<String> in = new HashSet<String>(); - private Set<String> out = new HashSet<String>(); - - public Set<String> testLocalSet(Set<String> in) { - Set<String> out = new HashSet<String>(); - out.add("Foo"); - out.add("Bar"); - for (String s : in) { - out.add(s); - } - return out; - } - - public Set<String> testFPCondition(Set<String> in) { - Set<String> out = new HashSet<String>(); - for (String s : in) { - if (s.startsWith("a")) - out.add(s); - } - return out; - } - - public Set<String> testKeyOrValueAdd(Map<String, String> in) - { - Set<String> out = new HashSet<String>(); - for (String s : in.keySet()) - out.add(s); - - for (String s : in.values()) - out.add(s); - - return out; - } - - public void testMemberSet() { - for (String s : in) - out.add(s); - } - - public Set<String> testFromArray(String[] in) { - Set<String> out = new HashSet<String>(); - for (String s : in) - out.add(s); - - return out; - } -} +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + + +public class UAA_Sample { + + private Set<String> in = new HashSet<String>(); + private Set<String> out = new HashSet<String>(); + + public Set<String> testLocalSet(Set<String> in) { + Set<String> out = new HashSet<String>(); + out.add("Foo"); + out.add("Bar"); + for (String s : in) { + out.add(s); + } + return out; + } + + public Set<String> testFPCondition(Set<String> in) { + Set<String> out = new HashSet<String>(); + for (String s : in) { + if (s.startsWith("a")) + out.add(s); + } + return out; + } + + public Set<String> testKeyOrValueAdd(Map<String, String> in) + { + Set<String> out = new HashSet<String>(); + for (String s : in.keySet()) + out.add(s); + + for (String s : in.values()) + out.add(s); + + return out; + } + + public void testMemberSet() { + for (String s : in) + out.add(s); + } + + public Set<String> testFromArray(String[] in) { + Set<String> out = new HashSet<String>(); + for (String s : in) + out.add(s); + + return out; + } +} Property changes on: trunk/fb-contrib/samples/UAA_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UCPM_Sample.java =================================================================== --- trunk/fb-contrib/samples/UCPM_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UCPM_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,13 +1,13 @@ - -public class UCPM_Sample -{ - public int testUcpm1(String s) - { - return s.indexOf("*") * 10; - } - - public String testUcpm2(String s) - { - return s.startsWith("*") ? s.substring(1) : s; - } -} + +public class UCPM_Sample +{ + public int testUcpm1(String s) + { + return s.indexOf("*") * 10; + } + + public String testUcpm2(String s) + { + return s.startsWith("*") ? s.substring(1) : s; + } +} Property changes on: trunk/fb-contrib/samples/UCPM_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UEC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UEC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UEC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,63 +1,63 @@ -import java.util.EnumMap; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - - -public class UEC_Sample -{ - public enum Suite { Spades, Hearts, Clubs, Diamonds }; - public enum FalsePositive { A, B, C }; - - private Set<Suite> wildSuites = new HashSet<Suite>(); - private EnumSet<Suite> eWildSuites = EnumSet.noneOf(Suite.class); - - public UEC_Sample() - { - wildSuites.add(Suite.Spades); - } - - public UEC_Sample(Suite s) - { - wildSuites.add(s); - } - - public Map<Suite, Integer> deal() - { - Map<Suite, Integer> hand = new HashMap<Suite, Integer>(); - hand.put(Suite.Spades, new Integer(10)); - hand.put(Suite.Hearts, new Integer(9)); - - return hand; - } - - public EnumMap<Suite, Integer> eDeal() - { - EnumMap<Suite, Integer> hand = new EnumMap(Suite.class); - hand.put(Suite.Spades, new Integer(10)); - hand.put(Suite.Hearts, new Integer(9)); - - return hand; - } - - public void uecFP() - { - Set<FalsePositive> testSet = EnumSet.of(FalsePositive.A); - - testSet.add(FalsePositive.B); - } - - public Set<Suite> getSuites() - { - return EnumSet.<Suite>allOf(Suite.class); - } - - public void uecFP2() - { - Set<Suite> suites = getSuites(); - - suites.add(Suite.Clubs); - } -} +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + + +public class UEC_Sample +{ + public enum Suite { Spades, Hearts, Clubs, Diamonds }; + public enum FalsePositive { A, B, C }; + + private Set<Suite> wildSuites = new HashSet<Suite>(); + private EnumSet<Suite> eWildSuites = EnumSet.noneOf(Suite.class); + + public UEC_Sample() + { + wildSuites.add(Suite.Spades); + } + + public UEC_Sample(Suite s) + { + wildSuites.add(s); + } + + public Map<Suite, Integer> deal() + { + Map<Suite, Integer> hand = new HashMap<Suite, Integer>(); + hand.put(Suite.Spades, new Integer(10)); + hand.put(Suite.Hearts, new Integer(9)); + + return hand; + } + + public EnumMap<Suite, Integer> eDeal() + { + EnumMap<Suite, Integer> hand = new EnumMap(Suite.class); + hand.put(Suite.Spades, new Integer(10)); + hand.put(Suite.Hearts, new Integer(9)); + + return hand; + } + + public void uecFP() + { + Set<FalsePositive> testSet = EnumSet.of(FalsePositive.A); + + testSet.add(FalsePositive.B); + } + + public Set<Suite> getSuites() + { + return EnumSet.<Suite>allOf(Suite.class); + } + + public void uecFP2() + { + Set<Suite> suites = getSuites(); + + suites.add(Suite.Clubs); + } +} Property changes on: trunk/fb-contrib/samples/UEC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/URV_Sample.java =================================================================== --- trunk/fb-contrib/samples/URV_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/URV_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,38 +1,38 @@ -import java.util.HashSet; -import java.util.TreeSet; - -public class URV_Sample extends URV_Super -{ - public Object getASet(boolean b) - { - if (b) - return new HashSet(); - else - return new TreeSet(); - } - - public Object getInfo(boolean b) - { - if (b) - return new String[4]; - else - return ""; - } - - @Override - public Object getInheritedInfo(boolean b) - { - if (b) - return new Integer(1); - else - return new Float(1.0); - } -} - -class URV_Super -{ - public Object getInheritedInfo(boolean b) - { - return null; - } -} +import java.util.HashSet; +import java.util.TreeSet; + +public class URV_Sample extends URV_Super +{ + public Object getASet(boolean b) + { + if (b) + return new HashSet(); + else + return new TreeSet(); + } + + public Object getInfo(boolean b) + { + if (b) + return new String[4]; + else + return ""; + } + + @Override + public Object getInheritedInfo(boolean b) + { + if (b) + return new Integer(1); + else + return new Float(1.0); + } +} + +class URV_Super +{ + public Object getInheritedInfo(boolean b) + { + return null; + } +} Property changes on: trunk/fb-contrib/samples/URV_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/USS_Sample.java =================================================================== --- trunk/fb-contrib/samples/USS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/USS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,100 +1,100 @@ -import java.util.StringTokenizer; - -public class USS_Sample -{ - public String[] testUss1(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreTokens()) - { - sarray[i] = st.nextToken(); - i++; - } - - return sarray; - } - - public String[] testUss2(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreTokens()) - { - sarray[i++] = st.nextToken(); - } - - return sarray; - } - - public String[] testUss3(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - for (int i = 0; i < count; i++) - { - sarray[i++] = st.nextToken(); - } - - return sarray; - } - - public String[] testUss4(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreElements()) - { - sarray[i++] = (String)st.nextElement(); - } - - return sarray; - } - - public String[] testUssFP5(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreElements()) - { - sarray[i++] = "***" + (String)st.nextElement(); - } - - return sarray; - } - - public String[] testUssFP6(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreTokens()) - { - String x = st.nextToken(); - if (x.equals("*")) - x = "Star"; - - sarray[i++] = x; - } - - return sarray; - } - - -} +import java.util.StringTokenizer; + +public class USS_Sample +{ + public String[] testUss1(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreTokens()) + { + sarray[i] = st.nextToken(); + i++; + } + + return sarray; + } + + public String[] testUss2(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreTokens()) + { + sarray[i++] = st.nextToken(); + } + + return sarray; + } + + public String[] testUss3(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + for (int i = 0; i < count; i++) + { + sarray[i++] = st.nextToken(); + } + + return sarray; + } + + public String[] testUss4(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreElements()) + { + sarray[i++] = (String)st.nextElement(); + } + + return sarray; + } + + public String[] testUssFP5(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreElements()) + { + sarray[i++] = "***" + (String)st.nextElement(); + } + + return sarray; + } + + public String[] testUssFP6(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreTokens()) + { + String x = st.nextToken(); + if (x.equals("*")) + x = "Star"; + + sarray[i++] = x; + } + + return sarray; + } + + +} Property changes on: trunk/fb-contrib/samples/USS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UTA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UTA_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UTA_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,34 +1,34 @@ -import java.util.Iterator; -import java.util.List; - -public class UTA_Sample -{ - public String[] testList1(List<String> l) - { - String[] data = new String[l.size()]; - for (int i = 0; i < l.size(); i++) - data[i] = l.get(i); - - return data; - } - - public Integer[] testList2(List<Integer> l) - { - int size = l.size(); - Integer[] data = new Integer[size]; - for (int i = 0; i < size; i++) - data[i] = l.get(i); - - return data; - } - - public Long[] testList3(List<Long> l) - { - Iterator<Long> it = l.iterator(); - Long[] data = new Long[l.size()]; - for (int i = 0; i < l.size(); i++) - data[i] = it.next(); - - return data; - } -} +import java.util.Iterator; +import java.util.List; + +public class UTA_Sample +{ + public String[] testList1(List<String> l) + { + String[] data = new String[l.size()]; + for (int i = 0; i < l.size(); i++) + data[i] = l.get(i); + + return data; + } + + public Integer[] testList2(List<Integer> l) + { + int size = l.size(); + Integer[] data = new Integer[size]; + for (int i = 0; i < size; i++) + data[i] = l.get(i); + + return data; + } + + public Long[] testList3(List<Long> l) + { + Iterator<Long> it = l.iterator(); + Long[] data = new Long[l.size()]; + for (int i = 0; i < l.size(); i++) + data[i] = it.next(); + + return data; + } +} Property changes on: trunk/fb-contrib/samples/UTA_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/fb-contrib/samples/samples-bugs.xml ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java 2007-09-15 18:59:26 UTC (rev 905) @@ -0,0 +1,139 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.JavaClass; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for classes that implement Serializable and implements readObject and w... [truncated message content] |