KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > eval > GlobalVariable


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.eval;
12
13 /**
14  * A global variable is a variable defined for an evaluation context and that persists
15  * accross evaluations.
16  */

17 public class GlobalVariable {
18     char[] typeName;
19     char[] name;
20     char[] initializer;
21     int declarationStart = -1, initializerStart = -1, initExpressionStart; // positions in the global variable class definition
22
int initializerLineStart = -1; // line in the global variable class definition
23
/**
24  * Creates a new global variable with the given type name, name and initializer.
25  * initializer can be null if there is none.
26  */

27 public GlobalVariable(char[] typeName, char[] name, char[] initializer) {
28     this.typeName = typeName;
29     this.name = name;
30     this.initializer = initializer;
31 }
32 /**
33  * Returns the initializer of this global variable. The initializer is a
34  * variable initializer (ie. an expression or an array initializer) as defined
35  * in the Java Language Specifications.
36  */

37 public char[] getInitializer() {
38     return this.initializer;
39 }
40 /**
41  * Returns the name of this global variable.
42  */

43 public char[] getName() {
44     return this.name;
45 }
46 /**
47  * Returns the dot separated fully qualified name of the type of this global variable,
48  * or its simple representation if it is a primitive type (eg. int, boolean, etc.)
49  */

50 public char[] getTypeName() {
51     return this.typeName;
52 }
53 /**
54  * Returns a readable representation of the receiver.
55  * This is for debugging purpose only.
56  */

57 public String JavaDoc toString() {
58     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
59     buffer.append(this.typeName);
60     buffer.append(" "); //$NON-NLS-1$
61
buffer.append(this.name);
62     if (this.initializer != null) {
63         buffer.append("= "); //$NON-NLS-1$
64
buffer.append(this.initializer);
65     }
66     buffer.append(";"); //$NON-NLS-1$
67
return buffer.toString();
68 }
69 }
70
Popular Tags