KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > classfmt > ElementValuePairInfo


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
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  * tyeung@bea.com - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.classfmt;
12
13 public class ElementValuePairInfo implements org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair {
14
15     static final ElementValuePairInfo[] NoMembers = new ElementValuePairInfo[0];
16
17     private char[] name;
18     private Object JavaDoc value;
19
20 ElementValuePairInfo(char[] name, Object JavaDoc value) {
21     this.name = name;
22     this.value = value;
23 }
24 public char[] getName() {
25     return this.name;
26 }
27 public Object JavaDoc getValue() {
28     return this.value;
29 }
30 public String JavaDoc toString() {
31     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
32     buffer.append(this.name);
33     buffer.append('=');
34     if (this.value instanceof Object JavaDoc[]) {
35         final Object JavaDoc[] values = (Object JavaDoc[]) this.value;
36         buffer.append('{');
37         for (int i = 0, l = values.length; i < l; i++) {
38             if (i > 0)
39                 buffer.append(", "); //$NON-NLS-1$
40
buffer.append(values[i]);
41         }
42         buffer.append('}');
43     } else {
44         buffer.append(this.value);
45     }
46     return buffer.toString();
47 }
48 }
49
Popular Tags