⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.java

📁 一个自制的DB framework,使用的配置方式新颖
💻 JAVA
字号:
/*01*/package bits;

/*02*/import javax.servlet.*; /*03*/
import javax.servlet.http.*; /*04*/
import java.io.*; /*05*/
import java.util.*; /*06*/
import javax.xml.parsers.*; /*07*/
import org.w3c.dom.*;

/*08*/public class config
/*09*/{
	/*10*/public static int a = 300;
	/*11*/public static final int ARRAYSIZE = 1000;
	/*12*/public static int[] protocol = new int[ARRAYSIZE];
	/*13*/public static String[] strSQL = new String[ARRAYSIZE];
	/*14*/public static String[] strForword = new String[ARRAYSIZE];
	/*15*/public static int[] strHandler = new int[ARRAYSIZE];
	/*16*/private String configfile = "";

	/*17*/public config(String path)
	/*18*/{
		/*19*/configfile = path;
		/*20*/this.parsed();
		/*21*/}

	/*22*/
	/*23*/public void parsed()
	/*24*/{
		/*25*/try
		/*26*/{
			/*27*/String filename = this.configfile;
			/*28*/DocumentBuilderFactory factory = DocumentBuilderFactory
					.newInstance();
			/*29*/DocumentBuilder builder = factory.newDocumentBuilder();
			/*30*/Document doc = builder.parse(new File(filename));
			/*31*/NodeList n1 = doc.getElementsByTagName("query");
			/*32*/for (int i = 0; i < n1.getLength(); i++)
			/*33*/{
				/*34*/Element node = (Element) n1.item(i);
				/*35*/int myid = Integer
						.parseInt(getNodeValue("queryid", node));
				/*36*/protocol[i] = myid;
				/*37*/int ireal = myid - 1000;
				/*38*/strSQL[ireal] = getNodeValue("querysql", node);
				/*39*/strForword[ireal] = getNodeValue("queryui", node);
				/*40*/strHandler[ireal] = Integer.parseInt(getNodeValue(
						"queryhandler", node));
				/*41*/}
			/*42*/}
		/*43*/catch (Exception e)
		/*44*/{
			/*45*/System.out.println(e.getMessage());
			/*46*/}
		/*47*/}

	/*48*/public String getNodeValue(String nodeName, Element node)
	/*49*/{
		/*50*/NodeList MyList = node.getElementsByTagName(nodeName);
		/*51*/Node nodeTemp = MyList.item(0).getFirstChild();
		/*52*/String strValue = nodeTemp.getNodeValue();
		/*53*/return strValue;
		/*54*/}

	/*55*/public actionitem searchSQL(int index, HttpServletRequest request)
	/*56*/{
		/*57*/int bcount = 0;
		/*58*/bcount = index - 1000;
		/*59*/String[] strTemp = new String[2];
		/*60*/actionitem obj = new actionitem();
		/*61*/obj.handlerid = strHandler[bcount];
		/*62*/obj.strforward = strForword[bcount];
		/*63*/strTemp[1] = strSQL[bcount];
		/*64*/char start = 'b';
		/*65*/for (int i = 0; i < 25; i++)
		/*66*/{
			/*67*/char cTemp = (char) (start + i);
			/*68*/String strTemp1 = "" + cTemp;
			/*69*/String b = request.getParameter(strTemp1);
			/*70*/if (b == null)
				b = "";
			/*71*/b = b.trim();
			/*72*/String strRp = "<" + strTemp1 + ">";
			/*73*/strTemp[1] = strTemp[1].replace(strRp, b);
			/*74*/}
		/*75*/obj.strsql = strTemp[1];
		/*76*/return obj;
		/*77*/}
	/*78*/
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -