Project

General

Profile

FixingOutputParam.java

Hynek Cihlar, 04/25/2014 01:44 PM

Download (1.6 KB)

 
1
package com.goldencode.testcases;
2

    
3
import com.goldencode.p2j.util.*;
4

    
5
import static com.goldencode.p2j.util.BlockManager.*;
6
import static com.goldencode.p2j.util.ArrayAssigner.*;
7

    
8
/**
9
 * Business logic (converted to Java from the 4GL source code
10
 * in fixing_output_param.p).
11
 */
12
public class FixingOutputParam
13
{
14
   integer[] i = new integer[2];
15

    
16
   /**
17
    * External procedure (converted to Java from the 4GL source code
18
    * in fixing_output_param.p).
19
    */
20
   public void execute()
21
   {
22
      externalProcedure(new Block()
23
      {
24
         public void init()
25
         {
26
            assignMulti(i, new integer(0));
27
            TransactionManager.registerUndo(i);
28
         }
29

    
30
         public void body()
31
         {
32
            foo(new ExtentExpr0());
33
         }
34
      });
35
   }
36

    
37
   public integer[] foo(final OutputExtentParameter<integer> extp)
38
   {
39
      return extentFunction(integer.class, new Block()
40
      {
41
         integer[] p = extp.getVariable();
42

    
43
         public void init()
44
         {
45
            extp.setParameter(p);
46
            assignMulti(p, new integer(0));
47
            ArrayAssigner.registerDynamicArray(p);
48
            TransactionManager.deregister(new Undoable[][]
49
            {
50
               p
51
            });
52
         }
53

    
54
         public void body()
55
         {
56
            p = ArrayAssigner.resize(p, 2);
57
            extp.setParameter(p);
58
         }
59
      });
60
   }
61

    
62
   private class ExtentExpr0
63
   extends OutputExtentParameter<integer>
64
   {
65
      public integer[] getVariable()
66
      {
67
         return i;
68
      }
69

    
70
      public void setVariable(final integer[] newRef)
71
      {
72
         i = newRef;
73
      }
74
   }
75
}