You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/06/22 22:48:56 UTC
svn commit: r549955 [11/16] - in
/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java: javax/naming/
javax/naming/directory/ javax/naming/event/ javax/naming/ldap/
javax/naming/spi/ org/apache/harmony/jndi/internal/
org/apache/harmony/jndi/inter...
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java Fri Jun 22 13:48:49 2007
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package org.apache.harmony.jndi.internal;
import java.applet.Applet;
@@ -44,9 +43,9 @@
/**
* This is a utility class that reads environment properties.
- *
*/
public final class EnvironmentReader {
+
// The name of application resource files
private static final String APPLICATION_RESOURCE_FILE = "jndi.properties"; //$NON-NLS-1$
@@ -61,14 +60,12 @@
/*
* Merge additional properties with already read ones.
*
- * @param src - the source containing additional properties
- * @param dst - the destination to put additional properties
- * @param valueAddToList - whether to add new values of C-type properties
+ * @param src - the source containing additional properties @param dst - the
+ * destination to put additional properties @param valueAddToList - whether
+ * to add new values of C-type properties
*/
- public static void mergeEnvironment(
- final Hashtable<?, ?> src,
- final Hashtable<Object, Object> dst,
- final boolean valueAddToList) {
+ public static void mergeEnvironment(final Hashtable<?, ?> src,
+ final Hashtable<Object, Object> dst, final boolean valueAddToList) {
Object key = null;
String val = null;
@@ -82,20 +79,19 @@
* If this property doesn't exist yet, add it.
*/
dst.put(key, src.get(key));
- } else if (
- valueAddToList
+ } else if (valueAddToList
&& (LdapContext.CONTROL_FACTORIES.equals(key)
- || Context.OBJECT_FACTORIES.equals(key)
- || Context.STATE_FACTORIES.equals(key)
- || Context.URL_PKG_PREFIXES.equals(key))) {
+ || Context.OBJECT_FACTORIES.equals(key)
+ || Context.STATE_FACTORIES.equals(key) || Context.URL_PKG_PREFIXES
+ .equals(key))) {
/*
* Otherwise, if this property can contain a list of values, add
* the additional values if the flag "valueAddToList" is true.
*/
// Read the original value
- val = (String)dst.get(key);
- // Values are combined into a single list separated by colons.
+ val = (String) dst.get(key);
+ // Values are combined into a single list separated by colons.
val = val + ":" + src.get(key); //$NON-NLS-1$
// The final value becomes the resulting value of that property
dst.put(key, val);
@@ -108,13 +104,14 @@
}
/*
- * Get the required 7 JNDI properties from JNDI properties source.
- * This method is designed as package visibility to improve performance
- * when called by anonymous inner classes.
+ * Get the required 7 JNDI properties from JNDI properties source. This
+ * method is designed as package visibility to improve performance when
+ * called by anonymous inner classes.
*
* @return a hashtable holding the required properties.
*/
- static Hashtable<Object, Object> filterProperties(final JNDIPropertiesSource source) {
+ static Hashtable<Object, Object> filterProperties(
+ final JNDIPropertiesSource source) {
final Hashtable<Object, Object> filteredProperties = new Hashtable<Object, Object>();
String propValue = null;
@@ -159,15 +156,16 @@
/*
* Read the required 7 JNDI properties from system properties and merge with
* existing properties. Note that the values of C-type properties are only
- * included when no corresponding value is presented in existing properties.
+ * included when no corresponding value is presented in existing properties.
*
* @param existingProps - existing properties
*/
- public static void readSystemProperties(final Hashtable<Object, Object> existingProps) {
+ public static void readSystemProperties(
+ final Hashtable<Object, Object> existingProps) {
/*
- * Privileged code is used to access system properties. This is
- * required if JNDI is run in Applet or other applications which
- * only have limited permissions to access certain resources.
+ * Privileged code is used to access system properties. This is required
+ * if JNDI is run in Applet or other applications which only have
+ * limited permissions to access certain resources.
*/
Hashtable<Object, Object> systemProperties = AccessController
.doPrivileged(new PrivilegedAction<Hashtable<Object, Object>>() {
@@ -181,33 +179,31 @@
/*
* Read the required 7 JNDI properties from applet parameters and merge with
* existing properties. Note that the values of C-type properties are only
- * included when no corresponding value is presented in existing properties.
+ * included when no corresponding value is presented in existing properties.
*
- * @param applet - the applet object
- * @param existingProps - existing properties
+ * @param applet - the applet object @param existingProps - existing
+ * properties
*/
- public static void readAppletParameters(Object applet, Hashtable<Object, Object> existingProps) {
+ public static void readAppletParameters(Object applet,
+ Hashtable<Object, Object> existingProps) {
if (null != applet) {
- Hashtable<Object, Object> appletParameters =
- filterProperties(new AppletParametersSource((Applet) applet));
+ Hashtable<Object, Object> appletParameters = filterProperties(new AppletParametersSource(
+ (Applet) applet));
mergeEnvironment(appletParameters, existingProps, false);
}
}
/*
* Read multiple resource files from the classpaths given the file name.
- * This method is designed as package visibility to improve performance
- * when called by anonymous inner classes.
+ * This method is designed as package visibility to improve performance when
+ * called by anonymous inner classes.
*
- * @param name - the name of the resource file
- * @param existingProps - existing properties, cannot be null
- * @param filter - to filter properties
+ * @param name - the name of the resource file @param existingProps -
+ * existing properties, cannot be null @param filter - to filter properties
*/
static Hashtable<Object, Object> readMultipleResourceFiles(
- final String name,
- final Hashtable<Object, Object> existingProps,
- ClassLoader cl)
- throws NamingException {
+ final String name, final Hashtable<Object, Object> existingProps,
+ ClassLoader cl) throws NamingException {
if (null == cl) {
cl = ClassLoader.getSystemClassLoader();
@@ -220,8 +216,8 @@
} catch (IOException ex) {
// Unexpected ClassLoader exception
// jndi.23=Failed to load JNDI resource files.
- ConfigurationException newEx =
- new ConfigurationException(Messages.getString("jndi.23")); //$NON-NLS-1$
+ ConfigurationException newEx = new ConfigurationException(Messages
+ .getString("jndi.23")); //$NON-NLS-1$
newEx.setRootCause(ex);
throw newEx;
}
@@ -241,8 +237,8 @@
} catch (IOException ex) {
// Can't read this resource file
// jndi.24=Failed to read JNDI resource files.
- ConfigurationException newEx =
- new ConfigurationException(Messages.getString("jndi.24")); //$NON-NLS-1$
+ ConfigurationException newEx = new ConfigurationException(
+ Messages.getString("jndi.24")); //$NON-NLS-1$
newEx.setRootCause(ex);
throw newEx;
} finally {
@@ -265,19 +261,21 @@
*
* @param existingProps - existing properties, cannot be null.
*/
- public static Hashtable<Object, Object> readApplicationResourceFiles(final Hashtable<Object, Object> existingProps)
- throws NamingException {
+ public static Hashtable<Object, Object> readApplicationResourceFiles(
+ final Hashtable<Object, Object> existingProps)
+ throws NamingException {
// Use privileged code to read the application resource files
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- public Void run() throws NamingException {
- readMultipleResourceFiles(
- APPLICATION_RESOURCE_FILE,
- existingProps,
- Thread.currentThread().getContextClassLoader());
- return null;
- }
- });
+ AccessController
+ .doPrivileged(new PrivilegedExceptionAction<Void>() {
+ public Void run() throws NamingException {
+ readMultipleResourceFiles(
+ APPLICATION_RESOURCE_FILE, existingProps,
+ Thread.currentThread()
+ .getContextClassLoader());
+ return null;
+ }
+ });
} catch (PrivilegedActionException e) {
Exception rootCause = e.getException();
if (rootCause instanceof NamingException) {
@@ -292,15 +290,16 @@
}
/*
- * Read the properties file "java.home"/lib/jndi.properties.
- * Pay attention to the privileged code for accessing this external resource
- * file. This is required if JNDI is run in Applet or other applications
- * which only have limited permissions to access certain resources.
+ * Read the properties file "java.home"/lib/jndi.properties. Pay attention
+ * to the privileged code for accessing this external resource file. This is
+ * required if JNDI is run in Applet or other applications which only have
+ * limited permissions to access certain resources.
*
* @param existingProps - existing properties, cannot be null.
*/
- public static Hashtable<Object, Object> readLibraryResourceFile(final Hashtable<Object, Object> existingProps)
- throws NamingException {
+ public static Hashtable<Object, Object> readLibraryResourceFile(
+ final Hashtable<Object, Object> existingProps)
+ throws NamingException {
final String sep = System.getProperty("file.separator"); //$NON-NLS-1$
String resPath = null;
@@ -316,18 +315,20 @@
final File resFile = new File(resPath);
final Properties p = new Properties();
// Use privileged code to determine whether the file exists
- boolean resFileExists = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- public Boolean run() {
- return Boolean.valueOf(resFile.exists());
- }
- }).booleanValue();
+ boolean resFileExists = AccessController.doPrivileged(
+ new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ return Boolean.valueOf(resFile.exists());
+ }
+ }).booleanValue();
if (resFileExists) {
try {
// Use privileged code to read the file
is = AccessController
.doPrivileged(new PrivilegedExceptionAction<FileInputStream>() {
public FileInputStream run() throws IOException {
- FileInputStream localInputStream = new FileInputStream(resFile);
+ FileInputStream localInputStream = new FileInputStream(
+ resFile);
p.load(localInputStream);
return localInputStream;
}
@@ -335,9 +336,10 @@
mergeEnvironment(p, existingProps, true);
} catch (PrivilegedActionException e) {
// Can't read "java.home"/lib/jndi.properties
- // jndi.25=Failed to read JNDI resource files in java home library.
- ConfigurationException newEx =
- new ConfigurationException(Messages.getString("jndi.25")); //$NON-NLS-1$
+ // jndi.25=Failed to read JNDI resource files in java home
+ // library.
+ ConfigurationException newEx = new ConfigurationException(
+ Messages.getString("jndi.25")); //$NON-NLS-1$
newEx.setRootCause(e.getException());
throw newEx;
} finally {
@@ -356,13 +358,12 @@
/*
* Read the service provider resource file.
*
- * @param context - the context
- * @param existingProps - existing properties, cannot be null.
+ * @param context - the context @param existingProps - existing properties,
+ * cannot be null.
*/
public static Hashtable<Object, Object> readProviderResourceFiles(
- final Context context,
- final Hashtable<Object, Object> existingProps)
- throws NamingException {
+ final Context context, final Hashtable<Object, Object> existingProps)
+ throws NamingException {
String factory = context.getClass().getName();
String resPath = null;
@@ -373,7 +374,7 @@
// Default package
resPath = PROVIDER_RESOURCE_FILE;
} else {
- // Replace "." with '/'
+ // Replace "." with '/'
resPath = factory.substring(0, len + 1);
resPath = resPath.replace('.', '/');
resPath += PROVIDER_RESOURCE_FILE;
@@ -382,15 +383,15 @@
// Use privileged code to read the provider resource files
try {
final String finalResPath = resPath;
- AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
- public String run() throws NamingException {
- readMultipleResourceFiles(
- finalResPath,
- existingProps,
- context.getClass().getClassLoader());
- return null;
- }
- });
+ AccessController
+ .doPrivileged(new PrivilegedExceptionAction<String>() {
+ public String run() throws NamingException {
+ readMultipleResourceFiles(finalResPath,
+ existingProps, context.getClass()
+ .getClassLoader());
+ return null;
+ }
+ });
} catch (PrivilegedActionException e) {
Exception rootCause = e.getException();
if (rootCause instanceof NamingException) {
@@ -409,24 +410,20 @@
* Get the list of the specified factory names from the supplied environment
* and the resource provider files of the given Context.
*
- * @param envmt The supplied environment.
- * @param ctx The Context whose resource provider files will be read.
- * @param key The name of the factory.
- * @return The list of the desired factory names.
- * @throws NamingException If an error occurs when reading the provider
- * resource files.
+ * @param envmt The supplied environment. @param ctx The Context whose
+ * resource provider files will be read. @param key The name of the factory.
+ * @return The list of the desired factory names. @throws NamingException If
+ * an error occurs when reading the provider resource files.
*/
public static String[] getFactoryNamesFromEnvironmentAndProviderResource(
- Hashtable<?, ?> envmt,
- Context ctx,
- String key)
- throws NamingException {
+ Hashtable<?, ?> envmt, Context ctx, String key)
+ throws NamingException {
List<String> fnames = new ArrayList<String>();
// collect tokens from envmt with key
if (null != envmt) {
- String str = (String)envmt.get(key);
+ String str = (String) envmt.get(key);
if (null != str) {
StringTokenizer st = new StringTokenizer(str, ":"); //$NON-NLS-1$
while (st.hasMoreTokens()) {
@@ -439,7 +436,7 @@
Hashtable<Object, Object> h = new Hashtable<Object, Object>();
// read provider resource file from ctx's package
EnvironmentReader.readProviderResourceFiles(ctx, h);
- String str = (String)h.get(key);
+ String str = (String) h.get(key);
if (null != str) {
StringTokenizer st = new StringTokenizer(str, ":"); //$NON-NLS-1$
while (st.hasMoreTokens()) {
@@ -447,7 +444,8 @@
}
}
}
- // if key is Context.URL_PKG_PREFIXES, append "com.sun.jndi.url" at the end
+ // if key is Context.URL_PKG_PREFIXES, append "com.sun.jndi.url" at the
+ // end
if (Context.URL_PKG_PREFIXES.equals(key)) {
fnames.add("com.sun.jndi.url"); //$NON-NLS-1$
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/PagedResultSearchControlValue.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/PagedResultSearchControlValue.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/PagedResultSearchControlValue.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/PagedResultSearchControlValue.java Fri Jun 22 13:48:49 2007
@@ -13,39 +13,42 @@
* 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.harmony.jndi.internal;
/**
* Represents the following ASN1 Syntax on java Types:
*
+ * <pre>
+ *
* realSearchControlValue ::= SEQUENCE {
* size INTEGER (0..maxInt),
* -- requested page size from client
* -- result set size estimate from server
* cookie OCTET STRING
* }
- *
- * @author Osvaldo C. Demo
- * @author Juan Giannuzzo
+ * </pre>
*/
public class PagedResultSearchControlValue {
-
+
private byte[] cookie;
+
private int size;
-
+
/**
- * Constructor
+ * Constructor
*
- * @param size an int with the size
- * @param cookie the cookie from the server
+ * @param size
+ * an int with the size
+ * @param cookie
+ * the cookie from the server
*/
public PagedResultSearchControlValue(int size, byte[] cookie) {
- this.cookie = cookie;
+ this.cookie = cookie;
this.size = size;
}
-
+
/**
* Getter method for cookie
*
@@ -54,7 +57,7 @@
public byte[] getCookie() {
return cookie;
}
-
+
/**
* Getter method for size
*
@@ -63,5 +66,5 @@
public int getSize() {
return size;
}
-
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/SortResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/SortResult.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/SortResult.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/SortResult.java Fri Jun 22 13:48:49 2007
@@ -13,15 +13,17 @@
* 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.harmony.jndi.internal;
import java.io.Serializable;
/**
- * Represents the following ASN1 Syntax to use with the Harmony ASN1 Parser:<br><br>
+ * Represents the following ASN1 Syntax to use with the Harmony ASN1 Parser:<br>
+ * <br>
*
+ * <pre>
* SortResult ::= SEQUENCE {
* sortResult ENUMERATED {
* success (0), -- results are sorted
@@ -45,28 +47,27 @@
* other (80)
* },
* attributeType [0] AttributeDescription OPTIONAL }
- *
- * @author Osvaldo C. Demo
- *
+ * </pre>
*/
-public class SortResult implements Serializable{
-
+public class SortResult implements Serializable {
+
private static final long serialVersionUID = 3633917983682858021L;
-
+
private int sortresult;
+
private String attributeType;
-
+
public SortResult(int sortresult, String attrtype) {
this.sortresult = sortresult;
this.attributeType = attrtype;
}
-
+
public String getAttributeType() {
return attributeType;
}
-
+
public int getSortresult() {
return sortresult;
}
-
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/UrlParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/UrlParser.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/UrlParser.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/UrlParser.java Fri Jun 22 13:48:49 2007
@@ -15,29 +15,29 @@
* limitations under the License.
*/
-
package org.apache.harmony.jndi.internal;
/**
- * Identifies the simplest URL syntax: <code>{scheme}:{scheme specific part}</code>.
- *
+ * Identifies the simplest URL syntax:
+ * <code>{scheme}:{scheme specific part}</code>.
*/
public class UrlParser {
-
+
/*
* Prevent instantiate.
*/
private UrlParser() {
- super();
+ super();
}
/**
- * Returns an URL's scheme part, in lower case. If the url is not a valid
+ * Returns an URL's scheme part, in lower case. If the url is not a valid
* URL, null is returned.
*
- * @param url a url string
- * @return the URL's scheme part, in lower case. If the url is not a
- * valid URL, null is returned.
+ * @param url
+ * a url string
+ * @return the URL's scheme part, in lower case. If the url is not a valid
+ * URL, null is returned.
*/
public static String getScheme(String url) {
if (null == url) {
@@ -52,14 +52,9 @@
boolean inCharSet;
for (int i = 0; i < scheme.length(); i++) {
c = scheme.charAt(i);
- inCharSet =
- (c >= 'A' && c <= 'Z')
- || (c >= 'a' && c <= 'z')
- || (c >= '0' && c <= '9')
- || c == '+'
- || c == '.'
- || c == '-'
- || c == '_';
+ inCharSet = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
+ || (c >= '0' && c <= '9') || c == '+' || c == '.'
+ || c == '-' || c == '_';
if (!inCharSet) {
return null;
}
@@ -68,5 +63,3 @@
}
}
-
-
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/Util.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/Util.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/Util.java Fri Jun 22 13:48:49 2007
@@ -36,13 +36,10 @@
/**
* Some useful utilities
- *
- * @author Osvaldo C. Demo
- *
*/
public class Util {
- private static HashMap errorCodes = new HashMap();
+ private static HashMap errorCodes = new HashMap();
static {
// TODO Add every needed LDAP errror code description and exception
@@ -65,17 +62,19 @@
/**
* Return the correct exception for a given error code
*
- * @param code error code
- * @return the correct NamingException
+ * @param code
+ * error code
+ * @return the correct NamingException
*/
public static NamingException getExceptionFromErrorCode(int code) {
if (code == 0) {
return null;
}
if (errorCodes.get(code) == null) {
- return new NamingException(Messages.getString("ldap.18")+" "+code+"]");
- } else {
- return (NamingException)errorCodes.get(code);
+ return new NamingException(Messages.getString("ldap.18") + " "
+ + code + "]");
}
+ return (NamingException) errorCodes.get(code);
}
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java Fri Jun 22 13:48:49 2007
@@ -13,14 +13,12 @@
* 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.harmony.jndi.internal.parser;
/**
* Represents a Type And a Value Pair
- *
- * @author Osvaldo C. Demo
*/
public class AttributeTypeAndValuePair {
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java Fri Jun 22 13:48:49 2007
@@ -13,7 +13,7 @@
* 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.harmony.jndi.internal.parser;
@@ -31,9 +31,6 @@
/**
* A Distinguised Name Parser according with the RFC2253 and RFC1779 for use
* with LdapName only
- *
- * @author Osvaldo C. Demo
- * @author Juan Giannuzzo
*/
public class LdapNameParser implements NameParser, LdapParser {
private String s = null;
@@ -76,7 +73,7 @@
for (int i = 0; i < c.length; i++) {
if ((c[i] == ',' || c[i] == ';') && c[i - 1] != '\\') {
- String sub = s.substring(from, i);
+ String sub = s.substring(from, i);
if (sub.equals("")) {
throw new InvalidNameException("Invalid name: " + s);
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java Fri Jun 22 13:48:49 2007
@@ -13,7 +13,7 @@
* 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.harmony.jndi.internal.parser;
@@ -23,9 +23,6 @@
/**
* Should be used when implementing a new Distinguished Name Parser
- *
- * @author Juan Giannuzzo
- *
*/
public interface LdapParser {
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java Fri Jun 22 13:48:49 2007
@@ -27,9 +27,6 @@
/**
* Class used to parse RDN components of a Distinguished name
- *
- * @author Osvaldo C. Demo
- *
*/
public class LdapRdnParser implements LdapParser {
@@ -189,11 +186,7 @@
counter++;
}
}
- if (counter == 1) {
- return true;
- } else {
- return false;
- }
+ return counter == 1;
}
private static String getUnEscapedValues(char[] chars) {
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java Fri Jun 22 13:48:49 2007
@@ -13,7 +13,7 @@
* 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.harmony.jndi.internal.parser;
@@ -32,21 +32,17 @@
import org.apache.harmony.jndi.internal.nls.Messages;
/**
- *
- * This class mantains a list of relative distinguished names
- * it supports multiple values for any attribute
- *
- * @author Osvaldo C. Demo
- *
+ * This class maintains a list of relative distinguished names it supports
+ * multiple values for any attribute
*/
public class LdapTypeAndValueList implements Map {
private List list = null;
-
+
private static final long serialVersionUID = -4540483835059087783L;
-
+
private Map attributes = new TreeMap();
-
+
/**
* @return the list size
*/
@@ -63,6 +59,7 @@
/**
* Used to check if a key exists in the list
+ *
* @return true if the key exists, false otherwise.
*/
public boolean containsKey(Object key) {
@@ -71,6 +68,7 @@
/**
* Used to check if a value exists in the list
+ *
* @return true if the value exists, false otherwise.
*/
public boolean containsValue(Object value) {
@@ -79,6 +77,7 @@
/**
* Used to get the values list from a key
+ *
* @return the list of values corresponding to the key
*/
public Object get(Object key) {
@@ -88,20 +87,22 @@
/**
* Used to insert Key/Value pairs
*
- * @param key the key
- * @param value a value
+ * @param key
+ * the key
+ * @param value
+ * a value
* @return the list of values corresponding to this key
*/
public Object put(Object key, Object value) {
- if (attributes.get(new ValueWrapper((String)key)) == null) {
+ if (attributes.get(new ValueWrapper((String) key)) == null) {
list = new ArrayList();
list.add(new ValueWrapper(value));
- attributes.put(new ValueWrapper((String)key),list);
+ attributes.put(new ValueWrapper((String) key), list);
} else {
- list = (List)attributes.get(new ValueWrapper((String)key));
+ list = (List) attributes.get(new ValueWrapper((String) key));
list.add(new ValueWrapper(value));
Collections.sort(list);
- attributes.put(new ValueWrapper((String)key),list);
+ attributes.put(new ValueWrapper((String) key), list);
}
return list;
}
@@ -113,9 +114,8 @@
return attributes.remove(key);
}
-
public void putAll(Map map) {
- throw new UnsupportedOperationException(Messages.getString("ldap.1B"));
+ throw new UnsupportedOperationException(Messages.getString("ldap.1B"));
}
/**
@@ -124,7 +124,7 @@
public void clear() {
attributes.clear();
}
-
+
public Set keySet() {
return attributes.keySet();
}
@@ -138,11 +138,12 @@
List list = new ArrayList();
for (Iterator iter = keySet().iterator(); iter.hasNext();) {
ValueWrapper element = (ValueWrapper) iter.next();
- BasicAttribute ba = new BasicAttribute(element.getStringValue(),true);
- List list2 = (List)attributes.get(element);
+ BasicAttribute ba = new BasicAttribute(element.getStringValue(),
+ true);
+ List list2 = (List) attributes.get(element);
for (Iterator iterator = list2.iterator(); iterator.hasNext();) {
ValueWrapper elementList = (ValueWrapper) iterator.next();
- ba.add(elementList.getValue());
+ ba.add(elementList.getValue());
}
list.add(ba);
}
@@ -150,67 +151,74 @@
}
public Collection values() {
- throw new UnsupportedOperationException(Messages.getString("ldap.1B"));
+ throw new UnsupportedOperationException(Messages.getString("ldap.1B"));
}
public Set entrySet() {
return attributes.entrySet();
}
-
+
public String toString() {
return attributes.toString();
}
-
+
/**
- * Its a wrapper for String/ByteArray that implements the Comparable interface
- * and uses an upper case string value to compare
+ * Its a wrapper for String/ByteArray that implements the Comparable
+ * interface and uses an upper case string value to compare
*
* @author Juan Giannuzzo
* @author Osvaldo C. Demo
*/
private class ValueWrapper implements Comparable {
-
+
private Object value;
-
+
/**
- * Constructor
- * @param value String value to make case insensitive
+ * Constructor
+ *
+ * @param value
+ * String value to make case insensitive
*/
- ValueWrapper(Object value){
- this.value=value;
- }
+ ValueWrapper(Object value) {
+ this.value = value;
+ }
/**
* Returns a String Value for the stored object value
*
- * @return String value
+ * @return String value
*/
- public String getStringValue() {
+ public String getStringValue() {
if (value instanceof String) {
- return (String) value;
- } else {
- return Rdn.escapeValue(value);
+ return (String) value;
}
- }
+ return Rdn.escapeValue(value);
+ }
/**
* Getter for value
+ *
* @return the value object (String or ByteArray)
*/
public Object getValue() {
return value;
}
-
+
/**
* Used to compare CaseInsensitiveStrings
*
- * @param obj object to compare
+ * @param obj
+ * object to compare
* @return 0 when its equal, 1 when its greater, -1 otherwise
- * @throws ClassCastException when the object is not an instance of CaseInsensitiveString
+ * @throws ClassCastException
+ * when the object is not an instance of
+ * CaseInsensitiveString
*
*/
public int compareTo(Object obj) {
- return getStringValue().toUpperCase().compareTo(((ValueWrapper)obj).getStringValue().toUpperCase());
- }
- }
+ return getStringValue().toUpperCase().compareTo(
+ ((ValueWrapper) obj).getStringValue().toUpperCase());
+ }
+ }
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java Fri Jun 22 13:48:49 2007
@@ -27,9 +27,7 @@
import org.apache.harmony.security.x509.DNParser;
/**
- * A relative distinguised name parser that does less checkings than DNParser
- *
- * @author Osvaldo C. Demo
+ * A relative distinguished name parser that does less checking than DNParser
*/
public class RelaxedDnParser extends DNParser {
@@ -57,17 +55,17 @@
// type pair
}
} catch (ArrayIndexOutOfBoundsException e) {
- throw new IOException(Messages.getString("ldap.1C"));
+ throw new IOException(Messages.getString("ldap.1C")); //$NON-NLS-1$
}
// Check for quotations and special chars on the type
for (int i = pos; i < equalIndex; i++) {
if (chars[i] == '\\') {
- throw new IOException(Messages.getString("ldap.1D"));
+ throw new IOException(Messages.getString("ldap.1D")); //$NON-NLS-1$
}
for (int j = 0; j < specialChars.length; j++) {
if (chars[i] == specialChars[j]) {
- throw new IOException(Messages.getString("ldap.1E"));
+ throw new IOException(Messages.getString("ldap.1E")); //$NON-NLS-1$
}
}
}
@@ -92,8 +90,8 @@
}
pos++;
}
-
- while (end > beg+1 && chars[end - 1] == ' ') {
+
+ while (end > beg + 1 && chars[end - 1] == ' ') {
end--;
}
@@ -211,9 +209,11 @@
// char
return chars[pos];
default:
- // RFC doesn't explicitly say that escaped hex pair is
- // interpreted as UTF-8 char. It only contains an example of such
- // DN.
+ /*
+ * RFC doesn't explicitly say that escaped hex pair is
+ * interpreted as UTF-8 char. It only contains an example of
+ * such DN.
+ */
return super.getUTF8();
}
}
@@ -232,7 +232,8 @@
try {
return new Character((char) Integer.parseInt(hex, 16));
} catch (NumberFormatException e) {
- throw new IOException(Messages.getString("ldap.20"));
+ throw new IOException(Messages.getString("ldap.20")); //$NON-NLS-1$
}
}
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java Fri Jun 22 13:48:49 2007
@@ -20,6 +20,7 @@
* @author Vasily Zakharov
* @version $Revision: 1.1.2.3 $
*/
+
package org.apache.harmony.jndi.provider;
import java.util.Hashtable;
@@ -40,17 +41,13 @@
import org.apache.harmony.jndi.internal.nls.Messages;
-
/**
* Base class for URL naming context implementations.
- *
+ *
* In many cases, subclasses should only override
- * {@link #getRootURLContext(String, Hashtable)} method
- * and provide a public constructor calling
+ * {@link #getRootURLContext(String, Hashtable)} method and provide a public
+ * constructor calling
* {@link GenericURLContext#GenericURLContext(Hashtable) super(environment)}.
- *
- * @author Vasily Zakharov
- * @version $Revision: 1.1.2.3 $
*/
public abstract class GenericURLContext implements Context {
@@ -68,11 +65,11 @@
/**
* Creates instance of this context with specified environment.
- *
- * @param environment
- * Environment to copy.
+ *
+ * @param environment
+ * Environment to copy.
*/
- @SuppressWarnings("unchecked") //$NON-NLS-1$
+ @SuppressWarnings("unchecked")
protected GenericURLContext(Hashtable<?, ?> environment) {
super();
if (environment == null) {
@@ -88,8 +85,7 @@
public Object lookup(Name name) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -123,8 +119,7 @@
public Object lookupLink(Name name) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -158,8 +153,7 @@
public void bind(Name name, Object obj) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -195,8 +189,7 @@
public void rebind(Name name, Object obj) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -232,8 +225,7 @@
public void unbind(Name name) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -269,8 +261,7 @@
public Context createSubcontext(Name name) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -304,8 +295,7 @@
public void destroySubcontext(Name name) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -337,37 +327,39 @@
/**
* {@inheritDoc}
- *
- * This method uses {@link #urlEquals(String, String)} to compare
- * URL prefixes of the names.
+ *
+ * This method uses {@link #urlEquals(String, String)} to compare URL
+ * prefixes of the names.
*/
public void rename(Name oldName, Name newName) throws NamingException {
if (!(oldName instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", oldName)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString(
+ "jndi.26", oldName)); //$NON-NLS-1$
}
if (!(newName instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", newName)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString(
+ "jndi.26", newName)); //$NON-NLS-1$
}
if ((oldName.size() == 1) ^ (newName.size() != 1)) {
- // jndi.27=Renaming of names of which one has only one component, +
- // and another has more than one component is not supported: {0} -> {1}
- throw new OperationNotSupportedException(
- Messages.getString("jndi.27", oldName, newName)); //$NON-NLS-1$
+ // jndi.27=Renaming of names of which one has only one component, +
+ // and another has more than one component is not supported: {0} ->
+ // {1}
+ throw new OperationNotSupportedException(Messages.getString(
+ "jndi.27", oldName, newName)); //$NON-NLS-1$
}
if (oldName.size() == 1) {
- rename(oldName.get(0), newName.get(0));
+ rename(oldName.get(0), newName.get(0));
} else {
if (!urlEquals(oldName.get(0), oldName.get(0))) {
- // jndi.28=Renaming of names using different URLs as their first components is not supported: {0} -> {1}
- throw new OperationNotSupportedException(
- Messages.getString("jndi.28", oldName, newName)); //$NON-NLS-1$
+ // jndi.28=Renaming of names using different URLs as their first
+ // components is not supported: {0} -> {1}
+ throw new OperationNotSupportedException(Messages.getString(
+ "jndi.28", oldName, newName)); //$NON-NLS-1$
}
Context context = getContinuationContext(oldName);
@@ -381,27 +373,28 @@
/**
* {@inheritDoc}
- *
+ *
* This method uses {@link #getURLPrefix(String)} and
- * {@link #getURLSuffix(String, String)} methods to parse string names,
- * and also uses {@link #urlEquals(String, String)}
- * to compare URL prefixes of the names.
+ * {@link #getURLSuffix(String, String)} methods to parse string names, and
+ * also uses {@link #urlEquals(String, String)} to compare URL prefixes of
+ * the names.
*/
public void rename(String oldName, String newName) throws NamingException {
String oldPrefix = getURLPrefix(oldName);
String newPrefix = getURLPrefix(newName);
- if(!urlEquals(oldPrefix, newPrefix)) {
- // jndi.29=Renaming of names using different URL prefixes is not supported: {0} -> {1}
- throw new OperationNotSupportedException(
- Messages.getString("jndi.29", oldName, newName)); //$NON-NLS-1$
+ if (!urlEquals(oldPrefix, newPrefix)) {
+ // jndi.29=Renaming of names using different URL prefixes is not
+ // supported: {0} -> {1}
+ throw new OperationNotSupportedException(Messages.getString(
+ "jndi.29", oldName, newName)); //$NON-NLS-1$
}
ResolveResult result = getRootURLContext(oldName, environment);
Context context = (Context) result.getResolvedObj();
try {
- context.rename(result.getRemainingName(),
- getURLSuffix(newPrefix, newName));
+ context.rename(result.getRemainingName(), getURLSuffix(newPrefix,
+ newName));
} finally {
context.close();
}
@@ -410,11 +403,11 @@
/**
* {@inheritDoc}
*/
- public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+ public NamingEnumeration<NameClassPair> list(Name name)
+ throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -432,7 +425,8 @@
/**
* {@inheritDoc}
*/
- public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+ public NamingEnumeration<NameClassPair> list(String name)
+ throws NamingException {
ResolveResult result = getRootURLContext(name, environment);
Context context = (Context) result.getResolvedObj();
@@ -446,11 +440,11 @@
/**
* {@inheritDoc}
*/
- public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+ public NamingEnumeration<Binding> listBindings(Name name)
+ throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -468,7 +462,8 @@
/**
* {@inheritDoc}
*/
- public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+ public NamingEnumeration<Binding> listBindings(String name)
+ throws NamingException {
ResolveResult result = getRootURLContext(name, environment);
Context context = (Context) result.getResolvedObj();
@@ -485,8 +480,7 @@
public NameParser getNameParser(Name name) throws NamingException {
if (!(name instanceof CompositeName)) {
// jndi.26=URL context can't accept non-composite name: {0}
- throw new InvalidNameException(
- Messages.getString("jndi.26", name)); //$NON-NLS-1$
+ throw new InvalidNameException(Messages.getString("jndi.26", name)); //$NON-NLS-1$
}
if (name.size() == 1) {
@@ -525,8 +519,7 @@
* {@inheritDoc}
*/
public String composeName(String name, String prefix) {
- return ((prefix.length() < 1) ? name
- : (name.length() < 1) ? prefix
+ return ((prefix.length() < 1) ? name : (name.length() < 1) ? prefix
: (prefix + '/' + name));
}
@@ -566,42 +559,42 @@
}
/**
- * Lookups the first component (considered a URL)
- * of the specified name using {@link #lookup(String)},
- * wraps it into {@link CannotProceedException}, passes it to
+ * Lookups the first component (considered a URL) of the specified name
+ * using {@link #lookup(String)}, wraps it into
+ * {@link CannotProceedException}, passes it to
* {@link NamingManager#getContinuationContext(CannotProceedException)}
* method and returns the result.
- *
+ *
* This method is used by {@link #lookup(Name)} and other public methods
* taking {@link Name} as a parameter.
- *
+ *
* This method uses {@link #createCannotProceedException(Name)} method.
- *
- * @param name
- * Name to parse.
- *
- * @return Continuation context.
- *
- * @throws NamingException
- * If some naming error occurs.
+ *
+ * @param name
+ * Name to parse.
+ *
+ * @return Continuation context.
+ *
+ * @throws NamingException
+ * If some naming error occurs.
*/
protected Context getContinuationContext(Name name) throws NamingException {
- return NamingManager.getContinuationContext(
- createCannotProceedException(name));
+ return NamingManager
+ .getContinuationContext(createCannotProceedException(name));
}
/**
- * Lookups the first component (considered a URL)
- * of the specified name using {@link #lookup(String)}
- * and wraps it into {@link CannotProceedException}.
- *
- * @param name
- * Name to parse.
- *
- * @return Created {@link CannotProceedException}.
- *
- * @throws NamingException
- * If some naming error occurs.
+ * Lookups the first component (considered a URL) of the specified name
+ * using {@link #lookup(String)} and wraps it into
+ * {@link CannotProceedException}.
+ *
+ * @param name
+ * Name to parse.
+ *
+ * @return Created {@link CannotProceedException}.
+ *
+ * @throws NamingException
+ * If some naming error occurs.
*/
protected final CannotProceedException createCannotProceedException(
Name name) throws NamingException {
@@ -612,53 +605,52 @@
}
/**
- * Determines the proper context from the specified URL and returns
- * the {@link ResolveResult} object with that context as resolved object
- * and the rest of the URL as remaining name.
- *
+ * Determines the proper context from the specified URL and returns the
+ * {@link ResolveResult} object with that context as resolved object and the
+ * rest of the URL as remaining name.
+ *
* This method is used by {@link #lookup(String)} and other public methods
* taking {@link String} name as a parameter.
- *
+ *
* This method must be overridden by particular URL context implementations.
- *
- * When overriding make sure that
- * {@link #getURLPrefix(String)},
+ *
+ * When overriding make sure that {@link #getURLPrefix(String)},
* {@link #getURLSuffix(String, String)} and
- * {@link #getRootURLContext(String, Hashtable)}
- * methods are in sync in how they parse URLs.
- *
- * @param url
- * URL.
- *
- * @param environment
- * Environment.
- *
- * @return {@link ResolveResult} object with resolved context
- * as resolved object the rest of the URL as remaining name.
- *
- * @throws NamingException
- * If some naming error occurs.
+ * {@link #getRootURLContext(String, Hashtable)} methods are in sync in how
+ * they parse URLs.
+ *
+ * @param url
+ * URL.
+ *
+ * @param environment
+ * Environment.
+ *
+ * @return {@link ResolveResult} object with resolved context as resolved
+ * object the rest of the URL as remaining name.
+ *
+ * @throws NamingException
+ * If some naming error occurs.
*/
- protected abstract ResolveResult getRootURLContext(
- String url, Hashtable<?, ?> environment) throws NamingException;
+ protected abstract ResolveResult getRootURLContext(String url,
+ Hashtable<?, ?> environment) throws NamingException;
/**
* Compares two URLs for equality.
- *
- * Implemented here as <code>url1.equals(url2)</code>.
- * Subclasses may provide different implementation.
- *
- * This method is only used by {@link #rename(Name, Name)}
- * and {@link #rename(String, String)} methods.
- *
- * @param url1
- * First URL to compare.
- *
- * @param url2
- * Second URL to compare.
- *
- * @return <code>true</code> if specified URLs are equal,
- * <code>false</code> otherwise.
+ *
+ * Implemented here as <code>url1.equals(url2)</code>. Subclasses may
+ * provide different implementation.
+ *
+ * This method is only used by {@link #rename(Name, Name)} and
+ * {@link #rename(String, String)} methods.
+ *
+ * @param url1
+ * First URL to compare.
+ *
+ * @param url2
+ * Second URL to compare.
+ *
+ * @return <code>true</code> if specified URLs are equal,
+ * <code>false</code> otherwise.
*/
protected boolean urlEquals(String url1, String url2) {
return url1.equals(url2);
@@ -666,29 +658,29 @@
/**
* Returns URL prefix, containing scheme name, hostname and port.
- *
- * This method is only used by {@link #rename(String, String)} method
- * and may be overridden by subclasses.
- *
- * When overriding make sure that
- * {@link #getURLPrefix(String)},
+ *
+ * This method is only used by {@link #rename(String, String)} method and
+ * may be overridden by subclasses.
+ *
+ * When overriding make sure that {@link #getURLPrefix(String)},
* {@link #getURLSuffix(String, String)} and
- * {@link #getRootURLContext(String, Hashtable)}
- * methods are in sync in how they parse URLs.
- *
- * @param url
- * URL to parse.
- *
- * @return URL prefix.
- *
- * @throws NamingException
- * If some naming error occurs.
+ * {@link #getRootURLContext(String, Hashtable)} methods are in sync in how
+ * they parse URLs.
+ *
+ * @param url
+ * URL to parse.
+ *
+ * @return URL prefix.
+ *
+ * @throws NamingException
+ * If some naming error occurs.
*/
protected String getURLPrefix(String url) throws NamingException {
int index = url.indexOf(':');
if (index < 0) {
// jndi.2A=Invalid URL: {0}
- throw new OperationNotSupportedException(Messages.getString("jndi.2A", url)); //$NON-NLS-1$
+ throw new OperationNotSupportedException(Messages.getString(
+ "jndi.2A", url)); //$NON-NLS-1$
}
index++;
@@ -701,32 +693,31 @@
/**
* Returns URL suffix, containing everything but the
- * {@linkplain #getURLPrefix(String) prefix} and separating slash,
- * as a single-component {@link CompositeName}.
- *
- * This method is only used by {@link #rename(String, String)} method
- * and may be overridden by subclasses.
- *
- * This method uses {@link #decodeURLString(String)}
- * to decode the suffix string.
- *
- * When overriding make sure that
- * {@link #getURLPrefix(String)},
+ * {@linkplain #getURLPrefix(String) prefix} and separating slash, as a
+ * single-component {@link CompositeName}.
+ *
+ * This method is only used by {@link #rename(String, String)} method and
+ * may be overridden by subclasses.
+ *
+ * This method uses {@link #decodeURLString(String)} to decode the suffix
+ * string.
+ *
+ * When overriding make sure that {@link #getURLPrefix(String)},
* {@link #getURLSuffix(String, String)} and
- * {@link #getRootURLContext(String, Hashtable)}
- * methods are in sync in how they parse URLs.
- *
- * @param prefix
- * URL prefix, returned by {@link #getURLPrefix(String)}
- * previously called on the same URL.
- *
- * @param url
- * URL to parse.
- *
- * @return URL suffix as a single-component {@link CompositeName}.
- *
- * @throws NamingException
- * If some naming error occurs.
+ * {@link #getRootURLContext(String, Hashtable)} methods are in sync in how
+ * they parse URLs.
+ *
+ * @param prefix
+ * URL prefix, returned by {@link #getURLPrefix(String)}
+ * previously called on the same URL.
+ *
+ * @param url
+ * URL to parse.
+ *
+ * @return URL suffix as a single-component {@link CompositeName}.
+ *
+ * @throws NamingException
+ * If some naming error occurs.
*/
protected Name getURLSuffix(String prefix, String url)
throws NamingException {
@@ -738,30 +729,30 @@
return new CompositeName();
}
- String suffix = url.substring(
- (url.charAt(length) == '/') ? (length + 1) : length);
+ String suffix = url
+ .substring((url.charAt(length) == '/') ? (length + 1) : length);
try {
return new CompositeName().add(decodeURLString(suffix));
} catch (IllegalArgumentException e) {
- throw (InvalidNameException)
- new InvalidNameException().initCause(e);
+ throw (InvalidNameException) new InvalidNameException()
+ .initCause(e);
}
}
/**
- * Decodes URL string by transforming URL-encoded characters
- * into their Unicode character representations.
- *
+ * Decodes URL string by transforming URL-encoded characters into their
+ * Unicode character representations.
+ *
* This method is used by {@link #getURLSuffix(String, String)}.
- *
- * @param str
- * URL or part of URL string.
- *
- * @return Decoded string.
- *
- * @throws IllegalArgumentException
- * If URL format is incorrect.
+ *
+ * @param str
+ * URL or part of URL string.
+ *
+ * @return Decoded string.
+ *
+ * @throws IllegalArgumentException
+ * If URL format is incorrect.
*/
protected static final String decodeURLString(String str)
throws IllegalArgumentException {
@@ -769,25 +760,26 @@
byte bytes[] = new byte[length];
int index = 0;
- for(int i = 0; i < length; ) {
+ for (int i = 0; i < length;) {
char c = str.charAt(i++);
if (c == '%') {
int next = i + 2;
if (next > length) {
- //jndi.2B=Invalid URL format: {0}
- new IllegalArgumentException(Messages.getString("jndi.2B", str)); //$NON-NLS-1$
+ // jndi.2B=Invalid URL format: {0}
+ new IllegalArgumentException(Messages.getString(
+ "jndi.2B", str)); //$NON-NLS-1$
}
try {
- bytes[index++] = (byte)
- Integer.parseInt(str.substring(i, next), 16);
+ bytes[index++] = (byte) Integer.parseInt(str.substring(i,
+ next), 16);
} catch (NumberFormatException e) {
throw (IllegalArgumentException)
- // jndi.2B=Invalid URL format: {0}
- new IllegalArgumentException(
- Messages.getString("jndi.2B", str)).initCause(e); //$NON-NLS-1$
+ // jndi.2B=Invalid URL format: {0}
+ new IllegalArgumentException(Messages.getString(
+ "jndi.2B", str)).initCause(e); //$NON-NLS-1$
}
i = next;
@@ -797,4 +789,5 @@
}
return new String(bytes, 0, index);
}
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java Fri Jun 22 13:48:49 2007
@@ -33,16 +33,12 @@
import org.apache.harmony.jndi.internal.nls.Messages;
-
/**
* Base class for URL naming context factory implementations.
- *
+ *
* In many cases, subclasses should only override
- * {@link #createURLContext(Hashtable)} method
- * and provide public no-args constructor.
- *
- * @author Vasily Zakharov
- * @version $Revision: 1.1.2.3 $
+ * {@link #createURLContext(Hashtable)} method and provide public no-args
+ * constructor.
*/
public abstract class GenericURLContextFactory implements ObjectFactory {
@@ -54,48 +50,47 @@
}
/**
- * Lookups the specified object in the underlying context.
- * Underlying context instance is provided by
- * {@link #createURLContext(Hashtable)}.
- *
+ * Lookups the specified object in the underlying context. Underlying
+ * context instance is provided by {@link #createURLContext(Hashtable)}.
+ *
* Follows the guidelines for URL context factories described in
* {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)}
* specification.
- *
- * If <code>obj</code> is <code>null</code>,
- * just creates and returns an underlying context.
- *
- * If <code>obj</code> is a proper URL string,
- * lookups and returns an object specified by that string.
- *
- * If <code>obj</code> is an array of URL strings,
- * tries to lookup each of them sequentially until lookup succeeds,
- * then returns the result. If no lookup succeeds, throws
- * {@link NamingException} describing the fail of a last lookup.
- *
+ *
+ * If <code>obj</code> is <code>null</code>, just creates and returns
+ * an underlying context.
+ *
+ * If <code>obj</code> is a proper URL string, lookups and returns an
+ * object specified by that string.
+ *
+ * If <code>obj</code> is an array of URL strings, tries to lookup each of
+ * them sequentially until lookup succeeds, then returns the result. If no
+ * lookup succeeds, throws {@link NamingException} describing the fail of a
+ * last lookup.
+ *
* <code>name</code> and <code>nameCtx</code> parameters are ignored.
- *
- * @param obj
- * Object to lookup, can be <code>null</code>.
- *
- * @param name
- * Ignored.
- *
- * @param nameCtx
- * Ignored.
- *
- * @param environment
- * Environment to use in creating the underlying context,
- * can be <code>null</code>.
- *
- * @return The object created.
- *
- * @throws ConfigurationException
- * If <code>obj</code> is neither <code>null</code>
- * nor a string, nor a string array, or is an empty string array.
- *
- * @throws NamingException
- * If lookup attempt failed.
+ *
+ * @param obj
+ * Object to lookup, can be <code>null</code>.
+ *
+ * @param name
+ * Ignored.
+ *
+ * @param nameCtx
+ * Ignored.
+ *
+ * @param environment
+ * Environment to use in creating the underlying context, can be
+ * <code>null</code>.
+ *
+ * @return The object created.
+ *
+ * @throws ConfigurationException
+ * If <code>obj</code> is neither <code>null</code> nor a
+ * string, nor a string array, or is an empty string array.
+ *
+ * @throws NamingException
+ * If lookup attempt failed.
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment) throws NamingException {
@@ -118,7 +113,8 @@
if (strings.length < 1) {
// jndi.2C=obj is an empty string array
- throw new ConfigurationException(Messages.getString("jndi.2C")); //$NON-NLS-1$
+ throw new ConfigurationException(Messages
+ .getString("jndi.2C")); //$NON-NLS-1$
}
NamingException exception = null;
@@ -139,23 +135,26 @@
}
// Unknown object type.
- // jndi.2D=obj is neither null, nor a string, nor a string array: {0}
- throw new IllegalArgumentException(Messages.getString("jndi.2D", obj)); //$NON-NLS-1$
+ // jndi.2D=obj is neither null, nor a string, nor a string array:
+ // {0}
+ throw new IllegalArgumentException(Messages.getString(
+ "jndi.2D", obj)); //$NON-NLS-1$
} finally {
context.close();
}
}
/**
- * Returns new instance of the necessary context.
- * Used by {@link #getObjectInstance(Object, Name, Context, Hashtable)}.
- *
+ * Returns new instance of the necessary context. Used by
+ * {@link #getObjectInstance(Object, Name, Context, Hashtable)}.
+ *
* Must be overridden by particular URL context factory implementations.
- *
- * @param environment
- * Environment.
- *
- * @return New context instance.
+ *
+ * @param environment
+ * Environment.
+ *
+ * @return New context instance.
*/
protected abstract Context createURLContext(Hashtable<?, ?> environment);
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java Fri Jun 22 13:48:49 2007
@@ -35,19 +35,15 @@
import javax.naming.spi.DirObjectFactory;
import javax.naming.spi.ObjectFactory;
-
/**
* Base class for URL directory context factory implementations.
- *
+ *
* In many cases, subclasses should only override
- * {@link #createURLDirContext(Hashtable)} method.
- * and provide public no-args constructor.
- *
- * @author Vasily Zakharov
- * @version $Revision: 1.1.2.2 $
+ * {@link #createURLDirContext(Hashtable)} method. and provide public no-args
+ * constructor.
*/
-public abstract class GenericURLDirContextFactory
- extends GenericURLContextFactory implements DirObjectFactory {
+public abstract class GenericURLDirContextFactory extends
+ GenericURLContextFactory implements DirObjectFactory {
/**
* Default constructor for subclasses.
@@ -57,55 +53,54 @@
}
/**
- * Lookups the specified object in the underlying context.
- * Underlying context instance is provided by
- * {@link #createURLContext(Hashtable)}.
- *
+ * Lookups the specified object in the underlying context. Underlying
+ * context instance is provided by {@link #createURLContext(Hashtable)}.
+ *
* Follows the guidelines for URL context factories described in
* {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)}
* specification.
- *
- * If <code>obj</code> is <code>null</code>,
- * just creates and returns an underlying context.
- *
- * If <code>obj</code> is a proper URL string,
- * lookups and returns an object specified by that string.
- *
- * If <code>obj</code> is an array of URL strings,
- * tries to lookup each of them sequentially until lookup succeeds,
- * then returns the result. If no lookup succeeds, throws
- * {@link NamingException} describing the fail of a last lookup.
- *
+ *
+ * If <code>obj</code> is <code>null</code>, just creates and returns
+ * an underlying context.
+ *
+ * If <code>obj</code> is a proper URL string, lookups and returns an
+ * object specified by that string.
+ *
+ * If <code>obj</code> is an array of URL strings, tries to lookup each of
+ * them sequentially until lookup succeeds, then returns the result. If no
+ * lookup succeeds, throws {@link NamingException} describing the fail of a
+ * last lookup.
+ *
* <code>name</code>, <code>nameCtx</code>, and <code>attrs</code>
* parameters are ignored.
- *
+ *
* This implementation just calls
* {@link #getObjectInstance(Object, Name, Context, Hashtable)}.
- *
- * @param obj
- * Object to lookup, can be <code>null</code>.
- *
- * @param name
- * Ignored.
- *
- * @param nameCtx
- * Ignored.
- *
- * @param environment
- * Environment to use in creating the underlying context,
- * can be <code>null</code>.
- *
- * @param attrs
- * Ignored.
- *
- * @return The object created.
- *
- * @throws ConfigurationException
- * If <code>obj</code> is neither <code>null</code>
- * nor a string, nor a string array, or is an empty string array.
- *
- * @throws NamingException
- * If lookup attempt failed.
+ *
+ * @param obj
+ * Object to lookup, can be <code>null</code>.
+ *
+ * @param name
+ * Ignored.
+ *
+ * @param nameCtx
+ * Ignored.
+ *
+ * @param environment
+ * Environment to use in creating the underlying context, can be
+ * <code>null</code>.
+ *
+ * @param attrs
+ * Ignored.
+ *
+ * @return The object created.
+ *
+ * @throws ConfigurationException
+ * If <code>obj</code> is neither <code>null</code> nor a
+ * string, nor a string array, or is an empty string array.
+ *
+ * @throws NamingException
+ * If lookup attempt failed.
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment, Attributes attrs) throws Exception {
@@ -114,7 +109,7 @@
/**
* {@inheritDoc}
- *
+ *
* This implementation just calls {@link #createURLDirContext(Hashtable)}.
*/
@Override
@@ -126,13 +121,15 @@
* Returns new instance of the necessary context. Used by
* {@link #getObjectInstance(Object, Name, Context, Hashtable)} and
* {@link #getObjectInstance(Object, Name, Context, Hashtable, Attributes)}.
- *
+ *
* Must be overridden by particular URL context factory implementations.
- *
- * @param environment
- * Environment.
- *
- * @return New context instance.
+ *
+ * @param environment
+ * Environment.
+ *
+ * @return New context instance.
*/
- protected abstract DirContext createURLDirContext(Hashtable<?, ?> environment);
+ protected abstract DirContext createURLDirContext(
+ Hashtable<?, ?> environment);
+
}
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java?view=diff&rev=549955&r1=549954&r2=549955
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java Fri Jun 22 13:48:49 2007
@@ -28,16 +28,16 @@
/**
* Trivial implementation of <code>NamingEnumeration</code> interface.
- * @author Alexei Zakharov
- * @version $Revision: 1.1.2.4 $
*/
public class BasicNamingEnumerator<T> implements NamingEnumeration<T> {
-
+
private final Enumeration<T> enumeration;
-
+
/**
* Constructs new enumerator from existing <code>Enumeration</code>.
- * @param enumeration enumeration
+ *
+ * @param enumeration
+ * enumeration
*/
public BasicNamingEnumerator(Enumeration<T> newEnum) {
this.enumeration = newEnum;
@@ -51,7 +51,8 @@
return enumeration.hasMoreElements();
}
- public void close() throws NamingException {}
+ public void close() throws NamingException {
+ }
public T nextElement() {
return enumeration.nextElement();
@@ -60,4 +61,5 @@
public boolean hasMoreElements() {
return enumeration.hasMoreElements();
}
+
}