My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.legstar.coxb.impl;

import java.sql.Timestamp;
import java.util.Date;

import com.legstar.coxb.CobolElement;
import com.legstar.coxb.ICobolComplexBinding;
import com.legstar.coxb.host.HostException;

/**
* An example of a custom binding.
* <p/>
* Used via an annotation: @CobolJavaTypeAdapter(value = CustomBinding.class)
* <p/>
* Shows how a java java.sql.Timestamp can be used in place of a java
* java.util.Date.
*
*/
public class CustomBinding extends CStringBinding {

public CustomBinding(String bindingName, String jaxbName,
Class < ? > jaxbType, CobolElement cobolAnnotations,
ICobolComplexBinding parentBinding) {
super(bindingName, jaxbName, jaxbType, cobolAnnotations, parentBinding);
}

/** {@inheritDoc} */
public void setObjectValue(final Object value) throws HostException {
if (value instanceof Timestamp) {
super.setObjectValue(new Date(((Timestamp) value).getTime()));
} else {
super.setObjectValue(value);
}
}

/** {@inheritDoc} */
public Object getObjectValue(final Class < ? > type) throws HostException {

if (type.equals(Timestamp.class)) {
return new Timestamp(
((Date) super.getObjectValue(Date.class)).getTime());
} else {
return super.getObjectValue(type);
}
}
}

Change log

r1839 by fady.moussallam on Jul 22, 2011   Diff
[maven-scm] copy for tag legstar-
core-1.5.4
Go to: 
Project members, sign in to write a code review

Older revisions

r1819 by fady.moussallam on Jul 16, 2011   Diff
Added minimal support for
CobolJavaTypeAdapter. Usable only
using reflection (not via
transformers)
All revisions of this file

File info

Size: 1437 bytes, 46 lines
Powered by Google Project Hosting