1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/javax/lang/model/element/Name.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,89 @@ 1.4 +/* 1.5 + * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package javax.lang.model.element; 1.30 + 1.31 +/** 1.32 + * An immutable sequence of characters. When created by the same 1.33 + * implementation, objects implementing this interface must obey the 1.34 + * general {@linkplain Object#equals equals contract} when compared 1.35 + * with each other. Therefore, {@code Name} objects from the same 1.36 + * implementation are usable in collections while {@code Name}s from 1.37 + * different implementations may not work properly in collections. 1.38 + * 1.39 + * <p>An empty {@code Name} has a length of zero. 1.40 + * 1.41 + * <p>In the context of {@linkplain 1.42 + * javax.annotation.processing.ProcessingEnvironment annotation 1.43 + * processing}, the guarantees for "the same" implementation must 1.44 + * include contexts where the {@linkplain javax.annotation.processing 1.45 + * API mediated} side effects of {@linkplain 1.46 + * javax.annotation.processing.Processor processors} could be visible 1.47 + * to each other, including successive annotation processing 1.48 + * {@linkplain javax.annotation.processing.RoundEnvironment rounds}. 1.49 + * 1.50 + * @author Joseph D. Darcy 1.51 + * @author Scott Seligman 1.52 + * @author Peter von der Ahé 1.53 + * @see javax.lang.model.util.Elements#getName 1.54 + * @since 1.6 1.55 + */ 1.56 +public interface Name extends CharSequence { 1.57 + /** 1.58 + * Returns {@code true} if the argument represents the same 1.59 + * name as {@code this}, and {@code false} otherwise. 1.60 + * 1.61 + * <p>Note that the identity of a {@code Name} is a function both 1.62 + * of its content in terms of a sequence of characters as well as 1.63 + * the implementation which created it. 1.64 + * 1.65 + * @param obj the object to be compared with this element 1.66 + * @return {@code true} if the specified object represents the same 1.67 + * name as this 1.68 + * @see Element#equals 1.69 + */ 1.70 + boolean equals(Object obj); 1.71 + 1.72 + /** 1.73 + * Obeys the general contract of {@link Object#hashCode Object.hashCode}. 1.74 + * 1.75 + * @see #equals 1.76 + */ 1.77 + int hashCode(); 1.78 + 1.79 + /** 1.80 + * Compares this name to the specified {@code CharSequence}. The result 1.81 + * is {@code true} if and only if this name represents the same sequence 1.82 + * of {@code char} values as the specified sequence. 1.83 + * 1.84 + * @return {@code true} if this name represents the same sequence 1.85 + * of {@code char} values as the specified sequence, {@code false} 1.86 + * otherwise 1.87 + * 1.88 + * @param cs The sequence to compare this name against 1.89 + * @see String#contentEquals(CharSequence) 1.90 + */ 1.91 + boolean contentEquals(CharSequence cs); 1.92 +}