| 1 | /* Name.java -- Name build up from different components
|
|---|
| 2 | Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU Classpath.
|
|---|
| 5 |
|
|---|
| 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.
|
|---|
| 10 |
|
|---|
| 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.
|
|---|
| 15 |
|
|---|
| 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.
|
|---|
| 20 |
|
|---|
| 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.
|
|---|
| 25 |
|
|---|
| 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. */
|
|---|
| 37 |
|
|---|
| 38 | package javax.naming;
|
|---|
| 39 |
|
|---|
| 40 | import java.util.Enumeration;
|
|---|
| 41 | import java.io.Serializable;
|
|---|
| 42 |
|
|---|
| 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>.
|
|---|
| 58 | *
|
|---|
| 59 | * @since 1.3
|
|---|
| 60 | * @author Anthony Green ([email protected])
|
|---|
| 61 | * @author Mark Wielaard ([email protected])
|
|---|
| 62 | */
|
|---|
| 63 | public interface Name extends Cloneable, Serializable
|
|---|
| 64 | {
|
|---|
| 65 | static final long serialVersionUID = -3617482732056931635L;
|
|---|
| 66 |
|
|---|
| 67 | /**
|
|---|
| 68 | * Returns the number of components of this <code>Name</code>.
|
|---|
| 69 | * The returned number can be zero.
|
|---|
| 70 | */
|
|---|
| 71 | public int size();
|
|---|
| 72 |
|
|---|
| 73 | /**
|
|---|
| 74 | * Returns <code>true</code> if the number of components of this
|
|---|
| 75 | * <code>Name</code> is zero, <code>false</code> otherwise.
|
|---|
| 76 | */
|
|---|
| 77 | public boolean isEmpty();
|
|---|
| 78 |
|
|---|
| 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.
|
|---|
| 82 | */
|
|---|
| 83 | public Enumeration getAll();
|
|---|
| 84 |
|
|---|
| 85 | /**
|
|---|
| 86 | * Gets the component at the given index.
|
|---|
| 87 | *
|
|---|
| 88 | * @exception ArrayIndexOutOfBoundsException if the given index is smaller
|
|---|
| 89 | * then zero or greater then or equal to <code>size()</code>.
|
|---|
| 90 | */
|
|---|
| 91 | public String get(int i);
|
|---|
| 92 |
|
|---|
| 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.
|
|---|
| 97 | *
|
|---|
| 98 | * @exception ArrayIndexOutOfBoundsException if the given index is smaller
|
|---|
| 99 | * then zero or greater then or equal to <code>size()</code>.
|
|---|
| 100 | */
|
|---|
| 101 | public Name getPrefix(int i);
|
|---|
| 102 |
|
|---|
| 103 | /**
|
|---|
| 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.
|
|---|
| 108 | *
|
|---|
| 109 | * @exception ArrayIndexOutOfBoundsException if the given index is smaller
|
|---|
| 110 | * then zero or greater then or equal to <code>size()</code>.
|
|---|
| 111 | */
|
|---|
| 112 | public Name getSuffix(int i);
|
|---|
| 113 |
|
|---|
| 114 | /**
|
|---|
| 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.
|
|---|
| 118 | *
|
|---|
| 119 | * @exception InvalidNameException if the given <code>String</code> is not a
|
|---|
| 120 | * valid component for this <code>Name</code>.
|
|---|
| 121 | */
|
|---|
| 122 | public Name add(String comp) throws InvalidNameException;
|
|---|
| 123 |
|
|---|
| 124 | /**
|
|---|
| 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.
|
|---|
| 128 | *
|
|---|
| 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>.
|
|---|
| 133 | */
|
|---|
| 134 | public Name add(int posn, String comp) throws InvalidNameException;
|
|---|
| 135 |
|
|---|
| 136 | /**
|
|---|
| 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.
|
|---|
| 140 | *
|
|---|
| 141 | * @exception InvalidNameException if any of the given components is not a
|
|---|
| 142 | * valid component for this <code>Name</code>.
|
|---|
| 143 | */
|
|---|
| 144 | public Name addAll(Name suffix) throws InvalidNameException;
|
|---|
| 145 |
|
|---|
| 146 | /**
|
|---|
| 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.
|
|---|
| 150 | *
|
|---|
| 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>.
|
|---|
| 155 | */
|
|---|
| 156 | public Name addAll(int posn, Name n) throws InvalidNameException;
|
|---|
| 157 |
|
|---|
| 158 | /**
|
|---|
| 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.
|
|---|
| 161 | *
|
|---|
| 162 | * @exception InvalidNameException if the given <code>String</code> is not a
|
|---|
| 163 | * valid component for this <code>Name</code>.
|
|---|
| 164 | */
|
|---|
| 165 | public Object remove(int posn) throws InvalidNameException;
|
|---|
| 166 |
|
|---|
| 167 | /**
|
|---|
| 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.
|
|---|
| 170 | */
|
|---|
| 171 | public boolean startsWith(Name name);
|
|---|
| 172 |
|
|---|
| 173 | /**
|
|---|
| 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.
|
|---|
| 176 | */
|
|---|
| 177 | public boolean endsWith(Name name);
|
|---|
| 178 |
|
|---|
| 179 | /**
|
|---|
| 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.
|
|---|
| 189 | */
|
|---|
| 190 | public int compareTo(Object obj);
|
|---|
| 191 |
|
|---|
| 192 | /**
|
|---|
| 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>.
|
|---|
| 196 | */
|
|---|
| 197 | public Object clone();
|
|---|
| 198 | }
|
|---|