mbenson 2004/12/13 11:12:36 Modified: src/main/org/apache/tools/ant RuntimeConfigurable.java Log: Remove unnecessary empty Hashtable instantiations, LOC bumming and Javadoc fixes. Revision Changes Path 1.55 +19 -36 ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java Index: RuntimeConfigurable.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- RuntimeConfigurable.java 27 Sep 2004 09:03:17 -0000 1.54 +++ RuntimeConfigurable.java 13 Dec 2004 19:12:36 -0000 1.55 @@ -40,6 +40,9 @@ */ public class RuntimeConfigurable implements Serializable { + /** Empty Hashtable. */ + private static final Hashtable EMPTY_HASHTABLE = new Hashtable(0); + /** Name of the element to configure. */ private String elementTag = null; @@ -183,11 +186,8 @@ * @since Ant 1.6 */ public Hashtable getAttributeMap() { - if (attributeMap != null) { - return new Hashtable(attributeMap); - } else { - return new Hashtable(1); - } + return (attributeMap == null) + ? EMPTY_HASHTABLE : new Hashtable(attributeMap); } /** @@ -208,9 +208,7 @@ * Must not be <code>null</code>. */ public void addChild(RuntimeConfigurable child) { - if (children == null) { - children = new ArrayList(); - } + children = (children == null) ? new ArrayList() : children; children.add(child); } @@ -232,11 +230,8 @@ * @since Ant 1.6 */ public Enumeration getChildren() { - if (children != null) { - return Collections.enumeration(children); - } else { - return new CollectionUtils.EmptyEnumeration(); - } + return (children == null) ? new CollectionUtils.EmptyEnumeration() + : Collections.enumeration(children); } /** @@ -246,14 +241,8 @@ * Should not be <code>null</code>. */ public void addText(String data) { - if (data.length() == 0) { - return; - } - if (characters != null) { - characters.append(data); - } else { - characters = new StringBuffer(data); - } + characters = (characters == null) + ? new StringBuffer(data) : characters.append(data); } /** @@ -347,7 +336,6 @@ if (proxyConfigured) { return; } - // Configure the object Object target = (wrappedObject instanceof TypeAdapter) ? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject; @@ -396,8 +384,7 @@ Enumeration e = getChildren(); while (e.hasMoreElements()) { - RuntimeConfigurable child - = (RuntimeConfigurable) e.nextElement(); + RuntimeConfigurable child = (RuntimeConfigurable) e.nextElement(); if (child.wrappedObject instanceof Task) { Task childTask = (Task) child.wrappedObject; childTask.setRuntimeConfigurableWrapper(child); @@ -416,11 +403,9 @@ * For TaskContainers, we simply skip configuration here. */ String tag = child.getElementTag().toLowerCase(Locale.US); - if (configureChildren - && ih.supportsNestedElement(tag)) { + if (configureChildren && ih.supportsNestedElement(tag)) { child.maybeConfigure(p); - ProjectHelper.storeChild(p, target, child.wrappedObject, - tag); + ProjectHelper.storeChild(p, target, child.wrappedObject, tag); } } @@ -443,9 +428,9 @@ /** * Apply presets, attributes and text are set if not currently set. - * nested elements are prepended. + * Nested elements are prepended. * - * @param r a <code>RuntimeConfigurable</code> value + * @param r a <code>RuntimeConfigurable</code> value. */ public void applyPreSet(RuntimeConfigurable r) { // Attributes @@ -458,11 +443,10 @@ } } // poly type - if (r.polyType != null && polyType == null) { - polyType = r.polyType; - } - // Children (this is a shadow of unknownElement#children) + polyType = (polyType == null) ? r.polyType : polyType; + + // Children (this is a shadow of UnknownElement#children) if (r.children != null) { List newChildren = new ArrayList(); newChildren.addAll(r.children); @@ -476,8 +460,7 @@ if (r.characters != null) { if (characters == null || characters.toString().trim().length() == 0) { - characters = - new StringBuffer(r.characters.toString()); + characters = new StringBuffer(r.characters.toString()); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]