?? bpel2pitop.java
字號:
/*
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
author: Yuan yongfu lijin liyong lib 511,the College of Mathematics and Computer Science,HuNan Normal University,China
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
*/
package edu.hunnu.webjetchecker.convert;
import java.util.StringTokenizer;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import edu.hunnu.webjetchecker.ActivityMap;
/**
* @author ly
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class Bpel2PiTop {
public boolean isLastValidNode(Node node) {
// 判斷該節(jié)點(diǎn)是否為最后一個有效節(jié)點(diǎn) !
boolean value = true;
ActivityMap activityMap = new ActivityMap();
for (Node nextSibling = node.getNextSibling(); nextSibling != null; nextSibling = nextSibling
.getNextSibling()) {
int type = activityMap.getType(nextSibling.getNodeName()
.toLowerCase());
if (type != 99 && type != 11) { // links不作為一個動作處理!
value = false;
break;
}
}
return value;
}
public String redeem(String str) {
// 如果得到的字符串不是以"."結(jié)尾,則認(rèn)為補(bǔ)上!
if (str.length() > 0) {
if (str.charAt(str.length() - 1) != '.')
str += ".";
}
return str;
}
public String reduce(String str) {
if (str.length() > 0) {
if (str.charAt(str.length() - 1) == '.')
str = str.substring(0, str.length() - 1);
}
return str;
}
public int getValidChildsNum(Node node) {
int num = 0;
ActivityMap activityMap = new ActivityMap();
if (node == null)
return 0;
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
int childType = activityMap.getType(child.getNodeName()
.toLowerCase());
if (childType != 99 && childType != 11)
num++;
}
return num;
}
public int getContrutorChildsNum(Node node) {
int num = 0;
ActivityMap activityMap = new ActivityMap();
int activityType = activityMap.getType(node.getNodeName());
if (activityType == 0) { // sequence
num = getValidChildsNum(node);
}
if (activityType == 1) { // switch
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeName().equalsIgnoreCase("case")
|| child.getNodeName().equalsIgnoreCase("otherwise")) {
num++;
}
}
}
if (activityType == 2) { // pick
for (Node child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (child.getNodeName().equalsIgnoreCase("onmessage")
|| child.getNodeName().equalsIgnoreCase("onAlarm")) {
num++;
}
}
}
if (activityType == 3) { // while
num = 1;
}
if (activityType == 5) { // flow
num = getValidChildsNum(node);
}
return num;
}
public int getNextValidChildType(Node node) {
ActivityMap activityMap = new ActivityMap();
int type;
Node nextSibling = node.getNextSibling();
while (nextSibling != null) {
type = activityMap.getType(nextSibling.getNodeName().toLowerCase());
if (type != 99 && type != 11)
return type;
nextSibling = nextSibling.getNextSibling();
}
return 4;
}
public String addRear(String info, String rearName) {
info += "&" + rearName;
return info;
}
public String addPre(String info, String pre) {
info = pre + "&" + info;
return info;
}
public String getRear(String info) {
String str = "";
StringTokenizer stringTokenizer = new StringTokenizer(info, "#");
String subInfo = stringTokenizer.nextToken();
subInfo = stringTokenizer.nextToken(); // 取右半部分
StringTokenizer stringTokenizer1 = new StringTokenizer(subInfo, "&");
int tokenCount = stringTokenizer1.countTokens();
for (int i = 1; i <= tokenCount; i++) {
String name = stringTokenizer1.nextToken();
str = name + "." + str; // 反向;因?yàn)橄忍砑拥暮笾脳l件應(yīng)放在最后!
}
return str;
}
public String removePre(String info) {
String name = "";
StringTokenizer stringTokenizer = new StringTokenizer(info, "#");
String subInfo = stringTokenizer.nextToken();// 取左半部分
StringTokenizer stringTokenizer1 = new StringTokenizer(subInfo, "&");
int tokenCount = stringTokenizer1.countTokens();
for (int i = 1; i <= tokenCount; i++) {
if (i == tokenCount - 1)
name = stringTokenizer1.nextToken();
}
return name;
}
public String deletePre(String info) {
String str = "";
StringTokenizer stringTokenizer = new StringTokenizer(info, "#");
String subInfo = stringTokenizer.nextToken();
subInfo = stringTokenizer.nextToken(); // 取右半部分
str = "#" + subInfo;
return str;
}
public static String modifyString(String Str, String newStr) {
// 在Str中找到最后以后".0",用newStr進(jìn)行替換!
int len = Str.length();
int i = len;
if (newStr.equals(""))
return Str;
if (i < 2)
return "";
while (i >= 2
&& !(Str.charAt(i - 1) == '0' && Str.charAt(i - 2) == '.')) {
i--;
}
String s1 = "";
String s2 = "";
if (i < 2)
System.out.println("The structure of String is not good !");
else {
s1 = Str.substring(0, i - 1);
if (len != i)
s2 = Str.substring(i, len);
}
return (s1 + newStr + s2);
}
public String supplant(String motherStr, String oldStr, String newStr) {
// 對motherStr中出現(xiàn)的oldStr用newStr替換!
if (motherStr.length() > 0 && oldStr.length() > 0) {
int index = motherStr.indexOf(oldStr);
if (index != -1) {
String firstStr = motherStr.substring(0, index);
String secondStr = motherStr.substring(index + oldStr.length());
motherStr = firstStr + newStr + secondStr;
}
}
return motherStr;
}
public String blackBox(String str) {
StringTokenizer stringTokenizer = new StringTokenizer(str, "&");
int tokenCount = stringTokenizer.countTokens();
String tempStr = "";
for (int i = 1; i <= tokenCount; i++) {
if (i < tokenCount)
tempStr += stringTokenizer.nextToken() + ".";
else
tempStr += stringTokenizer.nextToken();
}
return tempStr;
}
public Node getNamedItemIgnoreCase(NamedNodeMap attrs, String name) {
Node namedNode = null;
int attrsLength = attrs.getLength();
for (int i = 0; i < attrsLength; i++)
if (attrs.item(i).getNodeName().equalsIgnoreCase(name)) {
namedNode = attrs.item(i);
return namedNode;
}
return namedNode;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -