KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > impl > CharConstant


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.compiler.impl;
12
13 public class CharConstant extends Constant {
14
15     private char value;
16
17     public static Constant fromValue(char value) {
18         return new CharConstant(value);
19     }
20
21     private CharConstant(char value) {
22         this.value = value;
23     }
24     public byte byteValue() {
25         return (byte) value;
26     }
27     public char charValue() {
28         return this.value;
29     }
30     public double doubleValue() {
31         return value; // implicit cast to return type
32
}
33     public float floatValue() {
34         return value; // implicit cast to return type
35
}
36     public int intValue() {
37         return value; // implicit cast to return type
38
}
39     public long longValue() {
40         return value; // implicit cast to return type
41
}
42     public short shortValue() {
43         return (short) value;
44     }
45     public String JavaDoc stringValue() {
46         //spec 15.17.11
47
return String.valueOf(this.value);
48     }
49     public String JavaDoc toString(){
50     
51         return "(char)" + value; //$NON-NLS-1$
52
}
53     public int typeID() {
54         return T_char;
55     }
56 }
57
Popular Tags