|
1
|
|
/*
|
|
2
|
|
* JBind
|
|
3
|
|
*
|
|
4
|
|
* Copyright (c) by Stefan Wachter. All rights reserved.
|
|
5
|
|
*
|
|
6
|
|
* Usage, modification, and redistribution is subject to license terms that are
|
|
7
|
|
* available at 'http://www.jbind.org'. The JBind license is like the
|
|
8
|
|
* 'Apache Software License V 1.1'.
|
|
9
|
|
*/
|
|
10
|
|
package org.jbind.xml.instance.data;
|
|
11
|
|
|
|
12
|
|
import org.jbind.xml.core.data.CompareResult;
|
|
13
|
|
import org.jbind.xml.core.data.IAnyTypeData;
|
|
14
|
|
import org.jbind.xml.core.data.IGDay;
|
|
15
|
|
import org.jbind.xml.core.data.IGDayData;
|
|
16
|
|
import org.jbind.xml.core.data.IHasOrder;
|
|
17
|
|
import org.jbind.xml.core.data.ITimeZone;
|
|
18
|
|
import org.jbind.xml.msg.IConstraintViolations;
|
|
19
|
|
import org.jbind.xml.msg.XmlException;
|
|
20
|
|
|
|
21
|
|
public class GDayData extends AbstractDateOrTimeData implements IGDayData {
|
|
22
|
|
|
|
23
|
|
private IGDay myValue = null;
|
|
24
|
|
|
|
25
|
3
|
public GDayData() {}
|
|
26
|
|
|
|
27
|
3
|
protected void doAccept(String aString) throws XmlException {
|
|
28
|
3
|
super.doAccept(aString);
|
|
29
|
3
|
int idx = 0;
|
|
30
|
3
|
parseChar(aString, idx, '-');
|
|
31
|
3
|
idx++;
|
|
32
|
3
|
parseChar(aString, idx, '-');
|
|
33
|
3
|
idx++;
|
|
34
|
3
|
parseChar(aString, idx, '-');
|
|
35
|
3
|
idx++;
|
|
36
|
3
|
int day = parseInt(aString, idx, 2);
|
|
37
|
3
|
idx += 2;
|
|
38
|
3
|
ITimeZone timeZone = acceptTimeZone(aString, idx);
|
|
39
|
3
|
myValue = new GDay(day, timeZone);
|
|
40
|
|
}
|
|
41
|
|
|
|
42
|
0
|
public String getCanonicalForm_() {
|
|
43
|
0
|
return String.valueOf(myValue);
|
|
44
|
|
}
|
|
45
|
|
|
|
46
|
2
|
public IGDay getGDay() {
|
|
47
|
2
|
return myValue;
|
|
48
|
|
}
|
|
49
|
|
|
|
50
|
0
|
public void setGDay(IGDay aNewValue) throws XmlException {
|
|
51
|
0
|
IGDay oldValue = myValue;
|
|
52
|
0
|
myValue = aNewValue;
|
|
53
|
0
|
IConstraintViolations violations = completeSimpleStorageAssignment_();
|
|
54
|
0
|
if (!violations.isEmpty()) {
|
|
55
|
0
|
myValue = oldValue;
|
|
56
|
0
|
throw new XmlException(violations);
|
|
57
|
|
}
|
|
58
|
|
}
|
|
59
|
|
|
|
60
|
1
|
public boolean simpleStorageValueEquals(IAnyTypeData aData) {
|
|
61
|
1
|
return (aData instanceof IGDayData) && myValue.equals(((IGDayData)aData).getGDay());
|
|
62
|
|
}
|
|
63
|
|
|
|
64
|
4
|
public int simpleStorageValueHashCode() {
|
|
65
|
4
|
return myValue.hashCode();
|
|
66
|
|
}
|
|
67
|
|
|
|
68
|
3
|
public Object getSimpleStorageObject() {
|
|
69
|
3
|
return myValue;
|
|
70
|
|
}
|
|
71
|
|
|
|
72
|
0
|
public void setSimpleStorageObject(Object aValue) {
|
|
73
|
0
|
myValue = (IGDay)aValue;
|
|
74
|
|
}
|
|
75
|
|
|
|
76
|
0
|
protected CompareResult doGetCompareResult(IHasOrder aData) {
|
|
77
|
0
|
return myValue.compareTo(((IGDayData)aData).getGDay());
|
|
78
|
|
}
|
|
79
|
|
|
|
80
|
|
}
|
|
81
|
|
|