?? bpel2pi.java
字號:
String tempStr = tempAgent.getAction();
tempStr = "t." + tempStr;
listAction.add("t");
str += tempStr + "+ 0";
str = "(" + reduce(targetStr) + "(" + str + ")" + ")";
agent.setAction(str);
return agent;
}
public Agent ParsePick(Node node, Agent agent, String afterInfo) {
pickTimes++;
String str = "";
String partnerLinkValue = "";
String portTypeValueTemp = "";
String portTypeValue = "";
String operationValue = "";
String variableValue = "";
int i = 0;
String sourceStr = "";
String targetStr = "";
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeName().equalsIgnoreCase("source")) {
sourceStr += ParseLinkSource(child, agent);
}
if (child.getNodeName().equalsIgnoreCase("target")) {
targetStr += ParseLinkTarget(child, agent);
}
}
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeName().equalsIgnoreCase("onmessage")) {
onMessageTimes++;
NamedNodeMap attrs = node.getAttributes();
Node partnerLink = getNamedItemIgnoreCase(attrs, "partnerLink");
if (partnerLink != null) {
partnerLinkValue = ((Attr) partnerLink).getValue().trim()
.toLowerCase();
}
Node portType = getNamedItemIgnoreCase(attrs, "portType");
if (portType != null) {
portTypeValueTemp = ((Attr) portType).getValue().trim()
.toLowerCase();
}
if (portTypeValueTemp != null && !portTypeValueTemp.equals("")) {
int index = portTypeValueTemp.indexOf(":");
portTypeValue = portTypeValueTemp.substring(index + 1);
}
Node operation = getNamedItemIgnoreCase(attrs, "operation");
if (operation != null) {
operationValue = ((Attr) operation).getValue().trim()
.toLowerCase();
}
Node variable = getNamedItemIgnoreCase(attrs, "variable");
if (variable != null) {
variableValue = ((Attr) variable).getValue().trim()
.toLowerCase();
}
if (i == 0) {
str += partnerLinkValue + "$" + portTypeValue + "$"
+ operationValue + "$" + variableValue + "("
+ variableValue + ")" + ".";
} else {
str += "+" + partnerLinkValue + "$" + portTypeValue + "$"
+ operationValue + "$" + variableValue + "("
+ variableValue + ")" + ".";
}
agent.setFreeName(partnerLinkValue + "$" + portTypeValue + "$"
+ operationValue + "$" + variableValue);
agent.setBoundName(variableValue); // 添加自由名和限制名
Agent tempAgent = new Agent();
String tempAfterInfo = afterInfo;
if (!sourceStr.equals("")) {
StringTokenizer stringTokenizer = new StringTokenizer(
sourceStr, ".");
int tokenCount = stringTokenizer.countTokens();
for (int k = 0; k < tokenCount; k++) {
String temp = stringTokenizer.nextToken();
tempAfterInfo += "&" + temp;
}
}
tempAgent = ParseActivity(child, tempAgent, tempAfterInfo);
agent.setFreeName(tempAgent.freeName);
agent.setBoundName(tempAgent.boundName);
String tempStr = tempAgent.getAction();
str = redeem(str);
str += tempStr;
i++;
}
if (child.getNodeName().equalsIgnoreCase("onAlarm")) {
str += " + t.";
listAction.add("t");
onAlarmTimes++;
Agent tempAgent = new Agent();
if (!sourceStr.equals("")) {
StringTokenizer stringTokenizer = new StringTokenizer(
sourceStr, ".");
int tokenCount = stringTokenizer.countTokens();
for (int k = 0; k < tokenCount; k++) {
String temp = stringTokenizer.nextToken();
afterInfo += "&" + temp;
}
}
tempAgent = ParseActivity(child, tempAgent, afterInfo);
agent.setFreeName(tempAgent.freeName);
agent.setBoundName(tempAgent.boundName);
String tempStr = tempAgent.getAction();
str = redeem(str);
str += tempStr;
}
}
if (!targetStr.equals(""))
str += redeem(targetStr) + str;
str = "(" + redeem(targetStr) + "(" + str + ")" + ")";
agent.setAction(str);
return agent;
}
public Agent ParseSwitch(Node node, Agent agent, String afterInfo) {
switchTimes++;
String sourceStr = "";
String targetStr = "";
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeName().equalsIgnoreCase("source")) {
sourceStr += ParseLinkSource(child, agent);
}
if (child.getNodeName().equalsIgnoreCase("target")) {
targetStr += ParseLinkTarget(child, agent);
}
}
String str = "";
int childsNum = getContrutorChildsNum(node);
int i = 0;
int caseTimes = 0;
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
String activity = "";
if (child.getNodeName().equalsIgnoreCase("case")
|| child.getNodeName().equalsIgnoreCase("otherwise")) {
i++;
String tempAfterInfo = afterInfo;
Agent tempAgent = new Agent();
if (!sourceStr.equals("")) {
StringTokenizer stringTokenizer = new StringTokenizer(
sourceStr, ".");
int tokenCount = stringTokenizer.countTokens();
for (int k = 0; k < tokenCount; k++) {
String temp = stringTokenizer.nextToken();
tempAfterInfo += "&" + temp;
}
}
tempAgent = ParseActivity(child, tempAgent, tempAfterInfo);
agent.setFreeName(tempAgent.freeName);
agent.setBoundName(tempAgent.boundName);
activity = tempAgent.getAction();
// String conditionRemark = "";
if (child.getNodeName().equalsIgnoreCase("case")) {
caseTimes++;
if (i < childsNum)
str += activity + "+";
else
str += activity;
} else {
otherwiseTimes++;
if (i < childsNum)
str += activity + "+";
else
str += activity;
}
}
}
str = "t." + "(" + redeem(targetStr) + "(" + str + ")" + ")";
listAction.add("t");
agent.setAction(str);
return agent;
}
public Agent ParseFlow(Node node, Agent agent, String afterInfo) {
flowTimes++;
int childsNum = getValidChildsNum(node);
String str = "";
String sourceStr = "";
String targetStr = "";
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeName().equalsIgnoreCase("source")) {
sourceStr += ParseLinkSource(child, agent);
}
if (child.getNodeName().equalsIgnoreCase("target")) {
targetStr += ParseLinkTarget(child, agent);
}
}
String sourceRear[] = new String[childsNum]; // ,從0----childsNum-1開始存儲!
String tempSourceTotal = "";
if (!sourceStr.equals("")) { // 如果這不為空,則臨時構造多個后置名,分別添加到該節點的每個子節點,然后再并發并發一個添加的進程!
String linkSouStr = String.valueOf(linkSourceTimes);
for (int i = 0; i < childsNum; i++) {
String inputAct = "fl_s" + linkSouStr + String.valueOf(i);
String inputValue = "ifl_s" + linkSouStr + String.valueOf(i);
String outputValue = "ofl_s" + linkSouStr + String.valueOf(i);
String outputAct = "'" + inputAct;
String outputName = outputAct + "<" + outputValue + ">";
sourceRear[i] = outputName;
tempSourceTotal += inputAct + "(" + inputValue + ")" + ".";
agent.setBoundName(outputValue);
agent.setBoundName(inputAct + "&" + inputValue);
}
tempSourceTotal = reduce(tempSourceTotal);
}
int tokenCount = 0;
StringTokenizer stringTokenizer = new StringTokenizer(afterInfo, "&");
tokenCount = stringTokenizer.countTokens();
String array[][] = new String[tokenCount][childsNum]; // 每行儲存一個后置名字分裂的名字!
for (int i = 0; i < tokenCount; i++) { // 做兩層嵌套循環,對每個afterName的分量做分裂!
String token = stringTokenizer.nextToken();
StringTokenizer stringTokenizer1 = new StringTokenizer(token, "<");
String outAct = stringTokenizer1.nextToken();
String inAct = "";
if (outAct.charAt(0) != '\'')
System.out.println("in__flow: Name has error!");
else
inAct = outAct.substring(1);
String tempNames = "";
for (int j = 0; j < childsNum; j++) {
String tempOutputAction = outAct + "$" + String.valueOf(i)
+ String.valueOf(j);
String tempOutputValue = "ofl" + "$" + String.valueOf(i)
+ String.valueOf(j);
String tempInputAction = inAct + "$" + String.valueOf(i)
+ String.valueOf(j);
String tempInputValue = "ifl" + "$" + String.valueOf(i)
+ String.valueOf(j);
agent.setBoundName(tempOutputValue);
agent.setBoundName(tempInputAction + "&" + tempInputValue);
array[i][j] = tempOutputAction + "<" + tempOutputValue + ">";
array1.add(listIndex, new String(tempInputAction));
array2.add(listIndex, new String(""));
listIndex++;
tempNames += tempInputAction + "(" + tempInputValue + ")" + ".";
}
int location = array1.indexOf((String) inAct); // 對分裂的名字進行記錄,方便查找和替換!對應sequence
// 活動中的前置條件的處理!
if (location > -1)
array2.add(location, (String) (reduce(tempNames)));
}
int j = 0; // 記錄當前分析的是第幾個孩子!從0開始!
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
int childType = activityMap.getType(child.getNodeName()
.toLowerCase());
if (childType != 99 && childType != 11) { // 注意下面結構的邏輯關系!
String tempAfterInfo = "";
if (tokenCount > 0) {
for (int i = 0; i < tokenCount; i++)
tempAfterInfo += array[i][j] + ".";
tempAfterInfo = reduce(tempAfterInfo);
}
if (!sourceStr.equals("")) { // 將由于linkSource構造的臨時后置名字加入到afterInfo中!
String addAfterInfo = sourceRear[j];
tempAfterInfo += "&" + addAfterInfo;
}
Agent tempAgent = new Agent();
tempAgent = ParseNode(child, tempAgent, tempAfterInfo);
agent.setFreeName(tempAgent.freeName);
agent.setBoundName(tempAgent.boundName);
String tempStr = tempAgent.getAction();
if (!isLastValidNode(child))
str += tempStr + "|";
else
str += tempStr;
j++;
}
}
if (!sourceStr.equals("") && !tempSourceTotal.equals("")) {
str += "|" + redeem(tempSourceTotal) + reduce(sourceStr) + ".0";
}
str = "(" + redeem(targetStr) + "(" + str + ")" + ")";
// 這里不用加sourcelink,因為它已經發散到各個子節點中去了!
agent.setAction(str);
return agent;
}
public Agent ParseInvoke(Node node, Agent agent, String afterInfo) {
invokeTimes++;
String strin = "";
String strout = "";
String str = "";
String partnerLinkValue = "";
String portTypeValueTemp = "";
String portTypeValue = "";
String operationValue = "";
String inputVariableValue = "";
String outputVariableValue = "";
String sourceStr = "";
String targetStr = "";
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeName().equalsIgnoreCase("source")) {
sourceStr += ParseLinkSource(child, agent);
}
if (child.getNodeName().equalsIgnoreCase("target")) {
targetStr += ParseLinkTarget(child, agent);
}
}
NamedNodeMap attrs = node.getAttributes();
Node partnerLink = getNamedItemIgnoreCase(attrs, "partnerLink");
if (partnerLink != null) {
partnerLinkValue = ((Attr) partnerLink).getValue().trim()
.toLowerCase();
}
Node portType = getNamedItemIgnoreCase(attrs, "portType");
if (portType != null) {
portTypeValueTemp = ((Attr) portType).getValue().trim()
.toLowerCase();
}
if (portTypeValueTemp != null && !portTypeValueTemp.equals("")) {
int index = portTypeValueTemp.indexOf(":");
portTypeValue = portTypeValueTemp.substring(index + 1);
}
Node operation = getNamedItemIgnoreCase(attrs, "operation");
if (operation != null) {
operationValue = ((Attr) operation).getValue().trim().toLowerCase();
}
Node inputVariable = getNamedItemIgnoreCase(attrs, "inputVariable");
if (inputVariable != null) {
inputVariableValue = ((Attr) inputVariable).getValue().trim()
.toLowerCase();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -