|
21 | 21 | * Provides a Java implementation that is functionally equivalent to the COBOL |
22 | 22 | * EC01 sample program. |
23 | 23 | */ |
24 | | -public class LinkServEC01 |
25 | | -{ |
26 | | - /** |
27 | | - * Length of the COMMAREA returned by this program. |
28 | | - */ |
29 | | - private static final int CA_LEN = 18; |
30 | | - |
31 | | - /** |
32 | | - * Abend code used if the COMMAREA is too short. |
33 | | - */ |
34 | | - private static final String CA_LEN_ABCODE = "LEN"; |
35 | | - |
36 | | - /** |
37 | | - * CCSID of the current JVM. |
38 | | - */ |
39 | | - private static final String LOCALCCSID = System.getProperty("com.ibm.cics.jvmserver.local.ccsid"); |
| 24 | +public class LinkServEC01 { |
| 25 | + /** |
| 26 | + * Length of the COMMAREA returned by this program. |
| 27 | + */ |
| 28 | + private static final int CA_LEN = 18; |
40 | 29 |
|
41 | | - /** |
42 | | - * Main entry point to a CICS OSGi program. |
43 | | - * |
44 | | - * The fully qualified name of this class should be added to the CICS-MainClass entry in |
45 | | - * the parent OSGi bundle's manifest. |
46 | | - * |
47 | | - * This program is a Java version of the COBOL EC01 sample. It expects to be invoked with |
48 | | - * a COMMAREA of 18 bytes and returns the date. |
49 | | - */ |
50 | | - public static void main(CommAreaHolder cah) { |
51 | | - |
52 | | - // Get a reference to the current CICS task |
53 | | - Task task = Task.getTask(); |
| 30 | + /** |
| 31 | + * Abend code used if the COMMAREA is too short. |
| 32 | + */ |
| 33 | + private static final String CA_LEN_ABCODE = "LEN"; |
54 | 34 |
|
55 | | - // Check input area is long enough, else abend task |
56 | | - if ( cah.getValue().length < CA_LEN ) { |
57 | | - task.abend(CA_LEN_ABCODE); |
58 | | - } |
| 35 | + /** |
| 36 | + * CCSID of the current JVM. |
| 37 | + */ |
| 38 | + private static final String LOCALCCSID = System |
| 39 | + .getProperty("com.ibm.cics.jvmserver.local.ccsid"); |
59 | 40 |
|
60 | | - // Get time for return to caller |
61 | | - Date timestamp = new Date(); |
62 | | - SimpleDateFormat dfTime = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); |
63 | | - |
64 | | - try { |
65 | | - // Create byte array in local encoding |
66 | | - byte ba[] = dfTime.format(timestamp).getBytes(LOCALCCSID); |
67 | | - |
68 | | - // Copy into the byte array provided by the CommAreaHolder object |
69 | | - System.arraycopy(ba, 0, cah.getValue(), 0, ba.length); |
70 | | - } |
71 | | - catch (UnsupportedEncodingException uee) { |
72 | | - // Crude error handling for simple example |
73 | | - throw new RuntimeException(uee); |
74 | | - } |
75 | | - } |
| 41 | + /** |
| 42 | + * Main entry point to a CICS OSGi program. |
| 43 | + * |
| 44 | + * The fully qualified name of this class should be added to the |
| 45 | + * CICS-MainClass entry in the parent OSGi bundle's manifest. |
| 46 | + * |
| 47 | + * This program is a Java version of the COBOL EC01 sample. It expects to be |
| 48 | + * invoked with a COMMAREA of 18 bytes and returns the date. |
| 49 | + */ |
| 50 | + public static void main(CommAreaHolder cah) { |
| 51 | + |
| 52 | + // Get a reference to the current CICS task |
| 53 | + Task task = Task.getTask(); |
| 54 | + |
| 55 | + // Check input area is long enough, else abend task |
| 56 | + if (cah.getValue().length < CA_LEN) { |
| 57 | + task.abend(CA_LEN_ABCODE); |
| 58 | + } |
| 59 | + |
| 60 | + // Get time for return to caller |
| 61 | + Date timestamp = new Date(); |
| 62 | + SimpleDateFormat dfTime = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); |
| 63 | + |
| 64 | + try { |
| 65 | + // Create byte array in local encoding |
| 66 | + byte ba[] = dfTime.format(timestamp).getBytes(LOCALCCSID); |
| 67 | + |
| 68 | + // Copy into the byte array provided by the CommAreaHolder object |
| 69 | + System.arraycopy(ba, 0, cah.getValue(), 0, ba.length); |
| 70 | + } catch (UnsupportedEncodingException uee) { |
| 71 | + // Crude error handling for simple example |
| 72 | + throw new RuntimeException(uee); |
| 73 | + } |
| 74 | + } |
76 | 75 | } |
0 commit comments