KickJava   Java API By Example, From Geeks To Geeks.

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


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