2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / javax / naming / Name.java
blobf2dc17ffaf43b169d3b7e41159e9457548f5cf99
1 /* Name.java -- Name build up from different components
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package javax.naming;
40 import java.util.Enumeration;
41 import java.io.Serializable;
43 /**
44 * Interface descriping a name build up from different components.
45 * The components are represented as <code>String</code>s which are
46 * ordered from most significant to least significant. There are methods to
47 * get the number of components. Methods to get a particular component or group
48 * of components. Components can be added as <code>String</code>s or
49 * <code>Name</code>s and a component can be removed from any position in the
50 * <code>Name</code>.
51 * A <code>Name</code> can be compared to another <code>Name</code> and it can
52 * be checked if a particular <code>Name</code> starts or ends with the same
53 * components as another <code>Name</code>. Finally <code>Name</code>s can be
54 * serialized and cloned.
55 * <p>
56 * Since <code>Name</code>s can be empty (have no components) methods that
57 * return a <code>Name</code> will never return <code>null</code>.
59 * @since 1.3
60 * @author Anthony Green (green@redhat.com)
61 * @author Mark Wielaard (mark@klomp.org)
63 public interface Name extends Cloneable, Serializable
65 long serialVersionUID = -3617482732056931635L;
67 /**
68 * Returns the number of components of this <code>Name</code>.
69 * The returned number can be zero.
71 int size();
73 /**
74 * Returns <code>true</code> if the number of components of this
75 * <code>Name</code> is zero, <code>false</code> otherwise.
77 boolean isEmpty();
79 /**
80 * Returns a non-null (but possibly empty) <code>Enumeration</code> of the
81 * components of the <code>Name</code> as <code>String</code>s.
83 Enumeration getAll();
85 /**
86 * Gets the component at the given index.
88 * @exception ArrayIndexOutOfBoundsException if the given index is smaller
89 * then zero or greater then or equal to <code>size()</code>.
91 String get(int i);
93 /**
94 * Returns the components till the given index as a <code>Name</code>.
95 * The returned <code>Name</code> can be modified without changing the
96 * original.
98 * @exception ArrayIndexOutOfBoundsException if the given index is smaller
99 * then zero or greater then or equal to <code>size()</code>.
101 Name getPrefix(int i);
104 * Returns the components from the given index till the end as a
105 * <code>Name</code>.
106 * The returned <code>Name</code> can be modified without changing the
107 * original.
109 * @exception ArrayIndexOutOfBoundsException if the given index is smaller
110 * then zero or greater then or equal to <code>size()</code>.
112 Name getSuffix(int i);
115 * Adds the given <code>String</code> component to the end of this
116 * <code>Name</code>. The method modifies the current <code>Name</code> and
117 * then returns it.
119 * @exception InvalidNameException if the given <code>String</code> is not a
120 * valid component for this <code>Name</code>.
122 Name add(String comp) throws InvalidNameException;
125 * Inserts the given <code>String</code> component to this <code>Name</code>
126 * at the given index. The method modifies the current <code>Name</code> and
127 * then returns it.
129 * @exception ArrayIndexOutOfBoundsException if the given index is smaller
130 * then zero or greater then or equal to <code>size()</code>.
131 * @exception InvalidNameException if the given <code>String</code> is not a
132 * valid component for this <code>Name</code>.
134 Name add(int posn, String comp) throws InvalidNameException;
137 * Adds all the components of the given <code>Name</code> to the end of this
138 * <code>Name</code>. The method modifies the current <code>Name</code> and
139 * then returns it.
141 * @exception InvalidNameException if any of the given components is not a
142 * valid component for this <code>Name</code>.
144 Name addAll(Name suffix) throws InvalidNameException;
147 * Inserts all the components of the given <code>Name</code> to this
148 * <code>Name</code> at the given index. The method modifies the current
149 * <code>Name</code> and then returns it.
151 * @exception ArrayIndexOutOfBoundsException if the given index is smaller
152 * then zero or greater then or equal to <code>size()</code>.
153 * @exception InvalidNameException if any of the given components is not a
154 * valid component for this <code>Name</code>.
156 Name addAll(int posn, Name n) throws InvalidNameException;
159 * Removes the component at the given index from this <code>Name</code>.
160 * The method modifies the current <code>Name</code> and then returns it.
162 * @exception InvalidNameException if the given <code>String</code> is not a
163 * valid component for this <code>Name</code>.
165 Object remove(int posn) throws InvalidNameException;
168 * Returns <code>true</code> if this <code>Name</code> starts with the
169 * components of the given <code>Name</code>, <code>false</code> otherwise.
171 boolean startsWith(Name name);
174 * Returns <code>true</code> if this <code>Name</code> ends with the
175 * components of the given <code>Name</code>, <code>false</code> otherwise.
177 boolean endsWith(Name name);
180 * Compares the given object to this <code>Name</code>.
181 * Returns a negative value if the given <code>Object</code> is smaller then
182 * this <code>Name</code>, a positive value if the <code>Object</code> is
183 * bigger, and zero if the are equal. If the <code>Object</code> is not of
184 * a class that can be compared to the class of this <code>Name</code> then
185 * a <code>ClassCastException</code> is thrown. Note that it is not
186 * guaranteed that <code>Name</code>s implemented in different classes can
187 * be compared. The definition of smaller, bigger and equal is up to the
188 * actual implementing class.
190 int compareTo(Object obj);
193 * Returns a clone of this <code>Name</code>. It will be a deep copy of
194 * all the components of the <code>Name</code> so that changes to components
195 * of the components does not change the component in this <code>Name</code>.
197 Object clone();