Here you can find the source of getDSNameListInScriptText(String scriptText, NodeList tableList)
static ArrayList<String> getDSNameListInScriptText(String scriptText,
NodeList tableList)
//package com.java2s; import org.w3c.dom.*; public class Main { static ArrayList<String> getDSNameListInScriptText(String scriptText, NodeList tableList) { ArrayList<String> fieldList = new ArrayList<String>(); int pos, posWrk, wrkInt, posWrk2; String[] sectionDigit = { "(", ")", "{", "}", "+", "-", "/", "*", "=", "<", ">", ";", "|", "&", "\n", "\t", ",", " ", "!" }; String[] fieldProperty = { "value", "oldValue", "color", "enabled", "editable", "error", "valueChanged" }; boolean isFirstDigitOfField; String variantExpression, wrkStr1, wrkStr2, dataSource; org.w3c.dom.Element element; for (int i = 0; i < fieldProperty.length; i++) { pos = 0;// w ww . j a va2 s .c o m while (pos < scriptText.length()) { posWrk = scriptText.indexOf("." + fieldProperty[i], pos); if (posWrk == -1) { pos = scriptText.length(); } if (posWrk != -1) { wrkInt = posWrk - 1; while (wrkInt > -1) { wrkInt--; isFirstDigitOfField = false; if (wrkInt > -1) { wrkStr1 = scriptText.substring(wrkInt, wrkInt + 1); for (int j = 0; j < sectionDigit.length; j++) { if (wrkStr1.equals(sectionDigit[j])) { isFirstDigitOfField = true; break; } } } if (wrkInt == -1 || isFirstDigitOfField) { dataSource = ""; variantExpression = scriptText.substring( wrkInt + 1, posWrk); if (countStringInText(variantExpression, "_") > 1) { wrkStr2 = ""; for (int j = 0; j < tableList.getLength(); j++) { element = (org.w3c.dom.Element) tableList .item(j); wrkStr1 = element.getAttribute("ID") + "_"; if (variantExpression .startsWith(wrkStr1)) { if (wrkStr1.length() > wrkStr2 .length() + 1) { wrkStr2 = element .getAttribute("ID"); } } } if (!wrkStr2.equals("")) { dataSource = variantExpression.replace( wrkStr2 + "_", wrkStr2 + "."); if (!fieldList.contains(dataSource)) { fieldList.add(dataSource); } } } if (dataSource.equals("")) { posWrk2 = variantExpression.indexOf("_"); if (posWrk2 > -1) { dataSource = variantExpression .substring(0, posWrk2) + "." + variantExpression.substring( posWrk2 + 1, variantExpression .length()); if (!fieldList.contains(dataSource)) { fieldList.add(dataSource); } } } wrkInt = -1; pos = posWrk + 6; } } } } } return fieldList; } static public int countStringInText(String text, String searchString) { return (text.length() - text.replaceAll(searchString, "").length()) / searchString.length(); } }