1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package com.ontotext.wsmo4j.ontology; |
19 |
| |
20 |
| import java.math.BigDecimal; |
21 |
| import java.math.BigInteger; |
22 |
| |
23 |
| import org.omwg.logicalexpression.terms.Visitor; |
24 |
| import org.omwg.ontology.*; |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| public class SimpleDataValueImpl implements SimpleDataValue{ |
39 |
| |
40 |
| Object value = null; |
41 |
| SimpleDataType type = null; |
42 |
| |
43 |
0
| public SimpleDataValueImpl(SimpleDataType type, String value){
|
44 |
0
| if (!WsmlDataType.WSML_STRING.equals(
|
45 |
| type.getIRI().toString())){ |
46 |
0
| throw new IllegalArgumentException("Simple type string must have type wsml#string!");
|
47 |
| } |
48 |
0
| this.type = type;
|
49 |
0
| this.value = value;
|
50 |
| } |
51 |
| |
52 |
0
| public SimpleDataValueImpl(SimpleDataType type, BigInteger value){
|
53 |
0
| if (!WsmlDataType.WSML_INTEGER.equals(
|
54 |
| type.getIRI().toString())){ |
55 |
0
| throw new IllegalArgumentException("Simple type integer must have type wsml#integer!");
|
56 |
| } |
57 |
0
| this.type = type;
|
58 |
0
| this.value = value;
|
59 |
| } |
60 |
| |
61 |
0
| public SimpleDataValueImpl(SimpleDataType type, BigDecimal value){
|
62 |
0
| if (!WsmlDataType.WSML_DECIMAL.equals(
|
63 |
| type.getIRI().toString())){ |
64 |
0
| throw new IllegalArgumentException("Simple type decimal must have type wsml#decimal!");
|
65 |
| } |
66 |
0
| this.type = type;
|
67 |
0
| this.value = value;
|
68 |
| } |
69 |
| |
70 |
0
| public String asString() {
|
71 |
0
| return value.toString();
|
72 |
| } |
73 |
| |
74 |
0
| public String toString() {
|
75 |
0
| return asString();
|
76 |
| } |
77 |
| |
78 |
0
| public WsmlDataType getType() {
|
79 |
0
| return type;
|
80 |
| } |
81 |
| |
82 |
0
| public Object getValue() {
|
83 |
0
| return value;
|
84 |
| } |
85 |
| |
86 |
0
| public void accept(Visitor v) {
|
87 |
0
| v.visitSimpleDataValue(this);
|
88 |
| } |
89 |
| |
90 |
0
| public boolean equals(Object o){
|
91 |
0
| if (o == null || !(o instanceof SimpleDataValue)){
|
92 |
0
| return false;
|
93 |
| } |
94 |
0
| SimpleDataValue v = (SimpleDataValue)o;
|
95 |
0
| if (!v.getType().getIRI().toString().equals(type.getIRI().toString())){
|
96 |
0
| return false;
|
97 |
| } |
98 |
0
| return v.getValue().equals(value);
|
99 |
| } |
100 |
| |
101 |
0
| public int hashCode(){
|
102 |
0
| return value.hashCode();
|
103 |
| } |
104 |
| } |
105 |
| |
106 |
| |
107 |
| |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| |
116 |
| |
117 |
| |
118 |
| |