Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/naming/Name.java
38829 views
/*1* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.naming;2627import java.util.Enumeration;2829/**30* The <tt>Name</tt> interface represents a generic name -- an ordered31* sequence of components. It can be a composite name (names that32* span multiple namespaces), or a compound name (names that are33* used within individual hierarchical naming systems).34*35* <p> There can be different implementations of <tt>Name</tt>; for example,36* composite names, URLs, or namespace-specific compound names.37*38* <p> The components of a name are numbered. The indexes of a name39* with N components range from 0 up to, but not including, N. This40* range may be written as [0,N).41* The most significant component is at index 0.42* An empty name has no components.43*44* <p> None of the methods in this interface accept null as a valid45* value for a parameter that is a name or a name component.46* Likewise, methods that return a name or name component never return null.47*48* <p> An instance of a <tt>Name</tt> may not be synchronized against49* concurrent multithreaded access if that access is not read-only.50*51* @author Rosanna Lee52* @author Scott Seligman53* @author R. Vasudevan54* @since 1.355*/5657public interface Name58extends Cloneable, java.io.Serializable, Comparable<Object>59{6061/**62* The class fingerprint that is set to indicate63* serialization compatibility with a previous64* version of the class.65*/66static final long serialVersionUID = -3617482732056931635L;6768/**69* Generates a new copy of this name.70* Subsequent changes to the components of this name will not71* affect the new copy, and vice versa.72*73* @return a copy of this name74*75* @see Object#clone()76*/77public Object clone();7879/**80* Compares this name with another name for order.81* Returns a negative integer, zero, or a positive integer as this82* name is less than, equal to, or greater than the given name.83*84* <p> As with <tt>Object.equals()</tt>, the notion of ordering for names85* depends on the class that implements this interface.86* For example, the ordering may be87* based on lexicographical ordering of the name components.88* Specific attributes of the name, such as how it treats case,89* may affect the ordering. In general, two names of different90* classes may not be compared.91*92* @param obj the non-null object to compare against.93* @return a negative integer, zero, or a positive integer as this name94* is less than, equal to, or greater than the given name95* @throws ClassCastException if obj is not a <tt>Name</tt> of a96* type that may be compared with this name97*98* @see Comparable#compareTo(Object)99*/100public int compareTo(Object obj);101102/**103* Returns the number of components in this name.104*105* @return the number of components in this name106*/107public int size();108109/**110* Determines whether this name is empty.111* An empty name is one with zero components.112*113* @return true if this name is empty, false otherwise114*/115public boolean isEmpty();116117/**118* Retrieves the components of this name as an enumeration119* of strings. The effect on the enumeration of updates to120* this name is undefined. If the name has zero components,121* an empty (non-null) enumeration is returned.122*123* @return an enumeration of the components of this name, each a string124*/125public Enumeration<String> getAll();126127/**128* Retrieves a component of this name.129*130* @param posn131* the 0-based index of the component to retrieve.132* Must be in the range [0,size()).133* @return the component at index posn134* @throws ArrayIndexOutOfBoundsException135* if posn is outside the specified range136*/137public String get(int posn);138139/**140* Creates a name whose components consist of a prefix of the141* components of this name. Subsequent changes to142* this name will not affect the name that is returned and vice versa.143*144* @param posn145* the 0-based index of the component at which to stop.146* Must be in the range [0,size()].147* @return a name consisting of the components at indexes in148* the range [0,posn).149* @throws ArrayIndexOutOfBoundsException150* if posn is outside the specified range151*/152public Name getPrefix(int posn);153154/**155* Creates a name whose components consist of a suffix of the156* components in this name. Subsequent changes to157* this name do not affect the name that is returned and vice versa.158*159* @param posn160* the 0-based index of the component at which to start.161* Must be in the range [0,size()].162* @return a name consisting of the components at indexes in163* the range [posn,size()). If posn is equal to164* size(), an empty name is returned.165* @throws ArrayIndexOutOfBoundsException166* if posn is outside the specified range167*/168public Name getSuffix(int posn);169170/**171* Determines whether this name starts with a specified prefix.172* A name <tt>n</tt> is a prefix if it is equal to173* <tt>getPrefix(n.size())</tt>.174*175* @param n176* the name to check177* @return true if <tt>n</tt> is a prefix of this name, false otherwise178*/179public boolean startsWith(Name n);180181/**182* Determines whether this name ends with a specified suffix.183* A name <tt>n</tt> is a suffix if it is equal to184* <tt>getSuffix(size()-n.size())</tt>.185*186* @param n187* the name to check188* @return true if <tt>n</tt> is a suffix of this name, false otherwise189*/190public boolean endsWith(Name n);191192/**193* Adds the components of a name -- in order -- to the end of this name.194*195* @param suffix196* the components to add197* @return the updated name (not a new one)198*199* @throws InvalidNameException if <tt>suffix</tt> is not a valid name,200* or if the addition of the components would violate the syntax201* rules of this name202*/203public Name addAll(Name suffix) throws InvalidNameException;204205/**206* Adds the components of a name -- in order -- at a specified position207* within this name.208* Components of this name at or after the index of the first new209* component are shifted up (away from 0) to accommodate the new210* components.211*212* @param n213* the components to add214* @param posn215* the index in this name at which to add the new216* components. Must be in the range [0,size()].217* @return the updated name (not a new one)218*219* @throws ArrayIndexOutOfBoundsException220* if posn is outside the specified range221* @throws InvalidNameException if <tt>n</tt> is not a valid name,222* or if the addition of the components would violate the syntax223* rules of this name224*/225public Name addAll(int posn, Name n) throws InvalidNameException;226227/**228* Adds a single component to the end of this name.229*230* @param comp231* the component to add232* @return the updated name (not a new one)233*234* @throws InvalidNameException if adding <tt>comp</tt> would violate235* the syntax rules of this name236*/237public Name add(String comp) throws InvalidNameException;238239/**240* Adds a single component at a specified position within this name.241* Components of this name at or after the index of the new component242* are shifted up by one (away from index 0) to accommodate the new243* component.244*245* @param comp246* the component to add247* @param posn248* the index at which to add the new component.249* Must be in the range [0,size()].250* @return the updated name (not a new one)251*252* @throws ArrayIndexOutOfBoundsException253* if posn is outside the specified range254* @throws InvalidNameException if adding <tt>comp</tt> would violate255* the syntax rules of this name256*/257public Name add(int posn, String comp) throws InvalidNameException;258259/**260* Removes a component from this name.261* The component of this name at the specified position is removed.262* Components with indexes greater than this position263* are shifted down (toward index 0) by one.264*265* @param posn266* the index of the component to remove.267* Must be in the range [0,size()).268* @return the component removed (a String)269*270* @throws ArrayIndexOutOfBoundsException271* if posn is outside the specified range272* @throws InvalidNameException if deleting the component273* would violate the syntax rules of the name274*/275public Object remove(int posn) throws InvalidNameException;276}277278279