Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 857937D97 for ; Sat, 3 Dec 2011 21:06:17 +0000 (UTC) Received: (qmail 35633 invoked by uid 500); 3 Dec 2011 21:06:17 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 35565 invoked by uid 500); 3 Dec 2011 21:06:17 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 35558 invoked by uid 99); 3 Dec 2011 21:06:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Dec 2011 21:06:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Dec 2011 21:06:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C908623889DA for ; Sat, 3 Dec 2011 21:05:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1210006 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java Date: Sat, 03 Dec 2011 21:05:54 -0000 To: commits@commons.apache.org From: oheger@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111203210554.C908623889DA@eris.apache.org> Author: oheger Date: Sat Dec 3 21:05:54 2011 New Revision: 1210006 URL: http://svn.apache.org/viewvc?rev=1210006&view=rev Log: Java 1.5 compatibility: Javadocs, raw types, StringBuilder, etc. Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java?rev=1210006&r1=1210005&r2=1210006&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java (original) +++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java Sat Dec 3 21:05:54 2011 @@ -18,6 +18,7 @@ package org.apache.commons.configuration; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -55,7 +56,7 @@ public class JNDIConfiguration extends A private Context baseContext; /** The Set of keys that have been virtually cleared. */ - private Set clearedProperties = new HashSet(); + private Set clearedProperties = new HashSet(); /** * Creates a JNDIConfiguration using the default initial context as the @@ -118,10 +119,10 @@ public class JNDIConfiguration extends A * @param processedCtx a set with the so far processed objects * @throws NamingException If JNDI has an issue. */ - private void recursiveGetKeys(Set keys, Context context, String prefix, Set processedCtx) throws NamingException + private void recursiveGetKeys(Set keys, Context context, String prefix, Set processedCtx) throws NamingException { processedCtx.add(context); - NamingEnumeration elements = null; + NamingEnumeration elements = null; try { @@ -130,12 +131,12 @@ public class JNDIConfiguration extends A // iterates through the context's elements while (elements.hasMore()) { - NameClassPair nameClassPair = (NameClassPair) elements.next(); + NameClassPair nameClassPair = elements.next(); String name = nameClassPair.getName(); Object object = context.lookup(name); // build the key - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append(prefix); if (key.length() > 0) { @@ -175,7 +176,7 @@ public class JNDIConfiguration extends A * * @return an iterator with all keys */ - public Iterator getKeys() + public Iterator getKeys() { return getKeys(""); } @@ -187,17 +188,13 @@ public class JNDIConfiguration extends A * @param prefix the prefix * @return an iterator with the selected keys */ - public Iterator getKeys(String prefix) + @Override + public Iterator getKeys(String prefix) { // build the path String[] splitPath = StringUtils.split(prefix, "."); - List path = new ArrayList(); - - for (int i = 0; i < splitPath.length; i++) - { - path.add(splitPath[i]); - } + List path = Arrays.asList(splitPath); try { @@ -205,10 +202,10 @@ public class JNDIConfiguration extends A Context context = getContext(path, getBaseContext()); // return all the keys under the context found - Set keys = new HashSet(); + Set keys = new HashSet(); if (context != null) { - recursiveGetKeys(keys, context, prefix, new HashSet()); + recursiveGetKeys(keys, context, prefix, new HashSet()); } else if (containsKey(prefix)) { @@ -221,12 +218,12 @@ public class JNDIConfiguration extends A catch (NameNotFoundException e) { // expected exception, no need to log it - return new ArrayList().iterator(); + return new ArrayList().iterator(); } catch (NamingException e) { fireError(EVENT_READ_PROPERTY, null, null, e); - return new ArrayList().iterator(); + return new ArrayList().iterator(); } } @@ -240,7 +237,7 @@ public class JNDIConfiguration extends A * @return The context at that key's location in the JNDI tree, or null if not found * @throws NamingException if JNDI has an issue */ - private Context getContext(List path, Context context) throws NamingException + private Context getContext(List path, Context context) throws NamingException { // return the current context if the path is empty if (path == null || path.isEmpty()) @@ -248,17 +245,17 @@ public class JNDIConfiguration extends A return context; } - String key = (String) path.get(0); + String key = path.get(0); // search a context matching the key in the context's elements - NamingEnumeration elements = null; + NamingEnumeration elements = null; try { elements = context.list(""); while (elements.hasMore()) { - NameClassPair nameClassPair = (NameClassPair) elements.next(); + NameClassPair nameClassPair = elements.next(); String name = nameClassPair.getName(); Object object = context.lookup(name); @@ -291,7 +288,7 @@ public class JNDIConfiguration extends A { try { - NamingEnumeration enumeration = null; + NamingEnumeration enumeration = null; try { @@ -322,6 +319,7 @@ public class JNDIConfiguration extends A * @param value the value * @throws UnsupportedOperationException */ + @Override public void setProperty(String key, Object value) { throw new UnsupportedOperationException("This operation is not supported"); @@ -332,6 +330,7 @@ public class JNDIConfiguration extends A * * @param key the key of the property to remove */ + @Override public void clearProperty(String key) { clearedProperties.add(key); @@ -433,6 +432,7 @@ public class JNDIConfiguration extends A * @param obj the value * @throws UnsupportedOperationException */ + @Override protected void addPropertyDirect(String key, Object obj) { throw new UnsupportedOperationException("This operation is not supported");