01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.eval;
11:
12: /**
13: * A global variable is a variable defined for an evaluation context and that persists
14: * accross evaluations.
15: */
16: public class GlobalVariable {
17: char[] typeName;
18: char[] name;
19: char[] initializer;
20: int declarationStart = -1, initializerStart = -1,
21: initExpressionStart; // positions in the global variable class definition
22: int initializerLineStart = -1; // line in the global variable class definition
23:
24: /**
25: * Creates a new global variable with the given type name, name and initializer.
26: * initializer can be null if there is none.
27: */
28: public GlobalVariable(char[] typeName, char[] name,
29: char[] initializer) {
30: this .typeName = typeName;
31: this .name = name;
32: this .initializer = initializer;
33: }
34:
35: /**
36: * Returns the initializer of this global variable. The initializer is a
37: * variable initializer (ie. an expression or an array initializer) as defined
38: * in the Java Language Specifications.
39: */
40: public char[] getInitializer() {
41: return this .initializer;
42: }
43:
44: /**
45: * Returns the name of this global variable.
46: */
47: public char[] getName() {
48: return this .name;
49: }
50:
51: /**
52: * Returns the dot separated fully qualified name of the type of this global variable,
53: * or its simple representation if it is a primitive type (eg. int, boolean, etc.)
54: */
55: public char[] getTypeName() {
56: return this .typeName;
57: }
58:
59: /**
60: * Returns a readable representation of the receiver.
61: * This is for debugging purpose only.
62: */
63: public String toString() {
64: StringBuffer buffer = new StringBuffer();
65: buffer.append(this .typeName);
66: buffer.append(" "); //$NON-NLS-1$
67: buffer.append(this .name);
68: if (this .initializer != null) {
69: buffer.append("= "); //$NON-NLS-1$
70: buffer.append(this .initializer);
71: }
72: buffer.append(";"); //$NON-NLS-1$
73: return buffer.toString();
74: }
75: }
|