You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@apache.org on 2005/02/20 11:37:23 UTC
svn commit: r154501 -
jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationScope.java
Author: skitching
Date: Sun Feb 20 02:37:22 2005
New Revision: 154501
URL: http://svn.apache.org/viewcvs?view=rev&rev=154501
Log:
Make public constant private: only needed here.
Whitespace cleanups and javadoc improvements.
Modified:
jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationScope.java
Modified: jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationScope.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationScope.java?view=diff&r1=154500&r2=154501
==============================================================================
--- jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationScope.java (original)
+++ jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationScope.java Sun Feb 20 02:37:22 2005
@@ -1,19 +1,19 @@
/* $Id$
*
* Copyright 2003-2005 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.digester2.plugins;
@@ -31,7 +31,7 @@
* <p>
* Plugin declarations are created by either:
* <ul>
- * <li> PluginCreateAction from method startParse time, in the case where a
+ * <li> PluginCreateAction from method startParse, in the case where a
* plugin has a default plugin class.
* <li> PluginCreateAction from method begin, in the case where the input
* xml just declares the plugin class on the matching tag, eg
@@ -60,26 +60,26 @@
* popped, thereby discarding the out-of-scope plugin declarations.
* <p>
* Note that there is a problem with the current implementation of declaration
- * scoping. The problem is not in this class, but in the code which decides
+ * scoping. The problem is not in this class, but in the code which decides
* when to push and pop new instances of this class. Simply, declaration scopes
- * should last until the end of the parent xml element containing the
- * declaration (not the end of the declaration element itself) - but Digester
- * doesn't provide any hooks to allow detection of the end of the parent
- * element. The current solution, therefore, is to regard a scope as starting
- * when a PluginCreateAction fires. This does at least separate the scope of
- * declarations within a plugin from those "above" the plugin point which is
+ * should last until the end of the parent xml element containing the
+ * declaration (not the end of the declaration element itself) - but Digester
+ * doesn't provide any hooks to allow detection of the end of the parent
+ * element. The current solution, therefore, is to regard a scope as starting
+ * when a PluginCreateAction fires. This does at least separate the scope of
+ * declarations within a plugin from those "above" the plugin point which is
* the most important issue.
* <p>
- * At some future time, if digester provides the facility to perform actions
+ * At some future time, if digester provides the facility to perform actions
* associated with "the parent tag", then the PluginDeclarationScope stack
- * can be decoupled from the firing of PluginCreateRule instances.
+ * can be decoupled from the firing of PluginCreateRule instances.
*/
public class PluginDeclarationScope {
- public static final Context.ItemId PLUGIN_DECL_SCOPE
+ private static final Context.ItemId PLUGIN_DECL_SCOPE
= new Context.ItemId(PluginDeclarationScope.class, "PluginDecls");
-
+
/** Map of classname->Declaration */
private HashMap declarationsByClass = new HashMap();
@@ -88,25 +88,25 @@
/** the parent manager to which this one may delegate lookups. */
private PluginDeclarationScope parent;
-
+
// ---------------------------------------------------------------------
// Static Methods
// ---------------------------------------------------------------------
/**
- * Extract the current (top) PluginDeclarationScope object from the
+ * Extract the current (top) PluginDeclarationScope object from the
* provided context. If one hasn't been created yet, then do so.
* <p>
* This is similar to a singleton method, except that there is a
* PluginDeclarationScope per context.
- * <p>
- * Note that instead of using a "scratch stack" in the context, we
- * just use a "scratch item" which returns the most-recent
- * PluginDeclarationScope. As each of these objects contains a reference
- * to its "parent" scope, this is effectively a linked-list-stack.
*/
public static PluginDeclarationScope getInstance(Context context) {
- PluginDeclarationScope pds =
+ // Instead of using a "scratch stack" in the context, we
+ // just use a "scratch item" which returns the most-recent
+ // PluginDeclarationScope. As each of these objects contains a
+ // reference to its "parent" scope, this is effectively a
+ // linked-list-stack.
+ PluginDeclarationScope pds =
(PluginDeclarationScope) context.getItem(PLUGIN_DECL_SCOPE);
if (pds == null) {
pds = new PluginDeclarationScope();
@@ -115,18 +115,18 @@
return pds;
}
-
+
//------------------- constructors ---------------------------------------
/** Construct a "root" PluginDeclarationScope, ie one with no parent. */
public PluginDeclarationScope() {
}
- /**
- * Construct a "child" PluginDeclarationScope. When declarations are added
+ /**
+ * Construct a "child" PluginDeclarationScope. When declarations are added
* to a "child", they are stored within the child and do not modify the
* parent, so when the child goes out of scope, those declarations
- * disappear. When asking a "child" to retrieve a declaration, it
+ * disappear. When asking a "child" to retrieve a declaration, it
* delegates the search to its parent if it does not hold a matching
* entry itself.
* <p>
@@ -135,7 +135,7 @@
public PluginDeclarationScope(PluginDeclarationScope parent) {
this.parent = parent;
}
-
+
//------------------- methods --------------------------------------------
/**
@@ -150,12 +150,12 @@
public void addDeclaration(Declaration decl) {
Log log = LogUtils.getLogger(null);
boolean debug = log.isDebugEnabled();
-
+
Class pluginClass = decl.getPluginClass();
String id = decl.getId();
-
+
declarationsByClass.put(pluginClass.getName(), decl);
-
+
if (id != null) {
declarationsById.put(id, decl);
if (debug) {
@@ -171,9 +171,9 @@
* If no such plugin is known, null is returned.
*/
public Declaration getDeclarationByClass(String className) {
- Declaration decl =
+ Declaration decl =
(Declaration) declarationsByClass.get(className);
-
+
if ((decl == null) && (parent != null)) {
decl = parent.getDeclarationByClass(className);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org