![JAR search and dependency download from the Maven repository](/logo.png)
org.fife.rsta.ac.jsp.TldFile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of languagesupport Show documentation
Show all versions of languagesupport Show documentation
A library adding code completion and other advanced features for Java, JavaScript, Perl, and other languages to RSyntaxTextArea.
The newest version!
/*
* 07/05/2011
*
* Copyright (C) 2011 Robert Futrell
* robert_futrell at users.sourceforge.net
* http://fifesoft.com/rsyntaxtextarea
*
* This library is distributed under a modified BSD license. See the included
* LICENSE.md file for details.
*/
package org.fife.rsta.ac.jsp;
import java.io.*;
import java.util.*;
import java.util.jar.*;
import javax.xml.parsers.*;
import org.fife.rsta.ac.jsp.TldAttribute.TldAttributeParam;
import org.fife.ui.autocomplete.ParameterizedCompletion.Parameter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
/**
* A TLD.
*
* @author Robert Futrell
* @version 1.0
*/
public class TldFile {
private JspCompletionProvider provider;
private File jar;
private List tldElems;
public TldFile(JspCompletionProvider provider, File jar)
throws IOException {
this.provider = provider;
this.jar = jar;
tldElems = loadTldElems();
}
/**
* Returns the attributes for a tag.
*
* @param tagName The tag to look up.
* @return The attributes for the tag, or {@code null} if none.
*/
public List getAttributesForTag(String tagName) {
for (TldElement elem : tldElems) {
if (elem.getName().equals(tagName)) {
return elem.getAttributes();
}
}
return null;
}
private String getChildText(Node elem) {
StringBuilder sb = new StringBuilder();
NodeList children = elem.getChildNodes();
for (int i=0; i loadTldElems() throws IOException {
JarFile jar = new JarFile(this.jar);
List elems = null;
Enumeration entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.getName().endsWith("tld")) {
//System.out.println(entry.getName());
InputStream in = jar.getInputStream(entry);
elems = parseTld(in);
/*
for (int i=0; i parseTld(InputStream in) throws IOException {
List tldElems = new ArrayList<>();
BufferedInputStream bin = new BufferedInputStream(in);
//BufferedReader r = new BufferedReader(new InputStreamReader(bin));
//String line = null;
//while ((line=r.readLine())!=null) {
// System.out.println(line);
//}
//r.close();
//System.exit(0);
Document doc;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(bin);
} catch (Exception e) {
throw new IOException(e.getMessage());
}
Element root = doc.getDocumentElement(); // taglib
NodeList nl = root.getElementsByTagName("uri");
if (nl.getLength()!=1) {
throw new IOException("Expected 1 'uri' tag; found: " + nl.getLength());
}
//String uri = getChildText(nl.item(0));
//System.out.println("URI: " + uri);
nl = root.getElementsByTagName("tag");
for (int i=0; i attrs =
new ArrayList<>(attrNl.getLength());
for (int j=0; j
© 2015 - 2025 Weber Informatics LLC | Privacy Policy