01: package de.schlund.pfixcore.example.webservices;
02:
03: import java.util.Random;
04:
05: import org.w3c.dom.Element;
06:
07: import de.schlund.pfixcore.workflow.Context;
08: import de.schlund.pfixcore.workflow.ContextResource;
09: import de.schlund.pfixxml.ResultDocument;
10:
11: public class ContextDataImpl implements ContextResource, ContextData {
12:
13: String data;
14: String[] dataArray;
15:
16: public void init(Context context) {
17: }
18:
19: public void reset() {
20: }
21:
22: public boolean needsData() {
23: return false;
24: }
25:
26: public void insertStatus(ResultDocument resdoc, Element node)
27: throws Exception {
28: }
29:
30: public String exchangeData(String data, int strSize)
31: throws Exception {
32: this .data = data;
33: if (strSize < 0)
34: strSize = 0;
35: return generateString(strSize);
36: }
37:
38: public String[] exchangeDataArray(String[] data, int arrSize,
39: int strSize) throws Exception {
40: this .dataArray = data;
41: if (arrSize < 0)
42: arrSize = 0;
43: if (strSize < 0)
44: strSize = 0;
45: String[] ret = new String[arrSize];
46: for (int i = 0; i < arrSize; i++)
47: ret[i] = generateString(strSize);
48: return ret;
49: }
50:
51: final static Random random = new Random();
52:
53: public static String generateString(int length) {
54: StringBuffer sb = new StringBuffer();
55: int val = 0;
56: for (int i = 0; i < length; i++) {
57: while (!((val > 47 && val < 58) || (val > 64 && val < 91) || (val > 96 && val < 123))) {
58: val = random.nextInt(123);
59: }
60: sb.append((char) val);
61: val = 0;
62: }
63: return sb.toString();
64: }
65:
66: }
|