From b0b0b4a54c394b47aa64ce6cef12c5a8ec9e6992 Mon Sep 17 00:00:00 2001
From: kitfox
Date: Wed, 11 Apr 2007 21:22:12 +0000
Subject: Added SAX parser
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@7 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
---
build.xml | 193 +++++++++++++++++++++
lib/library/ant.jar | Bin 0 -> 999966 bytes
lib/library/javacc.jar | Bin 0 -> 378781 bytes
lib/library/junit.jar | Bin 0 -> 121070 bytes
manifest.mf | 14 ++
nbproject/private/private.xml | 4 +
nbproject/project.xml | 107 ++++++++++++
.../com/kitfox/salamander/parser/SVGParser.java | 58 +++++++
.../kitfox/salamander/parser/SVGParserAntTask.java | 98 +++++++++++
.../kitfox/salamander/parser/SVGParserHandler.java | 80 +++++++++
10 files changed, 554 insertions(+)
create mode 100755 build.xml
create mode 100755 lib/library/ant.jar
create mode 100755 lib/library/javacc.jar
create mode 100755 lib/library/junit.jar
create mode 100755 manifest.mf
create mode 100755 nbproject/private/private.xml
create mode 100755 nbproject/project.xml
create mode 100755 src/main/java/com/kitfox/salamander/parser/SVGParser.java
create mode 100755 src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java
create mode 100755 src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java
diff --git a/build.xml b/build.xml
new file mode 100755
index 0000000..967d469
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,193 @@
+
+
+
+ General 2D and 3D graphics routines
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/library/ant.jar b/lib/library/ant.jar
new file mode 100755
index 0000000..3a67607
Binary files /dev/null and b/lib/library/ant.jar differ
diff --git a/lib/library/javacc.jar b/lib/library/javacc.jar
new file mode 100755
index 0000000..5506008
Binary files /dev/null and b/lib/library/javacc.jar differ
diff --git a/lib/library/junit.jar b/lib/library/junit.jar
new file mode 100755
index 0000000..674d71e
Binary files /dev/null and b/lib/library/junit.jar differ
diff --git a/manifest.mf b/manifest.mf
new file mode 100755
index 0000000..b8c9199
--- /dev/null
+++ b/manifest.mf
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.7.0Beta3
+Created-By: 1.6.0-b105 (Sun Microsystems Inc.)
+Main-Class: com.kitfox.Main
+Built-By: kitfox
+
+Name: common
+Specification-Title: SVG Salamander
+Specification-Version: 1
+Specification-Vendor: Kitfox
+Implementation-Title: svg-salamander-core
+Implementation-Version: Version 1, Date April 11 2007
+Implementation-Vendor: Mark McKay, mark@kitfox.com
+
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100755
index 0000000..cc2c0e5
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100755
index 0000000..c074c4b
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,107 @@
+
+
+ org.netbeans.modules.ant.freeform
+
+
+
+ svg-salamander-core
+
+
+
+
+ java
+ src/main/java
+
+
+
+ java
+ src/main/res
+
+
+
+ java
+ src/test/java
+
+
+
+ java
+ src/test/res
+
+
+
+
+ build
+
+
+ clean
+
+
+ javadoc
+
+
+ run
+
+
+ checkintest
+
+
+ clean
+ build
+
+
+
+
+
+
+ src/main/java
+
+
+
+ src/main/res
+
+
+
+ src/test/java
+
+
+
+ src/test/res
+
+
+ build.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ src/main/java
+ lib/library/ant.jar;lib/library/javacc.jar;lib/library/junit.jar
+ 1.5
+
+
+ src/main/res
+ 1.5
+
+
+ src/test/java
+
+ 1.5
+
+
+ src/test/res
+
+ 1.5
+
+
+
+
diff --git a/src/main/java/com/kitfox/salamander/parser/SVGParser.java b/src/main/java/com/kitfox/salamander/parser/SVGParser.java
new file mode 100755
index 0000000..efdf6b9
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/parser/SVGParser.java
@@ -0,0 +1,58 @@
+/*
+ * SVGParser.java
+ *
+ * Created on April 11, 2007, 5:07 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.parser;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ *
+ * @author kitfox
+ */
+public class SVGParser
+{
+ public static interface SVGParserListener
+ {
+
+ }
+
+ /** Creates a new instance of SVGParser */
+ public SVGParser()
+ {
+ }
+
+ public static void parse(File source, SVGParserListener listener, boolean skipUpToDateFiles)
+ {
+ try
+ {
+ XMLReader parser;
+ parser = XMLReaderFactory.createXMLReader();
+ SVGParserHandler handler = new SVGParserHandler(listener);
+ parser.setContentHandler(handler);
+
+ InputSource is = new InputSource(new FileInputStream(source));
+ parser.parse(is);
+
+ }
+ catch (SAXException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java b/src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java
new file mode 100755
index 0000000..4c7a251
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java
@@ -0,0 +1,98 @@
+/*
+ * GraphicsCodeGenAntTask.java
+ *
+ * Created on March 3, 2007, 9:31 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import javax.imageio.ImageIO;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.FileScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+
+/**
+ * This ant task examines a directory hierarchy containing .xml files and
+ * for the XML files rooted in the GraphicsCodeGen.GRAPHICS_NS namespace,
+ * causes code generation to be run. Task will only update code that is missing
+ * or out of date to minimize processing time.
+ *
+ *
+ * <graphicsCodeGeneration>
+ * <fileset dir="${root.dir}">
+ * <include name="com/kitfox/monsters/** / *"/>
+ * </fileset>
+ * <fileset dir="${dir2}">
+ * </fileset>
+ * </graphicsCodeGeneration>
+ *
+ *
+ * @author kitfox
+ */
+public class SVGParserAntTask extends Task
+{
+// Path examinePath;
+ private ArrayList filesets = new ArrayList();
+
+
+ /** Creates a new instance of GraphicsCodeGenAntTask */
+ public SVGParserAntTask()
+ {
+ }
+
+ /**
+ * Adds a set of files.
+ */
+ public void addFileset(FileSet set)
+ {
+ filesets.add(set);
+ }
+
+ /**
+ * The examine path should be a subset of the classpath and include all the
+ * classes that should be examined for possible inclusion in the services list.
+ */
+// public Path createExaminePath() throws BuildException
+// {
+// if (examinePath == null)
+// {
+// examinePath = new Path(getProject());
+// return examinePath;
+// }
+// throw new BuildException("Only one examine path can be set");
+// }
+
+ public void execute() throws BuildException
+ {
+ /*
+ //This is necessary for ImageIO to find all pluggable image readers on the
+ // classpath
+ ImageIO.scanForPlugins();
+
+ for (FileSet fileSet: filesets)
+ {
+ FileScanner scanner = fileSet.getDirectoryScanner(getProject());
+ String[] files = scanner.getIncludedFiles();
+
+ File dir = fileSet.getDir();
+
+ for (String fileName: files)
+ {
+// if (!fileName.getName().endsWith(".xml")) continue;
+ File file = new File(dir, fileName);
+//System.err.println("*****File " + file);
+
+ //Conditionally generate code
+ GraphicsCodeGen.generateCode(file, true);
+ }
+ }
+ */
+ }
+
+}
diff --git a/src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java b/src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java
new file mode 100755
index 0000000..8119984
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java
@@ -0,0 +1,80 @@
+/*
+ * GraphicsDocumentHandler.java
+ *
+ * Created on March 3, 2007, 7:49 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.parser;
+
+import com.kitfox.salamander.parser.SVGParser.SVGParserListener;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+
+/**
+ *
+ * @author kitfox
+ */
+public class SVGParserHandler implements ContentHandler
+{
+// LinkedList nodeStack = new LinkedList();
+
+ final SVGParserListener listener;
+
+ /** Creates a new instance of GraphicsDocumentHandler */
+ public SVGParserHandler(SVGParserListener listener)
+ {
+ this.listener = listener;
+ }
+
+ public void setDocumentLocator(Locator locator)
+ {
+ }
+
+ public void startDocument() throws SAXException
+ {
+ }
+
+ public void endDocument() throws SAXException
+ {
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException
+ {
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException
+ {
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
+ {
+ }
+
+
+ public void endElement(String uri, String localName, String qName) throws SAXException
+ {
+ }
+
+ public void characters(char[] ch, int start, int length) throws SAXException
+ {
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
+ {
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException
+ {
+ }
+
+ public void skippedEntity(String name) throws SAXException
+ {
+ }
+
+}
--
cgit v1.2.3-55-g7522