Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Created on Feb 26, 2004
*
* The MIT License
* Copyright (c) 2004 Rob Rohan
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package cfml.dictionary;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
/**
* @author Rob
*
* Base class for dictionaries.
*
* The syntax dictionary keeps a name/object map of the tags and functions defined in the dictionary. It
* provides the methods for gaining access to the dictionary's defined functions & tags, plus access to the
* attributes that belong to a tag.
*
* I think, in future, the acces to the attributes should be done on an per-attribute basis, not gained from the
* syntax dictionary.
*
*/
public abstract class SyntaxDictionary {
/** any tag based items in the dictionary */
protected Map syntaxelements;
/** any function based elements */
protected Map functions;
/** any scope variables including user defined components */
protected Map scopeVars;
/** any scope variables */
protected Map scopes;
/** the file name for this dictionary */
protected String dictionaryURL = null;
public SyntaxDictionary() {
syntaxelements = new HashMap();
functions = new HashMap();
scopeVars = new HashMap();
scopes = new HashMap();
}
/**
* loads the xml dictionary "filename" into this object. Note: if this dictionary already has tags defined the new
* items will be added to this dictionary (not replaced)
*
* @param url
*/
public void loadDictionary(String url) {
setURL(url);
try {
loadDictionary();
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
public void setURL(String url) {
this.dictionaryURL = url;
}
/**
* get all top level language elements (tags)(in lowercase) these are the keys used in the tag HashMap not
* the tag objects them selves
*
* @return set of all the tag names using the keys
*/
public Set getAllElements() {
return syntaxelements.keySet();
}
/**
* gets a set that is a copy of all the tags
*
* @return a set of all the tag objects
*/
public Set getAllTags() {
Set total = new HashSet();
Set keys = getAllElements();
if (keys == null) {
return total;
}
Iterator it = keys.iterator();
while (it.hasNext()) {
total.add((Tag) syntaxelements.get((String) it.next()));
}
return total;
}
/**
* gets a set of all the function objects in this dictionary
*
* @return a set of all the tag objects
*/
public Set getAllFunctions() {
Set total = new HashSet();
Set keys = getFunctions();
Iterator it = keys.iterator();
while (it.hasNext()) {
total.add((Function) functions.get(it.next()));
}
return total;
}
/**
* gets a set that is a copy of all the scopes
*
* @return a set of all the scope objects
*/
public Set