<?xml version="1.0"?>

<ruleset name="Migration Rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../etc/ruleset_xml_schema.xml">
  <description>
Contains rules about migrating from one JDK version to another.  Don't use these rules directly,
      rather, use a wrapper ruleset such as migrating_to_13.xml.
  </description>

<rule name="ReplaceVectorWithList"
  message="Consider replacing this Vector with the newer java.util.List"
  class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/migrating.html#ReplaceVectorWithList">
  <description>
  Consider replacing this Vector with the newer java.util.List
  </description>
  <properties>
    <property name="xpath">
    <value>
<![CDATA[
//Type/ReferenceType/ClassOrInterfaceType[@Image='Vector']
 ]]>
    </value>
    </property>
  </properties>
  <priority>3</priority>
  <example>
<![CDATA[
public class Foo {
 void bar() {
    Vector v = new Vector();
 }
}
]]>
  </example>
</rule>

    <rule name="ReplaceHashtableWithMap"
      message="Consider replacing this Hashtable with the newer java.util.Map"
      class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/migrating.html#ReplaceHashtableWithMap">
      <description>
      Consider replacing this Hashtable with the newer java.util.Map
      </description>
      <properties>
        <property name="xpath">
        <value>
    <![CDATA[
    //Type/ReferenceType/ClassOrInterfaceType[@Image='Hashtable']
     ]]>
        </value>
        </property>
      </properties>
      <priority>3</priority>
      <example>
    <![CDATA[
    public class Foo {
     void bar() {
        Hashtable h = new Hashtable();
     }
    }
    ]]>
      </example>
    </rule>

    <rule name="ReplaceEnumerationWithIterator"
      message="Consider replacing this Enumeration with the newer java.util.Iterator"
      class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/migrating.html#ReplaceEnumerationWithIterator">
      <description>
      Consider replacing this Enumeration with the newer java.util.Iterator
      </description>
      <properties>
        <property name="xpath">
        <value>
    <![CDATA[
    //ImplementsList/ClassOrInterfaceType[@Image='Enumeration']
     ]]>
        </value>
        </property>
      </properties>
      <priority>3</priority>
      <example>
    <![CDATA[
public class Foo implements Enumeration {
    private int x = 42;
    public boolean hasMoreElements() {
        return true;
    }
    public Object nextElement() {
        return String.valueOf(i++);
    }
}
    ]]>
      </example>
    </rule>

    <rule name="AvoidEnumAsIdentifier"
          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
          class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/migrating.html#AvoidEnumAsIdentifier">
      <description>Finds all places 'enum' is used as an identifier is used</description>
      <properties>
          <property name="xpath">
              <value>
                  <![CDATA[
                    //VariableDeclaratorId[@Image='enum']
                  ]]>
              </value>
          </property>
      </properties>
        <priority>2</priority>
      <example>
  <![CDATA[
    public class A {
        public  class foo {
            String enum = "foo";
        }
    }
  ]]>
      </example>
    </rule>

    <rule name="AvoidAssertAsIdentifier"
          message="Avoid using assert as an identifier; it's a reserved word in JDK 1.4"
          class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/migrating.html#AvoidAssertAsIdentifier">
      <description>Finds all places 'assert' is used as an identifier is used</description>
      <properties>
          <property name="xpath">
              <value>
                  <![CDATA[
                    //VariableDeclaratorId[@Image='assert']
                  ]]>
              </value>
          </property>
      </properties>
        <priority>2</priority>
      <example>
  <![CDATA[
    public class A {
        public  class foo {
            String assert = "foo";
        }
    }
  ]]>
      </example>
    </rule>

    <rule name="IntegerInstantiation"
          message="Avoid instantiating Integer objects. Call Integer.valueOf() instead"
          class="net.sourceforge.pmd.rules.XPathRule">
      <description>In JDK 1.5, calling new Integer() causes memory allocation.  Integer.valueOf() is more memory friendly.</description>
      <properties>
          <property name="xpath">
              <value>
                  <![CDATA[
//PrimaryPrefix
 /AllocationExpression
  [not (ArrayDimsAndInits)
   and (ClassOrInterfaceType/@Image='Integer'
    or ClassOrInterfaceType/@Image='java.lang.Integer')]
                  ]]>
              </value>
          </property>
      </properties>
        <priority>2</priority>
      <example>
  <![CDATA[
public class Foo {
 private Integer i = new Integer(0); // change to Integer i = Integer.valueOf(0);
}
   ]]>
      </example>
    </rule>

</ruleset>

