0N/A/*
2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.naming;
0N/A
0N/Aimport java.util.Enumeration;
0N/A
0N/A/**
0N/A * The <tt>Name</tt> interface represents a generic name -- an ordered
0N/A * sequence of components. It can be a composite name (names that
0N/A * span multiple namespaces), or a compound name (names that are
0N/A * used within individual hierarchical naming systems).
0N/A *
0N/A * <p> There can be different implementations of <tt>Name</tt>; for example,
0N/A * composite names, URLs, or namespace-specific compound names.
0N/A *
0N/A * <p> The components of a name are numbered. The indexes of a name
0N/A * with N components range from 0 up to, but not including, N. This
0N/A * range may be written as [0,N).
0N/A * The most significant component is at index 0.
0N/A * An empty name has no components.
0N/A *
0N/A * <p> None of the methods in this interface accept null as a valid
0N/A * value for a parameter that is a name or a name component.
0N/A * Likewise, methods that return a name or name component never return null.
0N/A *
0N/A * <p> An instance of a <tt>Name</tt> may not be synchronized against
0N/A * concurrent multithreaded access if that access is not read-only.
0N/A *
0N/A * @author Rosanna Lee
0N/A * @author Scott Seligman
0N/A * @author R. Vasudevan
0N/A * @since 1.3
0N/A */
0N/A
0N/Apublic interface Name
0N/A extends Cloneable, java.io.Serializable, Comparable<Object>
0N/A{
0N/A
0N/A /**
0N/A * The class fingerprint that is set to indicate
0N/A * serialization compatibility with a previous
0N/A * version of the class.
0N/A */
0N/A static final long serialVersionUID = -3617482732056931635L;
0N/A
0N/A /**
0N/A * Generates a new copy of this name.
0N/A * Subsequent changes to the components of this name will not
0N/A * affect the new copy, and vice versa.
0N/A *
0N/A * @return a copy of this name
0N/A *
0N/A * @see Object#clone()
0N/A */
0N/A public Object clone();
0N/A
0N/A /**
0N/A * Compares this name with another name for order.
0N/A * Returns a negative integer, zero, or a positive integer as this
0N/A * name is less than, equal to, or greater than the given name.
0N/A *
0N/A * <p> As with <tt>Object.equals()</tt>, the notion of ordering for names
0N/A * depends on the class that implements this interface.
0N/A * For example, the ordering may be
0N/A * based on lexicographical ordering of the name components.
0N/A * Specific attributes of the name, such as how it treats case,
0N/A * may affect the ordering. In general, two names of different
0N/A * classes may not be compared.
0N/A *
0N/A * @param obj the non-null object to compare against.
0N/A * @return a negative integer, zero, or a positive integer as this name
0N/A * is less than, equal to, or greater than the given name
0N/A * @throws ClassCastException if obj is not a <tt>Name</tt> of a
0N/A * type that may be compared with this name
0N/A *
0N/A * @see Comparable#compareTo(Object)
0N/A */
0N/A public int compareTo(Object obj);
0N/A
0N/A /**
0N/A * Returns the number of components in this name.
0N/A *
0N/A * @return the number of components in this name
0N/A */
0N/A public int size();
0N/A
0N/A /**
0N/A * Determines whether this name is empty.
0N/A * An empty name is one with zero components.
0N/A *
0N/A * @return true if this name is empty, false otherwise
0N/A */
0N/A public boolean isEmpty();
0N/A
0N/A /**
0N/A * Retrieves the components of this name as an enumeration
0N/A * of strings. The effect on the enumeration of updates to
0N/A * this name is undefined. If the name has zero components,
0N/A * an empty (non-null) enumeration is returned.
0N/A *
0N/A * @return an enumeration of the components of this name, each a string
0N/A */
0N/A public Enumeration<String> getAll();
0N/A
0N/A /**
0N/A * Retrieves a component of this name.
0N/A *
0N/A * @param posn
0N/A * the 0-based index of the component to retrieve.
0N/A * Must be in the range [0,size()).
0N/A * @return the component at index posn
0N/A * @throws ArrayIndexOutOfBoundsException
0N/A * if posn is outside the specified range
0N/A */
0N/A public String get(int posn);
0N/A
0N/A /**
0N/A * Creates a name whose components consist of a prefix of the
0N/A * components of this name. Subsequent changes to
0N/A * this name will not affect the name that is returned and vice versa.
0N/A *
0N/A * @param posn
0N/A * the 0-based index of the component at which to stop.
0N/A * Must be in the range [0,size()].
0N/A * @return a name consisting of the components at indexes in
0N/A * the range [0,posn).
0N/A * @throws ArrayIndexOutOfBoundsException
0N/A * if posn is outside the specified range
0N/A */
0N/A public Name getPrefix(int posn);
0N/A
0N/A /**
0N/A * Creates a name whose components consist of a suffix of the
0N/A * components in this name. Subsequent changes to
0N/A * this name do not affect the name that is returned and vice versa.
0N/A *
0N/A * @param posn
0N/A * the 0-based index of the component at which to start.
0N/A * Must be in the range [0,size()].
0N/A * @return a name consisting of the components at indexes in
0N/A * the range [posn,size()). If posn is equal to
0N/A * size(), an empty name is returned.
0N/A * @throws ArrayIndexOutOfBoundsException
0N/A * if posn is outside the specified range
0N/A */
0N/A public Name getSuffix(int posn);
0N/A
0N/A /**
0N/A * Determines whether this name starts with a specified prefix.
0N/A * A name <tt>n</tt> is a prefix if it is equal to
0N/A * <tt>getPrefix(n.size())</tt>.
0N/A *
0N/A * @param n
0N/A * the name to check
0N/A * @return true if <tt>n</tt> is a prefix of this name, false otherwise
0N/A */
0N/A public boolean startsWith(Name n);
0N/A
0N/A /**
0N/A * Determines whether this name ends with a specified suffix.
0N/A * A name <tt>n</tt> is a suffix if it is equal to
0N/A * <tt>getSuffix(size()-n.size())</tt>.
0N/A *
0N/A * @param n
0N/A * the name to check
0N/A * @return true if <tt>n</tt> is a suffix of this name, false otherwise
0N/A */
0N/A public boolean endsWith(Name n);
0N/A
0N/A /**
0N/A * Adds the components of a name -- in order -- to the end of this name.
0N/A *
0N/A * @param suffix
0N/A * the components to add
0N/A * @return the updated name (not a new one)
0N/A *
0N/A * @throws InvalidNameException if <tt>suffix</tt> is not a valid name,
0N/A * or if the addition of the components would violate the syntax
0N/A * rules of this name
0N/A */
0N/A public Name addAll(Name suffix) throws InvalidNameException;
0N/A
0N/A /**
0N/A * Adds the components of a name -- in order -- at a specified position
0N/A * within this name.
0N/A * Components of this name at or after the index of the first new
0N/A * component are shifted up (away from 0) to accommodate the new
0N/A * components.
0N/A *
0N/A * @param n
0N/A * the components to add
0N/A * @param posn
0N/A * the index in this name at which to add the new
0N/A * components. Must be in the range [0,size()].
0N/A * @return the updated name (not a new one)
0N/A *
0N/A * @throws ArrayIndexOutOfBoundsException
0N/A * if posn is outside the specified range
0N/A * @throws InvalidNameException if <tt>n</tt> is not a valid name,
0N/A * or if the addition of the components would violate the syntax
0N/A * rules of this name
0N/A */
0N/A public Name addAll(int posn, Name n) throws InvalidNameException;
0N/A
0N/A /**
0N/A * Adds a single component to the end of this name.
0N/A *
0N/A * @param comp
0N/A * the component to add
0N/A * @return the updated name (not a new one)
0N/A *
0N/A * @throws InvalidNameException if adding <tt>comp</tt> would violate
0N/A * the syntax rules of this name
0N/A */
0N/A public Name add(String comp) throws InvalidNameException;
0N/A
0N/A /**
0N/A * Adds a single component at a specified position within this name.
0N/A * Components of this name at or after the index of the new component
0N/A * are shifted up by one (away from index 0) to accommodate the new
0N/A * component.
0N/A *
0N/A * @param comp
0N/A * the component to add
0N/A * @param posn
0N/A * the index at which to add the new component.
0N/A * Must be in the range [0,size()].
0N/A * @return the updated name (not a new one)
0N/A *
0N/A * @throws ArrayIndexOutOfBoundsException
0N/A * if posn is outside the specified range
0N/A * @throws InvalidNameException if adding <tt>comp</tt> would violate
0N/A * the syntax rules of this name
0N/A */
0N/A public Name add(int posn, String comp) throws InvalidNameException;
0N/A
0N/A /**
0N/A * Removes a component from this name.
0N/A * The component of this name at the specified position is removed.
0N/A * Components with indexes greater than this position
0N/A * are shifted down (toward index 0) by one.
0N/A *
0N/A * @param posn
0N/A * the index of the component to remove.
0N/A * Must be in the range [0,size()).
0N/A * @return the component removed (a String)
0N/A *
0N/A * @throws ArrayIndexOutOfBoundsException
0N/A * if posn is outside the specified range
0N/A * @throws InvalidNameException if deleting the component
0N/A * would violate the syntax rules of the name
0N/A */
0N/A public Object remove(int posn) throws InvalidNameException;
0N/A}