removed dead code.

This commit is contained in:
Rick Giles 2002-12-06 12:41:35 +00:00
parent 256220f857
commit 9dfb4e0f6b
9 changed files with 0 additions and 701 deletions

View File

@ -1,20 +0,0 @@
<?xml version="1.0"?>
<configuration tabWidth="4" basedir="${checkstyle.basedir}">
<TreeWalker>
<AvoidStarImport/>
<MemberNameCheck
format="^m_[a-zA-Z0-9]*$"/>
<ConstantNameCheck/>
<EmptyBlockCheck/>
<EqualsHashCodeCheck/>
<FileLengthCheck/>
<NoWhitespaceAfterCheck
tokens="DOT"
allowLineBreaks="true"/>
<GenericIllegalRegexpCheck
format="System.out.println"/>
</TreeWalker>
<PackageHtmlCheck/>
<TranslationCheck/>
</configuration>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE config SYSTEM "configuration.dtd">
<config name="configuration">
<property name="tabWidth" value="4" />
<property name="basedir" value="${checkstyle.basedir}" />
<config name="TreeWalker">
<config name="AvoidStarImport"/>
<config name="MemberNameCheck">
<property name="format" value="^m_[a-zA-Z0-9]*$"/>
</config>
<config name="ConstantNameCheck"/>
<config name="EmptyBlockCheck"/>
<config name="EqualsHashCodeCheck"/>
<config name="FileLengthCheck"/>
<config name="NoWhitespaceAfterCheck">
<property name="tokens" value="DOT"/>
<property name="allowLineBreaks" value="true"/>
</config>
<config name="GenericIllegalRegexpCheck">
<property name="format" value="System.out.println"/>
</config>
</config>
<config name="PackageHtmlCheck"/>
<config name="TranslationCheck"/>
</config>

View File

@ -1,27 +0,0 @@
<?xml version="1.0"?>
<digester-rules>
<!-- This form of rule is also accepted
<pattern value="configuration">
<config-create-rule
shortname="configuration"
classname="com.puppycrawl.tools.checkstyle.Configuration" />
</pattern>
-->
<config-create-rule
pattern="configuration"
classname="com.puppycrawl.tools.checkstyle.DefaultConfiguration" />
<config-create-rule
pattern="*/TreeWalker"
classname="com.puppycrawl.tools.checkstyle.TreeWalker" />
<config-create-rule
pattern="*/AvoidStarImport"
classname="com.puppycrawl.tools.checkstyle.AvoidStarImport" />
<config-create-rule
pattern="*/MemberNameCheck"
classname="com.puppycrawl.tools.checkstyle.MemberNameCheck" />
</digester-rules>

View File

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Rules for a digester to load a configuration -->
<!-- Digester ignores property-metadata elements -->
<digester-rules>
<!-- Define each configuration in a config element -->
<pattern value="*/config" >
<!-- Configuration create rule -->
<config
name="configuration"
classname="com.puppycrawl.tools.checkstyle.DefaultConfiguration" />
<config
name="TreeWalker"
classname="com.puppycrawl.tools.checkstyle.TreeWalker" />
<config
name="AvoidStarImport"
classname="com.puppycrawl.tools.checkstyle.AvoidStarImport" />
<config
name="NoWhitespaceAfterCheck"
classname="com.puppycrawl.tools.checkstyle.NoWhitespaceAfterCheck" />
<config
name="GenericIllegalRegexpCheck"
classname="com.puppycrawl.tools.checkstyle.GenericIllegalRegexpCheck" />
<!-- Example of a configuration that has a single property of type String. -->
<config
name="MemberNameCheck"
classname="com.puppycrawl.tools.checkstyle.MemberNameCheck" >
<property-metadata name="format" type="String" />
</config>
<!-- Example of a rule with one property of type enumeration. -->
<!-- In this case the property can only take on values from -->
<!-- the enumeration set. -->
<config
name="RightCurlyCheck"
classname="com.puppycrawl.tools.checkstyle.RightCurlyCheck">
<property-metadata name="location" type="Enumeration" >
<enumeration-set>
<value-option value="nl"/>
<value-option value="nlow"/>
<value-option value="alone"/>
</enumeration-set>
</property-metadata>
</config>
</pattern>
<pattern value="*/property">
<call-method-rule methodname="addAttribute" paramcount="2"/>
<call-param-rule paramnumber="0" attrname="name" />
<call-param-rule paramnumber="1" attrname="value" />
</pattern>
</digester-rules>

View File

@ -1,93 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2002 Oliver Burn
//
// 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.puppycrawl.tools.checkstyle;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import com.puppycrawl.tools.checkstyle.api.Configuration;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSet;
import org.apache.commons.digester.xmlrules.FromXmlRuleSet;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
/**
* Describe class <code>ConfigurationLoaderDigester</code> here.
*
* @author <a href="mailto:checkstyle@puppycrawl.com">Oliver Burn</a>
* @version 1.0
*/
class ConfigurationDigesterLoader
extends DefaultHandler
{
/** overriding properties **/
private Properties mOverrideProps = new Properties();
/**
* Creates a new <code>ConfigurationLoaderDigester</code> instance.
* @throws ParserConfigurationException if an error occurs
* @throws SAXException if an error occurs
*/
private ConfigurationDigesterLoader()
{
}
/**
* Returns the check configurations in a specified file.
* @param aRulesFname name of digester rules file
* @param aConfigFname name of config file
* @param aOverrideProps overriding properties
* @return the check configurations
* @throws CheckstyleException if an error occurs
*/
public static Configuration loadConfiguration(String aRulesFname,
String aConfigFname,
Properties aOverrideProps)
throws CheckstyleException
{
try {
final File rulesFile = new File(aRulesFname);
final File configFile = new File(aConfigFname);
final RuleSet ruleSet = new FromXmlRuleSet(rulesFile.toURL(),
new ConfigurationRuleParser());
final Digester digester = new Digester();
digester.addRuleSet(ruleSet);
digester.setValidating(false);
digester.push(new DefaultConfiguration("root"));
//TODO: apply aOverrideProps and perform property expansion
return (DefaultConfiguration) digester.parse(configFile);
}
catch (FileNotFoundException e) {
throw new CheckstyleException("unable to find " + aConfigFname);
}
catch (SAXException e) {
throw new CheckstyleException("unable to parse "
+ aConfigFname + " - " + e.getMessage());
}
catch (IOException e) {
throw new CheckstyleException("unable to read " + aConfigFname);
}
}
}

View File

@ -1,269 +0,0 @@
package com.puppycrawl.tools.checkstyle;
import org.apache.commons.digester.AbstractObjectCreationFactory;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.Rule;
import org.apache.commons.digester.xmlrules.DigesterRuleParser;
import org.xml.sax.Attributes;
/**
* This is a RuleSet that parses XML into Digester rules, and then
* adds those rules to a 'target' Digester.
* @author Rick Giles
* @version 1-Dec-2002
*/
public class ConfigurationRuleParser extends DigesterRuleParser
{
/** name of the Rule class */
private final String ruleClassName = Rule.class.getName();
/** @see org.apache.commons.digester.xmlrules.DigesterRuleParser */
public void addRuleInstances(Digester aDigester)
{
super.addRuleInstances(aDigester);
aDigester.addFactoryCreate(
"*/config-create-rule", new ConfigCreateRuleFactory());
aDigester.addRule(
"*/config-create-rule", new PatternRule("pattern"));
aDigester.addSetNext("*/config-create-rule", "add", ruleClassName);
aDigester.addFactoryCreate(
"*/config", new ConfigRuleFactory());
aDigester.addRule(
"*/config", new PatternRule("pattern"));
aDigester.addSetNext("*/config", "add", ruleClassName);
}
/**
* Factory for creating a configCreateRule
*/
protected class ConfigCreateRuleFactory
extends AbstractObjectCreationFactory
{
public Object createObject(Attributes anAttributes)
{
final String className = anAttributes.getValue("classname");
return new ConfigCreateRule(className);
}
}
/**
* Factory for creating a configCreateRule
*/
protected class ConfigRuleFactory
extends AbstractObjectCreationFactory
{
public Object createObject(Attributes anAttributes)
{
final String name = anAttributes.getValue("name");
final String className = anAttributes.getValue("classname");
return new ConfigRule(name, className);
}
}
/**
* A rule for extracting the pattern matching strings from the rules XML.
* In the digester-rules document type, a pattern can either be declared
* in the 'value' attribute of a <pattern> element (in which case the
* pattern applies to all rules elements contained within the <pattern>
* element), or it can be declared in the optional 'pattern' attribute of
* a rule element.
*/
private class PatternRule extends Rule
{
private String mAttrName;
private String mPattern = null;
/**
* Creates a pattern rule.
* @param attrName The name of the attribute containing the pattern
*/
public PatternRule(String aAttrName)
{
mAttrName = aAttrName;
}
/**
* If a pattern is defined for the attribute, push it onto the
* pattern stack.
* @param aAttrs the attributes to search.
*
*/
public void begin(String namespace, String name, Attributes aAttrs)
{
mPattern = aAttrs.getValue(mAttrName);
if (mPattern != null) {
patternStack.push(mPattern);
}
}
/**
* If there was a pattern for this element, pop it off the pattern
* stack.
*/
public void end(String namespace, String name)
{
if (mPattern != null) {
patternStack.pop();
}
}
}
protected class ConfigRule extends Rule
{
private String mName;
/** name of the class for the configuration */
private String mClassName;
private boolean isNameMatch;
/**
* Construct an configuration create rule with the specified class
* name.
*
* @param aClassName Java class name of the object to be created
*/
public ConfigRule(String aName, String aClassName)
{
mName = aName;
mClassName = aClassName;
}
/**
* Process the beginning of this element.
* @param aAtts The attribute list of this element
*/
public void begin(String aNamespace, String aName, Attributes aAtts)
{
// TODO: add logging
// if (digester.log.isDebugEnabled()) {
// digester.log.debug(
// "[ObjectCreateRule]{" + digester.match + "}New "
// + realClassName);
// }
// Instantiate the new object and push it on the context stack
final String name = aAtts.getValue("name");
if ((name != null) && (mName.equals(name))) {
isNameMatch = true;
final DefaultConfiguration config =
new DefaultConfiguration(mName);
config.addAttribute("classname", mClassName);
final DefaultConfiguration parent =
(DefaultConfiguration) digester.peek();
parent.addChild(config);
digester.push(config);
}
else {
isNameMatch = false;
}
}
/**
* Process the end of this element.
*/
public void end(String namespace, String name)
{
if (isNameMatch) {
Object top = digester.pop();
}
// TODO: add logging
// if (digester.log.isDebugEnabled()) {
// digester.log.debug("[ObjectCreateRule]{" + digester.match +
// "} Pop " + top.getClass().getName());
// }
}
/**
* Render a printable version of this Rule.
* @return a String representation of this Rule.
*/
public String toString()
{
StringBuffer sb = new StringBuffer("ConfigCreateRule0[");
sb.append("className=");
sb.append(mClassName);
sb.append("]");
return (sb.toString());
}
}
protected class ConfigCreateRule extends Rule
{
/** name of the class for the configuration */
private String mClassName;
/**
* Construct an configuration create rule with the specified class
* name.
*
* @param aClassName Java class name of the object to be created
*/
public ConfigCreateRule(String aClassName)
{
mClassName = aClassName;
}
/**
* Process the beginning of this element.
* @param aAtts The attribute list of this element
*/
public void begin(String aNamespace, String aName, Attributes aAtts)
{
// TODO: add logging
// if (digester.log.isDebugEnabled()) {
// digester.log.debug(
// "[ObjectCreateRule]{" + digester.match + "}New "
// + realClassName);
// }
// Instantiate the new object and push it on the context stack
final DefaultConfiguration config =
new DefaultConfiguration(mClassName);
config.addAttribute("classname", mClassName);
final int attCount = aAtts.getLength();
for (int i = 0; i < attCount; i++) {
final String name = aAtts.getQName(i);
final String value = aAtts.getValue(i);
config.addAttribute(name, value);
}
final DefaultConfiguration parent =
(DefaultConfiguration) digester.peek();
parent.addChild(config);
digester.push(config);
}
/**
* Process the end of this element.
*/
public void end(String namespace, String name)
{
Object top = digester.pop();
// TODO: add logging
// if (digester.log.isDebugEnabled()) {
// digester.log.debug("[ObjectCreateRule]{" + digester.match +
// "} Pop " + top.getClass().getName());
// }
}
/**
* Render a printable version of this Rule.
* @return a String representation of this Rule.
*/
public String toString()
{
StringBuffer sb = new StringBuffer("ConfigCreateRule[");
sb.append("className=");
sb.append(mClassName);
sb.append("]");
return (sb.toString());
}
}
}

View File

@ -1,77 +0,0 @@
package com.puppycrawl.tools.checkstyle;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.Configuration;
public class DigesterLoaderTest
{
public static void main(String[] args)
{
//test rules with elements named by shortened class name
try {
final String inputFname = "src/digester/checkstyle_checks.xml";
final String rulesFname = "src/digester/checkstyle_rules.xml";
final Configuration config =
ConfigurationDigesterLoader.loadConfiguration(
rulesFname, inputFname, null);
dump(config, 0);
}
catch (Exception exc) {
exc.printStackTrace();
}
//test rules with config elements
try {
final String inputFname = "src/digester/checkstyle_checksB.xml";
final String rulesFname = "src/digester/checkstyle_rulesB.xml";
final Configuration config =
ConfigurationDigesterLoader.loadConfiguration(
rulesFname, inputFname, null);
dump(config, 0);
}
catch (Exception exc) {
exc.printStackTrace();
}
}
/**
* Method dump.
* @param config
*/
private static void dump(Configuration aConfig, int aLevel)
{
for (int i = 0; i < aLevel; i++) {
System.out.print(" ");
}
dumpDetails(aConfig);
final Configuration[] children = aConfig.getChildren();
for (int i = 0; i < children.length; i++) {
dump(children[i], aLevel + 1);
}
}
/**
* Method dumpDetails.
* @param config
*/
private static void dumpDetails(Configuration aConfig)
{
System.out.print(aConfig.getName() + "[");
final String[] attNames = aConfig.getAttributeNames();
for (int i = 0; i < attNames.length; i++) {
try {
System.out.print(attNames[i] + "="
+ aConfig.getAttribute(attNames[i]) + ",");
}
catch (CheckstyleException ex) {
ex.printStackTrace();
}
}
System.out.println("]");
}
}

View File

@ -1,6 +0,0 @@
<!ELEMENT config (config | property)*>
<!ATTLIST config name CDATA #REQUIRED>
<!ELEMENT property EMPTY>
<!ATTLIST property name CDATA #REQUIRED
value CDATA #REQUIRED>

View File

@ -1,128 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
"Digester" component of the Jakarta Commons Subproject
DTD for the definition of Digester rules in XML.
$Id: digester-rules.dtd,v 1.4 2002/07/16 21:23:28 rdonkin Exp $
-->
<!-- This document type defines an XML format for defining Digester rules.
Digester is a framework for pattern-matching-based parsing of XML into
Java objects. See http://jakarta.apache.org/commons/digester.html. -->
<!ENTITY % rule-elements "call-method-rule | call-param-rule |
factory-create-rule | object-create-rule |
set-properties-rule | set-property-rule | set-top-rule |
set-next-rule" >
<!-- digester-rules is the root element. -->
<!ELEMENT digester-rules (pattern | include | call-method-rule | call-param-rule | factory-create-rule | object-create-rule | set-properties-rule | set-property-rule | set-top-rule | set-next-rule )*>
<!-- <pattern> defines a matching pattern, or part of a matching pattern. Any
rule nested in a pattern element prepends its parent's to its pattern.
Patterns may be recursively nested.
Example:
<pattern value="foo">
<pattern value="bar">
<object-create-rule pattern="baz" classname="Fubar" />
</pattern>
</pattern>
The above sample fragment defines an ObjectCreateRule associated
with the pattern "foo/bar/baz".
Note that the use of pattern elements is optional; an alternative is for
each rule element to contain a 'pattern' attribute. -->
<!ELEMENT pattern (pattern | include | call-method-rule | call-param-rule |
factory-create-rule | object-create-rule |
set-properties-rule | set-property-rule | set-top-rule |
set-next-rule )*>
<!ATTLIST pattern
value CDATA #REQUIRED>
<!--
<include> allows one set of digester rules to be included inside
another. The 'path' attribute contains the URI of the document to
include. Inclusion behaves as if the included rules document is
'macro-expanded' within the outer document.
Programmatically initialized rules can be included as well, via the
'class' attribute. The 'class' attribute should contain the name
of a class that implements
org.apache.commons.digester.xmlrules.DigesterRulesSource.
-->
<!ELEMENT include EMPTY>
<!ATTLIST include
path CDATA #IMPLIED
class CDATA #IMPLIED>
<!-- Each 'rule' element below corresponds to a concrete subclass
of org.apache.framework.digester.Rule.
Each 'rule' element has an optional 'pattern' attribute, which
defines the pattern for that rule instance. If the rule element
is nested inside one or more <pattern> elements, those patterns
will be prepended to the pattern specified in the rule's 'pattern'
attribute. -->
<!-- CallMethodRule -->
<!ELEMENT call-method-rule EMPTY>
<!ATTLIST call-method-rule
pattern CDATA #IMPLIED
methodname CDATA #REQUIRED
paramcount CDATA #IMPLIED
paramtypes CDATA #IMPLIED>
<!-- CallParamRule -->
<!ELEMENT call-param-rule EMPTY>
<!ATTLIST call-param-rule
pattern CDATA #IMPLIED
paramnumber CDATA #REQUIRED
attrname CDATA #IMPLIED>
<!-- FactoryCreateRule -->
<!ELEMENT factory-create-rule EMPTY>
<!ATTLIST factory-create-rule
pattern CDATA #IMPLIED
classname CDATA #REQUIRED
attrname CDATA #IMPLIED>
<!-- ObjectCreateRule -->
<!ELEMENT object-create-rule EMPTY>
<!ATTLIST object-create-rule
pattern CDATA #IMPLIED
classname CDATA #REQUIRED
attrname CDATA #IMPLIED>
<!-- SetPropertiesRule -->
<!ELEMENT set-properties-rule (alias)*>
<!ATTLIST factory-create-rule
pattern CDATA #IMPLIED>
<!-- An alias is a custom attribute->property name mapping -->
<!ELEMENT alias EMPTY>
<!ATTLIST alias
ÊÊÊÊ attr-name CDATA #REQUIRED
ÊÊÊÊ prop-name CDATA #IMPLIED>
<!-- SetPropertyRule -->
<!ELEMENT set-property-rule EMPTY>
<!ATTLIST set-property-rule
pattern CDATA #IMPLIED
name CDATA #IMPLIED
value CDATA #IMPLIED>
<!-- SetTopRule -->
<!ELEMENT set-top-rule EMPTY>
<!ATTLIST set-top-rule
pattern CDATA #IMPLIED
methodname CDATA #REQUIRED
paramtype CDATA #IMPLIED>
<!-- SetNextRule -->
<!ELEMENT set-next-rule EMPTY>
<!ATTLIST set-next-rule
pattern CDATA #IMPLIED
methodname CDATA #REQUIRED
paramtype CDATA #IMPLIED>