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.IGMonth;
|
15
|
|
import org.jbind.xml.core.data.IGMonthData;
|
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 GMonthData extends AbstractDateOrTimeData implements IGMonthData {
|
22
|
|
|
23
|
|
private IGMonth myValue = null;
|
24
|
|
|
25
|
1
|
public GMonthData() {}
|
26
|
|
|
27
|
1
|
protected void doAccept(String aString) throws XmlException {
|
28
|
1
|
super.doAccept(aString);
|
29
|
1
|
int idx = 0;
|
30
|
1
|
parseChar(aString, idx, '-');
|
31
|
1
|
idx++;
|
32
|
1
|
parseChar(aString, idx, '-');
|
33
|
1
|
idx++;
|
34
|
1
|
int month = parseInt(aString, idx, 2);
|
35
|
1
|
idx += 2;
|
36
|
1
|
parseChar(aString, idx, '-');
|
37
|
1
|
idx++;
|
38
|
1
|
parseChar(aString, idx, '-');
|
39
|
1
|
idx++;
|
40
|
1
|
ITimeZone timeZone = acceptTimeZone(aString, idx);
|
41
|
1
|
myValue = new GMonth(month, timeZone);
|
42
|
|
}
|
43
|
|
|
44
|
0
|
public String getCanonicalForm_() {
|
45
|
0
|
return String.valueOf(myValue);
|
46
|
|
}
|
47
|
|
|
48
|
2
|
public IGMonth getGMonth() {
|
49
|
2
|
return myValue;
|
50
|
|
}
|
51
|
|
|
52
|
0
|
public void setGMonth(IGMonth aNewValue) throws XmlException {
|
53
|
0
|
IGMonth oldValue = myValue;
|
54
|
0
|
myValue = aNewValue;
|
55
|
0
|
IConstraintViolations violations = completeSimpleStorageAssignment_();
|
56
|
0
|
if (!violations.isEmpty()) {
|
57
|
0
|
myValue = oldValue;
|
58
|
0
|
throw new XmlException(violations);
|
59
|
|
}
|
60
|
|
}
|
61
|
|
|
62
|
0
|
public boolean simpleStorageValueEquals(IAnyTypeData aData) {
|
63
|
0
|
return (aData instanceof IGMonthData) && myValue.equals(((IGMonthData)aData).getGMonth());
|
64
|
|
}
|
65
|
|
|
66
|
0
|
public int simpleStorageValueHashCode() {
|
67
|
0
|
return myValue.hashCode();
|
68
|
|
}
|
69
|
|
|
70
|
1
|
public Object getSimpleStorageObject() {
|
71
|
1
|
return myValue;
|
72
|
|
}
|
73
|
|
|
74
|
0
|
public void setSimpleStorageObject(Object aValue) {
|
75
|
0
|
myValue = (IGMonth)aValue;
|
76
|
|
}
|
77
|
|
|
78
|
0
|
protected CompareResult doGetCompareResult(IHasOrder aData) {
|
79
|
0
|
return myValue.compareTo(((IGMonthData)aData).getGMonth());
|
80
|
|
}
|
81
|
|
|
82
|
|
}
|
83
|
|
|