01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the
09: * Free Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU General Public License along with
18: * this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: *
22: * $Id: DataAddress.java 4289 2007-01-11 11:41:33Z lzheng $
23: */
24: package com.bostechcorp.cbesb.common.trn.compiler;
25:
26: /*
27: * This represents a compile time data address (source or target).
28: */
29: public class DataAddress {
30: static public final short ADDR_BADTYPE = -1;
31: static public final short ADDR_ABSOLUTE = 1;
32: static public final short ADDR_CONTEXT = 2;
33: static public final short ADDR_LITERAL = 3;
34: static public final short ADDR_VARIABLE = 4;
35: static public final short ADDR_INDIRECT = 5;
36: static public final short ADDR_METADATA = 6;
37:
38: private short addrType;
39: private String value; //holds the context name, literal value or variable name
40: private String path;
41: private int addressIndex;
42:
43: public int getAddressIndex() {
44: return addressIndex;
45: }
46:
47: public void setAddressIndex(int addressIndex) {
48: this .addressIndex = addressIndex;
49: }
50:
51: public short getAddrType() {
52: return addrType;
53: }
54:
55: public void setAddrType(short addrType) {
56: this .addrType = addrType;
57: }
58:
59: public String getPath() {
60: return path;
61: }
62:
63: public void setPath(String path) {
64: this .path = path;
65: }
66:
67: public String getValue() {
68: return value;
69: }
70:
71: public void setValue(String value) {
72: this .value = value;
73: }
74:
75: public static String[] createVarArray(DataAddress[] sources,
76: int arithmeticType) {
77: String[] varArray = new String[sources.length];
78:
79: if (arithmeticType == ArithmeticType.ARTYPE_INTEGER) {
80: for (int i = 0; i < sources.length; i++)
81: varArray[i] = "Integer.parseInt(dataAddresses["
82: + sources[i].getAddressIndex()
83: + "].getValue(sourceTree,metadataMap))";
84: } else if (arithmeticType == ArithmeticType.ARTYPE_FLOAT) {
85: for (int i = 0; i < sources.length; i++)
86: varArray[i] = " Float.parseFloat(dataAddresses["
87: + sources[i].getAddressIndex()
88: + "].getValue(sourceTree,metadataMap))";
89: } else {
90: for (int i = 0; i < sources.length; i++)
91: varArray[i] = "dataAddresses["
92: + sources[i].getAddressIndex()
93: + "].getValue(sourceTree,metadataMap)";
94:
95: }
96: return varArray;
97:
98: }
99: }
|