亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tldparser.java

?? jakarta-taglibs
?? JAVA
字號:
/*
 * Copyright 1999,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.taglibs.tools.ultradev.ctlx;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.InputSource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
import org.w3c.dom.DOMException;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Hashtable;
import java.net.URL;


/* file: TLDParser.java
 * author : Dan Mandell [dmandell@stanford.edu]
 * contributors : Julien Carnelos [juliencarnelos@netcourrier.com]
 *              : David Miller [dmiller_va@hotmail.com]
 * -------------------------------------------
 * Takes the URL of a TLD file as an argument and produces a text
 * file containing JavaScript declarations of associative
 * arrays representing all tags and their attributes in the supplied
 * TLD. Requires the xerces XML parser available from xml.apache.org
 *
 */


public class TLDParser extends HttpServlet {

	/* Output Modes */
	public final int ULTRADEV = 1;
	public final int OTHER = 2;
	public final int TLD_LIST = 3;
	
	/* Result Flags */
	public final int FAILURE = 0;
	public final int SUCCESS = 1;
	
	/* Private Constants/Defaults */
	private final String URL_SEP = "/";
	private final String PATH_TO_TLDS = URL_SEP + "tlds";
	private final String TLD_SUFFIX = ".tld";
	private final String UNDEFINED = "UNDEFINED";
	private final String DEFAULT_OUTPUT_FILE = "tagLibData.js";
	private final int DEFAULT_OUTPUT_MODE = ULTRADEV;
	
	/* Private Variables */
	private int result = FAILURE; // internal flag. Set to SUCCESS if parsing is successful
	private int mode; // defines format of the output
	private String outputFilePrefix; // for naming output files (ie: prefix.js, prefix.html)
	private PrintWriter out;
	private Hashtable tags;

	public void init(ServletConfig config) throws ServletException
	{
		super.init(config);
	}

	public void doGet(HttpServletRequest req, HttpServletResponse res)
					throws ServletException, IOException
	{
		tags = new Hashtable();
		out = new PrintWriter(res.getOutputStream());
		String userMode;
		URL tld = null;
		
		userMode = req.getParameter("mode").toLowerCase();
		outputFilePrefix = req.getParameter("prefix");
		String tldPath = PATH_TO_TLDS + URL_SEP + outputFilePrefix + TLD_SUFFIX;

		/* updated the separator to make it compatible with Windows based servers */
		tld = getServletConfig().getServletContext().getResource(tldPath);

            System.out.println( "tld = " + tld );
				
		if (userMode.equals("ultradev")) mode = ULTRADEV;
		else if (userMode.equals("other")) mode = OTHER;
		else if (userMode.equals("tldlist")) mode = TLD_LIST;
		
		if (mode == TLD_LIST) outputTLDList(req);
		else parseTLD(tld);

		out.close();
	}
		


/* funtion: parseTLD()
 * -------------------
 * Use the Xerces XML parser to create a DOM of the supplied TLD.
 * Passes the root element of the DOM to the createAttTable method
 * to create the attribute table.
 */
 
	private void parseTLD(URL TLD) {
		System.out.println("You entered " + TLD);
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setValidating(true);
		factory.setNamespaceAware(true);
			
		try {
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document doc = builder.parse(new InputSource(TLD.openStream()));
			Element root = doc.getDocumentElement();
			System.out.println("Creating attributes table");
			createAttTable(root);
			writeOutput();
			result = SUCCESS;
		}
		
		catch (org.xml.sax.SAXException e) {
			e.printStackTrace();
		}

		catch (javax.xml.parsers.ParserConfigurationException e) {
			e.printStackTrace();
		}

		catch (java.io.IOException e)	{
			e.printStackTrace();
		}		
	}
	
	
/* method: createAttTable()
 * ------------------------
 * Takes the root element in a DOM and enters the tags
 * into the tags table as an arraylist 
 *
 */
	private void createAttTable (Element root) {
		Node curTag = root.getFirstChild();
				
		curTag = getNextTag(curTag, "tag");//start with first <tag> node
		Tag thetag;
		
		while (curTag != null) {
			System.out.println("Current tag name is: " + getTagName(curTag));
			if (curTag.getNodeName().toLowerCase().equals("tag")) {
				thetag = analyzeAtts(curTag);
				tags.put(getTagName(curTag), thetag); 
			}	
			curTag = getNextTag(curTag, "tag");
		}
	}
	
 	
 /* method: analyzeAtts()
  * ---------------------
  * Analyzes each child of the supplied tag. If the child is an attribute,
  * the child Node is passed to checkFields to check if the attribute
  * should be written.
  */
 	
 	private Tag analyzeAtts(Node tagNode) {
  		Node bodyContentNode;
 		Node curAtt = getNextTag(tagNode.getFirstChild(), "attribute"); // go to first attribute
 		Node curField; // the current attribute field, ie. name,required, etc...
   		Node curFieldContent; // whatever content is inside the current field
  		String curFieldText; // the text data of the curFieldContent
   		String curFieldName; // the name of the current field Node
   		String attName = UNDEFINED; // the value of the attribute's "name" field
 		String attReq = UNDEFINED; // the value of the attribute's "required" field
 		Tag thetag = new Tag();

		bodyContentNode = getNextTag(tagNode.getFirstChild(), "bodycontent"); // node containing value of bodycontent
		if (bodyContentNode == null) 
			 bodyContentNode = getNextTag(tagNode.getFirstChild(), "body-content"); // support for JSP 1.2 naming		
 		if (bodyContentNode != null) { //set bodyContent based on text contained in body content node
 			String bodyContentText = ((Text)bodyContentNode.getFirstChild()).getData(); 
 			thetag.setBodyContent(bodyContentText.toLowerCase().equals("empty") ? false : true);
 		}

 		System.out.println("Analyzing attributes...");

 		while (curAtt != null) {
 			curField = curAtt.getFirstChild();
 			
 			while (curField != null) {	// store relevent attribute fields
 				if (curField.hasChildNodes()) {
 					curFieldContent = curField.getFirstChild();
 					curFieldName = curField.getNodeName().toLowerCase();
 					curFieldText = ((Text)curFieldContent).getData();
 				
 					if (curFieldName != null && curFieldName.equals("name")) {
 						attName = curFieldText;
 					}
 				
 					else if (curFieldName != null && curFieldName.equals("required")) {
 						attReq = curFieldText;
 					}
 				}
 				curField = curField.getNextSibling();
			}
			if (attName == null | attReq == null) { 
				//tag is malformed; either <name> or <required> does not exist
			
				System.err.println("Warning - Malformed tag: " + getTagName(tagNode));
				System.err.println("<name> and <required> are required fields in TLD");
				attName = attReq = UNDEFINED;
			}
			else if (attName != UNDEFINED && attReq != UNDEFINED){					
				// add attName to the tag's atts list
				thetag.addAtt(attName);
				// if att is required, also add it to the reqAtts list
				if (attReq.toLowerCase().equals("true")) {
					thetag.reqAtts.add(attName);
				}
				System.out.println("Attribute = " + attName);
				System.out.println("Required = " + attReq);
				attName = attReq = UNDEFINED;
			}
			curAtt = curAtt.getNextSibling();
		}
		return thetag;
	}


/* method: getNextTag()
 * ----------------------
 * Takes a Node object and returns the subsequent node that the getNodeName()
 * method returns a string equal (case insensitive) to the supplied tagName.
 *
 */
 
 	private Node getNextTag(Node curField, String tagName) {
 		Node nextTag = curField.getNextSibling();
 		
 		//continue through DOM until next tag matching tagName is found
 		while (nextTag != null && 
 			!(nextTag.getNodeName().toLowerCase().equals(tagName.toLowerCase()))) 
 		{
 			nextTag = nextTag.getNextSibling();
 		}

 		return nextTag;
 	}


/* method: getTagName()
 * ----------------------	
 * Takes a tag in a TLD DOM and returns a string version of the text data
 * in the tag's <name> field.
 *
 */

	private String getTagName(Node tag) {
		Node nameTag = getNextTag(tag.getFirstChild(), "name").getFirstChild();
		return ((Text)nameTag).getData();
	}
 	

/* method: writeOutput()
 * ---------------------
 * Writes the out file(s) based on the file output mode.
 * Currently a placeholder for future output formats.
 */
 
	private void writeOutput() {
		switch(mode) {
			case ULTRADEV:
				outputForUltraDev();
				break;
			default:
				outputForUltraDev();
				break;
		}
	}

/* method: outputForUltraDev()
 * ---------------------------
 * Writes the JavaScript (.js) and HTML (.html) files necessary to
 * represent the floater to the current directory.
 */
 
 	private void outputForUltraDev() {		
  		outputTaglibData();
 	}

	
/* method: outputTaglibData()
 * --------------------------
 * Outputs the taglib's TLD data, as a series of JavaScript  
 * associative array declarations, to the HTTP response object.
 *
 */

	private void outputTaglibData() {
		Object[] tagNames = (tags.keySet().toArray());
		Arrays.sort(tagNames);
		String curName;
		Object[] attributes, reqAttributes;
		Tag curTag;
		
		out.println("taglibs[\"" + outputFilePrefix + "\"]=[");	
		for (int i = 0; i < tagNames.length; i++) {
			curName = (String)tagNames[i];
			curTag = ((Tag)tags.get(curName));
			out.print("\t[\"" + curName + "\", " + curTag.hasBodyContent() + ", [");

			reqAttributes = ((ArrayList)(curTag.getReqAtts())).toArray();
			for (int j = 0; j < reqAttributes.length; j++) {
				out.print("\"" + reqAttributes[j] + "\"");
				if (j < reqAttributes.length - 1) out.print(", ");
			}
			out.print("], [");
			
			attributes = ((ArrayList)(curTag.getAtts())).toArray();
			for (int k = 0; k < attributes.length; k++) {
				out.print("\"" + attributes[k] + "\"");
				if (k < attributes.length - 1) out.print(", ");
			}

			out.print("]");

			/* easy to add any new information... */

			if ( i >= tagNames.length - 1 ) out.println( "]];");
			else
				out.println("],");
		}		
	}
	
	
/* method: outputTLDList()
 * -----------------------
 * Sends a tab-delimited list of TLDs in the servlet's TLDs directory 
 * to the http response out stream.
 *
 */
 
	private void outputTLDList(HttpServletRequest req) {
                String tldpath = getServletConfig().getServletContext().getRealPath(PATH_TO_TLDS);
		File dir = new File(tldpath);
		String[] files = dir.list();
		
		for (int i = 0; i < files.length; i++) {
			out.print(files[i].substring(0,files[i].indexOf(".")));
			if (i < files.length - 1) out.print("\t");
		}
	}
	
	
 
/** Public Accessors **/



/* method: setOutputPrefix()
 * -----------------------
 * Sets the name of the file to be written.
 *
 */

	public void setOutputPrefix(String prefix) {
		outputFilePrefix = prefix.toLowerCase();
 	}
  	

/* method: setOutputMode()
 * -------------------------
 * Sets the output mode of the parser. Available options listed at top
 * under "Output Modes". Modify this method as output modes are added.
 *
 */

	public void setOutputMode(int outputMode) {
		if (outputMode != ULTRADEV &&
		    outputMode != OTHER) {
		    	System.err.println("Invalid output mode.");
		}
		
		else {
			mode = outputMode;
		}				
	}


/* method: getOutputMode()
 * -----------------------
 * Returns the parser's output mode.
 *
 */

	public int getOutputMode() {
		return mode;
	}
	

/* method: getResult()
 * -------------------
 * Returns the value of the result flag. True if all operations completed
 * successfully.
 */
 
	public int getResult() {
		return result;
	}
	


/* Private classes */	
	


/* class: Tag
 * ----------
 * Private wrapper class. Stores an ArrayList of attributes, an ArrayList
 * of required attributes (kept seperate for performance purposes) and a 
 * bodyContent boolean, set to true if the tag allows any body content.
 */

	private class Tag {
		private ArrayList atts = new ArrayList();
		private ArrayList reqAtts = new ArrayList();
		private boolean bodyContent;
		
		public void addAtt (String att) {
			if (att != null) {
				System.out.println("Adding attribute: " + att);
				atts.add(att);
			}
		}
		
		public void addReqAtt (String att) {
			if (att != null ) {
				reqAtts.add(att);
			}
		}
		
		public void setBodyContent(boolean bc) {
			if (bc == true || bc == false) {
				bodyContent = bc;
			}
		}

		public ArrayList getAtts () {
			return atts;
		}
		
		public ArrayList getReqAtts () {
			return reqAtts;
		}
		
		public boolean hasBodyContent() {
			return bodyContent;
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久综合色一本| 午夜精品视频在线观看| 欧美成人在线直播| 欧美日韩国产高清一区二区| 国产成人精品一区二区三区四区 | 亚洲v中文字幕| 美女视频一区二区三区| 免费观看日韩电影| 国产在线精品一区二区夜色 | 91小视频在线免费看| 99精品久久久久久| 在线看不卡av| 欧美亚洲高清一区| 精品国产污网站| 一区在线播放视频| 午夜精品在线看| 国产美女久久久久| 欧美午夜精品一区| 久久久久国产成人精品亚洲午夜| 国产精品蜜臀在线观看| 亚洲精品大片www| 狠狠色狠狠色综合系列| 国产成人自拍高清视频在线免费播放| 成人免费毛片app| 欧美日韩国产在线播放网站| 国产视频一区在线观看| 一区二区三区91| 成人av手机在线观看| 欧美精品亚洲二区| 亚洲欧美成人一区二区三区| 亚洲成av人片| 91网站最新网址| 91精品国产91综合久久蜜臀| 自拍偷拍欧美激情| 国产69精品久久99不卡| 日韩精品一区二区三区中文不卡 | 亚洲激情校园春色| 高清久久久久久| 中文欧美字幕免费| 国产成都精品91一区二区三| 日韩一级在线观看| 午夜国产精品一区| 91精品国产高清一区二区三区蜜臀 | 日韩国产精品久久久久久亚洲| 成人午夜视频在线观看| 欧美极品美女视频| 天天av天天翘天天综合网色鬼国产| av影院午夜一区| 中文字幕一区二区三区四区| 成人av网站在线观看| 国产亚洲制服色| 国产成人日日夜夜| 国产欧美日韩视频在线观看| 99亚偷拍自图区亚洲| 亚洲高清免费在线| 欧美一区二区成人6969| 亚洲一区二区欧美激情| 色老头久久综合| 理论电影国产精品| 中文字幕av一区二区三区高| 丁香六月综合激情| 亚洲人成人一区二区在线观看 | 七七婷婷婷婷精品国产| 欧美大黄免费观看| 成人蜜臀av电影| 国产精品久久久一区麻豆最新章节| 国产成人在线视频播放| 亚洲已满18点击进入久久| 在线免费观看视频一区| 国精品**一区二区三区在线蜜桃| 久久久久久久性| 91视频免费播放| 国产精品一品二品| 丁香婷婷综合色啪| 一区二区三区免费看视频| 91福利精品视频| 成人国产电影网| 麻豆91精品91久久久的内涵| 日本一区二区电影| 精品国产网站在线观看| 欧美视频日韩视频| 成人app在线观看| 激情综合网最新| 亚洲综合清纯丝袜自拍| 中文字幕一区二区三| 国产欧美一区二区在线| 欧美巨大另类极品videosbest| 日本系列欧美系列| 日本欧美大码aⅴ在线播放| 亚洲精品国产高清久久伦理二区| 久久综合久久综合九色| 678五月天丁香亚洲综合网| 这里只有精品电影| 欧美一区二区三区在线电影| 成人18精品视频| 波多野结衣中文字幕一区二区三区| 美女脱光内衣内裤视频久久影院| 热久久免费视频| 成人小视频免费在线观看| 9l国产精品久久久久麻豆| 91网页版在线| 欧美在线你懂得| 欧美日韩中字一区| 国产成人免费视频网站高清观看视频 | 久久九九久久九九| 国产精品久久久久久久久晋中| 欧美不卡视频一区| 国产亚洲一区二区三区四区| 久久美女高清视频 | 国产91高潮流白浆在线麻豆 | 亚洲男同性恋视频| 中文字幕亚洲在| 亚洲国产日韩在线一区模特| 丝袜美腿亚洲一区| 久久99精品一区二区三区| 国产大片一区二区| 欧美日韩国产中文| 国产欧美日韩精品在线| 一区二区三区不卡视频在线观看 | 99久久精品一区二区| 精品99一区二区| 日韩国产一区二| 91成人网在线| 亚洲色图一区二区| 成人理论电影网| 欧美四级电影在线观看| 中文字幕一区在线观看| 久久99热这里只有精品| 91精品国产乱码| 秋霞午夜av一区二区三区| 欧美色综合网站| 一区二区免费看| 99久久综合99久久综合网站| 91精品国产综合久久精品性色 | 蜜桃视频一区二区三区| 91久久精品一区二区| 亚洲乱码日产精品bd| 国产精品一区二区91| 91精品国产一区二区| 亚洲大片一区二区三区| 欧美日韩成人一区二区| 精品综合久久久久久8888| 欧美性猛片aaaaaaa做受| 亚洲一区二区三区爽爽爽爽爽| 国产999精品久久久久久| 91精品国产高清一区二区三区 | 国产一区二区看久久| 欧美一激情一区二区三区| 男人的天堂久久精品| 2023国产一二三区日本精品2022| 久久精品噜噜噜成人av农村| 欧美国产丝袜视频| 在线观看日韩av先锋影音电影院| 一区二区三区久久| 欧美肥胖老妇做爰| 成人av网站在线观看免费| 一区二区三区四区蜜桃| aaa欧美日韩| 秋霞电影一区二区| 亚洲综合免费观看高清完整版在线 | 日韩avvvv在线播放| 欧美激情综合五月色丁香 | 一区二区三区中文字幕电影| 精品国产一区二区三区忘忧草| 国产精品 日产精品 欧美精品| 亚洲综合一区二区| 久久久久99精品一区| 欧洲视频一区二区| 99久久综合精品| 国产一区二区女| 老司机精品视频线观看86| 亚洲一区在线免费观看| 亚洲欧洲国产日本综合| 国产精品初高中害羞小美女文| 欧美xxxxxxxx| 欧美日本精品一区二区三区| 97se亚洲国产综合自在线观| 高清av一区二区| 风间由美性色一区二区三区| 人禽交欧美网站| 韩日av一区二区| 日韩精品成人一区二区三区| 亚洲国产一区视频| 亚洲成av人片一区二区| 亚洲精品免费在线观看| 亚洲一区二区高清| 偷窥国产亚洲免费视频| 亚洲欧美欧美一区二区三区| 国产精品久久久久三级| 亚洲精品视频在线观看网站| 一区二区三区在线免费| 亚洲成人动漫一区| 久久99国产精品久久99| 韩国av一区二区| 91麻豆精东视频| 9191成人精品久久| 日韩三级.com| 亚洲人成网站色在线观看| 亚洲欧美日韩人成在线播放| 视频在线观看一区二区三区|