1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.lookup;
13 import org.eclipse.jdt.core.compiler.CharOperation;
15 public class SignatureWrapper {
16 public char[] signature;
21 public SignatureWrapper(char[] signature) {
22 this.signature = signature;
24 this.end = this.bracket = -1;
26 public boolean atEnd() {
27 return this.start < 0 || this.start >= this.signature.length;
29 public int computeEnd() {
30 int index = this.start;
31 while (this.signature[index] == '[')
33 switch (this.signature[index]) {
36 this.end = CharOperation.indexOf(';', this.signature, this.start);
37 if (this.bracket <= this.start) // already know it if its > start
38 this.bracket = CharOperation.indexOf('<', this.signature, this.start);
40 if (this.bracket > this.start && this.bracket < this.end)
41 this.end = this.bracket;
42 else if (this.end == -1)
43 this.end = this.signature.length + 1;
46 this.end = this.start;
49 this.start = this.end + 1; // skip ';'
52 public char[] nextWord() {
53 this.end = CharOperation.indexOf(';', this.signature, this.start);
54 if (this.bracket <= this.start) // already know it if its > start
55 this.bracket = CharOperation.indexOf('<', this.signature, this.start);
56 int dot = CharOperation.indexOf('.', this.signature, this.start);
58 if (this.bracket > this.start && this.bracket < this.end)
59 this.end = this.bracket;
60 if (dot > this.start && dot < this.end)
63 return CharOperation.subarray(this.signature, this.start, this.start = this.end); // skip word
65 public String toString() {
66 return new String(this.signature) + " @ " + this.start; //$NON-NLS-1$