From 9dfb4e0f6bae5177e64becef853047f58488e9f7 Mon Sep 17 00:00:00 2001 From: Rick Giles Date: Fri, 6 Dec 2002 12:41:35 +0000 Subject: [PATCH] removed dead code. --- src/digester/checkstyle_checks.xml | 20 -- src/digester/checkstyle_checksB.xml | 25 -- src/digester/checkstyle_rules.xml | 27 -- src/digester/checkstyle_rulesB.xml | 56 ---- .../ConfigurationDigesterLoader.java | 93 ------ .../checkstyle/ConfigurationRuleParser.java | 269 ------------------ .../tools/checkstyle/DigesterLoaderTest.java | 77 ----- src/digester/configuration.dtd | 6 - src/digester/digester-rules.dtd | 128 --------- 9 files changed, 701 deletions(-) delete mode 100644 src/digester/checkstyle_checks.xml delete mode 100644 src/digester/checkstyle_checksB.xml delete mode 100644 src/digester/checkstyle_rules.xml delete mode 100644 src/digester/checkstyle_rulesB.xml delete mode 100644 src/digester/com/puppycrawl/tools/checkstyle/ConfigurationDigesterLoader.java delete mode 100644 src/digester/com/puppycrawl/tools/checkstyle/ConfigurationRuleParser.java delete mode 100644 src/digester/com/puppycrawl/tools/checkstyle/DigesterLoaderTest.java delete mode 100644 src/digester/configuration.dtd delete mode 100644 src/digester/digester-rules.dtd diff --git a/src/digester/checkstyle_checks.xml b/src/digester/checkstyle_checks.xml deleted file mode 100644 index bf8db0147..000000000 --- a/src/digester/checkstyle_checks.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/digester/checkstyle_checksB.xml b/src/digester/checkstyle_checksB.xml deleted file mode 100644 index dd2b3f3fa..000000000 --- a/src/digester/checkstyle_checksB.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/digester/checkstyle_rules.xml b/src/digester/checkstyle_rules.xml deleted file mode 100644 index c0f99be51..000000000 --- a/src/digester/checkstyle_rules.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/digester/checkstyle_rulesB.xml b/src/digester/checkstyle_rulesB.xml deleted file mode 100644 index 7e48ca589..000000000 --- a/src/digester/checkstyle_rulesB.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/digester/com/puppycrawl/tools/checkstyle/ConfigurationDigesterLoader.java b/src/digester/com/puppycrawl/tools/checkstyle/ConfigurationDigesterLoader.java deleted file mode 100644 index adec18734..000000000 --- a/src/digester/com/puppycrawl/tools/checkstyle/ConfigurationDigesterLoader.java +++ /dev/null @@ -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 ConfigurationLoaderDigester here. - * - * @author Oliver Burn - * @version 1.0 - */ -class ConfigurationDigesterLoader - extends DefaultHandler -{ - /** overriding properties **/ - private Properties mOverrideProps = new Properties(); - - /** - * Creates a new ConfigurationLoaderDigester 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); - } - } -} \ No newline at end of file diff --git a/src/digester/com/puppycrawl/tools/checkstyle/ConfigurationRuleParser.java b/src/digester/com/puppycrawl/tools/checkstyle/ConfigurationRuleParser.java deleted file mode 100644 index 8b73e3341..000000000 --- a/src/digester/com/puppycrawl/tools/checkstyle/ConfigurationRuleParser.java +++ /dev/null @@ -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 element (in which case the - * pattern applies to all rules elements contained within the - * 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()); - } - - } -} diff --git a/src/digester/com/puppycrawl/tools/checkstyle/DigesterLoaderTest.java b/src/digester/com/puppycrawl/tools/checkstyle/DigesterLoaderTest.java deleted file mode 100644 index 53d7915e5..000000000 --- a/src/digester/com/puppycrawl/tools/checkstyle/DigesterLoaderTest.java +++ /dev/null @@ -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("]"); - } - - -} \ No newline at end of file diff --git a/src/digester/configuration.dtd b/src/digester/configuration.dtd deleted file mode 100644 index 6d2fb4613..000000000 --- a/src/digester/configuration.dtd +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/digester/digester-rules.dtd b/src/digester/digester-rules.dtd deleted file mode 100644 index eed7bb25f..000000000 --- a/src/digester/digester-rules.dtd +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -