source: trunk/src/org/expeditee/simple/SPrimitive.java@ 309

Last change on this file since 309 was 235, checked in by ra33, 16 years ago

Refactored the way attribute value pairs work...
Moved static methods into attributeValuePairs class

File size: 1.3 KB
Line 
1package org.expeditee.simple;
2
3public abstract class SPrimitive<T> extends SVariable<T> {
4
5 public SPrimitive(String name, T value) {
6 super(name, value);
7 }
8
9 public SPrimitive(T value) {
10 super(null, value);
11 }
12
13 public SPrimitive() {
14 super();
15 }
16
17 public Long integerValue() throws IncorrectTypeException {
18 throw new IncorrectTypeException("integer",this.getClass().getName());
19 }
20
21 public Boolean booleanValue() throws IncorrectTypeException {
22 throw new IncorrectTypeException("boolean", this.getClass().getName());
23 }
24
25 public Double doubleValue() throws IncorrectTypeException {
26 throw new IncorrectTypeException("real", this.getClass().getName());
27 }
28
29 public Character characterValue() throws IncorrectTypeException {
30 throw new IncorrectTypeException("character", this.getClass().getName());
31 }
32
33 public abstract void setValue(SPrimitive v) throws IncorrectTypeException;
34
35 @Override
36 public void setValue(SVariable<T> v) throws IncorrectTypeException {
37 if (v instanceof SPrimitive) {
38 setValue((SPrimitive<?>) v);
39 return;
40 }
41 throw new IncorrectTypeException("primitive", "pointer");
42 }
43
44 /**
45 * Sets the value of the primitive using a string.
46 *
47 * @param s
48 * @throws Exception
49 */
50 public abstract void parse(String s) throws Exception;
51
52 @Override
53 public String toString() {
54 return stringValue();
55 }
56}
Note: See TracBrowser for help on using the repository browser.