< prev index next >

src/jdk.rmic/share/classes/sun/tools/java/Identifier.java

Print this page




 183      * the name was not qualified.  The qualifier does not include
 184      * any inner part of the name.
 185      */
 186     public Identifier getQualifier() {
 187         return isQualified() ? (Identifier)value : idNull;
 188     }
 189 
 190     /**
 191      * Return the unqualified name.
 192      * In the case of an inner name, the unqualified name
 193      * will itself contain components.
 194      */
 195     public Identifier getName() {
 196         return isQualified() ?
 197             Identifier.lookup(name.substring(((Identifier)value).name.length() + 1)) : this;
 198     }
 199 
 200     /** A space character, which precedes the first inner class
 201      *  name in a qualified name, and thus marks the qualification
 202      *  as involving inner classes, instead of merely packages.<p>
 203      *  Ex:  <tt>java.util.Vector. Enumerator</tt>.
 204      */
 205     public static final char INNERCLASS_PREFIX = ' ';
 206 
 207     /* Explanation:
 208      * Since much of the compiler's low-level name resolution code
 209      * operates in terms of Identifier objects.  This includes the
 210      * code which walks around the file system and reports what
 211      * classes are where.  It is important to get nesting information
 212      * right as early as possible, since it affects the spelling of
 213      * signatures.  Thus, the low-level import and resolve code must
 214      * be able Identifier type must be able to report the nesting
 215      * of types, which implied that that information must be carried
 216      * by Identifiers--or that the low-level interfaces be significantly
 217      * changed.
 218      */
 219 
 220     /**
 221      * Check if the name is inner (ie: it contains a ' ').
 222      */
 223     public boolean isInner() {
 224         return (ipos > 0);
 225     }
 226 
 227     /**
 228      * Return the class name, without its qualifier,
 229      * and with any nesting flattened into a new qualfication structure.
 230      * If the original identifier is inner,
 231      * the result will be qualified, and can be further
 232      * decomposed by means of <tt>getQualifier</tt> and <tt>getName</tt>.
 233      * <p>
 234      * For example:
 235      * <pre>
 236      * Identifier id = Identifier.lookup("pkg.Foo. Bar");
 237      * id.getName().name      =>  "Foo. Bar"
 238      * id.getFlatName().name  =>  "Foo.Bar"
 239      * </pre>
 240      */
 241     public Identifier getFlatName() {
 242         if (isQualified()) {
 243             return getName().getFlatName();
 244         }
 245         if (ipos > 0 && name.charAt(ipos-1) == '.') {
 246             if (ipos+1 == name.length()) {
 247                 // last component is idNull
 248                 return Identifier.lookup(name.substring(0,ipos-1));
 249             }
 250             String n = name.substring(ipos+1);
 251             String t = name.substring(0,ipos);
 252             return Identifier.lookup(t+n);




 183      * the name was not qualified.  The qualifier does not include
 184      * any inner part of the name.
 185      */
 186     public Identifier getQualifier() {
 187         return isQualified() ? (Identifier)value : idNull;
 188     }
 189 
 190     /**
 191      * Return the unqualified name.
 192      * In the case of an inner name, the unqualified name
 193      * will itself contain components.
 194      */
 195     public Identifier getName() {
 196         return isQualified() ?
 197             Identifier.lookup(name.substring(((Identifier)value).name.length() + 1)) : this;
 198     }
 199 
 200     /** A space character, which precedes the first inner class
 201      *  name in a qualified name, and thus marks the qualification
 202      *  as involving inner classes, instead of merely packages.<p>
 203      *  Ex:  {@code java.util.Vector. Enumerator}.
 204      */
 205     public static final char INNERCLASS_PREFIX = ' ';
 206 
 207     /* Explanation:
 208      * Since much of the compiler's low-level name resolution code
 209      * operates in terms of Identifier objects.  This includes the
 210      * code which walks around the file system and reports what
 211      * classes are where.  It is important to get nesting information
 212      * right as early as possible, since it affects the spelling of
 213      * signatures.  Thus, the low-level import and resolve code must
 214      * be able Identifier type must be able to report the nesting
 215      * of types, which implied that that information must be carried
 216      * by Identifiers--or that the low-level interfaces be significantly
 217      * changed.
 218      */
 219 
 220     /**
 221      * Check if the name is inner (ie: it contains a ' ').
 222      */
 223     public boolean isInner() {
 224         return (ipos > 0);
 225     }
 226 
 227     /**
 228      * Return the class name, without its qualifier,
 229      * and with any nesting flattened into a new qualfication structure.
 230      * If the original identifier is inner,
 231      * the result will be qualified, and can be further
 232      * decomposed by means of {@code getQualifier} and {@code getName}.
 233      * <p>
 234      * For example:
 235      * <pre>
 236      * Identifier id = Identifier.lookup("pkg.Foo. Bar");
 237      * id.getName().name      =>  "Foo. Bar"
 238      * id.getFlatName().name  =>  "Foo.Bar"
 239      * </pre>
 240      */
 241     public Identifier getFlatName() {
 242         if (isQualified()) {
 243             return getName().getFlatName();
 244         }
 245         if (ipos > 0 && name.charAt(ipos-1) == '.') {
 246             if (ipos+1 == name.length()) {
 247                 // last component is idNull
 248                 return Identifier.lookup(name.substring(0,ipos-1));
 249             }
 250             String n = name.substring(ipos+1);
 251             String t = name.substring(0,ipos);
 252             return Identifier.lookup(t+n);


< prev index next >