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 2006/03/15 15:57:17 UTC
svn commit: r386087 [4/45] - in /incubator/harmony/enhanced/classlib/trunk:
make/ make/patternsets/ modules/jndi/ modules/jndi/META-INF/
modules/jndi/make/ modules/jndi/make/common/ modules/jndi/src/
modules/jndi/src/main/ modules/jndi/src/main/java/ m...
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,483 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+import java.util.Hashtable;
+import javax.naming.spi.NamingManager;
+
+import com.ibm.jndi.UrlParser;
+import com.ibm.jndi.EnvironmentReader;
+
+/**
+ * An <code>InitialContext</code> object is required as the starting context
+ * for any naming operations.
+ * Other contexts and subcontexts may be created later. Contexts may consist
+ * of different implementations according to the needs of the application. All
+ * naming operations are performed relative to a context and names are resolved
+ * beginning with the initial context.
+ * <p>
+ * When constructing an initial context, environment properties from a range
+ * of sources may be used to initialize the environment. See the specification
+ * of the {@link Context} interface for further details of environment
+ * properties.</p>
+ * <p>
+ * The environment at runtime determines the initial context implementation.
+ * By default, the naming frameworks look for the initial context factory class
+ * name in the property <code>Context.INITIAL_CONTEXT_FACTORY</code>. When URL
+ * strings must be resolved, a different policy is used which is described
+ * below.</p>
+ * <p>
+ * A <code>NoInitialContextException</code> is thrown when it cannot create an
+ * initial context. The exception may occur not only during constructor
+ * invocation, but may occur later. For example, when a subclass of <code>
+ * InitialContext</code> uses the lazy initialization option, <code>
+ * InitialContext</code> methods may be invoked later which require the
+ * initialization to be completed at that time using the <code>init</code>
+ * protected method. In these circumstances, <code>NoInitialContextException
+ * </code> may be thrown some time after the constructor was invoked. JNDI
+ * applications should be written to be independent of when initial context
+ * is actually initialized.</p>
+ * <p>
+ * If environment property <code>Context.INITIAL_CONTEXT_FACTORY</code> has a
+ * non-null value, then the specified initial context factory may experience a
+ * problem trying to instantiate an initial context and so throw an exception.
+ * It is a responsibility of the service provider implementation as to when an
+ * exception is thrown to report the problem to the JNDI application.</p>
+ * <p>
+ * URL names comprising a String format described by RFC1738 may be components
+ * of names passed to naming operations. Typically, the URL is composed of the
+ * "scheme" - such as one of http, ldap, dns - followed by additional text. If
+ * the JNDI can identify the URL scheme from the specified name, then it is
+ * used to construct a classname suffix in the following form:<br>
+ * <pre>
+ * <package_prefix> . <scheme> . <scheme>URLContextFactory
+ * </pre>
+ * Several variants of the classname are constructed using each element of the
+ * <code>Context.URL_PACKAGE_PREFIXES</code> environment property. Note that an
+ * additional package prefix - "com.sun.jndi.url" - is always considered to be
+ * at the end of those already present in the value of that environment
+ * property. Although a service provider may also provide a URL context
+ * implementation as well as a context implementation, it is not required to do
+ * so, and so an arbitrary service provider might not provide for creating URL
+ * contexts.</p>
+ * <p>
+ * If a URL context is successfully created for a specified URL scheme, the
+ * factory can create contexts for arbitrary URLs of the same scheme.
+ * <code>NamingManager.setInitialContextFactoryBuilder</code> may be used to
+ * specify an alternate policy for locating factories for initial contexts and
+ * URL contexts.</p>
+ * <p>
+ * On successful completion of <code>InitialContext</code> initialization, the
+ * service provider implementation will have returned an appropriate <code>
+ * Context</code> object which can be used for looking up and manipulating names
+ * which may or may not be URL names. <code>InitialContext</code> methods other
+ * than those dealing with environments should delegate context operations to
+ * that <code>Context</code> object.</p>
+ *
+ * @see Context
+ *
+ */
+public class InitialContext implements Context {
+
+ /*
+ * -------------------------------------------------------------------
+ * Instance variables
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Set to the result of the first successful invocation of <code>
+ * NamingManager.getInitialContext</code> by <code>getDefaultInitCtx
+ * </code>.
+ * Initially null.
+ */
+ protected Context defaultInitCtx;
+
+ /**
+ * Set to true when <code>NamingManager.getInitialContext</code> has
+ * been invoked to obtain an initial context.
+ * Initially false.
+ */
+ protected boolean gotDefault;
+
+ /**
+ * Contains all those JNDI environment properties that were found in any
+ * of the the sources of JNDI environment properties.
+ * Initially null.
+ */
+ protected Hashtable myProps;
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Constructs an <code>InitialContext</code> instance without using any
+ * environment properties.
+ * This constructor is effectively the same as using constructor
+ * <code>InitialContext((Hashtable)null)</code>.
+ *
+ * @throws NamingException If failed to create an <code>InitialContext</code>.
+ */
+ public InitialContext() throws NamingException {
+ this(null);
+ }
+
+ /**
+ * Constructs an <code>InitialContext</code> instance using environment
+ * properties in the supplied parameter which may be null.
+ *
+ * @param environment the JNDI environment properties used to create
+ * the context
+ * @throws NamingException If failed to create an <code>InitialContext</code>.
+ */
+ public InitialContext(Hashtable environment) throws NamingException {
+ internalInit(environment);
+ }
+
+ /**
+ * Constructs an <code>InitialContext</code> instance by indicating whether
+ * a lazy initialization is desired.
+ * Effectively, this is the same as using constructor <code>InitialContext()
+ * </code> if lazy initialization is not indicated.
+ * <p>
+ * This constructor may be invoked with a parameter value of true and the
+ * implementation will defer initialization of the instance. This may be
+ * used in an <code>InitialContext</code> subclass constructor in which
+ * later action will set up a <code>Hashtable</code> object with appropriate
+ * environment properties and pass that to the <code>init</code> method to
+ * complete initalization of the <code>InitialContext</code> object.</p>
+ *
+ * @param doNotInit Specifies whether to initialize the new instance.
+ * @throws NamingException If failed to create an <code>InitialContext</code>.
+ */
+ protected InitialContext(boolean doNotInit) throws NamingException {
+ if (!doNotInit) {
+ internalInit(null);
+ }
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /*
+ * Does private initilaziation.
+ *
+ * @param env the JNDI environment properties used to create
+ * the context
+ * @throws NamingException If failed to create an InitialContext.
+ */
+ private void internalInit(Hashtable env) throws NamingException {
+
+ // 1. Read the environment parameter used to create this Context
+ if (null == env) {
+ myProps = new Hashtable();
+ } else {
+ myProps = (Hashtable) env.clone();
+ }
+
+ // 2. Read Applet parameters
+ EnvironmentReader.readAppletParameters(
+ myProps.get(Context.APPLET),
+ myProps);
+
+ // 3. Read System properties
+ EnvironmentReader.readSystemProperties(myProps);
+
+ // 4.1 Read application/applet resource files
+ EnvironmentReader.readApplicationResourceFiles(myProps);
+
+ // 4.2 Read "java.home"/lib/jndi.properties
+ EnvironmentReader.readLibraryResourceFile(myProps);
+
+ // 5. No need to read service provider resource files
+
+ // if JNDI standard property "java.naming.factory.initial" has a non-null value
+ if (myProps.containsKey(INITIAL_CONTEXT_FACTORY)) {
+ // call getDefaultInitCtx() to initialize gotDefault and defaultInitCtx
+ getDefaultInitCtx();
+ }
+ }
+
+ /**
+ * Uses the specified environment parameter together with other JNDI
+ * properties to initialize this <code>InitialContext</code> object.
+ * The <code>myProps</code> field will be filled with found JNDI properties.
+ * If JNDI standard property "java.naming.factory.initial" has a non-null
+ * value, then <code>getDefaultInitCtx</code> is invoked to try to
+ * initialize fields <code>gotDefault</code> and <code>defaultInitCtx</code>
+ * of the <code>InitialContext</code> object.
+ *
+ * @param env the JNDI environment properties supplied to
+ * create the context
+ * @throws NamingException If naming problems are encountered during
+ * initialization of these fields.
+ */
+ protected void init(Hashtable env) throws NamingException {
+ this.internalInit(env);
+ }
+
+ /*
+ * Initializes the default initial context.
+ *
+ * @throws NamingException If failed to initialize this InitialContext.
+ */
+ private void initializeDefaultInitCtx() throws NamingException {
+ if (!this.gotDefault) {
+ this.defaultInitCtx = NamingManager.getInitialContext(myProps);
+ if (null == this.defaultInitCtx) {
+ throw new NoInitialContextException("Failed to create an initial context."); //$NON-NLS-1$
+ }
+ this.gotDefault = true;
+ }
+ }
+
+ /**
+ * Gets the default underlying <code>Context</code> implementation.
+ * If <code>gotDefault</code> is true, returns the value of <code>
+ * defaultInitCtx</code>. Otherwise, calls <code>NamingManager.getInitialContext
+ * </code> to return an initial context for the current environment into
+ * <code>defaultInitCtx</code>, then <code>gotDefault</code> is set true.
+ * If the resulting context object is null, a <code>NoInitialContextException
+ * </code> is thrown, otherwise the value of <code>defaultInitCtx</code> is
+ * returned.
+ *
+ * @return the default context
+ * @throws NoInitialContextException
+ * If <code>NamingManager.getInitialContext</code>
+ * returns null.
+ * @throws NamingException If failed to create the default context.
+ */
+ protected Context getDefaultInitCtx() throws NamingException {
+ initializeDefaultInitCtx();
+ return this.defaultInitCtx;
+ }
+
+ /**
+ * Returns a non-null context for the specified name of Name representation.
+ * <p>
+ * If an initial context factory builder has been defined, then the
+ * specified <code>Name</code> parameter is ignored and the result of <code>
+ * getDefaultInitCtx</code> is returned. Otherwise, if the first component
+ * of the name is not a URL string, then it returns the result of invoking
+ * <code>getDefaultInitCtx</code>. Otherwise, it attempts to return a URL
+ * context {@link javax.naming.spi.NamingManager#getURLContext(String, Hashtable)},
+ * but if unsuccessful, returns the result of invoking
+ * <code>getDefaultInitCtx</code>.</p>
+ *
+ * @param name a name used in a naming operation which may not
+ * be null
+ * @return a context which may be a URL context
+ * @throws NamingException If failed to get the desired context.
+ */
+ protected Context getURLOrDefaultInitCtx(Name name)
+ throws NamingException {
+ // If the name has components
+ if (0 < name.size()) {
+ return getURLOrDefaultInitCtx(name.get(0));
+ }
+ return getDefaultInitCtx();
+ }
+
+ /**
+ * Returns a non-null context for the specified name of string
+ * representation.
+ * <p>
+ * If an initial context factory builder has been defined, then the
+ * specified name parameter is ignored and the result of <code>
+ * getDefaultInitCtx</code> is returned. Otherwise, if the name is not a URL
+ * string, then it returns the result of invoking <code>getDefaultInitCtx
+ * </code>. Otherwise, it attempts to return a URL context
+ * {@link javax.naming.spi.NamingManager#getURLContext(String, Hashtable)},
+ * but if unsuccessful, returns the result of invoking <code>
+ * getDefaultInitCtx</code>.</p>
+ *
+ * @param name a name used in a naming operation which may not
+ * be null
+ * @return a context which may be a URL context
+ * @throws NamingException If failed to get the desired context.
+ */
+ protected Context getURLOrDefaultInitCtx(String name)
+ throws NamingException {
+
+ /*
+ * If an initial context factory builder has been defined, then the
+ * specified name parameter is ignored and the result of
+ * getDefaultInitCtx() is returned.
+ */
+ if (NamingManager.hasInitialContextFactoryBuilder()) {
+ return getDefaultInitCtx();
+ }
+
+ if (null == name) {
+ throw new NullPointerException("null"); //$NON-NLS-1$
+ }
+
+ // If the name has components
+ String scheme = UrlParser.getScheme(name);
+ Context ctx = null;
+ if (null != scheme) {
+ // So the first componet is a valid URL
+ ctx = NamingManager.getURLContext(scheme, myProps);
+ }
+ return null == ctx ? getDefaultInitCtx() : ctx;
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods of Interface Context
+ * -------------------------------------------------------------------
+ */
+
+ public Object lookup(Name name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).lookup(name);
+ }
+
+ public Object lookup(String name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).lookup(name);
+ }
+
+ public void bind(Name name, Object obj) throws NamingException {
+ getURLOrDefaultInitCtx(name).bind(name, obj);
+ }
+
+ public void bind(String name, Object obj) throws NamingException {
+ getURLOrDefaultInitCtx(name).bind(name, obj);
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException {
+ getURLOrDefaultInitCtx(name).rebind(name, obj);
+ }
+
+ public void rebind(String name, Object obj) throws NamingException {
+ getURLOrDefaultInitCtx(name).rebind(name, obj);
+ }
+
+ public void unbind(Name name) throws NamingException {
+ getURLOrDefaultInitCtx(name).unbind(name);
+ }
+
+ public void unbind(String name) throws NamingException {
+ getURLOrDefaultInitCtx(name).unbind(name);
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException {
+ getURLOrDefaultInitCtx(oldName).rename(oldName, newName);
+ }
+
+ public void rename(String oldName, String newName) throws NamingException {
+ getURLOrDefaultInitCtx(oldName).rename(oldName, newName);
+ }
+
+ public NamingEnumeration list(Name name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).list(name);
+ }
+
+ public NamingEnumeration list(String name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).list(name);
+ }
+
+ public NamingEnumeration listBindings(Name name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).listBindings(name);
+ }
+
+ public NamingEnumeration listBindings(String name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).listBindings(name);
+ }
+
+ public void destroySubcontext(Name name) throws NamingException {
+ getURLOrDefaultInitCtx(name).destroySubcontext(name);
+ }
+
+ public void destroySubcontext(String name) throws NamingException {
+ getURLOrDefaultInitCtx(name).destroySubcontext(name);
+ }
+
+ public Context createSubcontext(Name name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).createSubcontext(name);
+ }
+
+ public Context createSubcontext(String name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).createSubcontext(name);
+ }
+
+ public Object lookupLink(Name name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).lookupLink(name);
+ }
+
+ public Object lookupLink(String name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).lookupLink(name);
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).getNameParser(name);
+ }
+
+ public NameParser getNameParser(String name) throws NamingException {
+ return getURLOrDefaultInitCtx(name).getNameParser(name);
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ if (null == name || null == prefix) {
+ throw new InvalidNameException("Invalid name."); //$NON-NLS-1$
+ }
+ Name comName = (Name) prefix.clone();
+ comName.addAll(name);
+ return comName;
+ }
+
+ public String composeName(String name, String prefix)
+ throws NamingException {
+ if (null == name || null == prefix) {
+ throw new InvalidNameException("Invalid name."); //$NON-NLS-1$
+ }
+ return composeName(new CompositeName(name), new CompositeName(prefix))
+ .toString();
+ }
+
+ public Object addToEnvironment(String propName, Object propVal)
+ throws NamingException {
+ this.myProps.put(propName, propVal);
+ return getDefaultInitCtx().addToEnvironment(propName, propVal);
+ }
+
+ public Object removeFromEnvironment(String propName)
+ throws NamingException {
+ this.myProps.remove(propName);
+ return getDefaultInitCtx().removeFromEnvironment(propName);
+ }
+
+ public Hashtable getEnvironment() throws NamingException {
+ return getDefaultInitCtx().getEnvironment();
+ }
+
+ public void close() throws NamingException {
+ getDefaultInitCtx().close();
+ }
+
+ public String getNameInNamespace() throws NamingException {
+ return getDefaultInitCtx().getNameInNamespace();
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InsufficientResourcesException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InsufficientResourcesException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InsufficientResourcesException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InsufficientResourcesException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,55 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is the <code>NamingException</code> used when limited resources
+ * prevent completion of a request.
+ * <p>
+ * Multithreaded access to an instance is only safe when client code locks the
+ * object first.</p>
+ *
+ */
+public class InsufficientResourcesException extends NamingException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ static final long serialVersionUID = 6227672693037844532L; // J2SE 1.4.2
+
+ /**
+ * Constructs an <code>InsufficientResourcesException</code> instance
+ * with all data initialized to null.
+ */
+ public InsufficientResourcesException() {
+ super();
+ }
+
+ /**
+ * Constructs an <code>InsufficientResourcesException</code> instance
+ * with the specified message.
+ *
+ * @param s The detail message for the exception. It may be null.
+ */
+ public InsufficientResourcesException(String s) {
+ super(s);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InterruptedNamingException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InterruptedNamingException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InterruptedNamingException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InterruptedNamingException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,55 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is the <code>NamingException</code> used when an operation is
+ * interrupted.
+ * <p>
+ * Multithreaded access to an instance is only safe when client code locks the
+ * object first.</p>
+ *
+ */
+public class InterruptedNamingException extends NamingException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ static final long serialVersionUID = 6404516648893194728L; // J2SE 1.4.2
+
+ /**
+ * Constructs an <code>InterruptedNamingException</code> instance
+ * with all data initialized to null.
+ */
+ public InterruptedNamingException() {
+ super();
+ }
+
+ /**
+ * Constructs an <code>InterruptedNamingException</code> instance
+ * with the specified message.
+ *
+ * @param s The detail message for the exception. It may be null.
+ */
+ public InterruptedNamingException(String s) {
+ super(s);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InvalidNameException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InvalidNameException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InvalidNameException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InvalidNameException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,61 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * An <code>InvalidNameException</code> is the <code>NamingException</code>
+ * used when a supplied name does not match the required format.
+ * <p>
+ * Multithreaded access to a <code>InvalidNameException</code> instance is
+ * only safe when client code locks the object first.</p>
+ *
+ */
+public class InvalidNameException extends NamingException {
+
+ /*
+ * For serialization purposes, the following fields must appear in the
+ * order given and specified serialVersionUID must be used.
+ */
+ static final long serialVersionUID = -8370672380823801105L; // J2SE 1.4.2
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Constructs an <code>InvalidNameException</code> instance
+ * with all data initialized to null.
+ */
+ public InvalidNameException() {
+ super();
+ }
+
+ /**
+ * Constructs an <code>InvalidNameException</code> instance
+ * with a specified error message.
+ *
+ * @param msg The detail message for the exception. It may be null.
+ */
+ public InvalidNameException(String msg) {
+ super(msg);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LimitExceededException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LimitExceededException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LimitExceededException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LimitExceededException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,54 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is the <code>NamingException</code> used when a restriction is exceeded.
+ * <p>
+ * Multithreaded access to an instance is only safe when client code locks the
+ * object first.</p>
+ *
+ */
+public class LimitExceededException extends NamingException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ static final long serialVersionUID = -776898738660207856L; // J2SE 1.4.2
+
+ /**
+ * Constructs a <code>LimitExceededException</code> instance
+ * with all data initialized to null.
+ */
+ public LimitExceededException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>LimitExceededException</code> instance
+ * with the specified message.
+ *
+ * @param s The detail message for the exception. It may be null.
+ */
+ public LimitExceededException(String s) {
+ super(s);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,204 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * Naming operations may throw a <code>LinkException</code> when attempting
+ * to resolve links. Methods are provided to save diagnostic information about how far
+ * link resolution has progressed.
+ * <p>
+ * Multithreaded access to a single <code>LinkException</code> instance is only
+ * safe when client code uses appropriate synchronization and locking.</p>
+ *
+ */
+public class LinkException extends NamingException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ private final static long serialVersionUID = -7967662604076777712L;
+
+ /**
+ * Description of why the link could not be resolved.
+ */
+ protected String linkExplanation;
+
+ /**
+ * Composite name containing the name which could not be resolved.
+ */
+ protected Name linkRemainingName;
+
+ /**
+ * Composite name containing the name which was resolved.
+ */
+ protected Name linkResolvedName;
+
+ /**
+ * Contains the object that linkResolvedName relates to.
+ */
+ protected Object linkResolvedObj;
+
+ /*
+ * ==========================================
+ * constructors
+ * ==========================================
+ */
+
+ /**
+ * Constructs a <code>LinkException</code> instance
+ * with all data initialized to null.
+ */
+ public LinkException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>LinkException</code> instance
+ * with the specified message.
+ *
+ * @param s The detail message for the exception. It may be null.
+ */
+ public LinkException(String s) {
+ super(s);
+ }
+
+ /*
+ * ==========================================
+ * methods
+ * ==========================================
+ */
+
+ /**
+ * Outputs the string representation of this <code>NamingException</code>
+ * together with the details of the remaining name.
+ *
+ * @return the string representation of this <code>NamingException</code>
+ * together with the details of the remaining name.
+ */
+ public String toString() {
+ return toStringImpl(false);
+ }
+
+ private String toStringImpl(boolean b) {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append("; the link remaining name is - '").append(linkRemainingName).append( //$NON-NLS-1$
+ "'"); //$NON-NLS-1$
+ if (b && null != linkResolvedObj) {
+ sb.append("; the link resolved object is - '").append( //$NON-NLS-1$
+ linkResolvedObj).append(
+ "'"); //$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Outputs the string representation of this <code>NamingException</code>
+ * together with the details of the remaining name.
+ * <p>
+ * If boolean b is set to true then also outputs the resolved object.<br/>
+ * If boolean b is set to false then the behavior is the same
+ * as <code>toString()</code>.
+ *
+ * @param b Indicates if the resolved object need to be outputed.
+ * @return the string representation of this <code>NamingException</code>
+ * together with the details of the remaining name.
+ */
+ public String toString(boolean b) {
+ return toStringImpl(b);
+ }
+
+ /**
+ * Retrieves the value of the <code>linkExplanation</code> field.
+ *
+ * @return the value of the <code>linkExplanation</code> field.
+ */
+ public String getLinkExplanation() {
+ return linkExplanation;
+ }
+
+ /**
+ * Retrieves the value of the <code>linkRemainingName</code> field.
+ *
+ * @return the value of the <code>linkRemainingName</code> field.
+ */
+ public Name getLinkRemainingName() {
+ return linkRemainingName;
+ }
+
+ /**
+ * Retrieves the value of the <code>linkResolvedName</code> field.
+ *
+ * @return the value of the <code>linkResolvedName</code> field.
+ */
+ public Name getLinkResolvedName() {
+ return linkResolvedName;
+ }
+
+ /**
+ * Retrieves the value of the <code>linkResolvedObj</code> field.
+ *
+ * @return the value of the <code>linkResolvedObj</code> field.
+ */
+ public Object getLinkResolvedObj() {
+ return linkResolvedObj;
+ }
+
+ /**
+ * Sets the <code>linkExplanation</code> field to the specified value.
+ *
+ * @param string the new <code>linkExplanation</code> value to be set.
+ */
+ public void setLinkExplanation(String string) {
+ linkExplanation = string;
+ }
+
+ /**
+ * Sets the <code>linkRemainingName</code> to the specified name.
+ * It may be null. The remaining name details must not change even if
+ * the original <code>Name</code> itself changes.
+ *
+ * @param name the new <code>linkRemainingName</code> value to be set.
+ * It may be null.
+ */
+ public void setLinkRemainingName(Name name) {
+ linkRemainingName = null == name ? null : (Name) name.clone();
+ }
+
+ /**
+ * Sets the <code>linkResolvedName</code> to the specified name.
+ * This may be null. The resolved name details must not change even if
+ * the original <code>Name</code> itself changes.
+ *
+ * @param name the new <code>linkResolvedName</code> value to be set.
+ */
+ public void setLinkResolvedName(Name name) {
+ linkResolvedName = null == name ? null : (Name) name.clone();
+ }
+
+ /**
+ * Sets the <code>linkResolvedObj</code> field to object. This may be null.
+ *
+ * @param object the new <code>linkResolvedObj</code> value to be set.
+ */
+ public void setLinkResolvedObj(Object object) {
+ linkResolvedObj = object;
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkLoopException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkLoopException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkLoopException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkLoopException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,55 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is the <code>NamingException</code> used when a link results in a loop
+ * or if too many links are being done.
+ * <p>
+ * Multithreaded access to an instance is only safe when client code locks the
+ * object first.</p>
+ *
+ */
+public class LinkLoopException extends LinkException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ static final long serialVersionUID = -3119189944325198009L;
+
+ /**
+ * Constructs a <code>LinkLoopException</code> instance
+ * with all data initialized to null.
+ */
+ public LinkLoopException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>LinkLoopException</code> instance
+ * with the specified message.
+ *
+ * @param s The detail message for the exception. It may be null.
+ */
+ public LinkLoopException(String s) {
+ super(s);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkRef.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkRef.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkRef.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkRef.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,115 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is a type of <code>Reference</code> used to point to an address of type
+ * "LinkAddress" where the address given is actually the string representation
+ * of a valid <code>Name</code>.
+ *
+ * @see Reference
+ *
+ */
+public class LinkRef extends Reference {
+
+ /*
+ * -------------------------------------------------------------------
+ * Constants
+ * -------------------------------------------------------------------
+ */
+
+ /*
+ * This constant is used during deserialization to check the J2SE version which
+ * created the serialized object.
+ */
+ static final long serialVersionUID = -5386290613498931298L; //J2SE 1.4.2
+
+ /*
+ * The type name of the address this LinkRef points to.
+ */
+ private static final String ADDR_TYPE = "LinkAddress"; //$NON-NLS-1$
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Constructs a <code>LinkRef</code> instance using the supplied <code>name
+ * </code> of <code>Name</code> representation.
+ * The class name is set to the name of this <code>LinkRef</code> class.
+ * The factory class and location default to null. There is one address
+ * entry which has "LinkAddress" as the address type and the string
+ * representation of the supplied name as the address.
+ *
+ * @param name the <code>Name</code> to be used as a link which
+ * cannot be null
+ */
+ public LinkRef(Name name) {
+ this(name.toString());
+ }
+
+ /**
+ * Constructs a <code>LinkRef</code> instance using the supplied <code>name
+ * </code> of <code>String</code> representation.
+ * The class name is set to the name of this <code>LinkRef</code> class.
+ * The factory class and location default to null. There is one address
+ * entry which has "LinkAddress" as the address type and the string
+ * representation of the supplied name as the address.
+ *
+ * @param s the name to be used as a link which cannot be null
+ */
+ public LinkRef(String s) {
+ super(LinkRef.class.getName(), new StringRefAddr(ADDR_TYPE, s));
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Gets the string representation of the name used as a link which cannot be
+ * null.
+ *
+ * @return the string representation of the name used as a link
+ * @throws MalformedLinkException
+ * If this is not a <code>Reference</code> with a class
+ * name which matches the name of this LinkRef class.
+ * @throws NamingException
+ * If other <code>NamingException</code> is encountered.
+ */
+ public String getLinkName() throws NamingException {
+ if (!LinkRef.class.getName().equals(this.getClassName())) {
+ throw new MalformedLinkException("This is an invalid LinkRef object!"); //$NON-NLS-1$
+ }
+ try {
+ RefAddr addr = get(ADDR_TYPE);
+ if (null == addr) {
+ throw new MalformedLinkException(
+ "There is no address with type: " + ADDR_TYPE); //$NON-NLS-1$
+ }
+ return (String) addr.getContent();
+ } catch (NullPointerException e) {
+ throw new MalformedLinkException(e.getMessage());
+ }
+ }
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/MalformedLinkException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/MalformedLinkException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/MalformedLinkException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/MalformedLinkException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,55 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is the <code>NamingException</code> used when a link turns out to
+ * be malformed.
+ * <p>
+ * Multithreaded access to an instance is only safe when client code locks the
+ * object first.</p>
+ *
+ */
+public class MalformedLinkException extends LinkException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ static final long serialVersionUID = -3066740437737830242L;
+
+ /**
+ * Constructs a <code>MalformedLinkException</code> instance
+ * with all data initialized to null.
+ */
+ public MalformedLinkException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>MalformedLinkException</code> instance
+ * with the specified message.
+ *
+ * @param arg0 The detail message for the exception. It may be null.
+ */
+ public MalformedLinkException(String arg0) {
+ super(arg0);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Name.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Name.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Name.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Name.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,211 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+
+/**
+ * A <code>Name</code> interface represents a name in a naming service.
+ * <p>
+ * A name which implements this interface has a sequence of zero or more
+ * elements delimited by separators. Each element can be accessed using its
+ * position. The first element is at position 0.</p>
+ * <p>
+ * This interface is implemented by 2 classes - <code>CompoundName</code>
+ * and <code>CompositeName</code>.</p>
+ * <p>
+ * Examples of names are:
+ * <pre>
+ * File system name - for example /home/jenningm/.profile
+ * DNS hostname - for example www.apache.org
+ * Internet URL - for example http://www.eclipse.org/org/index.html
+ * </pre></p>
+ *
+ * @see CompositeName
+ * @see CompoundName
+ */
+public interface Name extends Cloneable, Serializable {
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Get all the elements of this <code>Name</code>.
+ * If the <code>Name</code> is empty then return an empty
+ * <code>Enumeration</code>.
+ *
+ * @return an enumeration of <code>Name</code> elements - cannot be null
+ */
+ public Enumeration getAll();
+
+ /**
+ * Get an element of this <code>Name</code>.
+ *
+ * @param i the index of the required element - must be greater
+ * than or equal to 0 and less than size().
+ * @return the element at the specified position
+ * @throws ArrayIndexOutOfBoundsException when the position is invalid.
+ * If the <code>Name</code> is empty this always returns
+ * <code>ArrayIndexOutOfBoundsException</code>
+ */
+ public String get(int i);
+
+ /**
+ * Create a new <code>Name</code> which comprises the first several
+ * elements of this <code>Name</code>.
+ *
+ * @param i the index of the first element not to be included - must be
+ * greater than or equal to 0 and less than or equal to size.
+ * If 0 then an empty name is returned.
+ * @return a new <code>Name</code> which comprises the first several
+ * elements of this <code>Name</code>
+ * @throws ArrayIndexOutOfBoundsException when the position is invalid.
+ */
+ public Name getPrefix(int i);
+
+ /**
+ * Create a new <code>Name</code> which comprises the last
+ * (<code>size() - i</code>) elements of this <code>Name</code>.
+ *
+ * @param i the index of the first element to be included - must be
+ * greater than or equal to 0 and less than size.
+ * @return a new <code>Name</code> which comprises the last
+ * (<code>size() - i</code>) elements of this
+ * <code>Name</code>
+ * @throws ArrayIndexOutOfBoundsException when the position is invalid.
+ */
+ public Name getSuffix(int i);
+
+ /**
+ * Append a name to this <code>Name</code>. The name itself may have a
+ * number of elements.
+ *
+ * @param name the name to append onto this <code>Name</code>.
+ * @return this <code>Name</code>
+ * @throws InvalidNameException if name is invalid or the addition of the
+ * name results in this <code>Name</code> becoming invalid.
+ */
+ public Name addAll(Name name) throws InvalidNameException;
+
+ /**
+ * Insert a name within this <code>Name</code> at the specified position.
+ * The name itself may have a number of elements.
+ *
+ * @param i the index of the element where to start inserting the name
+ * - must be greater than or equal to 0 and less than or equal
+ * to size.
+ * @param name the name to insert into this <code>Name</code>.
+ * @return this <code>Name</code>
+ * @throws InvalidNameException if name is invalid or the addition of the
+ * name results in this <code>Name</code> becoming invalid.
+ */
+ public Name addAll(int i, Name name) throws InvalidNameException;
+
+ /**
+ * Append an element to this <code>Name</code>.
+ *
+ * @param s the string to append
+ * @return this <code>Name</code>
+ * @throws InvalidNameException if the addition of the element results in
+ * this <code>Name</code> becoming invalid.
+ */
+ public Name add(String s) throws InvalidNameException;
+
+ /**
+ * Insert an element within this <code>Name</code> at the specified
+ * position.
+ *
+ * @param i the index of the element where to insert the element -
+ * must be greater than or equal to 0 and less than or equal to
+ * size.
+ * @param s the String to insert
+ * @return this <code>Name</code>.
+ * @throws InvalidNameException if the insertion of the element results in
+ * this Name becoming invalid.
+ */
+ public Name add(int i, String s) throws InvalidNameException;
+
+ /**
+ * Delete an element from this <code>Name</code>.
+ *
+ * @param i the index of the element to delete - must be greater
+ * than or equal to 0 and less than size.
+ * @return the deleted element
+ * @throws InvalidNameException if the deletion of the element results in
+ * this <code>Name</code> becoming invalid.
+ */
+ public Object remove(int i) throws InvalidNameException;
+
+ /**
+ * Create a copy of this <code>Name</code>.
+ *
+ * @return a complete (deep) copy of the object.
+ */
+ public Object clone();
+
+ /**
+ * Compare this <code>Name</code> with the one supplied as a parameter.
+ * Each class which implements this interface will have a specification
+ * of how to do the comparison.
+ *
+ * @param o the object to compare - cannot be null.
+ * @return a negative number means this is less than the supplied object.
+ * a positive number means this is greater than the supplied
+ * object. Zero means the two objects are equal.
+ */
+ public int compareTo(Object o);
+
+ /**
+ * Get the size of this <code>Name</code>. The size of a <code>Name</code>
+ * is its number of elements.
+ *
+ * @return the size of this name - cannot be null - can be zero
+ */
+ public int size();
+
+ /**
+ * Check if this <code>Name</code> is empty. A <code>Name</code> is empty
+ * when it has no elements.
+ *
+ * @return true if empty, else returns false
+ */
+ public boolean isEmpty();
+
+ /**
+ * Check if this <code>Name</code> starts with the elements in the
+ * supplied name. The supplied name itself may have a number of elements.
+ *
+ * @param name the name to check against this name
+ * @return true when the supplied name matches else returns false
+ */
+ public boolean startsWith(Name name);
+
+ /**
+ * Check if this <code>Name</code> ends with the elements in the supplied
+ * name. The supplied name itself may have a number of elements.
+ *
+ * @param name the name to check against this name.
+ * @return true when the supplied name matches else returns false.
+ */
+ public boolean endsWith(Name name);
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameAlreadyBoundException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameAlreadyBoundException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameAlreadyBoundException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameAlreadyBoundException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,55 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is the <code>NamingException</code> used when trying to add a name
+ * which is already bound.
+ * <p>
+ * Multithreaded access to an instance is only safe when client code locks the
+ * object first.</p>
+ *
+ */
+public class NameAlreadyBoundException extends NamingException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ static final long serialVersionUID = -8491441000356780586L;
+
+ /**
+ * Constructor a <code>NameAlreadyBoundException</code> instance
+ * with all data initialized to null.
+ */
+ public NameAlreadyBoundException() {
+ super();
+ }
+
+ /**
+ * Constructor a <code>NameAlreadyBoundException</code> instance
+ * with the specified message.
+ *
+ * @param arg0 The detail message for the exception. It may be null.
+ */
+ public NameAlreadyBoundException(String arg0) {
+ super(arg0);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,196 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+import java.io.Serializable;
+
+/**
+ * <code>NameClassPair</code> associates a name in a naming service with a
+ * specified class name and also with a relative flag. In JNDI,
+ * <code>NameClassPair</code> is extended by <code>javax.naming.Binding</code>;
+ * <code>Binding</code> objects are used in <code>javax.naming.Context</code>
+ * implementations.
+ * <p>
+ * A <code>NameClassPair</code> object is not thread-safe unless appropriate
+ * synchronization is applied to any code manipulating these objects.</p>
+ * <p>
+ * As this class implements the <code>Serializable</code> interface, it is
+ * important that fields below are declared with the same names.</p>
+ *
+ */
+public class NameClassPair implements Serializable {
+
+ /*
+ * -------------------------------------------------------------------
+ * Constants
+ * -------------------------------------------------------------------
+ */
+
+ // J2SE 1.4.2
+ private static final long serialVersionUID = 5620776610160863339L;
+
+ /*
+ * -------------------------------------------------------------------
+ * Instance variables
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * The name used in a naming service. This field may be null and has default
+ * value of null.
+ *
+ * @serial
+ */
+ private String name;
+
+ /**
+ * The class of an object represented by this name in a naming service.
+ * This field may be null and has default value null.
+ *
+ * @serial
+ */
+ private String className;
+
+ /**
+ * This flag indicates whether the name s used in a naming service is relative
+ * to the context. It is set by setRelative and is not derived. This field has
+ * default value true. If this is set to false then the name is not relative and
+ * is actually a URL.
+ *
+ * @serial
+ */
+ private boolean isRel;
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Construct a <code>NameClassPair</code> from a name and a class.
+ * Both arguments can be null.
+ * Relative flag is true.
+ *
+ * @param name a name used in naming service
+ * @param className a class name
+ */
+ public NameClassPair(String name, String className) {
+ this(name, className, true);
+ }
+
+ /**
+ * Construct a <code>NameClassPair</code> from a name, a class and a
+ * relative flag. The name and class arguments can be null.
+ *
+ * @param name a name used in naming service
+ * @param className a class name
+ * @param relative a relative flag
+ */
+ public NameClassPair(String name, String className, boolean relative) {
+ this.name = name;
+ this.className = className;
+ this.isRel = relative;
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Returns the value of the class which may be null.
+ *
+ * @return the value of the class which may be null.
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * Returns the value of the name field which may be null.
+ *
+ * @return the value of the name field which may be null.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the value of the relative flag.
+ *
+ * @return the value of the relative flag.
+ */
+ public boolean isRelative() {
+ return isRel;
+ }
+
+ /**
+ * Set the class of this object. The argument can be null.
+ *
+ * @param className a class name
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ /**
+ * Set the name of this object. The argument can be null.
+ *
+ * @param name a name used in naming service
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set the isRelative flag field of this object.
+ *
+ * @param relative a relative flag
+ */
+ public void setRelative(boolean relative) {
+ this.isRel = relative;
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods override parent class Object
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * If the flag is set to false then the string is preceded with
+ * "(not relative)" and then has the name value, ": " and the class
+ * value.
+ *
+ * @return a string representation of this object
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ if (!isRel) {
+ buf.append("(not relative)"); //$NON-NLS-1$
+ }
+ buf.append(getName());
+ buf.append(": "); //$NON-NLS-1$
+ buf.append(getClassName()); // getClassName() is overrided by subclass
+ return buf.toString();
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameNotFoundException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameNotFoundException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameNotFoundException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameNotFoundException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,55 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * This is the <code>NamingException</code> used when part of a name cannot
+ * be found.
+ * <p>
+ * Multithreaded access to an instance is only safe when client code locks the
+ * object first.</p>
+ *
+ */
+public class NameNotFoundException extends NamingException {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ static final long serialVersionUID = -8007156725367842053L;
+
+ /**
+ * Constructs a <code>NameNotFoundException</code> instance
+ * with all data initialized to null.
+ */
+ public NameNotFoundException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>NameNotFoundException</code> instance
+ * with the specified message.
+ *
+ * @param s The detail message for the exception. It may be null.
+ */
+ public NameNotFoundException(String s) {
+ super(s);
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameParser.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameParser.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameParser.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameParser.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,49 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * A <code>NameParser</code> is used to validate and decompose a name from a
+ * particular namespace. It is implemented by classes provided in spi
+ * implementations.
+ *
+ */
+public interface NameParser {
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Takes a name in a <code>String s</code> and validates it according to
+ * the rules for the namespace. (See <code>CompoundName</code> for the
+ * guidelines on name format and system parameters which affect the
+ * translation of a name.) The name is then decomposed into its elements
+ * and returned as a <code>Name</code>.
+ *
+ * @param s the name to be examined - cannot be null
+ * @return a <code>Name</code> instance, cannot be null.
+ * @throws InvalidNameException when the supplied string violates format
+ * rules
+ * @throws NamingException
+ */
+ public Name parse(String s) throws InvalidNameException, NamingException;
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingEnumeration.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingEnumeration.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingEnumeration.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingEnumeration.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,63 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+import java.util.Enumeration;
+import javax.naming.NamingException;
+
+/**
+ * A <code>NamingEnumeration</code> interface is an <code>Enumeration</code>
+ * which has been extended to support <code>NamingException</code>s. They can
+ * be thrown when getting the next element, checking if the Enumeration has
+ * more elements or on closing the <code>Enumeration</code>.
+ *
+ */
+public interface NamingEnumeration extends Enumeration {
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Get the next element.
+ *
+ * @return the next element - can be null.
+ * @exception NamingException if a naming error occurs
+ * @exception java.util.NoSuchElementException when no more elements exist.
+ */
+ public Object next() throws NamingException;
+
+ /**
+ * Check for more elements.
+ *
+ * @return if more elements exist return true else return false.
+ * @exception NamingException if a naming error occurs
+ */
+ public boolean hasMore() throws NamingException;
+
+ /**
+ * Close the enumeration.
+ *
+ * @exception NamingException if a naming error occurs
+ */
+ public void close() throws NamingException;
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,379 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * A <code>NamingException</code> is the basic exception thrown by the naming
+ * classes. There are numerous subclasses of it which are used to further
+ * describe the type of error encountered.
+ * <p>
+ * A <code>NamingException</code> can hold information relating to an error
+ * encountered when trying to resolve a <code>Name</code>. It holds the two
+ * parts of the original name, firstly the part of the name which was
+ * successfully resolved, secondly the part of the name which could not be
+ * resolved.</p>
+ * <p>
+ * For example:<br />
+ * ------------<br />
+ * The resolved name could be something like http://www.apache.org where jndi has
+ * successfully resolved the DNS name.
+ * The part of the name which could not be resolved could be something like
+ * java/classes.index.html where jndi could not resolve the file name.</p>
+ * <p>
+ * It can also refer to the object that is associated with the resolved name.</p>
+ * <p>
+ * Additionaly it can refer to another exception, which may be the root cause
+ * of this exception.</p>
+ * <p>
+ * Multithreaded access to a <code>NamingException</code> instance is only
+ * safe when client code locks the object first.</p>
+ *
+ */
+public class NamingException extends Exception {
+
+ /*
+ * This constant is used during deserialization to check the J2SE version
+ * which created the serialized object.
+ */
+ private static final long serialVersionUID = -1299181962103167177L;
+
+ /*
+ * -------------------------------------------------------------------
+ * Instance variables
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * The resolved name. This may be null.
+ */
+ protected Name resolvedName = null;
+
+ /**
+ * The remaining name. This may be null.
+ */
+ protected Name remainingName = null;
+
+ /**
+ * The resolved object. This may be null.
+ */
+ protected Object resolvedObj = null;
+
+ /**
+ * The exception that caused this NamingException to be raised. This may be null.
+ */
+ protected Throwable rootException = null;
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Constructs a <code>NamingException</code> instance
+ * with all data initialized to null.
+ */
+ public NamingException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>NamingException</code> instance
+ * with the specified message. All other fields are initialized to null.
+ *
+ * @param s The detail message for the exception. It may be null.
+ */
+ public NamingException(String s) {
+ super(s);
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Returns the message passed in as a param to the constructor.
+ * This may be null.
+ *
+ * @return the message passed in as a param to the constructor.
+ */
+ public String getExplanation() {
+ return super.getMessage();
+ }
+
+ /**
+ * Appends the supplied string to the <code>Name</code> held as the
+ * remaining name. The string may be null.
+ *
+ * @param s the string to append to the remaining Name.
+ * @throws IllegalArgumentException if appending the supplied
+ * String s causes the name to become invalid.
+ */
+ public void appendRemainingComponent(String s) {
+ if (null != s) {
+ try {
+ if (null == remainingName) {
+ remainingName = new CompositeName(""); //$NON-NLS-1$
+ }
+ remainingName = remainingName.add(s);
+ } catch (InvalidNameException e) {
+ throw new IllegalArgumentException("Found invalid name, reason: " + e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * Returns the remaining name. This may be null.
+ *
+ * @return the remaining name. This may be null.
+ */
+ public Name getRemainingName() {
+ return remainingName;
+ }
+
+ /**
+ * Returns the resolved name. This may be null.
+ *
+ * @return the resolved name. This may be null.
+ */
+ public Name getResolvedName() {
+ return resolvedName;
+ }
+
+ /**
+ * Returns the resolved object. This may be null.
+ *
+ * @return the resolved object. This may be null.
+ */
+ public Object getResolvedObj() {
+ return resolvedObj;
+ }
+
+ /**
+ * Sets the resolved name to the specified name. This may be null.
+ * The resolved name details must not change even if the original
+ * <code>Name</code> itself changes.
+ *
+ * @param name the resolved name to set.
+ */
+ public void setResolvedName(Name name) {
+ resolvedName = null == name ? null : (Name) name.clone();
+ }
+
+ /**
+ * Sets the remaining name to the specified n. This may be null.
+ * The remaining name details must not change even if the original
+ * <code>Name</code> itself changes.
+ *
+ * @param name the remaining name to set.
+ */
+ public void setRemainingName(Name name) {
+ remainingName = null == name ? null : (Name) name.clone();
+ }
+
+ /**
+ * Sets the resolved object to the specified o. This may be null.
+ *
+ * @param o the resolved object to set.
+ */
+ public void setResolvedObj(Object o) {
+ resolvedObj = o;
+ }
+
+ /**
+ * Appends the elements of the supplied <code>Name</code> n to the
+ * <code>Name</code> held as the remaining name. The <code>Name</code> n
+ * may be null or may be empty.
+ *
+ * @param n the name to append to the remaining name.
+ * @throws IllegalArgumentException if appending the supplied
+ * <code>Name</code> n causes the name to become invalid.
+ */
+ public void appendRemainingName(Name n) {
+ if (null != n) {
+ try {
+ if (null == remainingName) {
+ remainingName = new CompositeName(""); //$NON-NLS-1$
+ }
+ remainingName = remainingName.addAll(n);
+ } catch (InvalidNameException e) {
+ throw new IllegalArgumentException("Found invalid name, reason: " + e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * Returns the exception which caused this <code>NamingException</code>
+ * which may be null.
+ *
+ * @return the exception which caused this <code>NamingException</code>
+ * which may be null.
+ */
+ public Throwable getRootCause() {
+ return rootException;
+ }
+
+ /**
+ * Sets the exception that caused this <code>NamingException</code>.
+ * It may be null.
+ * Ignore the supplied parameter if it is actually this exception.
+ *
+ * @param t the exception that caused this <code>NamingException</code>.
+ */
+ public void setRootCause(Throwable t) {
+ if (t != this) {
+ rootException = t;
+ }
+ }
+
+ /**
+ * Returns the same details as the <code>toString()</code> method except
+ * that, if the <code>flag</code> is set to true, then details of the
+ * resolved object are also appended to the string.
+ * The actual format can be decided by the implementor.
+ *
+ * @param flag Indicates if the resolved object need to be returned.
+ *
+ * @return the string represenatation of this <code>NamingException</code>.
+ */
+ public String toString(boolean flag) {
+ return toStringImpl(flag);
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods override parent class Exception
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * If there is a root exception associated with this
+ * <code>NamingException</code> then first print the class name and message
+ * of this <code>NamingException</code>, followed by the text
+ * ". The stack trace of the root exception is: ", followed by the stack
+ * trace of the exception which caused this exception.
+ * <p>
+ * If there is no root exception associated with this
+ * <code>NamingException</code> then print the stack trace of this
+ * <code>NamingException</code>.</p>
+ * <p>
+ * The output from this goes to <code>System.err</code>.</p>
+ */
+ public void printStackTrace() {
+ if (null != rootException) {
+ System.err.print(super.toString());
+ System.err.print(". The stack trace of the root exception is: "); //$NON-NLS-1$
+ rootException.printStackTrace();
+ } else {
+ super.printStackTrace();
+ }
+ }
+
+ /**
+ * Performs the same as <code>printStackTrace()</code> except the output
+ * goes to the specified <code>PrintStream</code> p.
+ *
+ * @param p the <code>PrintStream</code> to which the stack trace is
+ * printed.
+ */
+ public void printStackTrace(PrintStream p) {
+ if (null != rootException) {
+ p.print(super.toString());
+ p.print(". The stack trace of the root exception is: "); //$NON-NLS-1$
+ rootException.printStackTrace(p);
+ } else {
+ super.printStackTrace(p);
+ }
+ }
+
+ /**
+ * Performs the same as <code>printStackTrace()</code> except the output
+ * goes to the specified <code>PrintWriter</code> p.
+ *
+ * @param p the <code>PrintWrite</code> to which the stack trace is
+ * printed.
+ */
+ public void printStackTrace(PrintWriter p) {
+ if (null != rootException) {
+ p.print(super.toString());
+ p.print(". The stack trace of the root exception is: "); //$NON-NLS-1$
+ rootException.printStackTrace(p);
+ } else {
+ super.printStackTrace(p);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Throwable#getCause()
+ */
+ public Throwable getCause() {
+ return super.getCause();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Throwable#initCause(Throwable)
+ */
+ public Throwable initCause(Throwable cause) {
+ return super.initCause(cause);
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods override parent class Object
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Returns the string represenatation of this <code>NamingException</code>.
+ * The string contains the string representation of this exception together
+ * with details of the exception which caused this and any remaining
+ * portion of the <code>Name</code>.
+ * <p>
+ * The actual format can be decided by the implementor.</p>
+ *
+ * @return the string
+ */
+ public String toString() {
+ return this.toStringImpl(false);
+ }
+
+ private String toStringImpl(boolean flag) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(super.toString());
+ if (null != rootException) {
+ sb.append(" [Root exception is ").append(rootException.toString()).append( //$NON-NLS-1$
+ "]"); //$NON-NLS-1$
+ }
+ if (null != remainingName) {
+ sb.append("; Remaining name: '").append(remainingName.toString()).append("'"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ if (flag && null != resolvedObj) {
+ sb.append("; Resolved object: '").append(resolvedObj.toString()).append("'"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return sb.toString();
+ }
+
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingSecurityException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingSecurityException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingSecurityException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingSecurityException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,56 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 javax.naming;
+
+/**
+ * A <code>NamingSecurityException</code> is the <code>NamingException</code>
+ * used when a security exception is encountered. There are other security
+ * related exceptions which extend this one.
+ * <p>
+ * Multithreaded access to a <code>NamingSecurityException</code> instance is
+ * only safe when client code locks the object first.</p>
+ *
+ */
+public abstract class NamingSecurityException extends NamingException {
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Constructs a <code>NamingSecurityException</code> instance
+ * with all data initialized to null.
+ */
+ public NamingSecurityException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>NamingSecurityException</code> instance
+ * with the specified message.
+ *
+ * @param s The detail message for this exception. It may be null.
+ */
+ public NamingSecurityException(String s) {
+ super(s);
+ }
+
+}
+
+