?? bpel2remarkpi.java
字號:
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
int childType = activityMap.getType(child.getNodeName()
.toLowerCase());
if (childType != 99 && childType != 11) {
childsNum++; // 記錄該節點中所擁有的孩子的數目
String rearName = output[childsNum];
Agent tempAgent = new Agent(); // 對子節點生成一個新進程對象,保存該節點及其子孫的所有信息!
tempAgent = ParseNode(child, tempAgent, rearName); // 對每個子節點生成一個進程對象,進行分析
// 把子進程的自由名和邦定名傳入父進程
agent.setFreeName((ArrayList) tempAgent.freeName);
agent.setBoundName((ArrayList) tempAgent.boundName); // 這里會不會重復設置名字
String tempStr = tempAgent.getAction(); // 對子節點的分析結果
// 前置條件的處理!
// 下面一段對那些曾經分裂引起前置條件變化的替換進行處理!將array1中已經替換的前置名用分裂后的名字替換!
String previousName = input[childsNum];
StringTokenizer tempStringTokenizer = new StringTokenizer(
previousName, "&");
int tokenCount = tempStringTokenizer.countTokens();
String transform = "";
for (int j = 1; j <= tokenCount; j++) {
String strObject = tempStringTokenizer.nextToken();// 得到前置條件的一個名字
StringTokenizer tempStringTokenizer1 = new StringTokenizer(
strObject, "(");// 獲得前置條件某個名字的通道名
String chunnelName = tempStringTokenizer1.nextToken();
int location = array1.indexOf(chunnelName);
String tempObject = "";
if (location > -1)
tempObject = (String) array2.get(location);
if (!tempObject.equals("")) // 原來的名字已經由于子節點的分裂發生了變化
strObject = tempObject;
if (j < tokenCount)
transform += strObject + ".";
else
transform += strObject;
}
tempStr = redeem(transform) + tempStr;// 這里其實就是加上了前置條件
if (!isLastValidNode(child))
str += tempStr + "|";
else
str += tempStr;
} // end if
} // end for
if (!afterInfo.equals("") || !sourceStr.equals("")) { // 在sequence
// 中的出站鏈接和從父節點中傳遞的afterInfo可以看作一樣的內容處理!
afterInfo = blackBox(afterInfo); // 將用"&"相連的名字變成用"."相連!
// String tempStr = redeem(afterInfo) + reduce(sourceStr) + ".0" ;
String tempStr = redeem(afterInfo);
if (!sourceStr.equals(""))
tempStr += reduce(sourceStr) + ".0";
else
tempStr += "0";
str = modifyString(str, tempStr);
}
str = "(*start_sequence#" + sequenceStr + "#*)" + "("
+ redeem(targetStr) + "(" + str + ")" + ")" + "(*end_sequence#"
+ sequenceStr + "#*)";
agent.setAction(str);
return agent;
}
public Agent ParseWhile(Node node, Agent agent, String afterInfo) {
// this method is according to the idea of SongYan
whileTimes++;
String whileStr = String.valueOf(whileTimes);
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);
}
}
Agent tempAgent = new Agent();
tempAgent = ParseActivity(node, tempAgent, afterInfo);
agent.setFreeName(tempAgent.freeName);
agent.setBoundName(tempAgent.boundName);
String tempStr = tempAgent.getAction();
tempStr = "t." + tempStr;
str += tempStr + "+ 0";
str = "(" + reduce(targetStr) + "(" + "(*start_while#" + whileStr
+ "#*)" + str + "(*end_while#" + whileStr + "#*)" + ")" + ")";
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 pickStr = String.valueOf(pickTimes);
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();
}
String onMessageStr = String.valueOf(onMessageTimes);
if (i == 0) {
str += "(*start_onMessage#" + onMessageStr + "#*)"
+ partnerLinkValue + "$" + portTypeValue + "$"
+ operationValue + "$" + variableValue + "("
+ variableValue + ")" + "(*end_onMessage#"
+ onMessageStr + "#*)" + ".";
} else {
str += "+" + "(*start_onMessage#" + onMessageStr + "#*)"
+ partnerLinkValue + "$" + portTypeValue + "$"
+ operationValue + "$" + variableValue + "("
+ variableValue + ")" + "(*end_onMessage#"
+ onMessageStr + "#*)" + ".";
}
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.";
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);
String onAlarmStr = String.valueOf(onAlarmTimes);
str += "(*start_onAlarm#" + onAlarmStr + "#*)" + tempStr
+ "(*end_onAlarm#" + onAlarmStr + "#*)";
}
}
if (!targetStr.equals(""))
str += redeem(targetStr) + str;
str = "(*start_pick#" + pickStr + "#*)" + "(" + redeem(targetStr) + "("
+ str + ")" + ")" + "(*end_pick#" + pickStr + "#*)";
agent.setAction(str);
return agent;
}
public Agent ParseSwitch(Node node, Agent agent, String afterInfo) {
switchTimes++;
String switchStr = String.valueOf(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++;
String caseStr = String.valueOf(caseTimes);
NamedNodeMap attrs = child.getAttributes();
Node linkNameNode = getNamedItemIgnoreCase(attrs,
"condition");
String linkName = ((Attr) linkNameNode).getValue().trim()
.toLowerCase();
conditionRemark = "(*condition = " + "\"" + linkName + "\""
+ "*)";
if (i < childsNum)
str += "(*start_case#" + caseStr + "#*)"
+ conditionRemark + activity + "(*end_case#"
+ caseStr + "#*)" + " + ";
else
str += "(*start_case#" + caseStr + "#*)"
+ conditionRemark + activity + "(*end_case#"
+ caseStr + "#*)";
} else {
otherwiseTimes++;
String otherwiseStr = String.valueOf(otherwiseTimes);
if (i < childsNum)
str += "(*start_otherwise#" + otherwiseStr + "#*)"
+ conditionRemark + activity
+ "(*end_otherwise#" + otherwiseStr + "#*)"
+ " + ";
else
str += "(*start_otherwise#" + otherwiseStr + "#*)"
+ conditionRemark + activity
+ "(*end_otherwise#" + otherwiseStr + "#*)";
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -