summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/salamander/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/salamander/parser')
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/parser/SVGParser.java96
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java98
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/parser/SVGParserHandler.java80
3 files changed, 0 insertions, 274 deletions
diff --git a/src/main/java/com/kitfox/salamander/parser/SVGParser.java b/src/main/java/com/kitfox/salamander/parser/SVGParser.java
deleted file mode 100755
index d588b08..0000000
--- a/src/main/java/com/kitfox/salamander/parser/SVGParser.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-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()
- {
- }
-
- /**
- * Parse an SVG document. The document may be either uncompressed XML (.svg)
- * or a zipped document (.svgz). This routine will automatically detect
- * zipped documents and unzip them.
- */
- public static void parse(File source, SVGParserListener listener)
- {
- try
- {
- XMLReader parser;
- parser = XMLReaderFactory.createXMLReader();
- SVGParserHandler handler = new SVGParserHandler(listener);
- parser.setContentHandler(handler);
-
- FileInputStream fis = new FileInputStream(source);
- BufferedInputStream bis = new BufferedInputStream(fis);
- bis.mark(4);
- //Check for gzip magic number
- DataInputStream din = new DataInputStream(bis);
- long magicNumber = din.readLong();
- bis.reset();
-
- InputStream svgStream;
- if ((int)magicNumber == 0x4b50)
- {
- //PK Zip file
- ZipInputStream zin = new ZipInputStream(bis);
- ZipEntry entry = zin.getNextEntry();
- byte[] buf = new byte[(int)entry.getSize()];
- for (int offset = 0; offset < buf.length; offset += zin.read(buf, offset, buf.length - offset));
- zin.closeEntry();
- zin.close();
-
- svgStream = new ByteArrayInputStream(buf);
- }
- else
- {
- //Treat input as uncompressed XML
- svgStream = bis;
- }
-
- InputSource is = new InputSource(svgStream);
- 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
deleted file mode 100755
index 4c7a251..0000000
--- a/src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.
- *
- * <code>
- * &lt;graphicsCodeGeneration&gt;
- * &lt;fileset dir="${root.dir}"&gt;
- * &lt;include name="com/kitfox/monsters/** / *"/&gt;
- * &lt;/fileset&gt;
- * &lt;fileset dir="${dir2}"&gt;
- * &lt;/fileset&gt;
- * &lt;/graphicsCodeGeneration&gt;
- * </code>
- *
- * @author kitfox
- */
-public class SVGParserAntTask extends Task
-{
-// Path examinePath;
- private ArrayList<FileSet> filesets = new ArrayList<FileSet>();
-
-
- /** 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
deleted file mode 100755
index 8119984..0000000
--- a/src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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<CodeGenNode> nodeStack = new LinkedList<CodeGenNode>();
-
- 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
- {
- }
-
-}