[jboss-svn-commits] JBoss Common SVN: r4495 - in jbossxb/branches/split: saxparser and 17 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jun 11 11:19:11 EDT 2010
Author: alex.loubyansky at jboss.com
Date: 2010-06-11 11:19:10 -0400 (Fri, 11 Jun 2010)
New Revision: 4495
Added:
jbossxb/branches/split/saxparser/
jbossxb/branches/split/saxparser/.classpath
jbossxb/branches/split/saxparser/.project
jbossxb/branches/split/saxparser/.settings/
jbossxb/branches/split/saxparser/.settings/org.eclipse.jdt.ui.prefs
jbossxb/branches/split/saxparser/pom.xml
jbossxb/branches/split/saxparser/src/
jbossxb/branches/split/saxparser/src/main/
jbossxb/branches/split/saxparser/src/main/java/
jbossxb/branches/split/saxparser/src/main/java/org/
jbossxb/branches/split/saxparser/src/main/java/org/jboss/
jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/
jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/
jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/
jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java
jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/sax/
jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/sax/SaxJBossXBParser.java
jbossxb/branches/split/saxparser/src/main/resources/
jbossxb/branches/split/saxparser/src/test/
jbossxb/branches/split/saxparser/src/test/java/
jbossxb/branches/split/saxparser/src/test/java/org/
jbossxb/branches/split/saxparser/src/test/java/org/jboss/
jbossxb/branches/split/saxparser/src/test/java/org/jboss/test/
jbossxb/branches/split/saxparser/src/test/java/org/jboss/test/xb/
jbossxb/branches/split/saxparser/src/test/java/org/jboss/test/xb/sax/
jbossxb/branches/split/saxparser/src/test/java/org/jboss/test/xb/sax/MainTestCase.java
jbossxb/branches/split/saxparser/src/test/resources/
Log:
sax parser for xb
Added: jbossxb/branches/split/saxparser/.classpath
===================================================================
--- jbossxb/branches/split/saxparser/.classpath (rev 0)
+++ jbossxb/branches/split/saxparser/.classpath 2010-06-11 15:19:10 UTC (rev 4495)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**/*.java" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: jbossxb/branches/split/saxparser/.project
===================================================================
--- jbossxb/branches/split/saxparser/.project (rev 0)
+++ jbossxb/branches/split/saxparser/.project 2010-06-11 15:19:10 UTC (rev 4495)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jbossxb-saxparser</name>
+ <comment>JBoss XML Binding SAX parser</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: jbossxb/branches/split/saxparser/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- jbossxb/branches/split/saxparser/.settings/org.eclipse.jdt.ui.prefs (rev 0)
+++ jbossxb/branches/split/saxparser/.settings/org.eclipse.jdt.ui.prefs 2010-06-11 15:19:10 UTC (rev 4495)
@@ -0,0 +1,3 @@
+#Wed May 26 15:18:42 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
Added: jbossxb/branches/split/saxparser/pom.xml
===================================================================
--- jbossxb/branches/split/saxparser/pom.xml (rev 0)
+++ jbossxb/branches/split/saxparser/pom.xml 2010-06-11 15:19:10 UTC (rev 4495)
@@ -0,0 +1,155 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>5</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jbossxb-saxparser</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>JBoss XML Binding</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss XML Binding</description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/common/jbossxb/branches/split/jbossxb-saxparser/trunk</connection>
+ </scm>
+ <build>
+ <finalName>jbossxb-saxparser</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <!-- The tagBase property is needed during the release process so that the maven release plugin
+ will create the release tag in the appropriate location. -->
+ <tagBase>https://svn.jboss.org/repos/common/jbossxb/tags</tagBase>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- the tessuite will be run twice.
+ the first/default execution will run with the default xb configuration
+ if there are failures, the next execution won't be run -->
+ <testFailureIgnore>false</testFailureIgnore>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <excludes>
+ <exclude>org/jboss/test/xml/RepeatedElementsUnitTestCase.java</exclude> <!-- JBXB-88 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertyAllUnmarshallingTestCase.java</exclude> <!-- JBXB-193 -->
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <!-- this execution will run with xb.builder.useUnorderedSequence=true
+ the reports from the previous testsuite run will be overriden
+ which is ok, since if the previous execution fails, this execution shouldn't start -->
+ <id>unordered-sequence-true-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testFailureIgnore>false</testFailureIgnore>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <excludes>
+ <exclude>org/jboss/test/xml/RepeatedElementsUnitTestCase.java</exclude> <!-- JBXB-88 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertyAllUnmarshallingTestCase.java</exclude> <!-- JBXB-193 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertySequenceUnmarshallingTestCase.java</exclude> <!-- unordered sequence makes it JBXB-193 -->
+ <exclude>org/jboss/test/xb/builder/repeatableterms/test/RepeatableTermsUnitTestCase.java</exclude>
+
+ <!-- below are the tests that don't depend on the setting -->
+ <exclude>org/jboss/test/xb/validator/test/BasicBindingValidatorUnitTestCase.java</exclude>
+ </excludes>
+ <systemProperties>
+ <property>
+ <name>xb.builder.useUnorderedSequence</name>
+ <value>true</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ <execution>
+ <!-- this execution will run with xb.builder.repeatableParticleHandlers=false -->
+ <id>repeatable-handlers-false-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testFailureIgnore>false</testFailureIgnore>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <excludes>
+ <exclude>org/jboss/test/xml/RepeatedElementsUnitTestCase.java</exclude> <!-- JBXB-88 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertyAllUnmarshallingTestCase.java</exclude> <!-- JBXB-193 -->
+ <!-- below are the tests that don't depend on the setting -->
+ <exclude>org/jboss/test/xb/validator/test/BasicBindingValidatorUnitTestCase.java</exclude>
+ </excludes>
+ <systemProperties>
+ <property>
+ <name>xb.builder.repeatableParticleHandlers</name>
+ <value>false</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb-core</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb-core</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>1.1.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
\ No newline at end of file
Added: jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java
===================================================================
--- jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java (rev 0)
+++ jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java 2010-06-11 15:19:10 UTC (rev 4495)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.xb.binding.parser;
+
+import org.jboss.xb.binding.parser.sax.SaxJBossXBParser;
+
+/**
+ * A JBossXBParserFactoryImpl.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossXBParserFactoryImpl implements JBossXBParserFactory
+{
+ @Override
+ public JBossXBParser createParser()
+ {
+ return new SaxJBossXBParser();
+ }
+}
Added: jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/sax/SaxJBossXBParser.java
===================================================================
--- jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/sax/SaxJBossXBParser.java (rev 0)
+++ jbossxb/branches/split/saxparser/src/main/java/org/jboss/xb/binding/parser/sax/SaxJBossXBParser.java 2010-06-11 15:19:10 UTC (rev 4495)
@@ -0,0 +1,432 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.xb.binding.parser.sax;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.JBossXBRuntimeException;
+import org.jboss.xb.binding.parser.JBossXBParser;
+import org.xml.sax.Attributes;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+
+/**
+ * A SaxJBossXBParser.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class SaxJBossXBParser implements JBossXBParser, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, ErrorHandler
+{
+ private static final Logger log = Logger.getLogger("org.jboss.xb.binding.parser.sax.SaxJBossXBParser");
+
+ private static final SAXParserFactory saxFactory = SAXParserFactory.newInstance();
+ static
+ {
+ saxFactory.setValidating(true);
+ saxFactory.setNamespaceAware(true);
+
+ try
+ {
+ saxFactory.setXIncludeAware(true);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ log.trace("setXIncludeAware is not supported by the SAXParserFactory", e);
+ }
+ }
+
+ private final SAXParser parser;
+ private final XMLReader reader;
+ private JBossXBParser.ContentHandler contentHandler;
+ private boolean trace;
+
+ public SaxJBossXBParser()
+ throws JBossXBRuntimeException
+ {
+ trace = log.isTraceEnabled();
+ try
+ {
+ parser = saxFactory.newSAXParser();
+ reader = parser.getXMLReader();
+ }
+ catch(Exception e)
+ {
+ throw new JBossXBRuntimeException("Failed to create a new SAX parser", e);
+ }
+
+ reader.setContentHandler(this);
+ reader.setErrorHandler(this);
+
+ reader.setEntityResolver(
+ new EntityResolver()
+ {
+ private EntityResolver delegate;
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ if(delegate == null)
+ delegate = new JBossEntityResolver();
+ return delegate.resolveEntity(publicId, systemId);
+ }
+ }
+ );
+
+ // LexicalHandler
+ try
+ {
+ reader.setProperty("http://xml.org/sax/properties/lexical-handler", this);
+ }
+ catch(Exception e)
+ {
+ log.trace("LexicalHandler", e);
+ }
+
+/*
+ setFeature(Unmarshaller.VALIDATION, true);
+ setFeature(Unmarshaller.SCHEMA_VALIDATION, true);
+ setFeature(Unmarshaller.SCHEMA_FULL_CHECKING, true);
+ setFeature(Unmarshaller.DYNAMIC_VALIDATION, true);
+ setFeature(Unmarshaller.NAMESPACES, true);
+*/
+ }
+
+ // JBossXBParser implementation
+
+ public void setEntityResolver(EntityResolver entityResolver)
+ throws JBossXBException
+ {
+ reader.setEntityResolver(entityResolver);
+ }
+
+ public void setProperty(String name, Object value)
+ {
+ try
+ {
+ reader.setProperty(name, value);
+ }
+ catch(SAXException e)
+ {
+ throw new JBossXBRuntimeException("Failed to set property on the XML reader", e);
+ }
+ }
+
+ public void setFeature(String name, boolean value)
+ {
+ try
+ {
+ reader.setFeature(name, value);
+ if(trace)
+ log.trace(name+" set to: "+reader.getFeature(name));
+ }
+ catch(SAXException e)
+ {
+ throw new JBossXBRuntimeException("Failed to set feature on the XMLReader", e);
+ }
+ }
+
+ public void parse(String systemId, ContentHandler handler) throws JBossXBException
+ {
+ this.contentHandler = handler;
+ if(trace)
+ logParserInfo();
+
+ try
+ {
+ reader.parse(systemId);
+ }
+ catch(Throwable e)
+ {
+ throw new JBossXBException("Failed to parse source: " + getLocationAsString(systemId), e);
+ }
+ }
+
+ public void parse(InputStream is, ContentHandler handler) throws JBossXBException
+ {
+ parse(new InputSource(is), handler);
+ }
+
+ public void parse(Reader reader, ContentHandler handler) throws JBossXBException
+ {
+ parse(new InputSource(reader), handler);
+ }
+
+ public void parse(InputSource source, ContentHandler handler) throws JBossXBException
+ {
+ this.contentHandler = handler;
+ if(trace)
+ logParserInfo();
+
+ try
+ {
+ reader.parse(source);
+ }
+ catch(Throwable e)
+ {
+ String str;
+ if(locator != null)
+ str = getLocationAsString(null);
+ else if(source.getSystemId() != null)
+ str = source.getSystemId();
+ else if(source.getByteStream() != null)
+ str = source.getByteStream().toString();
+ else if(source.getCharacterStream() != null)
+ str = source.getCharacterStream().toString();
+ else
+ str = "";
+ throw new JBossXBException("Failed to parse source: " + str, e);
+ }
+ }
+
+ public String getLocationAsString(String fileName)
+ {
+ if (locator == null)
+ return fileName;
+ else
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ String id = locator.getSystemId();
+ if (id == null)
+ id = locator.getPublicId();
+ if (id == null)
+ id = "xml_stream";
+ buffer.append(id).append('@');
+ buffer.append(locator.getLineNumber());
+ buffer.append(',');
+ buffer.append(locator.getColumnNumber());
+ return buffer.toString();
+ }
+ }
+
+ private void logParserInfo()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Created parser: ").append(parser)
+ .append(", isNamespaceAware: ").append(parser.isNamespaceAware())
+ .append(", isValidating: ").append(parser.isValidating())
+ .append(", isXIncludeAware: ");
+ try
+ {
+ sb.append(parser.isXIncludeAware());
+ }
+ catch(UnsupportedOperationException e)
+ {
+ sb.append("unsupported operation '").append(e.getMessage()).append('\'');
+ }
+ log.trace(sb.toString());
+ }
+
+ // LexicalHandler
+ private Locator locator;
+
+ public void comment(char[] ch, int start, int length) throws SAXException
+ {
+ }
+
+ public void startDTD(String name, String publicId, String systemId) throws SAXException
+ {
+ if (contentHandler instanceof DtdAwareContentHandler)
+ {
+ DtdAwareContentHandler dach = (DtdAwareContentHandler) contentHandler;
+ dach.startDTD(name, publicId, systemId);
+ }
+ }
+
+ public void endDTD() throws SAXException
+ {
+ if (contentHandler instanceof DtdAwareContentHandler)
+ {
+ DtdAwareContentHandler dach = (DtdAwareContentHandler) contentHandler;
+ dach.endDTD();
+ }
+ }
+
+ public void startEntity(String name) throws SAXException
+ {
+ }
+
+ public void endEntity(String name) throws SAXException
+ {
+ }
+
+ public void startCDATA() throws SAXException
+ {
+ }
+
+ public void endCDATA() throws SAXException
+ {
+ }
+
+ // ContentHandler
+
+ public void endDocument()
+ {
+ }
+
+ public void startDocument()
+ {
+ }
+
+ public void characters(char ch[], int start, int length)
+ {
+ // todo look at this later
+ // do not notify content handler if these are just whitespaces
+ //int i = start;
+ //while(i < start + length)
+ //{
+ // if(!Character.isWhitespace(ch[i++]))
+ // {
+ contentHandler.characters(ch, start, length);
+ // break;
+ // }
+ //}
+ }
+
+ public void ignorableWhitespace(char ch[], int start, int length)
+ {
+ }
+
+ public void endPrefixMapping(String prefix)
+ {
+ contentHandler.endPrefixMapping(prefix);
+ }
+
+ public void skippedEntity(String name)
+ {
+ }
+
+ public Locator getDocumentLocator()
+ {
+ return locator;
+ }
+
+ public void setDocumentLocator(Locator locator)
+ {
+ this.locator = locator;
+ }
+
+ public void processingInstruction(String target, String data)
+ {
+ contentHandler.processingInstruction(target, data);
+ }
+
+ public void startPrefixMapping(String prefix, String uri)
+ {
+ contentHandler.startPrefixMapping(prefix, uri);
+ }
+
+ public void endElement(String namespaceURI, String localName, String qName)
+ {
+ if (trace)
+ {
+ String name = localName.length() == 0 ? qName : namespaceURI + ':' + localName;
+ log.trace("Enter endElement " + name);
+ try
+ {
+ contentHandler.endElement(namespaceURI, localName, qName);
+ }
+ finally
+ {
+ log.trace("Exit endElement " + name);
+ }
+ }
+ else
+ contentHandler.endElement(namespaceURI, localName, qName);
+ }
+
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
+ {
+ if (trace)
+ {
+ String name = localName.length() == 0 ? qName : namespaceURI + ':' + localName;
+ log.trace("Enter startElement " + name);
+
+ try
+ {
+ contentHandler.startElement(namespaceURI, localName, qName, atts);
+ }
+ finally
+ {
+ log.trace("Exit startElement " + name);
+ }
+ }
+ else
+ contentHandler.startElement(namespaceURI, localName, qName, atts);
+ }
+
+ // Error handling
+
+ public void warning(SAXParseException exception)
+ {
+ log.warn(formatMessage(exception));
+ }
+
+ public void error(SAXParseException exception) throws SAXException
+ {
+ throw new SAXException(formatMessage(exception));
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException
+ {
+ throw new SAXException(formatMessage(exception));
+ }
+
+ public String formatMessage(SAXParseException exception)
+ {
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append(exception.getMessage()).append(" @ ");
+ String location = exception.getPublicId();
+ if (location != null)
+ {
+ buffer.append(location);
+ }
+ else
+ {
+ location = exception.getSystemId();
+ if (location != null)
+ {
+ buffer.append(location);
+ }
+ else
+ {
+ buffer.append("*unknown*");
+ }
+ }
+ buffer.append('[');
+ buffer.append(exception.getLineNumber()).append(',');
+ buffer.append(exception.getColumnNumber()).append(']');
+ return buffer.toString();
+ }
+}
Added: jbossxb/branches/split/saxparser/src/test/java/org/jboss/test/xb/sax/MainTestCase.java
===================================================================
--- jbossxb/branches/split/saxparser/src/test/java/org/jboss/test/xb/sax/MainTestCase.java (rev 0)
+++ jbossxb/branches/split/saxparser/src/test/java/org/jboss/test/xb/sax/MainTestCase.java 2010-06-11 15:19:10 UTC (rev 4495)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.xb.sax;
+
+
+import org.jboss.test.xb.XbTestSuite;
+import org.jboss.test.xb.builder.BuilderTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+
+/**
+ * A MainTestSuite.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainTestCase extends TestCase
+{
+ public static Test suite()
+ {
+ return XbTestSuite.suite();
+ }
+}
More information about the jboss-svn-commits
mailing list