sboag 00/10/12 19:33:19
Modified: java Makefile build.xml
java/samples/ApplyXPath ApplyXPath.java
java/samples/Pipe Pipe.java
java/samples/SAX2SAX SAX2SAX.java
java/samples/SimpleTransform SimpleTransform.java
java/samples/TransformToDom TransformToDom.java
java/samples/UseStylesheetParam UseStylesheetParam.java
java/samples/extensions SimpleRedirect.java
java/samples/servlet ApplyXSLT.java
DefaultApplyXSLTProperties.java
java/src makecompat makexslt4j
java/src/org/apache/xalan/client XSLTProcessorApplet.java
java/src/org/apache/xalan/lib Redirect.java
java/src/org/apache/xalan/processor
CompilingStylesheetHandler.java
CompilingStylesheetProcessor.java
ProcessorImport.java ProcessorInclude.java
ProcessorOutputElem.java StylesheetHandler.java
StylesheetProcessor.java
java/src/org/apache/xalan/stree SourceTreeHandler.java
java/src/org/apache/xalan/templates ElemTemplateElement.java
FuncDocument.java FuncFormatNumb.java
OutputFormatExtended.java StylesheetComposed.java
StylesheetRoot.java
java/src/org/apache/xalan/transformer MsgMgr.java
ResultTreeHandler.java SerializerSwitcher.java
TransformState.java TransformerImpl.java
java/src/org/apache/xalan/utils QName.java TreeWalker.java
java/src/org/apache/xalan/xpath/xml
ProblemListenerDefault.java
java/src/org/apache/xalan/xslt Process.java
StylesheetHandler.java StylesheetRoot.java
XSLProcessorContext.java XSLTEngineImpl.java
XSLTProcessor.java XSLTProcessorFactory.java
XSLTResultTarget.java
java/src/org/apache/xml/serialize/transition
BaseMarkupSerializer.java HTMLSerializer.java
IndentPrinter.java LineSeparator.java Method.java
Printer.java SerializerFactoryImpl.java
TextSerializer.java XHTMLSerializer.java
XMLSerializer.java
java/src/org/apache/xpath Expression.java
SourceTreeManager.java XPath.java XPathContext.java
java/src/org/apache/xpath/compiler Compiler.java
XPathParser.java
Added: java/src/org/apache/serialize DOMSerializer.java Method.java
OutputFormat.java QName.java Serializer.java
SerializerFactory.java SerializerHandler.java
package.html serializer.properties
java/src/org/apache/serialize/helpers HTMLOutputFormat.java
TextOutputFormat.java XHTMLOutputFormat.java
XMLOutputFormat.java
java/src/org/apache/trax Examples.java Processor.java
ProcessorException.java
ProcessorFactoryException.java Result.java
Templates.java TemplatesBuilder.java
TransformException.java Transformer.java
URIResolver.java package.html patterns.xml
patterns.xsl trax.properties
java/src/org/apache/xalan/utils/synthetic Class.java
JavaUtils.java SynthesisException.java
TestDriver.java
java/src/org/apache/xalan/utils/synthetic/reflection
Constructor.java EntryPoint.java Field.java
Member.java Method.java
Log:
Moved trax.* to org.apache.trax.*
Moved serialized.* to org.apache.serialize.*
Moved synthetic.* to org.apache.xalan.utils.synthetic.*
Updated makefiles, antfile, samples (though I didn't test the samples...)
Revision Changes Path
1.5 +3 -3 xml-xalan/java/Makefile
Index: Makefile
===================================================================
RCS file: /home/cvs/xml-xalan/java/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Makefile 2000/10/09 23:25:14 1.4
+++ Makefile 2000/10/13 02:33:02 1.5
@@ -52,11 +52,11 @@
PROPPATH = org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)res
$(JARNAME)::
$(CP) src/$(PROPPATH)/*.properties src/$(CLASS_DIR)/$(PROPPATH)/.; \
- $(CP) src/serialize/*.properties src/$(CLASS_DIR)/serialize/.; \
+ $(CP) src/org/apache/serialize/*.properties
src/$(CLASS_DIR)/org/apache/serialize/.; \
$(CP) src/org/apache/xml/serialize/transition/*.res
src/$(CLASS_DIR)/org/apache/xml/serialize/transition/.; \
- $(CP) src/trax/*.properties src/$(CLASS_DIR)/trax/.; \
+ $(CP) src/org/apache/trax/*.properties
src/$(CLASS_DIR)/org/apache/trax/.; \
echo -n "Jarring ../bin/$@ .. "; \
- cd src/$(CLASS_DIR); $(JAR) $(JARFLAGS) ../../bin/$@ org trax serialize
synthetic; \
+ cd src/$(CLASS_DIR); $(JAR) $(JARFLAGS) ../../bin/$@ org; \
echo "done"
compatjars:
1.28 +7 -7 xml-xalan/java/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xalan/java/build.xml,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- build.xml 2000/10/11 14:38:34 1.27
+++ build.xml 2000/10/13 02:33:02 1.28
@@ -40,7 +40,7 @@
- Much of this file stolen from Stefano's xml-xerces build.xml
- $Id: build.xml,v 1.27 2000/10/11 14:38:34 dleslie Exp $
+ $Id: build.xml,v 1.28 2000/10/13 02:33:02 sboag Exp $
==================================================================== -->
@@ -60,8 +60,8 @@
<property name="src.dir" value="./src"/>
<property name="xpath.reldir" value="org/apache/xpath"/>
<property name="xalan.reldir" value="org/apache/xalan"/>
- <property name="trax.reldir" value="trax"/>
- <property name="serialize.reldir" value="serialize"/>
+ <property name="trax.reldir" value="org/apache/trax"/>
+ <property name="serialize.reldir" value="org/apache/serialize"/>
<property name="serializer.reldir"
value="org/apache/xml/serialize/transition"/>
<property name="jaxp.reldir" value="javax/xml/parsers"/>
<property name="sax.reldir" value="org/xml/sax"/>
@@ -267,9 +267,9 @@
<!-- generate patterns.html, a TRaX "patterns design" document -->
<java fork="yes" classname="org.apache.xalan.xslt.Process"
classpath="${java.class.path}:${build.dir}/${xalan.jar}"
- args="-in ${src.dir}/trax/patterns.xml
+ args="-in ${src.dir}/org/apache/trax/patterns.xml
-xsl ${xdocs.style}/stylesheets/patterns.xsl
- -out ${build.apidocs}/trax/patterns.html"/> <!-- patterns.html
TRaX desing document -->
+ -out ${build.apidocs}/org/apache/trax/patterns.html"/> <!--
patterns.html TRaX desing document -->
<copyfile src="./xdocs/sources/xalan/trax.gif"
dest="${build.apidocs}/trax/trax.gif"/>
<javadoc
@@ -277,8 +277,8 @@
doclet="xalanjdoc.Standard"
sourcepath="${src.dir}"
overview="${src.dir}/javadocOverview.html"
-
packagenames="org.apache.xalan.client,org.apache.xalan.extensions,org.apache.xalan.lib,org.apache.xalan.lib.sql,org.apache.xalan.processor,org.apache.xalan.res,org.apache.xalan.stree,org.apache.xalan.templates,org.apache.xalan.trace,org.apache.xalan.transformer,org.apache.xalan.utils,org.apache.xpath,org.apache.xpath.axes,org.apache.xpath.compiler,org.apache.xpath.functions,org.apache.xpath.objects,org.apache.xpath.operations,org.apache.xpath.patterns,org.apache.xpath.res,org.w3c.xslt,serialize,serialize.helpers,org.apache.xml.serialize.transition,trax,org.xml.sax,org.xml.sax.helpers,org.w3c.dom,org.w3c.dom.range,org.w3c.dom.traversal,javax.xml.parsers"
- group="TrAX trax,Xalan_Core
org.apache.xalan.processor:org.apache.xalan.templates:org.apache.xalan.transformer,XPath
org.apache.xpath*:org.w3c.xslt,Xalan_Other
org.apache.xalan.client:org.apache.xalan.dtm:org.apache.xalan.extensions:org.apache.xalan.res:org.apache.xalan.stree:org.apache.xalan.trace:org.apache.xalan.utils,Xalan_Extensions
org.apache.xalan.lib*,Serializers
serialize*:org.apache.xml.serialize.transition,SAX_2 org.xml.sax*,DOM_2
org.w3c.dom*,XML_PARSING javax.xml.parsers"
+
packagenames="org.apache.xalan.client,org.apache.xalan.extensions,org.apache.xalan.lib,org.apache.xalan.lib.sql,org.apache.xalan.processor,org.apache.xalan.res,org.apache.xalan.stree,org.apache.xalan.templates,org.apache.xalan.trace,org.apache.xalan.transformer,org.apache.xalan.utils,org.apache.xpath,org.apache.xpath.axes,org.apache.xpath.compiler,org.apache.xpath.functions,org.apache.xpath.objects,org.apache.xpath.operations,org.apache.xpath.patterns,org.apache.xpath.res,org.w3c.xslt,org.apache.serialize,org.apache.serialize.helpers,org.apache.xml.serialize.transition,org.apache.trax,org.xml.sax,org.xml.sax.helpers,org.w3c.dom,org.w3c.dom.range,org.w3c.dom.traversal,javax.xml.parsers"
+ group="TrAX org.apache.trax,Xalan_Core
org.apache.xalan.processor:org.apache.xalan.templates:org.apache.xalan.transformer,XPath
org.apache.xpath*:org.w3c.xslt,Xalan_Other
org.apache.xalan.client:org.apache.xalan.dtm:org.apache.xalan.extensions:org.apache.xalan.res:org.apache.xalan.stree:org.apache.xalan.trace:org.apache.xalan.utils,Xalan_Extensions
org.apache.xalan.lib*,Serializers
org.apache.serialize*:org.apache.xml.serialize.transition,SAX_2
org.xml.sax*,DOM_2 org.w3c.dom*,XML_PARSING javax.xml.parsers"
destdir="${build.apidocs}"
author="true"
version="true"
1.5 +5 -5 xml-xalan/java/samples/ApplyXPath/ApplyXPath.java
Index: ApplyXPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/ApplyXPath/ApplyXPath.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ApplyXPath.java 2000/10/05 02:55:54 1.4
+++ ApplyXPath.java 2000/10/13 02:33:03 1.5
@@ -79,11 +79,11 @@
import javax.xml.parsers.ParserConfigurationException;
// Imported Serializer classes
-import serialize.OutputFormat;
-import serialize.Serializer;
-import serialize.SerializerFactory;
-import org.apache.xml.serialize.transition.XMLSerializer;
-import org.apache.xml.serialize.transition.TextSerializer;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.Serializer;
+import org.apache.serialize.SerializerFactory;
+import org.apache.xml.org.apache.serialize.transition.XMLSerializer;
+import org.apache.xml.org.apache.serialize.transition.TextSerializer;
/**
* Very basic utility for applying an XPath epxression to an xml file and
printing information
1.3 +7 -7 xml-xalan/java/samples/Pipe/Pipe.java
Index: Pipe.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/Pipe/Pipe.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Pipe.java 2000/09/28 12:48:41 1.2
+++ Pipe.java 2000/10/13 02:33:03 1.3
@@ -56,13 +56,13 @@
*/
// Imported TraX classes
-import trax.Processor;
-import trax.Templates;
-import trax.Transformer;
-import trax.Result;
-import trax.ProcessorException;
-import trax.ProcessorFactoryException;
-import trax.TransformException;
+import org.apache.trax.Processor;
+import org.apache.trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Result;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.TransformException;
// Imported SAX classes
import org.xml.sax.InputSource;
1.2 +8 -8 xml-xalan/java/samples/SAX2SAX/SAX2SAX.java
Index: SAX2SAX.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/SAX2SAX/SAX2SAX.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SAX2SAX.java 2000/08/28 17:33:22 1.1
+++ SAX2SAX.java 2000/10/13 02:33:03 1.2
@@ -61,14 +61,14 @@
* stylesheet, the XML input, and the transformation.
*/
-import trax.Processor;
-import trax.TemplatesBuilder;
-import trax.Templates;
-import trax.Transformer;
-import trax.Result;
-import trax.ProcessorException;
-import trax.ProcessorFactoryException;
-import trax.TransformException;
+import org.apache.trax.Processor;
+import org.apache.trax.TemplatesBuilder;
+import org.apache.trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Result;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.TransformException;
import org.xml.sax.XMLReader;
import org.xml.sax.ContentHandler;
1.2 +11 -11
xml-xalan/java/samples/SimpleTransform/SimpleTransform.java
Index: SimpleTransform.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/samples/SimpleTransform/SimpleTransform.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleTransform.java 2000/07/27 14:32:46 1.1
+++ SimpleTransform.java 2000/10/13 02:33:04 1.2
@@ -55,13 +55,13 @@
* <http://www.apache.org/>.
*/
// Imported TraX classes
-import trax.Processor;
-import trax.Templates;
-import trax.Transformer;
-import trax.Result;
-import trax.ProcessorException;
-import trax.ProcessorFactoryException;
-import trax.TransformException;
+import org.apache.trax.Processor;
+import org.apache.trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Result;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.TransformException;
// Imported SAX classes
@@ -82,8 +82,8 @@
throws ProcessorException, ProcessorFactoryException,
TransformException, SAXException, IOException
{
- // Instantiate a stylesheet processor. The trax.Processor newInstance()
- // method with "xslt" as the argument reads the trax.processor.xslt
+ // Instantiate a stylesheet processor. The org.apache.trax.Processor
newInstance()
+ // method with "xslt" as the argument reads the
org.apache.trax.processor.xslt
// system property to determine the actual class to instantiate:
// org.apache.xalan.processor.StylesheetProcessor.
Processor processor = Processor.newInstance("xslt");
@@ -91,7 +91,7 @@
// Use the stylesheet processor to process the stylesheet (foo.xsl) and
// return a Templates object. As implemented by StylesheetProcessor,
// the process() method uses the Xerces SAX processor to parse the
stylesheet
- // and returns a StylesheetRoot (an implementation of the
trax.Templates interface)
+ // and returns a StylesheetRoot (an implementation of the
org.apache.trax.Templates interface)
// from the ContentHandler for the SAX processor. The Templates
(StylesheetRoot)
// object contains an XSLT schema and the stylesheet data.
Templates templates = processor.process(new InputSource("foo.xsl"));
@@ -99,7 +99,7 @@
// Use the Templates object to generate a Transformer object. As
implemented by
// StylesheetRoot, newTransformer() returns an instance of
// org.apache.xalan.transformer.Transformer, an implementation of the
- // trax.Transformer interface.
+ // org.apache.trax.Transformer interface.
Transformer transformer = templates.newTransformer();
// Use the transformer to apply the Templates (StylesheetRoot) object
to an XML document
1.4 +7 -7 xml-xalan/java/samples/TransformToDom/TransformToDom.java
Index: TransformToDom.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/samples/TransformToDom/TransformToDom.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransformToDom.java 2000/10/05 20:32:43 1.3
+++ TransformToDom.java 2000/10/13 02:33:04 1.4
@@ -56,13 +56,13 @@
*/
// Imported TraX classes
-import trax.Processor;
-import trax.Templates;
-import trax.Transformer;
-import trax.Result;
-import trax.ProcessorException;
-import trax.ProcessorFactoryException;
-import trax.TransformException;
+import org.apache.trax.Processor;
+import org.apache.trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Result;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.TransformException;
// Imported java.io class
import java.io.IOException;
1.2 +7 -7
xml-xalan/java/samples/UseStylesheetParam/UseStylesheetParam.java
Index: UseStylesheetParam.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/samples/UseStylesheetParam/UseStylesheetParam.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UseStylesheetParam.java 2000/07/27 18:13:14 1.1
+++ UseStylesheetParam.java 2000/10/13 02:33:04 1.2
@@ -56,13 +56,13 @@
*/
// Imported TraX classes
-import trax.Processor;
-import trax.Templates;
-import trax.Transformer;
-import trax.Result;
-import trax.ProcessorException;
-import trax.ProcessorFactoryException;
-import trax.TransformException;
+import org.apache.trax.Processor;
+import org.apache.trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Result;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.TransformException;
// Imported SAX classes
1.2 +7 -7 xml-xalan/java/samples/extensions/SimpleRedirect.java
Index: SimpleRedirect.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/extensions/SimpleRedirect.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleRedirect.java 2000/08/03 19:07:46 1.1
+++ SimpleRedirect.java 2000/10/13 02:33:05 1.2
@@ -56,13 +56,13 @@
*/
// Imported TraX classes
-import trax.Processor;
-import trax.Templates;
-import trax.Transformer;
-import trax.Result;
-import trax.ProcessorException;
-import trax.ProcessorFactoryException;
-import trax.TransformException;
+import org.apache.trax.Processor;
+import org.apache.trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Result;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.TransformException;
// Imported SAX classes
1.7 +2 -2 xml-xalan/java/samples/servlet/ApplyXSLT.java
Index: ApplyXSLT.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/servlet/ApplyXSLT.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ApplyXSLT.java 2000/08/10 11:50:24 1.6
+++ ApplyXSLT.java 2000/10/13 02:33:05 1.7
@@ -1,5 +1,5 @@
/*****************************************************************************************************
- * $Id: ApplyXSLT.java,v 1.6 2000/08/10 11:50:24 dleslie Exp $
+ * $Id: ApplyXSLT.java,v 1.7 2000/10/13 02:33:05 sboag Exp $
*
* Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
* This software is provided without a warranty of
any kind.
@@ -32,7 +32,7 @@
import org.xml.sax.SAXNotSupportedException;
import org.w3c.dom.*;
-import trax.*;
+import org.apache.trax.*;
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xalan.stree.SourceTreeHandler;
import org.apache.xpath.objects.XObject;
1.3 +2 -2
xml-xalan/java/samples/servlet/DefaultApplyXSLTProperties.java
Index: DefaultApplyXSLTProperties.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/samples/servlet/DefaultApplyXSLTProperties.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultApplyXSLTProperties.java 2000/08/09 14:01:13 1.2
+++ DefaultApplyXSLTProperties.java 2000/10/13 02:33:05 1.3
@@ -1,5 +1,5 @@
/*****************************************************************************************************
- * $Id: DefaultApplyXSLTProperties.java,v 1.2 2000/08/09 14:01:13 dleslie
Exp $
+ * $Id: DefaultApplyXSLTProperties.java,v 1.3 2000/10/13 02:33:05 sboag Exp $
*
* Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
* This software is provided without a warranty of
any kind.
@@ -215,7 +215,7 @@
protected void setSystemProperties()
{
Properties props = new Properties();
- props.put("trax.processor.xslt",
"org.apache.xalan.processor.StylesheetProcessor");
+ props.put("org.apache.trax.processor.xslt",
"org.apache.xalan.processor.StylesheetProcessor");
props.put("org.xml.sax.driver",
"org.apache.xerces.parsers.SAXParser");
props.put("serialize.methods", "xml,html,Text");
props.put("serialize.xml", "org.apache.xml.serialize.XMLSerializer");
1.2 +0 -1 xml-xalan/java/src/makecompat
Index: makecompat
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/makecompat,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- makecompat 2000/07/25 16:05:37 1.1
+++ makecompat 2000/10/13 02:33:06 1.2
@@ -25,7 +25,6 @@
TRACEDIR = $(PROJDIR)$(PATHSEP)trace
RESDIR = $(PROJDIR)$(PATHSEP)res
STREEDIR = $(PROJDIR)$(PATHSEP)stree
-TRAXDIR = trax
SUBDIRS =
SRCS = \
1.20 +28 -29 xml-xalan/java/src/makexslt4j
Index: makexslt4j
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/makexslt4j,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- makexslt4j 2000/10/13 00:34:44 1.19
+++ makexslt4j 2000/10/13 02:33:06 1.20
@@ -24,7 +24,6 @@
TRACEDIR = $(PROJDIR)$(PATHSEP)trace
RESDIR = $(PROJDIR)$(PATHSEP)res
STREEDIR = $(PROJDIR)$(PATHSEP)stree
-TRAXDIR = trax
SUBDIRS =
SRCS = \
@@ -237,34 +236,34 @@
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)XMLCharacterRecognizer.java
\
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)xslt$(PATHSEP)Process.java \
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)xslt$(PATHSEP)StylesheetSpec.java \
- trax$(PATHSEP)Examples.java \
- trax$(PATHSEP)Processor.java \
- trax$(PATHSEP)ProcessorException.java \
- trax$(PATHSEP)ProcessorFactoryException.java \
- trax$(PATHSEP)Result.java \
- trax$(PATHSEP)Templates.java \
- trax$(PATHSEP)TemplatesBuilder.java \
- trax$(PATHSEP)Transformer.java \
- trax$(PATHSEP)TransformException.java \
- trax$(PATHSEP)URIResolver.java \
- serialize$(PATHSEP)DOMSerializer.java \
- serialize$(PATHSEP)Method.java \
- serialize$(PATHSEP)OutputFormat.java \
- serialize$(PATHSEP)QName.java \
- serialize$(PATHSEP)Serializer.java \
- serialize$(PATHSEP)SerializerFactory.java \
- serialize$(PATHSEP)SerializerHandler.java \
- serialize$(PATHSEP)helpers$(PATHSEP)HTMLOutputFormat.java \
- serialize$(PATHSEP)helpers$(PATHSEP)TextOutputFormat.java \
- serialize$(PATHSEP)helpers$(PATHSEP)XHTMLOutputFormat.java \
- serialize$(PATHSEP)helpers$(PATHSEP)XMLOutputFormat.java \
- synthetic$(PATHSEP)Class.java \
- synthetic$(PATHSEP)SynthesisException.java \
- synthetic$(PATHSEP)reflection$(PATHSEP)Constructor.java \
- synthetic$(PATHSEP)reflection$(PATHSEP)EntryPoint.java \
- synthetic$(PATHSEP)reflection$(PATHSEP)Field.java \
- synthetic$(PATHSEP)reflection$(PATHSEP)Member.java \
- synthetic$(PATHSEP)reflection$(PATHSEP)Method.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)Examples.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)Processor.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)ProcessorException.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)ProcessorFactoryException.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)Result.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)Templates.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)TemplatesBuilder.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)Transformer.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)TransformException.java \
+ org$(PATHSEP)apache$(PATHSEP)trax$(PATHSEP)URIResolver.java \
+ org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)DOMSerializer.java \
+ org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)Method.java \
+ org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)OutputFormat.java \
+ org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)QName.java \
+ org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)Serializer.java \
+ org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)SerializerFactory.java \
+ org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)SerializerHandler.java \
+
org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)helpers$(PATHSEP)HTMLOutputFormat.java
\
+
org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)helpers$(PATHSEP)TextOutputFormat.java
\
+
org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)helpers$(PATHSEP)XHTMLOutputFormat.java
\
+
org$(PATHSEP)apache$(PATHSEP)serialize$(PATHSEP)helpers$(PATHSEP)XMLOutputFormat.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)synthetic$(PATHSEP)Class.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)synthetic$(PATHSEP)SynthesisException.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)synthetic$(PATHSEP)reflection$(PATHSEP)Constructor.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)synthetic$(PATHSEP)reflection$(PATHSEP)EntryPoint.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)synthetic$(PATHSEP)reflection$(PATHSEP)Field.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)synthetic$(PATHSEP)reflection$(PATHSEP)Member.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)synthetic$(PATHSEP)reflection$(PATHSEP)Method.java
\
org$(PATHSEP)w3c$(PATHSEP)xslt$(PATHSEP)ExpressionContext.java \
org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Attr.java \
org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)CDATASection.java \
1.1
xml-xalan/java/src/org/apache/serialize/DOMSerializer.java
Index: DOMSerializer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize;
import java.io.IOException;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
/**
* Interface for a DOM serializer implementation.
* <p>
* The DOM serializer is a facet of a serializer. A serializer may or may
* not support a DOM serializer.
* <p>
* Example:
* <pre>
* Document doc;
* Serializer ser;
* OutputStream os;
*
* ser.setOutputStream( os );
* ser.asDOMSerializer( doc );
* </pre>
*
*
* @version Alpha
* @author <a href="mailto:Scott_Boag/CAM/[EMAIL PROTECTED]">Scott Boag</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public interface DOMSerializer
{
/**
* Serializes the DOM element. Throws an exception only if an I/O
* exception occured while serializing.
*
* @param elem The element to serialize
* @throws IOException An I/O exception occured while serializing
*/
public void serialize( Element elem )
throws IOException;
/**
* Serializes the DOM document. Throws an exception only if an I/O
* exception occured while serializing.
*
* @param doc The document to serialize
* @throws IOException An I/O exception occured while serializing
*/
public void serialize( Document doc )
throws IOException;
/**
* Serializes the DOM document fragment. Throws an exception only
* if an I/O exception occured while serializing.
*
* @param frag The document fragment to serialize
* @throws IOException An I/O exception occured while serializing
*/
public void serialize( DocumentFragment frag )
throws IOException;
}
1.1 xml-xalan/java/src/org/apache/serialize/Method.java
Index: Method.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize;
/**
* Names of the four default output methods.
* <p>
* Four default output methods are defined: XML, HTML, XHTML and TEXT.
* Serializers may support additional output methods. The names of
* these output methods should be encoded as <tt>namespace:local</tt>.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see OutputFormat
*/
public final class Method
{
/**
* The output method for XML documents: <tt>xml</tt>.
*/
public static final String XML = "xml";
/**
* The output method for HTML documents: <tt>html</tt>.
*/
public static final String HTML = "html";
/**
* The output method for XHTML documents: <tt>xhtml</tt>.
*/
public static final String XHTML = "xhtml";
/**
* The output method for text documents: <tt>text</tt>.
*/
public static final String Text = "text";
}
1.1 xml-xalan/java/src/org/apache/serialize/OutputFormat.java
Index: OutputFormat.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize;
/**
* The output format affects the manner in which a document is
* serialized. The output format determines the output method,
* encoding, indentation, document type, and various other properties
* that affect the manner in which a document is serialized.
* <p>
* Once an output format has been handed to a serializer or XSLT
* processor, the application should not attempt to reuse it. The
* serializer or XSLT processor may modify the properties of the
* output format object.
* <p>
* Implementations may provide classes that extend <tt>OutputFormat</tt>
* with additional properties, e.g. indentation level, line separation,
* namespace handlers, etc. An application may use these extra properties
* by constructing an output format object based on the implementation
* specified type.
* <p>
* <tt>OutputFormat</tt> has been modeled after the XSLT <xsl:output>
* element declaration. However, it does not assume the existence of an
* XSLT processor or a particular serializer.
* <p>
* Typical usage scenarios supported by <tt>OutputFormat<tt>:
* <ul>
* <li>The application constructs an <tt>OutputFormat</tt> object and
* passes it to the serializer
* <li>The application constructs an <tt>OutputFormat</tt> object and
* passes it to the XSLT processor, overriding the properties
* specified in the stylesheet
* <li>The XSLT processor constructs an <tt>OutputFormat</tt> object
* and passes it to the serializer
* <li>The XSLT processor constructs an <tt>OutputFormat</tt> object
* from the stylesheet and returns it to the applicatio, the
* application passes <tt>OutputFormat</tt> to the serializer
* </ul>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* <a href="mailto:[EMAIL PROTECTED]">Keith Visco</a>
* @see Method
*/
public class OutputFormat
{
/**
* Holds the output method specified for this document,
* or null if no method was specified.
*
* @see Method
*/
private String _method = Method.XML;
/**
* Specifies the version of the output method, null for the
* default.
*/
private String _version = null;
/**
* True if indentation is requested, false for no indentation.
*/
private boolean _indent = false;
/**
* The amount to indent a line, when indent is set to true.
*/
private int _indentAmount = 4;
/**
* The encoding to use, if an input stream is used, UTF-8 for
* the default.
*/
private String _encoding = "UTF-8";
/**
* The specified media type or null.
*/
private String _mediaType = null;
/**
* The specified document type system identifier, or null.
*/
private String _doctypeSystemId = null;
/**
* The specified document type public identifier, or null.
*/
private String _doctypePublicId = null;
/**
* Ture if the XML declaration should be ommited;
*/
private boolean _omitXmlDeclaration = false;
/**
* List of element tag names whose text node children must
* be output as CDATA.
*/
private QName[] _cdataElements = new QName[ 0 ];
/**
* List of element tag names whose text node children must
* be output unescaped.
*/
private QName[] _nonEscapingElements = new QName[ 0 ];
/**
* True if spaces should be preserved in elements that do not
* specify otherwise, or specify the default behavior.
*/
private boolean _preserve = false;
/**
* True if the document type should be marked as standalone.
*/
private boolean _standalone = false;
/**
* Constructs a new output format with the default values.
*/
public OutputFormat()
{
}
/**
* Returns the method specified for this output format. See [EMAIL
PROTECTED]
* Method} for a list of the default methods. Other methods should
* be of the format <tt>namespace:local</tt>. The default is
* [EMAIL PROTECTED] Method#XML}.
*
* @return The specified output method
*/
public String getMethod()
{
return _method;
}
/**
* Sets the method for this output format. See [EMAIL PROTECTED] Method}
for
* a list of the default methods. Other methods should be of the
* format <tt>namespace:local</tt>.
*
* @param method The output method, or null
*/
public void setMethod( String method )
{
_method = method;
}
/**
* Returns the version for this output method. If no version was
* specified, will return null and the default version number will
* be used. If the serializer does not support that particular
* version, it should default to a supported version.
*
* @return The specified method version, or null
*/
public String getVersion()
{
return _version;
}
/**
* Sets the version for this output method.
*
* @param version The output method version, or null
*/
public void setVersion( String version )
{
_version = version;
}
/**
* Returns true if indentation was specified. If no indentation
* was specified, returns false. A derived class may support
* additional properties, e.g. indentation level, line width to
* wrap at, tab/spaces, etc.
*
* @return True if indentation was specified
*/
public boolean getIndent()
{
return _indent;
}
/**
* Sets the indentation on and off. A derived class may support
* additional properties, e.g. indentation level, line width to
* wrap at, tab/spaces, etc. A serializer need not support
* indentation.
*
* @param ident True specifies identiation
*/
public void setIndent( boolean indent )
{
_indent = indent;
}
/**
* Returns the amount to indent if indentation was specified.
*
* @return True if indentation was specified
*/
public int getIndentAmount()
{
return _indentAmount;
}
/**
* Sets how much to indent, if indentation was specified.
*
* @param amount Number of spaces to indent.
*/
public void setIndentAmount( int amount )
{
_indentAmount = amount;
}
/**
* Returns the specified encoding. If no encoding was specified,
* the default is used. For XML and HTML the default would be
* "UTF-8". For other output methods, the default encoding is
* unspecified.
*
* @return The encoding
*/
public String getEncoding()
{
return _encoding;
}
/**
* Sets the encoding for this output method. Null means the
* default encoding for the selected output method. For XML and
* HTML the default would be "UTF-8". For other output methods,
* the default encoding is unspecified.
*
* @param encoding The encoding, or null
*/
public void setEncoding( String encoding )
{
_encoding = encoding;
}
/**
* Returns the specified media type. For each output method a
* default media type will be used if one was not specified.
*
* @return The specified media type, or null
*/
public String getMediaType()
{
return _mediaType;
}
/**
* Sets the media type. For each output method a default media
* type will be used if one was not specified.
*
* @param mediaType The specified media type
*/
public void setMediaType( String mediaType )
{
_mediaType = mediaType;
}
/**
* Sets the document type public identifiers. If not specified the
* document type will depend on the output method (e.g. HTML, XHTML)
* or from some other mechanism (e.g. SAX events, DOM DocumentType).
*
* @param publicId The public identifier
*/
public void setDoctypePublicId( String publicId )
{
_doctypePublicId = publicId;
}
/**
* Returns the specified document type public identifier,
* or null.
*/
public String getDoctypePublicId()
{
return _doctypePublicId;
}
/**
* Sets the document type system identifiers. If not specified the
* document type will depend on the output method (e.g. HTML, XHTML)
* or from some other mechanism (e.g. SAX events, DOM DocumentType).
*
* @param systemId The system identifier
*/
public void setDoctypeSystemId( String systemId )
{
_doctypeSystemId = systemId;
}
/**
* Returns the specified document type system identifier,
* or null.
*/
public String getDoctypeSystemId()
{
return _doctypeSystemId;
}
/**
* Returns true if the document type is standalone.
* The default is false.
*/
public boolean getStandalone()
{
return _standalone;
}
/**
* Sets document DTD standalone. The public and system
* identifiers must be null for the document to be
* serialized as standalone.
*
* @param standalone True if document DTD is standalone
*/
public void setStandalone( boolean standalone )
{
_standalone = standalone;
}
/**
* Returns true if the XML document declaration should
* be ommited. The default is false.
*/
public boolean getOmitXMLDeclaration()
{
return _omitXmlDeclaration;
}
/**
* Sets XML declaration omitting on and off.
*
* @param omit True if XML declaration should be ommited
*/
public void setOmitXMLDeclaration( boolean omit )
{
_omitXmlDeclaration = omit;
}
/**
* Returns a list of all the elements whose text node children
* should be output as CDATA. Returns an empty array if no such
* elements were specified.
*
* @return List of all CDATA elements
*/
public QName[] getCDataElements()
{
return _cdataElements;
}
/**
* Sets the list of elements for which text node children
* should be output as CDATA.
*
* @param cdataElements List of all CDATA elements
*/
public void setCDataElements( QName[] cdataElements )
{
if ( cdataElements == null )
_cdataElements = new QName[ 0 ];
else
_cdataElements = cdataElements;
}
/**
* Returns a list of all the elements whose text node children
* should be output unescaped (no character references). Returns
* an empty array if no such elements were specified.
*
* @return List of all non escaping elements
*/
public QName[] getNonEscapingElements()
{
return _nonEscapingElements;
}
/**
* Sets the list of elements for which text node children
* should be output unescaped (no character references).
*
* @param nonEscapingElements List of all non-escaping elements
*/
public void setNonEscapingElements( QName[] nonEscapingElements )
{
if ( nonEscapingElements == null )
_nonEscapingElements = new QName[ 0 ];
else
_nonEscapingElements = nonEscapingElements;
}
/**
* Returns true if the default behavior for this format is to
* preserve spaces. All elements that do not specify otherwise
* or specify the default behavior will be formatted based on
* this rule. All elements that specify space preserving will
* always preserve space.
*/
public boolean getPreserveSpace()
{
return _preserve;
}
/**
* Sets space preserving as the default behavior. The default is
* space stripping and all elements that do not specify otherwise
* or use the default value will not preserve spaces.
*
* @param preserve True if spaces should be preserved
*/
public void setPreserveSpace( boolean preserve )
{
_preserve = preserve;
}
}
1.1 xml-xalan/java/src/org/apache/serialize/QName.java
Index: QName.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize;
/**
* A qualified name. A qualified name has a local name, a namespace
* URI and a prefix (if known). A <tt>QName</tt> may also specify
* a non-qualified name by having a null namespace URI.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public class QName
{
/**
* The local name.
*/
protected String _localName;
/**
* The namespace URI.
*/
protected String _namespaceURI;
/**
* The namespace prefix.
*/
protected String _prefix;
/**
* Constructs an empty QName.
*/
protected QName()
{
}
/**
* Constructs a new QName with the specified namespace URI and
* local name.
*
* @param namespaceURI The namespace URI if known, or null
* @param localName The local name
*/
public QName( String namespaceURI, String localName )
{
if ( localName == null )
throw new IllegalArgumentException( "Argument 'localName' is
null" );
_namespaceURI = namespaceURI;
_localName = localName;
}
/**
* Constructs a new QName with the specified namespace URI, prefix
* and local name.
*
* @param namespaceURI The namespace URI if known, or null
* @param prefix The namespace prefix is known, or null
* @param localName The local name
*/
public QName( String namespaceURI, String prefix, String localName )
{
if ( localName == null )
throw new IllegalArgumentException( "Argument 'localName' is
null" );
_namespaceURI = namespaceURI;
_prefix = prefix;
_localName = localName;
}
/**
* Returns the namespace URI. Returns null if the namespace URI
* is not known.
*
* @return The namespace URI, or null
*/
public String getNamespaceURI()
{
return _namespaceURI;
}
/**
* Returns the namespace prefix. Returns null if the namespace
* prefix is not known.
*
* @return The namespace prefix, or null
*/
public String getPrefix()
{
return _prefix;
}
/**
* Returns the local part of the qualified name.
*
* @return The local part of the qualified name
*/
public String getLocalName()
{
return _localName;
}
/**
* Override equals and agree that we're equal if
* the passed object is a string and it matches
* the name of the arg.
*/
public boolean equals(String ns, String localPart)
{
return ( ( ( _localName == null && localPart == null ) ||
( _localName != null && _localName.equals( localPart ) ) ) &&
( ( _namespaceURI == null && ns == null ) ||
( _namespaceURI != null && _namespaceURI.equals( ns ) ) ) );
}
public boolean equals( Object object )
{
if ( object == this )
return true;
if ( object instanceof QName ) {
return ( ( ( _localName == null && ( (QName) object )._localName
== null ) ||
( _localName != null && _localName.equals( ( (QName)
object )._localName ) ) ) &&
( ( _namespaceURI == null && ( (QName) object
)._namespaceURI == null ) ||
( _namespaceURI != null && _namespaceURI.equals( (
(QName) object )._namespaceURI ) ) ) );
}
return false;
}
public String toString()
{
return _prefix != null ? ( _prefix + ":" + _localName ) :
( _namespaceURI != null ? ( _namespaceURI + "^" + _localName ) :
_localName );
}
}
1.1 xml-xalan/java/src/org/apache/serialize/Serializer.java
Index: Serializer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize;
import java.io.Writer;
import java.io.OutputStream;
import java.io.IOException;
import org.xml.sax.DocumentHandler;
import org.xml.sax.ContentHandler;
/**
* A serializer is used for serializing a document with a given output
* method. The [EMAIL PROTECTED] Serializer} object serves as an anchor point
for
* setting the output stream and output format, for obtaining objects
* for serializing the document, and for resetting the serializer.
* <p>
* Prior to using the serializer, the output format and output stream
* or writer should be set. The serializer is then used in one of
* three ways:
* <ul>
* <li>To serialize SAX 1 events call [EMAIL PROTECTED] #asDocumentHandler}
* <li>To serialize SAX 2 events call [EMAIL PROTECTED] #asContentHandler}
* <li>To serialize a DOM document call [EMAIL PROTECTED] #asDOMSerializer}
* </ul>
* <p>
* The application may call one of these methods to obtain a way to
* serialize the document. It may not attempt to use two different
* handlers at the same time, nor should it use the same handler to
* serialize two documents.
* <p>
* The serializer may be recycled and used with a different or the
* same output format and output stream, by calling the [EMAIL PROTECTED]
#reset}
* method after completing serialization.
* <p>
* A serializer is not thread safe. Only one thread should call the
* <tt>asXXX</tt> methods and use the returned handler.
* <p>
* Example:
* <pre>
* ser = SerializerFactory.getSerializer( Method.XML );
* emptyDoc( ser, System.out );
* emptyDoc( ser, System.err );
* . . .
*
* void emptyDoc( Serializer ser, OutputStream os )
* {
* ser.setOutputStream( os );
* ser.asDocumentHandler().startDocument();
* ser.asDocumentHandler().startElement( "empty", new AttributeListImpl()
);
* ser.asDocumentHandler().endElement( "empty" );
* ser.asDocumentHandler().endDocument();
* ser.reset();
* }
* </pre>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @author <a href="mailto:Scott_Boag/CAM/[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface Serializer
{
/**
* Specifies an output stream to which the document should be
* serialized. This method should not be called while the
* serializer is in the process of serializing a document.
* <p>
* The encoding specified in the [EMAIL PROTECTED] OutputFormat} is used,
or
* if no encoding was specified, the default for the selected
* output method.
*
* @param output The output stream
*/
public void setOutputStream( OutputStream output );
public OutputStream getOutputStream();
/**
* Specifies a writer to which the document should be serialized.
* This method should not be called while the serializer is in
* the process of serializing a document.
* <p>
* The encoding specified for the [EMAIL PROTECTED] OutputFormat} must be
* identical to the output format used with the writer.
*
* @param writer The output writer stream
*/
public void setWriter( Writer writer );
public Writer getWriter();
/**
* Specifies an output format for this serializer. It the
* serializer has already been associated with an output format,
* it will switch to the new format. This method should not be
* called while the serializer is in the process of serializing
* a document.
*
* @param format The output format to use
*/
public void setOutputFormat( OutputFormat format );
/**
* Returns the output format for this serializer.
*
* @return The output format in use
*/
public OutputFormat getOutputFormat();
/**
* Return a [EMAIL PROTECTED] DocumentHandler} interface into this
serializer.
* If the serializer does not support the [EMAIL PROTECTED]
DocumentHandler}
* interface, it should return null.
*
* @return A [EMAIL PROTECTED] DocumentHandler} interface into this
serializer,
* or null if the serializer is not SAX 1 capable
* @throws IOException An I/O exception occured
*/
public DocumentHandler asDocumentHandler()
throws IOException;
/**
* Return a [EMAIL PROTECTED] ContentHandler} interface into this
serializer.
* If the serializer does not support the [EMAIL PROTECTED]
ContentHandler}
* interface, it should return null.
*
* @return A [EMAIL PROTECTED] ContentHandler} interface into this
serializer,
* or null if the serializer is not SAX 2 capable
* @throws IOException An I/O exception occured
*/
public ContentHandler asContentHandler()
throws IOException;
/**
* Return a [EMAIL PROTECTED] DOMSerializer} interface into this
serializer.
* If the serializer does not support the [EMAIL PROTECTED] DOMSerializer}
* interface, it should return null.
*
* @return A [EMAIL PROTECTED] DOMSerializer} interface into this
serializer,
* or null if the serializer is not DOM capable
* @throws IOException An I/O exception occured
*/
public DOMSerializer asDOMSerializer()
throws IOException;
/**
* Resets the serializer. If this method returns true, the
* serializer may be used for subsequent serialization of new
* documents. It is possible to change the output format and
* output stream prior to serializing, or to use the existing
* output format and output stream.
*
* @return True if serializer has been reset and can be reused
*/
public boolean reset();
}
1.1
xml-xalan/java/src/org/apache/serialize/SerializerFactory.java
Index: SerializerFactory.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.InputStream;
/**
* Factory for creating default serializers. An implementation need
* only support the default output methods (XML, HTML and Text).
* Additional serializers may be constructed directly by the application.
* <p>
* The factory is used with the default serializers provided by the
* implementation and named in the <tt>serializer.properties</tt>
* file of the implementation.
* <p>
* Usage example:
* <pre>
* Serializer ser;
*
* ser = SerializerFactory.getSerializer( Method.XML );
* </pre>
* or,
* <pre>
* Serializer ser;
* OutputFormat format;
*
* format = SerializerFactory.getOutputFormat( Method.HTML );
* ser = SerializerFactory.getSerializer( format );
* </pre>
* <p>
*
*
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public abstract class SerializerFactory
{
/**
* The name of the properties file listing all the supported
* serializers. (<tt>/org/xml/serilize/serializer.properties</tt>).
*/
public static final String PropertiesResource = "serializer.properties";
/**
* The name of the property listing all the supported output
* methods. Contains a comma delimited list of method names.
* (<tt>serialize.methods</tt>).
*/
public static final String PropertyMethods = "serialize.methods";
/**
* The prefix of a property supplying the class name for a
* serializer implementing a specific method.
* (<tt>serialize.</tt>).
*/
public static final String PropertySerializerPrefix = "serialize.";
/**
* The prefix of a property supplying the class name for an
* output format implementing a specific method.
* (<tt>serialize.format.</tt>).
*/
public static final String PropertyFormatPrefix =
"serialize.format.";
/**
* Associates output methods to serializer classes.
*/
private static Hashtable _serializers = new Hashtable();
/**
* Associates output methods to default output formats.
*/
private static Hashtable _formats = new Hashtable();
/**
* Returns a serializer for the specified output method. Returns
* null if no implementation exists that supports the specified
* output method. For a list of the default output methods see
* [EMAIL PROTECTED] Method}.
*
* @param method The output method
* @return A suitable serializer, or null
*/
public static Serializer getSerializer( String method )
{
Serializer ser;
Class cls;
cls = (Class) _serializers.get( method );
if ( cls == null )
return null;
try {
ser = (Serializer) cls.newInstance();
} catch ( Exception except ) {
return null;
}
return ser;
}
/**
* Returns a serializer for the specified output method. Returns
* null if no implementation exists that supports the specified
* output method. For a list of the default output methods see
* [EMAIL PROTECTED] Method}.
*
* @param format The output format
* @return A suitable serializer, or null
*/
public static Serializer getSerializer( OutputFormat format )
{
Serializer ser;
Class cls;
if ( format.getMethod() == null )
throw new IllegalArgumentException( "The output format has not method
name" );
cls = (Class) _serializers.get( format.getMethod() );
if ( cls == null )
return null;
try {
ser = (Serializer) cls.newInstance();
} catch ( Exception except ) {
return null;
}
ser.setOutputFormat( format );
return ser;
}
/**
* Returns an output format for the specified output method.
* An implementation may extend [EMAIL PROTECTED] OutputFormat} to provide
* additional properties.
*
* @param method The output method
* @return A suitable output format
*/
public static OutputFormat getOutputFormat( String method )
{
OutputFormat format;
Class cls;
cls = (Class) _formats.get( method );
if ( cls != null ) {
try {
format = (OutputFormat) cls.newInstance();
return format;
} catch ( Exception except ) { }
}
format = new OutputFormat();
format.setMethod( method );
return format;
}
/**
* Returns an enumeration of all the output methods supported by this
* implementation. The enumeration contains the names of all the output
* methods for which this implementation provides a serializer.
*
* @return An enumeration of all output methods
*/
public Enumeration listMethods()
{
return _serializers.keys();
}
/**
* Static constructor loads serializers and output formats
* from properties file.
*/
static {
Properties props;
StringTokenizer token;
try {
props = new Properties();
InputStream is = SerializerFactory.class.getResourceAsStream(
PropertiesResource );
if(null == is)
System.err.println( "Can't get serializer property file: " +
PropertiesResource );
props.load( is );
if ( props.getProperty ( PropertyMethods ) == null )
System.err.println( "Serializer property file has no " +
PropertyMethods + " property" );
else {
token = new StringTokenizer( props.getProperty ( PropertyMethods ),
", " );
while ( token.hasMoreElements() )
{
String method;
String clsName;
Class cls;
method = token.nextToken();
// Get the serializer class that matches this output method
clsName = props.getProperty( PropertySerializerPrefix + method );
if ( clsName == null )
{
System.err.println( "Could not find property for serializer
implementing output method " + method );
}
else
{
try {
cls = Class.forName(clsName);
// Breaks in jview -sb
// cls = SerializerFactory.class.getClassLoader().loadClass(
clsName );
_serializers.put( method, cls );
}
catch ( ClassNotFoundException except )
{
System.err.println( "Could not locate serializer class " +
clsName );
}
}
// Get the output format class that matches this output method
clsName = props.getProperty( PropertyFormatPrefix + method );
if ( clsName == null )
{
// Don't complain in this case. -sb
// System.err.println( "Could not find property for output format
implementing output method " + method );
}
else
{
try {
cls = Class.forName(clsName);
// Breaks in jview -sb
// cls = SerializerFactory.class.getClassLoader().loadClass(
clsName );
_formats.put( method, cls );
}
catch ( ClassNotFoundException except )
{
System.err.println( "Could not locate output format class " +
clsName );
}
}
}
}
} catch ( IOException except ) {
System.err.println( "Error loading " + PropertiesResource + ": " +
except.toString() );
}
}
}
1.1
xml-xalan/java/src/org/apache/serialize/SerializerHandler.java
Index: SerializerHandler.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize;
import org.xml.sax.SAXException;
/**
* Interface that supplements [EMAIL PROTECTED] org.xml.sax.DocumentHandler}
and
* [EMAIL PROTECTED] org.xml.sax.ContentHandler} with additional methods
suitable
* for serialization. This interface is required only for XML and
* HTML serializers.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public interface SerializerHandler
{
/**
* Starts an un-escaping section. All characters printed within an
* un-escaping section are printed as is, without escaping special
* characters into entity references. Only XML and HTML serializers
* need to support this method.
* <p>
* The contents of the un-escaping section will be delivered through
* the regular <tt>characters</tt> event.
*/
public void startNonEscaping()
throws SAXException;
/**
* Ends an un-escaping section.
*
* @see #startNonEscaping
*/
public void endNonEscaping()
throws SAXException;
/**
* Starts a whitespace preserving section. All characters printed
* within a preserving section are printed without indentation and
* without consolidating multiple spaces. This is equivalent to
* the <tt>xml:space="preserve"</tt> attribute. Only XML
* and HTML serializers need to support this method.
* <p>
* The contents of the whitespace preserving section will be delivered
* through the regular <tt>characters</tt> event.
*/
public void startPreserving()
throws SAXException;
/**
* Ends a whitespace preserving section.
*
* @see #startPreserving
*/
public void endPreserving()
throws SAXException;
}
1.1 xml-xalan/java/src/org/apache/serialize/package.html
Index: package.html
===================================================================
<!-- CVS $Revision: 1.1 $ $Date: 2000/10/13 02:33:06 $ -->
<html>
<title>Interfaces for SAX and DOM serializers.</title>
<body>
<p>Defines an interface for SAX and DOM serializers, a serializer
factory and its configuration, the output format properties,
and related interfaces.<p>
<dl>
<dt><b>Version: </b></dt><dd>Alpha $Revision: 1.1 $ $Date: 2000/10/13
02:33:06 $</dd>
<dt><b>Author: </b></dt><dd><a href="mailto:[EMAIL PROTECTED]">Assaf
Arkin</a></dd>
<dt><b>Goals: </b></dt><dd>
<ul>
<li>Define an interface for serializers that will allow an
application
to use any implementation.</li>
<li>Support SAX 1, SAX 2, DOM Level 1, DOM Level 2
serialization</li>
<li>Allow implementations to extend the interfaces and provide
additional
functionality, and support implementations for any output
method.</li>
<li>Provide a factory for the default output methods (XML, HTML,
Text).</li>
</ul>
</dd>
</dl>
<h3>The Serializer Interfaces</h3>
<p>[EMAIL PROTECTED] serialize.Serializer} defines the interface
supported by
a serializer. A serializer implements a mechanism for producing output
from
a series of SAX events or a DOM document, in a given format (aka the
output
method). A serializer can be constructed directly, or obtained from
some
factory, it may implement the base functionality or provide additional
functionality suitable for the given output method (e.g. indentation in
XML, page control in PDF, etc).</p>
<p>A serializer is not thread safe and may not be used concurrently,
however,
a serializer may be recyclable and used to serialize any number of
documents
with the same output method.</p>
<p>Before serializing a document, the serializer must be set with the
output
stream or writer, and optionally with an [EMAIL PROTECTED]
serialize.OutputFormat}
specifying the output properties. Serializer implementations may
support
additional methods to control the way in which documents are
serialized,
or extend [EMAIL PROTECTED] serialize.OutputFormat} and offer
additional
output properties.</p>
<p>[EMAIL PROTECTED] serialize.Serializer} and [EMAIL PROTECTED]
serialize.OutputFormat}
provides the minimum functionality that all serializers must support
and that an application may depend on, and are based on the XSLT 1.0
specification.</p>
<p>For the purpose of serializing, a handle to the serializer is obtained
that can be either a SAX 1 <tt>DocumentHandler</tt>, a SAX 2
<tt>ContentHandler</tt>
or a DOM Level 1/2 [EMAIL PROTECTED] serialize.DOMSerializer}. The
application
should obtain and use only one handle at any given time and may not
reuse
the handle to serialize multiple documents. It is illegal for the
application
to call two different handle returning methods without resetting the
serializer,
or two use the same handle after resetting the serializer.</p>
<p>[EMAIL PROTECTED] serialize.SerializerFactory} provides a means of
obtaining
the default serializers available from a given implementation. At the
minimum
an implementation should support XML, HTML and Text serializers. When
additional
serializers are available, the application may obtain them through the
[EMAIL PROTECTED]
serialize.SerializerFactory} or construct them directly.</p>
<p>Non-escaping and whitespace preserving output control is offered for
XML, HTML and similar output methods, but it is not mandatory that a
serializer support these output control methods. Non-escaping and
whitespace
preserving can be set globally through [EMAIL PROTECTED]
serialize.OutputFormat},
or directly when serializing SAX events through [EMAIL PROTECTED]
serialize.SerializerHandler}.
Serializers are not required to implement the [EMAIL PROTECTED]
serialize.SerializerHandler}
interface.</p>
<h3>Usage Examples</h3>
<p>Serialize a DOM document as XML:</p>
<pre>
void printXML( Document doc, OutputStream stream, String encoding )
{
OutputFormat format;
Serializer ser;
// Obtain a suitable output format for the XML method and
// set the encoding.
format = SerializerFactory.getOutputFormat( Method.XML );
format.setEncoding( encoding );
// Obtain a suitable serializer for the XML method and
// set the output stream.
ser = SerializerFactory.getSerializer( format );
ser.setOutputStream( stream );
// Use DOMSerializer to serialize the document
ser.asDOMSerializer().serialize( doc );
}
</pre>
<p>Serialize an empty HTML document using SAX events, reuse the
serializer:</p>
<pre>
Serializer ser;
// Obtain an HTML serializer once, use it multiple times.
ser = SerializerFactory.getSerializer( Method.HTML );
printEmptyHTML( ser, System.out );
printEmptyHTML( ser, System.err );
. . .
void printEmptyHTML( Serializer ser, OutputStream os )
{
ser.setOutputStream( os );
ser.asDocumentHandler().startDocument();
ser.asDocumentHandler().startElement( "html", new AttributeListImpl() );
ser.asDocumentHandler().endElement( "html" );
ser.asDocumentHandler().endDocument();
ser.reset();
}
</pre>
<h3>The Properties File</h3>
<p>An implementation will include a serializer properties file called
<tt>serializer.properties</tt> located in the <tt>serialize</tt>
package. The properties file lists all the default serializers
supported
by that implementation. Serializers that are not listed in the
properties
file may be constructed directly by the application.</p>
<p>The properties file contains a property <tt>serialize.methods</tt>
listing all the output methods supported by the implementation (comma
separated list). For each method a property <tt>serialize.[method]</tt>
names the class of the [EMAIL PROTECTED] serialize.Serializer}
implementation.
The optional property <tt>serialize.format.[method]</tt> names the
class of a suitable [EMAIL PROTECTED] serialize.OutputFormat}
implementation.</p>
</body>
</html>
1.1
xml-xalan/java/src/org/apache/serialize/serializer.properties
Index: serializer.properties
===================================================================
#
# $Revision: 1.1 $ $Date: 2000/10/13 02:33:06 $
#
# Note: This properties file is provided for illustrative purposes
# only and is not part of the interface definition.
# This properties file is located in the implementation JAR
# and different implementations will specify different
# implementation classes and output methods.
#
#
# Lis the methods supported by this implementation
#
serialize.methods=xml,html,xhtml,text
#
# Use the transition serializer implementations for the default methods
#
serialize.xml=org.apache.xml.serialize.transition.XMLSerializer
serialize.html=org.apache.xml.serialize.transition.HTMLSerializer
serialize.xhtml=org.apache.xml.serialize.transition.XHTMLSerializer
serialize.text=org.apache.xml.serialize.transition.TextSerializer
# serialize.wml:wml=org.apache.xml.serialize.transition.WMLSerializer
#
# Use the helper output formats for the default methods
#
serialize.format.xml=org.apache.serialize.helpers.XMLOutputFormat
serialize.format.html=org.apache.serialize.helpers.HTMLOutputFormat
serialize.format.xhtml=org.apache.serialize.helpers.XHTMLOutputFormat
serialize.format.text=org.apache.serialize.helpers.TextOutputFormat
1.1
xml-xalan/java/src/org/apache/serialize/helpers/HTMLOutputFormat.java
Index: HTMLOutputFormat.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize.helpers;
import org.apache.serialize.OutputFormat;
import org.apache.serialize.Method;
/**
* Output format for HTML documents.
* <p>
* The output format affects the manner in which a document is
* serialized. The output format determines the output method,
* encoding, indentation, document type, and various other properties
* that affect the manner in which a document is serialized.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public class HTMLOutputFormat
extends OutputFormat
{
public HTMLOutputFormat()
{
setMethod( Method.HTML );
setMediaType( "text/html" );
setOmitXMLDeclaration( true );
setPreserveSpace( false );
setDoctypePublicId( "-//W3C//DTD HTML 4.0//EN" );
setDoctypeSystemId(
"http://www.w3.org/TR/WD-html-in-xml/DTD/xhtml1-strict.dtd" );
}
public HTMLOutputFormat( String encoding )
{
this();
setEncoding( encoding );
}
public HTMLOutputFormat( boolean indenting )
{
this();
setIndent( indenting );
}
}
1.1
xml-xalan/java/src/org/apache/serialize/helpers/TextOutputFormat.java
Index: TextOutputFormat.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize.helpers;
import org.apache.serialize.OutputFormat;
import org.apache.serialize.Method;
/**
* Output format for text documents.
* <p>
* The output format affects the manner in which a document is
* serialized. The output format determines the output method,
* encoding, indentation, document type, and various other properties
* that affect the manner in which a document is serialized.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public class TextOutputFormat
extends OutputFormat
{
public TextOutputFormat()
{
setMethod( Method.Text );
setMediaType( "text/plain" );
setPreserveSpace( true );
}
public TextOutputFormat( String encoding )
{
this();
setEncoding( encoding );
}
public TextOutputFormat( boolean indenting )
{
this();
setIndent( indenting );
setPreserveSpace( false );
}
}
1.1
xml-xalan/java/src/org/apache/serialize/helpers/XHTMLOutputFormat.java
Index: XHTMLOutputFormat.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize.helpers;
import org.apache.serialize.OutputFormat;
import org.apache.serialize.Method;
/**
* Output format for XHTML documents.
* <p>
* The output format affects the manner in which a document is
* serialized. The output format determines the output method,
* encoding, indentation, document type, and various other properties
* that affect the manner in which a document is serialized.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public class XHTMLOutputFormat
extends OutputFormat
{
public XHTMLOutputFormat()
{
setMethod( Method.XHTML );
setMediaType( "text/html" );
setOmitXMLDeclaration( true );
setPreserveSpace( false );
setDoctypePublicId( "-//W3C//DTD XHTML 1.0 Strict//EN" );
setDoctypeSystemId(
"http://www.w3.org/TR/WD-html-in-xml/DTD/xhtml1-strict.dtd" );
}
public XHTMLOutputFormat( String encoding )
{
this();
setEncoding( encoding );
}
public XHTMLOutputFormat( boolean indenting )
{
this();
setIndent( indenting );
}
}
1.1
xml-xalan/java/src/org/apache/serialize/helpers/XMLOutputFormat.java
Index: XMLOutputFormat.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.serialize.helpers;
import org.apache.serialize.OutputFormat;
import org.apache.serialize.Method;
/**
* Output format for XML documents.
* <p>
* The output format affects the manner in which a document is
* serialized. The output format determines the output method,
* encoding, indentation, document type, and various other properties
* that affect the manner in which a document is serialized.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public class XMLOutputFormat
extends OutputFormat
{
public XMLOutputFormat()
{
setMethod( Method.XML );
setMediaType( "text/xml" );
setPreserveSpace( true );
}
public XMLOutputFormat( String encoding )
{
this();
setEncoding( encoding );
}
public XMLOutputFormat( boolean indenting )
{
this();
setIndent( indenting );
setPreserveSpace( false );
}
}
1.1 xml-xalan/java/src/org/apache/trax/Examples.java
Index: Examples.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
// Needed java classes
import java.io.InputStream;
import java.io.Reader;
import java.io.IOException;
// Needed SAX classes
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.Parser;
import org.xml.sax.helpers.ParserAdapter;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.XMLReader;
import org.xml.sax.ContentHandler;
// Needed DOM classes
import org.w3c.dom.Node;
// Needed Serializer classes
import org.apache.serialize.OutputFormat;
import org.apache.serialize.Serializer;
import org.apache.serialize.SerializerFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.BufferedInputStream; // dml
/**
* Some examples to show how the Simple API for Transformations
* could be used.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class Examples
{
public static void main( String argv[] )
throws ProcessorException, ProcessorFactoryException,
TransformException, SAXException, IOException,
ParserConfigurationException
{
System.out.println("==== exampleSimple ====");
exampleSimple("foo.xml", "foo.xsl");
System.out.println("\n==== exampleSAX2SAX ====");
exampleSAX2SAX("foo.xml", "foo.xsl");
System.out.println("\n==== exampleXMLFilter ====");
exampleXMLFilter("foo.xml", "foo.xsl");
System.out.println("\n==== exampleXMLFilterChain ====");
exampleXMLFilterChain("foo.xml", "foo.xsl", "foo2.xsl", "foo.xsl");
System.out.println("\n==== exampleDOM2DOM ====");
exampleDOM2DOM("foo.xml", "foo.xsl");
System.out.println("\n==== exampleParam ====");
exampleParam("foo.xml", "param.xsl");
System.out.println("\n==== exampleOutputFormat ====");
exampleOutputFormat("foo.xml", "foo.xsl");
System.out.println("==== exampleUseAssociated ====");
}
/**
* Show the simplest possible transformation from system id to output
stream.
*/
public static void exampleSimple(String sourceID, String xslID)
throws ProcessorException, ProcessorFactoryException,
TransformException, SAXException, IOException
{
Processor processor = Processor.newInstance("xslt");
Templates templates = processor.process(new InputSource(xslID));
Transformer transformer = templates.newTransformer();
transformer.transform(new InputSource(sourceID), new Result(System.out));
}
/**
* Show the Transformer using SAX events in and SAX events out.
*/
public static void exampleSAX2SAX(String sourceID, String xslID)
throws SAXException, IOException // , ParserConfigurationException
{
Processor processor = Processor.newInstance("xslt");
XMLReader reader = XMLReaderFactory.createXMLReader();
// Have a Templates builder handle the parse events from the SAXParser's
// parse of an xslt file.
TemplatesBuilder templatesBuilder = processor.getTemplatesBuilder();
reader.setContentHandler(templatesBuilder);
if(templatesBuilder instanceof org.xml.sax.ext.LexicalHandler)
reader.setProperty("http://xml.org/sax/properties/lexical-handler",
templatesBuilder);
reader.parse(xslID);
Templates templates = templatesBuilder.getTemplates();
// Get a transformer instance for the templates.
Transformer transformer = templates.newTransformer();
// Set the result handling to be a serialization to System.out.
Serializer serializer = SerializerFactory.getSerializer("xml");
serializer.setOutputStream(System.out);
transformer.setContentHandler(serializer.asContentHandler());
// Cause the transformation to occur by asking the parser to send
// the parse events from "foo.xsl" to the transformer.
ContentHandler chandler = transformer.getInputContentHandler();
reader.setContentHandler(chandler);
if(chandler instanceof org.xml.sax.ext.LexicalHandler)
reader.setProperty("http://xml.org/sax/properties/lexical-handler",
chandler);
else
reader.setProperty("http://xml.org/sax/properties/lexical-handler",
null);
reader.parse(sourceID);
}
/**
* Show the Transformer as a SAX2 XMLFilter/XMLReader. In this case
* the Transformer acts like a parser, and can in fact be polymorphicaly
* used in places where a SAX parser would be used.
*/
public static void exampleXMLFilter(String sourceID, String xslID)
throws SAXException, IOException// , ParserConfigurationException
{
Processor processor = Processor.newInstance("xslt");
Templates templates = processor.process(new InputSource(xslID));
Transformer transformer = templates.newTransformer();
// Set the result handling to be a serialization to System.out.
Serializer serializer = SerializerFactory.getSerializer(new
OutputFormat());
serializer.setOutputStream(System.out);
transformer.setContentHandler(serializer.asContentHandler());
// The transformer will use a SAX parser as it's reader.
XMLReader reader = XMLReaderFactory.createXMLReader();
transformer.setParent(reader);
// Now, when you call transformer.parse, it will set itself as
// the content handler for the parser object (it's "parent"), and
// will then call the parse method on the parser.
transformer.parse(new InputSource(sourceID));
}
/**
* This example shows how to chain events from one Transformer
* to another transformer, using the Transformer as a
* SAX2 XMLFilter/XMLReader.
*/
public static void exampleXMLFilterChain(String sourceID, String xslID_1,
String xslID_2, String xslID_3)
throws SAXException, IOException// , ParserConfigurationException
{
Processor processor = Processor.newInstance("xslt");
Templates stylesheet1 = processor.process(new InputSource(xslID_1));
Transformer transformer1 = stylesheet1.newTransformer();
Templates stylesheet2= processor.process(new InputSource(xslID_2));
Transformer transformer2 = stylesheet2.newTransformer();
Templates stylesheet3 = processor.process(new InputSource(xslID_3));
Transformer transformer3= stylesheet3.newTransformer();
XMLReader reader = XMLReaderFactory.createXMLReader();
// transformer1 will use a SAX parser as it's reader.
transformer1.setParent(reader);
// transformer2 will use transformer1 as it's reader.
transformer2.setParent(transformer1);
// transform3 will use transform2 as it's reader.
transformer3.setParent(transformer2);
// transform3 will output the events to the serializer.
Serializer serializer = SerializerFactory.getSerializer(new
OutputFormat());
serializer.setOutputStream(System.out);
transformer3.setContentHandler(serializer.asContentHandler());
// Now, when you call transformer3 to parse, it will set
// itself as the ContentHandler for transform2, and
// call transform2.parse, which will set itself as the
// content handler for transform1, and call transform1.parse,
// which will set itself as the content listener for the
// SAX parser, and call parser.parse(new InputSource("foo.xml")).
transformer3.parse(new InputSource(sourceID));
}
/**
* Show how to transform a DOM tree into another DOM tree.
* This uses the javax.xml.parsers to parse an XML file into a
* DOM, and create an output DOM.
*/
public static void exampleDOM2DOM(String sourceID, String xslID)
throws SAXException, IOException, ParserConfigurationException
{
Processor processor = Processor.newInstance("xslt");
if(processor.getFeature("http://xml.org/trax/features/dom/input"))
{
Templates templates;
{
DocumentBuilderFactory dfactory =
DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);
dfactory.setValidating(true);
DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
org.w3c.dom.Document outNode = docBuilder.newDocument();
Node doc = docBuilder.parse(new InputSource(xslID));
templates = processor.processFromNode(doc);
}
Transformer transformer = templates.newTransformer();
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
org.w3c.dom.Document outNode = docBuilder.newDocument();
Node doc = docBuilder.parse(new InputSource(sourceID));
transformer.transformNode(doc, new Result(outNode));
Serializer serializer = SerializerFactory.getSerializer(new
OutputFormat());
serializer.setOutputStream(System.out);
serializer.asDOMSerializer().serialize(outNode);
}
else
{
throw new org.xml.sax.SAXNotSupportedException("DOM node processing not
supported!");
}
}
/**
* This shows how to set a parameter for use by the templates.
*/
public static void exampleParam(String sourceID, String xslID)
throws ProcessorException, ProcessorFactoryException,
TransformException, SAXException, IOException
{
Processor processor = Processor.newInstance("xslt");
Templates templates = processor.process(new InputSource(xslID));
Transformer transformer = templates.newTransformer();
transformer.setParameter("my-param", null /* namespace */, "hello to
you!");
transformer.transform(new InputSource(sourceID), new Result(System.out));
}
/**
* Show how to override output properties.
*/
public static void exampleOutputFormat(String sourceID, String xslID)
throws ProcessorException, ProcessorFactoryException,
TransformException, SAXException, IOException
{
Processor processor = Processor.newInstance("xslt");
Templates templates = processor.process(new InputSource(xslID));
OutputFormat oprops = templates.getOutputFormat();
oprops.setIndent( true );
Transformer transformer = templates.newTransformer();
transformer.setOutputFormat(oprops);
transformer.transform(new InputSource(sourceID), new Result(System.out));
}
/**
* Show how to get stylesheets that are associated with a given
* xml document via the xml-stylesheet PI (see
http://www.w3.org/TR/xml-stylesheet/).
*/
public static void exampleUseAssociated()
throws ProcessorException, ProcessorFactoryException,
TransformException, SAXException, IOException
{
Processor processor = Processor.newInstance("xslt");
InputSource docSouce = new InputSource("foo.xml");
InputSource[] sources
= processor.getAssociatedStylesheets(docSouce, "text/xslt", null, null);
// Processor may remember it read the given document...
Templates templates = (null != sources) ?
processor.processMultiple(sources) :
processor.process(new InputSource("default.xsl"));
Transformer transformer = templates.newTransformer();
transformer.transform(docSouce, new Result(System.out));
}
}
1.1 xml-xalan/java/src/org/apache/trax/Processor.java
Index: Processor.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.util.Properties;
import java.util.Enumeration;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.XMLReader;
import org.xml.sax.ErrorHandler;
import org.xml.sax.EntityResolver;
import org.w3c.dom.Node;
/**
* A particular transformation Processor is "plugged" into the platform via
* Processor in one of two ways: 1) as a platform default,
* and 2) through external specification by a system property named
* "org.xml.org.apache.trax.Processor.[type]" obtained using
* java.lang.System.getProperty(). The [type] part of the property specifies
* the processing language to be used, for instance,
"org.apache.trax.processor.xslt" would
* specify an XSLT processor. This property (or platform default)
* names a class that is a concrete subclass of
org.xml.org.apache.trax.Processor.
* The subclass shall implement a public no-args constructor used by
* the base abstract class to create an instance of the factory using
* the newInstance() method.
*
* <p>The platform default is only used if no external implementation is
* available.</p>
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Separate Factory?</h4></dt>
* <dd>Should there be a separate ProcessorFactory class, to be
* more consistent with javax.xml.parsers.SAXParserFactory? Doing this
* would allow this class to be an interface instead of an abstract
class.</dd>
* <dt><h4>Separate DOM Interface?</h4></dt>
* <dd>Should there be a separate DOMProcessor class, instead of
* having the processFromNode method?</dd>
* <dt><h4>XMLReader vs. Parser vs. SAXParser/DocumentBuilder</h4></dt>
* <dd>Currently the interfaces support XMLReader. Should this be
* javax.xml.parsers.SAXParser/javax.xml.parsers.DocumentBuilder?
* Or, perhaps just org.xml.sax.Parser?</dd>
* <dt><h4>XMLReader derivation?</h4></dt>
* <dd>Should this derive from XMLReader (in a similar way that
Transformer
* derives from XMLFilter)?</dd>
* </dl>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public abstract class Processor
{
/**
* Set the name of the default concrete class to be used.
*/
private static String platformDefaultFactoryName = null;
/**
* The name of the properties file used to get the
org.apache.trax.processor.xslt
* property via getResourceAsStream.
*/
public static String PropertiesResource = "trax.properties";
/**
* Set the name of the default concrete class to be used.
* @param classname Full classname of concrete implementation
* of org.xml.org.apache.trax.Processor.
*/
public static void setPlatformDefaultProcessor(String classname)
{
platformDefaultFactoryName = classname;
}
private static String getFactoryNameFromResourceStream(String factoryKey)
{
try
{
Properties props = new Properties();
InputStream is = Processor.class.getResourceAsStream(
PropertiesResource );
if(null == is)
return null;
props.load( is );
return props.getProperty ( factoryKey );
}
catch(IOException ioe)
{
return null;
}
}
/**
* Obtain a new instance of a Processor object.
* @return Concrete instance of an Processor object.
*/
public static Processor newInstance(String type)
throws ProcessorFactoryException
{
Processor factory = null;
String factoryName;
try
{
String factoryKey = "trax.processor."+type;
factoryName = null;
try
{
factoryName = System.getProperty(factoryKey);
}
catch (SecurityException e){}
if(null == factoryName)
{
try
{
factoryName = getFactoryNameFromResourceStream(factoryKey);
}
catch (SecurityException e){}
}
if(null == factoryName)
factoryName = platformDefaultFactoryName;
if(null == factoryName)
throw new ProcessorFactoryException("Can't find trax property:
"+factoryKey, null);
Class factoryClass = Class.forName(factoryName);
factory = (Processor)factoryClass.newInstance();
}
catch(java.lang.IllegalAccessException iae)
{
throw new ProcessorFactoryException("Transformation Processor can not
be accessed!", iae);
}
catch(java.lang.InstantiationException ie)
{
throw new ProcessorFactoryException("Not able to create Transformation
Processor!", ie);
}
catch(java.lang.ClassNotFoundException cnfe)
{
throw new ProcessorFactoryException("Transformation Processor not
found!", cnfe);
}
return factory;
}
/**
* Process the source into a templates object.
*
* @param source An object that holds a URL, input stream, etc.
* @returns A Templates object capable of being used for transformation
purposes.
* @exception SAXException May throw this if it needs to create a
XMLReader,
* and XMLReaderFactory.createXMLReader() fails.
* @exception java.io.IOException An IO exception from the parser,
* possibly from a byte stream or character stream
* supplied by the application.
* @exception ProcessorException May throw this during the parse when it
* is constructing the Templates object and fails.
*/
public abstract Templates process(InputSource source)
throws ProcessorException, SAXException, IOException;
/**
* Process the stylesheet from a DOM tree, if the
* processor supports the "http://xml.org/trax/features/dom/input"
* feature.
*
* @param node A DOM tree which must contain
* valid transform instructions that this processor understands.
* @returns A Templates object capable of being used for transformation
purposes.
*/
public abstract Templates processFromNode(Node node)
throws ProcessorException;
/**
* Process the stylesheet from a DOM tree, if the
* processor supports the "http://xml.org/trax/features/dom/input"
* feature.
*
* @param node A DOM tree which must contain
* valid transform instructions that this processor understands.
* @param systemID The systemID from where xsl:includes and xsl:imports
* should be resolved from.
* @returns A Templates object capable of being used for transformation
purposes.
*/
public abstract Templates processFromNode(Node node, String systemID)
throws ProcessorException;
/**
* Process a series of inputs, treating them in import or cascade
* order. This is mainly for support of the getAssociatedStylesheets
* method, but may be useful for other purposes.
*
* @param sources An array of SAX InputSource objects.
* @returns A Templates object capable of being used for transformation
purposes.
*/
public abstract Templates processMultiple(InputSource[] source)
throws ProcessorException;
/**
* Get InputSource specification(s) that are associated with the
* given document specified in the source param,
* via the xml-stylesheet processing instruction
* (see http://www.w3.org/TR/xml-stylesheet/), and that matches
* the given criteria. Note that it is possible to return several
stylesheets
* that match the criteria, in which case they are applied as if they were
* a list of imports or cascades.
* <p>Note that DOM2 has it's own mechanism for discovering stylesheets.
* Therefore, there isn't a DOM version of this method.</p>
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Does the xml-stylesheet recommendation really support multiple
stylesheets?</h4></dt>
* <dd>Mike Kay wrote: I don't see any support in the
* xml-stylesheet recommendation for this interpretation of what you
should do
* if there's more than one match. Scott Boag replies: It's in the
HTML references.
* But it's a bit subtle. We talked about this at the last XSL WG
F2F, and people
* agreed to the multiple stylesheet stuff. I'll try and work out
the specific
* references. Probably the xml-stylesheet recommendation needs to
have a note
* added to it.</dd>
* </dl>
*
* @param media The media attribute to be matched. May be null, in which
* case the prefered templates will be used (i.e. alternate =
no).
* @param title The value of the title attribute to match. May be null.
* @param charset The value of the charset attribute to match. May be null.
* @returns An array of InputSources that can be passed to processMultiple
method.
*/
public abstract InputSource[] getAssociatedStylesheets(InputSource source,
String media,
String title,
String charset)
throws ProcessorException;
/**
* Get a TemplatesBuilder object that can process SAX
* events into a Templates object, if the processor supports the
* "http://xml.org/trax/features/sax/input" feature.
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Should Processor derive from
org.xml.sax.ContentHandler?</h4></dt>
* <dd>Instead of requesting an object from the Processor class, should
* the Processor class simply derive from
org.xml.sax.ContentHandler?</dd>
* </dl>
* @return A TemplatesBuilder object, or null if not supported.
* @exception May throw a ProcessorException if a TemplatesBuilder
* can not be constructed for some reason.
*/
public abstract TemplatesBuilder getTemplatesBuilder()
throws ProcessorException;
//======= CONFIGURATION METHODS =======
/**
* The XML reader to be used for the templates,
* and for the source documents if it is not set.
*/
private XMLReader reader;
/**
* Set an XML parser for the templates. This may also
* be used for the XML input for the source tree, if
* the setXMLReader method on the Transformation
* method is not set.
*/
public void setXMLReader(XMLReader reader)
{
this.reader = reader;
}
/**
* Get the XML parser used for the templates. This may also
* be used for the XML input for the source tree, if
* the setXMLReader method on the Transformation
* method is not set.
* @return Valid XMLReader object, or null if none has been set.
*/
public XMLReader getXMLReader()
{
return reader;
}
/**
* Look up the value of a feature.
*
* <p>The feature name is any fully-qualified URI. It is
* possible for an Processor to recognize a feature name but
* to be unable to return its value; this is especially true
* in the case of an adapter for a SAX1 Parser, which has
* no way of knowing whether the underlying parser is
* validating, for example.</p>
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Should getFeature be changed to hasFeature?</h4></dt>
* <dd>Keith Visco writes: Should getFeature be changed to hasFeature?
* It returns a boolean which indicated whether the "state"
* of feature is "true or false". I assume this means whether
* or not a feature is supported? I know SAX is using "getFeature",
* but to me "hasFeature" is cleaner.</dd>
* </dl>
*
* @param name The feature name, which is a fully-qualified
* URI.
* @return The current state of the feature (true or false).
* @exception org.xml.sax.SAXNotRecognizedException When the
* Processor does not recognize the feature name.
* @exception org.xml.sax.SAXNotSupportedException When the
* Processor recognizes the feature name but
* cannot determine its value at this time.
*/
public boolean getFeature (String name)
throws SAXNotRecognizedException, SAXNotSupportedException
{
throw new SAXNotRecognizedException(name);
}
/**
* Set the state of a feature.
*
* <p>The feature name is any fully-qualified URI. It is
* possible for an Processor to recognize a feature name but
* to be unable to set its value; this is especially true
* in the case of an adapter for a SAX1 Parser, which has
* no way of affecting whether the underlying parser is
* validating, for example.</p>
*
* @param name The feature name, which is a fully-qualified
* URI.
* @param state The requested state of the feature (true or false).
* @exception org.xml.sax.SAXNotRecognizedException When the
* Processor does not recognize the feature name.
* @exception org.xml.sax.SAXNotSupportedException When the
* Processor recognizes the feature name but
* cannot set the requested value.
*/
public void setFeature (String name, boolean value)
throws SAXNotRecognizedException, SAXNotSupportedException
{
throw new SAXNotRecognizedException(name);
}
private URIResolver resolver;
/**
* Set an object that will be used to resolve URIs used in
* xsl:import, etc. This will be used as the default for the
* transformation.
* @param resolver An object that implements the URIResolver interface,
* or null.
*/
public void setURIResolver(URIResolver resolver)
{
this.resolver = resolver;
}
/**
* Set an object that will be used to resolve URIs used in
* xsl:import, etc. This will be used as the default for the
* transformation.
* @param resolver An object that implements the URIResolver interface,
* or null.
*/
public URIResolver getURIResolver()
{
return resolver;
}
ErrorHandler errorHandler;
/**
* Allow an application to register an error event handler.
*
* <p>If the application does not register an error handler, all
* error events reported by the SAX parser will be silently
* ignored; however, normal processing may not continue. It is
* highly recommended that all SAX applications implement an
* error handler to avoid unexpected bugs.</p>
*
* <p>Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.</p>
*
* @param handler The error handler.
* @exception java.lang.NullPointerException If the handler
* argument is null.
* @see #getErrorHandler
*/
public void setErrorHandler (ErrorHandler handler)
{
if (handler == null) {
throw new NullPointerException("Null error handler");
}
errorHandler = handler;
}
/**
* Return the current error handler.
*
* @return The current error handler, or null if none
* has been registered.
* @see #setErrorHandler
*/
public ErrorHandler getErrorHandler ()
{
return errorHandler;
}
private EntityResolver entityResolver;
/**
* Allow an application to register an entity resolver.
*
* <p>If the application does not register an entity resolver,
* the XMLReader will perform its own default resolution.</p>
*
* <p>Applications may register a new or different resolver in the
* middle of a parse, and the SAX parser must begin using the new
* resolver immediately.</p>
*
* @param resolver The entity resolver.
* @exception java.lang.NullPointerException If the resolver
* argument is null.
* @see #getEntityResolver
*/
public void setEntityResolver (EntityResolver resolver)
{
entityResolver = resolver;
}
/**
* Return the current entity resolver.
*
* @return The current entity resolver, or null if none
* has been registered.
* @see #setEntityResolver
*/
public EntityResolver getEntityResolver ()
{
return entityResolver;
}
}
1.1
xml-xalan/java/src/org/apache/trax/ProcessorException.java
Index: ProcessorException.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
import org.xml.sax.SAXParseException;
import org.xml.sax.SAXException;
import org.xml.sax.Locator;
import org.xml.sax.helpers.LocatorImpl;
/**
* This exception serves as a root exception of TRaX exception, and
* is thrown in raw form when an exceptional condition occurs in the
* Processor object.
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Abstract exception root?</h4></dt>
* <dd>Should the root TRaX exception be abstract?</dd>
* <dt><h4>Derive from SAXException?</h4></dt>
* <dd>Keith Visco writes: I don't think these exceptions should extend
* SAXException, but could nest a SAXException if necessary.</dd>
* </dl>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class ProcessorException extends SAXParseException
{
//////////////////////////////////////////////////////////////////////
// Constructors.
//////////////////////////////////////////////////////////////////////
/**
* Create a new ProcessorException from a message.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback.</p>
*
* @param message The error or warning message.
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public ProcessorException (String message)
{
super(message, null);
}
/**
* Create a new ProcessorException from a message and a Locator.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback.</p>
*
* @param message The error or warning message.
* @param locator The locator object for the error or warning.
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public ProcessorException (String message, Locator locator)
{
super(message, locator);
}
/**
* Wrap an existing exception in a ProcessorException.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback, and needs to wrap an existing exception that is not a
* subclass of SAXException.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param locator The locator object for the error or warning.
* @param e Any exception
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public ProcessorException (String message, Locator locator,
Exception e)
{
super( message, locator, e);
}
/**
* Wrap an existing exception in a ProcessorException.
*
* <p>This is used for throwing processor exceptions before
* the processing has started.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param e Any exception
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public ProcessorException (String message, Exception e)
{
super( "TRaX Processor Exception", new LocatorImpl(), e);
}
/**
* Create a new ProcessorException.
*
* <p>This constructor is most useful for parser writers.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
*
* @param message The error or warning message.
* @param publicId The public identifer of the entity that generated
* the error or warning.
* @param systemId The system identifer of the entity that generated
* the error or warning.
* @param lineNumber The line number of the end of the text that
* caused the error or warning.
* @param columnNumber The column number of the end of the text that
* cause the error or warning.
* @see org.xml.sax.Parser#setLocale
*/
public ProcessorException (String message, String publicId, String systemId,
int lineNumber, int columnNumber)
{
super(message, publicId, systemId, lineNumber, columnNumber);
}
/**
* Create a new ProcessorException with an embedded exception.
*
* <p>This constructor is most useful for parser writers who
* need to wrap an exception that is not a subclass of
* SAXException.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
*
* @param message The error or warning message, or null to use
* the message from the embedded exception.
* @param publicId The public identifer of the entity that generated
* the error or warning.
* @param systemId The system identifer of the entity that generated
* the error or warning.
* @param lineNumber The line number of the end of the text that
* caused the error or warning.
* @param columnNumber The column number of the end of the text that
* cause the error or warning.
* @param e Another exception to embed in this one.
* @see org.xml.sax.Parser#setLocale
*/
public ProcessorException (String message, String publicId, String systemId,
int lineNumber, int columnNumber, Exception e)
{
super(message, publicId, systemId, lineNumber, columnNumber, e);
}
/**
* Print the the trace of methods from where the error
* originated. This will trace all nested exception
* objects, as well as this object.
* @param s The stream where the dump will be sent to.
*/
public void printStackTrace(java.io.PrintStream s)
{
if(s == null)
s = System.err;
try
{
super.printStackTrace(s);
}
catch(Exception e){}
Exception exception = getException();
for(int i = 0; (i < 10) && (null != exception); i++)
{
s.println("---------");
exception.printStackTrace(s);
if(exception instanceof SAXException)
{
SAXException se = (SAXException)exception;
Exception prev = exception;
exception = se.getException();
if(prev == exception)
break;
}
else
{
exception = null;
}
}
}
/**
* Find the most contained message.
* @returns The error message of the originating exception.
*/
public String getMessage()
{
StringBuffer sbuffer = new StringBuffer();
if(null != super.getMessage())
{
sbuffer.append(super.getMessage());
}
if(null != getSystemId())
{
sbuffer.append("; SystemID: ");
sbuffer.append(getSystemId());
}
if(0 != getLineNumber())
{
sbuffer.append("; Line#: ");
sbuffer.append(getLineNumber());
}
if(0 != getColumnNumber())
{
sbuffer.append("; Column#: ");
sbuffer.append(getColumnNumber());
}
Exception exception = getException();
while(null != exception)
{
if(null != exception.getMessage())
{
sbuffer.append("\n (");
sbuffer.append( exception.getClass().getName());
sbuffer.append( "): ");
sbuffer.append(exception.getMessage());
}
if((!((exception instanceof TransformException) ||
(exception instanceof ProcessorException))) &&
(exception instanceof SAXException))
{
if(exception instanceof SAXParseException)
{
SAXParseException spe = (SAXParseException)exception;
if(null != spe.getSystemId())
{
sbuffer.append("; SystemID: ");
sbuffer.append(spe.getSystemId());
}
if(0 != spe.getLineNumber())
{
sbuffer.append("; Line#: ");
sbuffer.append(spe.getLineNumber());
}
if(0 != spe.getColumnNumber())
{
sbuffer.append("; Column#: ");
sbuffer.append(spe.getColumnNumber());
}
}
SAXException se = (SAXException)exception;
exception = se.getException();
}
else
{
exception = null;
}
}
return sbuffer.toString();
}
/**
* Print the the trace of methods from where the error
* originated. This will trace all nested exception
* objects, as well as this object.
* @param s The writer where the dump will be sent to.
*/
public void printStackTrace(java.io.PrintWriter s)
{
if(s == null)
s = new java.io.PrintWriter(System.err);
try
{
super.printStackTrace(s);
}
catch(Exception e){}
Exception exception = getException();
for(int i = 0; (i < 10) && (null != exception); i++)
{
s.println("---------");
try
{
exception.printStackTrace(s);
}
catch(Exception e)
{
s.println("Could not print stack trace...");
}
if(exception instanceof SAXException)
{
SAXException se = (SAXException)exception;
Exception prev = exception;
exception = se.getException();
if(prev == exception)
{
exception = null;
break;
}
}
else
{
exception = null;
}
}
}
}
1.1
xml-xalan/java/src/org/apache/trax/ProcessorFactoryException.java
Index: ProcessorFactoryException.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
import org.xml.sax.SAXException;
/**
* The ProcessorFactoryException is a type of ProcessorException that
* is thrown when a configurable factory object can not
* be created.
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>No open issues are known for this class</h4></dt>
* <dd></dd>
* </dl>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class ProcessorFactoryException extends SAXException
{
/**
* Create a new ProcessorFactoryException from an existing exception.
*
* @param message The detail message.
* @param e The exception to be wrapped in a SAXException.
* @see org.xml.sax.SAXException
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public ProcessorFactoryException (String message, Exception e)
{
super(message, e);
}
}
1.1 xml-xalan/java/src/org/apache/trax/Result.java
Index: Result.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
import java.lang.String;
import java.io.OutputStream;
import java.io.Writer;
import org.w3c.dom.Node;
/**
* Acts as an holder for a transformation result tree.
* <p>This class is modeled after the SAX InputSource class, except that it
* is for the Result target, and in addition to streams, and writers,
* it also can specify a DOM node to which nodes will be appended.</p>
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Should this be an interface?</h4></dt>
* <dd>Should this be an interface instead of a concrete class? The
justification
* for it being a class is that it is just a bag of data, and contains
no
* behavior of its own.</dd>
* </dl>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class Result
{
/**
* Zero-argument default constructor.
*/
public Result ()
{
}
/**
* Create a new output target with a byte stream.
*
* @param byteStream The raw byte stream that will contain the document.
*/
public Result (OutputStream byteStream)
{
setByteStream(byteStream);
}
/**
* Create a new output target with a character stream.
*
* @param characterStream The character stream where the result will be
written.
*/
public Result (Writer characterStream)
{
setCharacterStream(characterStream);
}
/**
* Create a new output target with a DOM node.
*
* @param n The DOM node that will contain the result tree.
*/
public Result (Node n)
{
setNode(n);
}
/**
* Set the byte stream for this output target.
*
* @param byteStream A byte stream that will contain the result document.
*/
public void setByteStream (OutputStream byteStream)
{
this.byteStream = byteStream;
}
/**
* Get the byte stream for this output target.
*
* @return The byte stream, or null if none was supplied.
*/
public OutputStream getByteStream ()
{
return byteStream;
}
/**
* Set the character stream for this output target.
*
* @param characterStream The character stream that will contain
* the result document.
*/
public void setCharacterStream (Writer characterStream)
{
this.characterStream = characterStream;
}
/**
* Get the character stream for this output target.
*
* @return The character stream, or null if none was supplied.
*/
public Writer getCharacterStream ()
{
return characterStream;
}
/**
* Set the node that will contain the result DOM tree.
*/
public void setNode (Node node)
{
this.node = node;
}
/**
* Get the node that will contain the result tree.
*/
public Node getNode ()
{
return node;
}
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
protected OutputStream byteStream;
protected Writer characterStream;
protected Node node;
}
1.1 xml-xalan/java/src/org/apache/trax/Templates.java
Index: Templates.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
import org.apache.serialize.OutputFormat;
/**
* The Templates object is the runtime representation of compiled
* transformation instructions. Templatess must be threadsafe for a given
instance
* over multiple threads concurrently, and are generally meant to
* be used multiple times in a given session.
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>newTransformer</h4></dt>
* <dd>Is newTransformer the right way to create a transformer? The
alternative might
* be to have a factory method in the Transformer class that takes as
an argument
* a Templates object.</dd>
* </dl>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface Templates
{
/**
* Create a new transformation context for this Templates object.
*/
Transformer newTransformer();
/**
* Get the properties for xsl:output. The object returned will
* be a clone of the internal values, and thus it can be mutated
* without mutating the Templates object, and then handed in to
* the process method.
* @return A OutputProperties object that may be mutated.
*
* @see org.xml.org.apache.serialize.OutputFormat
*/
OutputFormat getOutputFormat();
}
1.1 xml-xalan/java/src/org/apache/trax/TemplatesBuilder.java
Index: TemplatesBuilder.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
/**
* This is a SAX ContentHandler that may be used to process SAX
* events into an Templates objects. This is an abstract class
* instead of an interface, so it can be a ContentHandler object,
* for passing into the JAXP SAXParser interface.
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Should Processor derive from org.xml.sax.ContentHandler?</h4></dt>
* <dd>Instead of requesting an object from the Processor class, should
* the Processor class simply derive from
org.xml.sax.ContentHandler?</dd>
* <dt><h4>ContentHandler vs. ContentHandler</h4></dt>
* <dd>I don't think I would use ContentHandler at all, except that JAXP
uses it.
* Maybe we should go back to using ContentHandler?</dd>
* </dl>
*/
public interface TemplatesBuilder extends org.xml.sax.ContentHandler
{
/**
* When this object is used as a ContentHandler or DocumentHandler, it
* creates a Templates object, which the caller can get once
* the SAX events have been completed.
* @return The stylesheet object that was created during
* the SAX event process, or null if no stylesheet has
* been created.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public Templates getTemplates()
throws TransformException;
/**
* Set the base ID (URL or system ID) for the stylesheet
* created by this builder. This must be set in order to
* resolve relative URLs in the stylesheet.
* @param baseID Base URL for this stylesheet.
*/
public void setBaseID(String baseID);
}
1.1
xml-xalan/java/src/org/apache/trax/TransformException.java
Index: TransformException.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
import org.xml.sax.SAXParseException;
import org.xml.sax.SAXException;
import org.xml.sax.Locator;
import org.xml.sax.helpers.LocatorImpl;
/**
* This simply subclasses the TransformException for the purposes
* of being able to be caught in a catch clause.
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>No open issues are known for this class</h4></dt>
* <dd></dd>
* </dl>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class TransformException extends SAXParseException
{
/**
* Create a new TransformException.
*
* @param message The error or warning message.
* @see org.xml.sax.SAXException
*/
public TransformException (String message)
{
super(message, new LocatorImpl());
}
/**
* Create a new TransformException wrapping an existing exception.
*
* @param e The exception to be wrapped in a SAXException.
* @see org.xml.sax.SAXException
*/
public TransformException (Exception e)
{
super(e.getMessage(), new LocatorImpl(), e);
}
/**
* Create a new TransformException wrapping an existing exception.
*
* @param e The exception to be wrapped in a SAXException.
* @see org.xml.sax.SAXException
*/
public TransformException (Exception e, Locator locator)
{
super(e.getMessage(), locator, e);
}
/**
* Wrap an existing exception in a TransformException.
*
* <p>This is used for throwing processor exceptions before
* the processing has started.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param e Any exception
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public TransformException (String message, Exception e)
{
super( message, new LocatorImpl(), e);
}
/**
* Create a new TransformException from a message and a Locator.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback.</p>
*
* @param message The error or warning message.
* @param locator The locator object for the error or warning.
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public TransformException (String message, Locator locator)
{
super(message, locator);
}
/**
* Wrap an existing exception in a TransformException.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback, and needs to wrap an existing exception that is not a
* subclass of SAXException.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param locator The locator object for the error or warning.
* @param e Any exception
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public TransformException (String message, Locator locator,
Exception e)
{
super( message, locator, e);
}
/**
* Create a new TransformException.
*
* <p>This constructor is most useful for parser writers.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
*
* @param message The error or warning message.
* @param publicId The public identifer of the entity that generated
* the error or warning.
* @param systemId The system identifer of the entity that generated
* the error or warning.
* @param lineNumber The line number of the end of the text that
* caused the error or warning.
* @param columnNumber The column number of the end of the text that
* cause the error or warning.
* @see org.xml.sax.Parser#setLocale
*/
public TransformException (String message,
String publicId, String systemId,
int lineNumber, int columnNumber)
{
super(message, publicId, systemId, lineNumber, columnNumber);
}
/**
* Create a new TransformException with an embedded exception.
*
* <p>This constructor is most useful for parser writers who
* need to wrap an exception that is not a subclass of
* SAXException.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
*
* @param message The error or warning message, or null to use
* the message from the embedded exception.
* @param publicId The public identifer of the entity that generated
* the error or warning.
* @param systemId The system identifer of the entity that generated
* the error or warning.
* @param lineNumber The line number of the end of the text that
* caused the error or warning.
* @param columnNumber The column number of the end of the text that
* cause the error or warning.
* @param e Another exception to embed in this one.
* @see org.xml.sax.Parser#setLocale
*/
public TransformException (String message, String publicId, String systemId,
int lineNumber, int columnNumber, Exception e)
{
super(message, publicId, systemId, lineNumber, columnNumber, e);
}
/**
* Print the the trace of methods from where the error
* originated. This will trace all nested exception
* objects, as well as this object.
* @param s The stream where the dump will be sent to.
*/
public void printStackTrace(java.io.PrintStream s)
{
if(s == null)
s = System.err;
try
{
super.printStackTrace(s);
}
catch(Exception e){}
Exception exception = getException();
for(int i = 0; (i < 10) && (null != exception); i++)
{
s.println("---------");
exception.printStackTrace(s);
if(exception instanceof SAXException)
{
SAXException se = (SAXException)exception;
Exception prev = exception;
exception = se.getException();
if(prev == exception)
break;
}
else
{
exception = null;
}
}
}
private boolean isSimilar(Exception e1, Exception e2)
{
boolean isSimilar = false;
if((e1 instanceof SAXParseException) &&
(e2 instanceof SAXParseException))
{
// If the file and line number are the same, then only
// report the top-level error.
SAXParseException spe1 = (SAXParseException)e1;
String oldSystemID = spe1.getSystemId();
int oldLine = spe1.getLineNumber();
int oldColumn = spe1.getColumnNumber();
SAXParseException spe2 = (SAXParseException)e2;
String newSystemID = spe2.getSystemId();
int newLine = spe2.getLineNumber();
int newColumn = spe2.getColumnNumber();
if(oldSystemID == null)
oldSystemID = "";
if(newSystemID == null)
newSystemID = "";
isSimilar = (oldSystemID.equals(newSystemID)
&& (oldLine == newLine)
&& (oldColumn == newColumn));
}
return isSimilar;
}
private void appendMessageAndInfo(StringBuffer sbuffer)
{
String message = super.getMessage();
String systemID = getSystemId();
int line = getLineNumber();
int column = getColumnNumber();
if(null != message)
{
sbuffer.append(message);
}
if(null != systemID)
{
sbuffer.append("; SystemID: ");
sbuffer.append(systemID);
}
if(0 != line)
{
sbuffer.append("; Line#: ");
sbuffer.append(line);
}
if(0 != column)
{
sbuffer.append("; Column#: ");
sbuffer.append(column);
}
}
/**
* Find the most contained message.
* @returns The error message of the originating exception.
*/
public String getMessage()
{
StringBuffer sbuffer = new StringBuffer();
appendMessageAndInfo(sbuffer);
Exception prev = this;
Exception exception = getException();
while(null != exception)
{
if((!((exception instanceof TransformException) ||
(exception instanceof ProcessorException))) &&
(exception instanceof SAXException))
{
if(exception instanceof SAXParseException)
{
if(!isSimilar(prev, exception))
{
SAXParseException spe = (SAXParseException)exception;
String message = spe.getMessage();
if(null != message)
{
sbuffer.append("\n (");
sbuffer.append( spe.getClass().getName());
sbuffer.append( "): ");
sbuffer.append(message);
}
if(null != spe.getSystemId())
{
sbuffer.append("; SystemID: ");
sbuffer.append(spe.getSystemId());
}
if(0 != spe.getLineNumber())
{
sbuffer.append("; Line#: ");
sbuffer.append(spe.getLineNumber());
}
if(0 != spe.getColumnNumber())
{
sbuffer.append("; Column#: ");
sbuffer.append(spe.getColumnNumber());
}
}
}
else if(!isSimilar(prev, exception))
{
String message = exception.getMessage();
if(null != message)
{
sbuffer.append("\n (");
sbuffer.append( exception.getClass().getName());
sbuffer.append( "): ");
sbuffer.append(message);
}
}
prev = exception;
exception = ((SAXException)exception).getException();
}
else if(!isSimilar(prev, exception))
{
String message = exception.getMessage();
if(null != message)
{
sbuffer.append("\n (");
sbuffer.append( exception.getClass().getName());
sbuffer.append( "): ");
sbuffer.append(message);
}
exception = null;
}
}
return sbuffer.toString();
}
/**
* Print the the trace of methods from where the error
* originated. This will trace all nested exception
* objects, as well as this object.
* @param s The writer where the dump will be sent to.
*/
public void printStackTrace(java.io.PrintWriter s)
{
if(s == null)
s = new java.io.PrintWriter(System.err);
try
{
super.printStackTrace(s);
}
catch(Exception e){}
Exception exception = getException();
for(int i = 0; (i < 10) && (null != exception); i++)
{
s.println("---------");
try
{
exception.printStackTrace(s);
}
catch(Exception e)
{
s.println("Could not print stack trace...");
}
if(exception instanceof SAXException)
{
SAXException se = (SAXException)exception;
Exception prev = exception;
exception = se.getException();
if(prev == exception)
{
exception = null;
break;
}
}
else
{
exception = null;
}
}
}
}
1.1 xml-xalan/java/src/org/apache/trax/Transformer.java
Index: Transformer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
import org.xml.sax.InputSource;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;
import org.xml.sax.DocumentHandler;
import org.xml.sax.ContentHandler;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.ext.DeclHandler;
import org.apache.serialize.OutputFormat;
import org.w3c.dom.Node;
/**
* This object represents a Transformer, which is a SAX2 XMLFilter.
* An object of this class can not be used concurrently over multiple threads.
*
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>Separate DOM Interface?</h4></dt>
* <dd>Should there be a separate DOMTransformer class, instead of
* having the transformNode method?</dd>
* <dt><h4>XMLFilter derivation?</h4></dt>
* <dd>There is some question in some people's mind whether or not
* the Transformer interface should extend XMLFilter.</dd>
* <dt><h4>XMLReader vs. Parser vs. SAXParser/DocumentBuilder</h4></dt>
* <dd>Currently the interfaces support XMLReader. Should this be
* javax.xml.parsers.SAXParser/javax.xml.parsers.DocumentBuilder?
* Or, perhaps just org.xml.sax.Parser?</dd>
* <dt><h4>ContentHandler is entitled to expect a well-formed
tree</h4></dt>
* <dd>Mike Kay: The output of XSLT is a well-balanced tree, or to put it
* another way, a well-formed external general parsed entity, but it
is not in
* general a well-formed XML document. Specifically, it can have
multiple
* elements and text nodes as children of the root. It's quite
possible to feed
* such a tree into a SAX ContentHandler, but to do so breaks the
implicit
* contract that the tree will be well-formed, and I have certainly
encountered
* SAX ContentHandlers (or DocumentHandlers) that break if you try to
do this
* (FOP is an example). This is one of those awful cases where it's
difficult
* to provide the right solution for the 95% of people who want to
generate
* well-formed output without falling over in the other 5% of cases.
In Saxon
* I've been moving in the direction of allowing the ContentHandler
itself to
* declare that it is prepared to accept well-balanced (but
ill-formed) input.
* </dd>
* </dl>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface Transformer extends XMLFilter
{
/**
* Process the source tree to SAX parse events.
* @param xmlSource The input for the source tree.
*/
public void transform( InputSource xmlSource)
throws TransformException;
/**
* Process the source tree to the output result.
* @param xmlSource The input for the source tree.
* @param outputTarget The output source target.
*/
public void transform( InputSource xmlSource, Result outputTarget)
throws TransformException;
/**
* Process the source node to the output result, if the
* processor supports the "http://xml.org/trax/features/dom/input"
* feature.
* @param node The input source node, which can be any valid DOM node.
* @param outputTarget The output source target.
*/
public void transformNode( Node node, Result outputTarget)
throws TransformException;
/**
* Process the source node to to SAX parse events, if the
* processor supports the "http://xml.org/trax/features/dom/input"
* feature.
* @param node The input source node, which can be any valid DOM node.
*/
public void transformNode( Node node )
throws TransformException;
/**
* Get a SAX2 ContentHandler for the input.
* @return A valid ContentHandler, which should never be null, as
* long as getFeature("http://xml.org/trax/features/sax/input")
* returns true.
* <h3>Open issues:</h3>
* <dl>
* <dt><h4>ContentHandler vs. ContentHandler</h4></dt>
* <dd>I don't think I would use ContentHandler at all, except that JAXP
uses it.
* Maybe we should go back to using ContentHandler?</dd>
* </dl>
*/
ContentHandler getInputContentHandler();
/**
* Get a SAX2 DeclHandler for the input.
* @return A valid DeclHandler, which should never be null, as
* long as getFeature("http://xml.org/trax/features/sax/input")
* returns true.
*/
DeclHandler getInputDeclHandler();
/**
* Get a SAX2 LexicalHandler for the input.
* @return A valid LexicalHandler, which should never be null, as
* long as getFeature("http://xml.org/trax/features/sax/input")
* returns true.
*/
LexicalHandler getInputLexicalHandler();
/**
* Set the output properties for the transformation. These
* properties will override properties set in the templates
* with xsl:output.
*
* @see org.xml.org.apache.serialize.OutputFormat
*/
void setOutputFormat(OutputFormat oformat);
/**
* Set a parameter for the templates.
* @param name The name of the parameter.
* @param namespace The namespace of the parameter.
* @value The value object. This can be any valid Java object
* -- it's up to the processor to provide the proper
* coersion to the object, or simply pass it on for use
* in extensions.
*/
void setParameter(String name, String namespace, Object value);
/**
* Reset the parameters to a null list.
*/
void resetParameters();
/**
* Set an object that will be used to resolve URIs used in
* document(), etc.
* @param resolver An object that implements the URIResolver interface,
* or null.
*/
void setURIResolver(URIResolver resolver);
}
1.1 xml-xalan/java/src/org/apache/trax/URIResolver.java
Index: URIResolver.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Transformations for XML (TRaX)
// Copyright �2000 Lotus Development Corporation, Exoffice Technologies,
// Oracle Corporation, Michael Kay of International Computers Limited, Apache
// Software Foundation. All rights reserved.
package org.apache.trax;
//import java.io.IOException;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.w3c.dom.Node;
/**
* <p><i>This version of URIResolver reflects the proposal made by Michael
Kay to revise
* the interface as defined in TRAX 0.6.</i></p>
*
* <p>An interface that can be called by the processor to for turning the
* URIs used in document() and xsl:import etc into an InputSource or a
* Node if the processor supports the
"http://xml.org/trax/features/dom/input" feature.</p>
*
* Node that the URIResolver is stateful (it remembers the most recent URI)
so separate
* instances must be used in each thread.
*
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface URIResolver
{
/**
* This will be called by the processor when it encounters
* an xsl:include, xsl:import, or document() function, if it needs
* a DOM tree. The URIResolver must be prepared to return either a
* DOM tree, or a SAX InputSource, or both. This method must not be called
* unless setURI() has been called first.
*
* @param inputSource The value returned from the EntityResolver.
* @returns a DOM node that represents the resolution of the URI
* to a tree, if the
* URI resolver is capable of returning a DOM Node; or null otherwise.
*/
public Node getDOMNode (InputSource inputSource)
throws TransformException;
/**
* This method returns the SAX2 parser to use with the InputSource
* obtained from this URI.
* It may return null if any SAX2-conformant XML parser can be used,
* or if getInputSource() will also return null. The parser must
* be free for use (i.e.
* not currently in use for another parse().
*
* @param inputSource The value returned from the EntityResolver.
* @returns a SAX2 parser to use with the InputSource.
*/
public XMLReader getXMLReader(InputSource inputSource)
throws TransformException;
}
1.1 xml-xalan/java/src/org/apache/trax/package.html
Index: package.html
===================================================================
<!-- CVS $Revision: 1.1 $ $Date: 2000/10/13 02:33:07 $ -->
<html>
<title>Transformations for XML (TRaX).</title>
<body>
<p>Defines a global interface for generating Templates and performing XML
transformations.</p>
<p>A Processor uses a SAX XMLReader and a TemplatesBuilder (a SAX
ContentHandler) to process the transformation instructions
and produce a Templates object. A Transformer applies the Templates
object (with any input parameters and serializer
OutputFormat properties) to the XML input and generates the content for a
Result object.<p>
<dl>
<dt><b>Version: </b></dt><dd>Alpha, 0.5, March 20, 2000</dd>
<dt><b>Author: </b></dt><dd><a href="mailto:[EMAIL PROTECTED]">Scott
Boag</a>
<dd>(with help from Keith Visco, Mike Kay,
Oracle, Assaf Arkin, and many others)</dd>
<dt><b>Goals: </b></dt><dd>
<ul>
<li>Define a vendor-neutral and language-neutral interface for tree
transformations that will allow an application to use any
implementation.</li>
<li>Support SAX 1, SAX 2, DOM Level 1, and the [EMAIL PROTECTED]
org.xml.serialize.Serializer} interfaces.</li>
<li>Provide a good model for concurent and optimized
transformations.</li>
<li>Provide a reasonable model for incremental processing.</li>
<li>Provide a reasonable model for passing data from the calling
application
to the transformation.</li>
</ul>
</dd>
</dl>
<h3>Usage Examples</h3>
<p>See <a href="Examples.html#method_detail">Examples Page</a></p>
<h3>The TRaX Interfaces</h3>
<p>To create a Processor, call the factory interface on the
trax.Processor class. The actual Processor is
plugged into the platform either as a platform default or as specified
by the org.xml.trax.Processor.[type] system
property (org.xml.trax.Processor.xslt, for example, indicates an XSLT
processor).</p>
<p>The Processor and Transformer both provide SAX style
getFeature/setFeature methods. For example, you can ask the
Transformer whether it supports the
"http://xml.org/trax/features/dom/input" feature before you attempt to process
XML input
submitted as a DOM tree.</p>
<p>The Processor's primary purpose is to process transformation
instructions, such as an XSLT stylesheet, into a threadsafe
Templates object. The Processor can get these instructions from a SAX
InputSource, a DOM tree, or a list of InputSources
specified by an xml-stylesheet instruction in the XML source.</p>
<p>The Templates object is a bag of instructions that tells the
Transformer} how to transform a source tree. It is meant
to be thread safe for concurrent use in multiple threads. Currently, the
Templates object has just two methods:</p>
<ul>
<li>newTransformer() creates a Transformer object associated with the
Templates object</li>
<li>getOutputFormat() returns an org.xml.serialize.OutputFormat object
that you may modify and hand in to the
Transformer object</li>
</ul>
<p>The Transformer object represents a single transformation. You can
only use the Transformer object in one thread at
a time. You can pass parameters to the Transformer object, which will
then be used during the transformation. You can
also set the OutputFormat, which overrides the properties obtained
from the owning Templates object. The primary
Transformer method is transform(), which takes as input a SAX
InputSource}. But there are a couple of other ways to
cause a transformation to occur. You can use the transformNode()
method to transform a DOM Node. You can also obtain
SAX parse event handler interfaces, such as DocumentHandler, which can
then be used as SAX event catchers. A
Transformer is also a SAX XMLFilter, which resembles an XML
reader/parser, except that it obtains its events from another
XML reader rather than from a primary source like an XML document or
database. For example, you can use the Transformer
as a SAX XMLFilter to chain or pipe transformations. The Transformer
also allows you to use a SAX XMLFilter
polymorphicaly as a SAX XMLReader.</p>
<p>The output of a transformation is specified via a Result object. This
is very much like a SAX InputSource, except that
it allows you to specify OutputStreams, Writers, or DOM Nodes. To
specify SAX output, simply use
the SAX XMLReader methods (the Transformer is also a SAX XMLReader),
and call the transform() method that takes
only an InputSource (no Result object).</p>
<h3>Design Patterns</h3>
<p>For more detailed information on the patterns see the <a
href="patterns.html">Design Patterns Document</a></p>
<p>For open design issues, see the class and method headers.</p>
</body>
</html>
1.1 xml-xalan/java/src/org/apache/trax/patterns.xml
Index: patterns.xml
===================================================================
<patterns module="TRaX">
<pattern>
<pattern-name>Processor</pattern-name>
<intent>Serve as a vendor neutral Processor interface for XSLT processors
and
similar processors.</intent>
<responsibilities>Serve as a factory for a concrete implementation of
an Processor, serve as a factory for Templates objects, and
manage processor specific features.</responsibilities>
<thread-safety>Processors can not run concurrently.</thread-safety>
</pattern>
<pattern>
<pattern-name>Templates</pattern-name>
<intent>The run time representation of the transformation
instructions.</intent>
<responsibilities>Acts as a data bag for transformation instructions, act
as
a factory for Transformers.</responsibilities>
<thread-safety>Threadsafe concurrently over multiple threads once
construction is complete.</thread-safety>
</pattern>
<pattern>
<pattern-name>TemplatesBuilder</pattern-name>
<intent>An event handler for parse events that specify the transformation
instructions.</intent>
<responsibilities>Handle parse events, and build a Templates
object.</responsibilities>
<thread-safety>Only safe one instance per thread.</thread-safety>
</pattern>
<pattern>
<pattern-name>Transformer</pattern-name>
<intent>Act as a per-thread execution context for transformations, act as
an interface
for performing the transformation.</intent>
<thread-safety>Only safe one instance per thread.</thread-safety>
<notes>The Transformer is bound to the Templates object that created
it.</notes>
</pattern>
<pattern>
<pattern-name>URIResolver</pattern-name>
<intent>An interface that can be called by the processor to for turning the
URIs used in document(), xsl:import, etc. into an InputSource.</intent>
<responsibilities>Returns an InputSource or NodeInputSource,
given a URI.</responsibilities>
<thread-safety>Needs to be threadsafe concurrently over multiple
threads.</thread-safety>
</pattern>
<pattern>
<pattern-name>Result</pattern-name>
<potential-alternate-name>ResultTarget</potential-alternate-name>
<intent>Serve as a single object for multiple types of output, so there can
be simple process method signatures.</intent>
<responsibilities>Act as simple data holder for output stream, DOM node,
ContentHandler, etc.</responsibilities>
<thread-safety>Threadsafe concurrently over multiple threads for read-only,
must be synchronized for edit.</thread-safety>
</pattern>
<pattern>
<pattern-name>NodeInputSource</pattern-name>
<intent>Serve as a single vendor-neutral object for multiple types of
input. Primarily useful as a return for objects that may need to
return DOM nodes, as well as streams, etc.</intent>
<responsibilities>Act as simple data holder for System IDs, DOM nodes,
streams, etc.</responsibilities>
<thread-safety>Threadsafe concurrently over multiple threads for read-only,
must be synchronized for edit.</thread-safety>
</pattern>
<pattern>
<pattern-name>ProcessorException</pattern-name>
<intent>Need specific processor exception that can be caught by a catch
clause.</intent>
<responsibilities>Same as for SAXException.</responsibilities>
<thread-safety>Instance per thread.</thread-safety>
</pattern>
<pattern>
<pattern-name>ProcessorFactoryException</pattern-name>
<intent>Need specific processor factory exception that can be caught by a
catch
clause.</intent>
<responsibilities>Same as for SAXException.</responsibilities>
<thread-safety>Instance per thread.</thread-safety>
</pattern>
<pattern>
<pattern-name>TransformException</pattern-name>
<intent>Need specific transform exception that can be caught by a catch
clause.</intent>
<responsibilities>Same as for SAXException.</responsibilities>
<thread-safety>Instance per thread.</thread-safety>
</pattern>
</patterns>
1.1 xml-xalan/java/src/org/apache/trax/patterns.xsl
Index: patterns.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="patterns">
<HTML>
<TITLE>Design Patterns: <xsl:value-of select="@module"/></TITLE>
<BODY>
<H1>Design Patterns: <xsl:value-of select="@module"/></H1>
<img src="trax.gif"/>
<xsl:for-each select="pattern">
<HR/>
<xsl:for-each select="pattern-name">
<H2><xsl:value-of select="."/></H2>
</xsl:for-each>
<DL>
<xsl:apply-templates select="*"/>
</DL>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="pattern-name"/>
<xsl:template match="intent">
<DT>Intent</DT>
<DD><xsl:value-of select="."/></DD>
</xsl:template>
<xsl:template match="responsibilities">
<DT>Responsibilities</DT>
<DD><xsl:value-of select="."/></DD>
</xsl:template>
<xsl:template match="thread-safety">
<DT>Thread-safety</DT>
<DD><xsl:value-of select="."/></DD>
</xsl:template>
<xsl:template match="*">
<DT><xsl:value-of select="name(.)"/></DT>
<DD><xsl:value-of select="."/></DD>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/java/src/org/apache/trax/trax.properties
Index: trax.properties
===================================================================
#
# $Revision: 1.1 $ $Date: 2000/10/13 02:33:07 $
#
# Note: This properties file is provided for illustrative purposes
# only and is not part of the interface definition.
# This properties file is located in the implementation JAR
# and different implementations will specify different
# implementation classes and output methods.
#
# The TRaX Stylesheet processor
trax.processor.xslt=org.apache.xalan.processor.StylesheetProcessor
1.5 +15 -15
xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java
Index: XSLTProcessorApplet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSLTProcessorApplet.java 2000/10/12 12:45:33 1.4
+++ XSLTProcessorApplet.java 2000/10/13 02:33:08 1.5
@@ -76,13 +76,13 @@
import org.apache.xalan.transformer.TransformerImpl;
// Needed TRaX classes
-import trax.Result;
-import trax.Processor;
-import trax.ProcessorFactoryException;
-import trax.Transformer;
-import trax.TransformException;
-import trax.Templates;
-import trax.TemplatesBuilder;
+import org.apache.trax.Result;
+import org.apache.trax.Processor;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.Transformer;
+import org.apache.trax.TransformException;
+import org.apache.trax.Templates;
+import org.apache.trax.TemplatesBuilder;
// Needed SAX classes
import org.xml.sax.InputSource;
@@ -97,9 +97,9 @@
import org.w3c.dom.Document;
// Needed Serializer classes
-import serialize.OutputFormat;
-import serialize.Serializer;
-import serialize.SerializerFactory;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.Serializer;
+import org.apache.serialize.SerializerFactory;
/**
* <meta name="usage" content="general"/>
@@ -422,11 +422,11 @@
Templates templates = m_templatesBuilder.getTemplates();
TransformerImpl transformer =
(TransformerImpl)templates.newTransformer();
// Result result = new Result(pw);
- serialize.Serializer serializer = new
org.apache.xml.serialize.transition.HTMLSerializer();
- // serialize.Serializer serializer =
serialize.SerializerFactory.getSerializer( "HTML" );
+ org.apache.serialize.Serializer serializer = new
org.apache.xml.serialize.transition.HTMLSerializer();
+ // org.apache.serialize.Serializer serializer =
org.apache.serialize.SerializerFactory.getSerializer( "HTML" );
serializer.setWriter(pw);
org.xml.sax.ContentHandler handler = serializer.asContentHandler();
- // new org.apache.xml.serialize.HTMLSerializer(pw, new
OutputFormat()).asContentHandler();
+ // new org.apache.xml.org.apache.serialize.HTMLSerializer(pw, new
OutputFormat()).asContentHandler();
transformer.setContentHandler(handler);
transformer.setParent(m_reader);
transform(transformer, new InputSource(xmlbuf));
@@ -726,8 +726,8 @@
if(null != m_key)
transformer.setParameter(m_key, null, m_expression);
// Result result = new Result(pw);
- serialize.Serializer serializer = new
org.apache.xml.serialize.transition.HTMLSerializer();
this.showStatus("serializer is "+ serializer);
- //serialize.Serializer serializer =
serialize.SerializerFactory.getSerializer( "HTML" );
+ org.apache.serialize.Serializer serializer = new
org.apache.xml.serialize.transition.HTMLSerializer();
this.showStatus("serializer is "+ serializer);
+ //org.apache.serialize.Serializer serializer =
org.apache.serialize.SerializerFactory.getSerializer( "HTML" );
serializer.setWriter(pw);
org.xml.sax.ContentHandler handler = serializer.asContentHandler();
1.6 +2 -2 xml-xalan/java/src/org/apache/xalan/lib/Redirect.java
Index: Redirect.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Redirect.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Redirect.java 2000/10/05 17:03:44 1.5
+++ Redirect.java 2000/10/13 02:33:08 1.6
@@ -61,7 +61,7 @@
import java.net.URL;
import org.w3c.dom.*;
import org.xml.sax.ContentHandler;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
import org.apache.xalan.extensions.XSLProcessorContext;
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xalan.templates.StylesheetRoot;
@@ -362,7 +362,7 @@
FileOutputStream ostream = new FileOutputStream(file);
ContentHandler flistener
- = transformer.createResultContentHandler(new trax.Result(ostream),
format);
+ = transformer.createResultContentHandler(new
org.apache.trax.Result(ostream), format);
flistener.startDocument();
if(shouldPutInTable)
1.8 +21 -21
xml-xalan/java/src/org/apache/xalan/processor/CompilingStylesheetHandler.java
Index: CompilingStylesheetHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/CompilingStylesheetHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CompilingStylesheetHandler.java 2000/10/05 20:18:43 1.7
+++ CompilingStylesheetHandler.java 2000/10/13 02:33:08 1.8
@@ -70,10 +70,10 @@
import org.apache.xalan.templates.StylesheetRoot;
import org.apache.xalan.templates.Stylesheet;
import org.apache.xalan.templates.XMLNSDecl;
-import trax.ProcessorException;
-import trax.TemplatesBuilder;
-import trax.Templates;
-import trax.TransformException;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.TemplatesBuilder;
+import org.apache.trax.Templates;
+import org.apache.trax.TransformException;
import org.apache.xpath.XPath;
import org.apache.xpath.XPathFactory;
import org.apache.xpath.compiler.XPathParser;
@@ -96,7 +96,7 @@
// Java Compiler support. *****
// TODO: Merge the Microsoft VJ++ workarounds in this file into that one.
-import synthetic.JavaUtils;
+import org.apache.xalan.utils.synthetic.JavaUtils;
/**
* <meta name="usage" content="advanced"/>
@@ -219,7 +219,7 @@
Other nodes simply have their .evaluate() invoked
TODO: Their children really should be walked for further compilation
opportunities.
- TODO: ***** OPTIMIZATION: We should preload/cache the synthetic.Class
+ TODO: ***** OPTIMIZATION: We should preload/cache the
org.apache.xalan.utils.synthetic.Class
objects rather than doing forName/forClass lookups every time.
*/
ElemTemplate compileTemplate(ElemTemplate source)
@@ -232,8 +232,8 @@
{
// public class ACompiledTemplate000...
// extends CompiledTemplate (partly abstract superclass)
- synthetic.Class tClass=
- synthetic.Class.declareClass(className);
+ org.apache.xalan.utils.synthetic.Class tClass=
+ org.apache.xalan.utils.synthetic.Class.declareClass(className);
tClass.setModifiers(java.lang.reflect.Modifier.PUBLIC);
tClass.setSuperClass(tClass.forName("org.apache.xalan.processor.CompiledTemplate"));
@@ -243,7 +243,7 @@
// Set at construction. ElemTemplateElements and AVTs...
// Synthesis needs a more elegant way to declare array classes
// given a base class...
- synthetic.reflection.Field m_interpretArray=
+ org.apache.xalan.utils.synthetic.reflection.Field m_interpretArray=
tClass.declareField("m_interpretArray");
// org.apache.xalan.templates.ElemTemplateElement
m_interpretArray.setType(tClass.forName("java.lang.Object[]"));
@@ -254,12 +254,12 @@
// be set in execute() but testable in getNamespaceForPrefix --
// and the latter, most unfortunately, is not passed the xctxt
so
// making that threadsafe is a bit ugly.
- synthetic.reflection.Field m_nsThreadContexts=
+ org.apache.xalan.utils.synthetic.reflection.Field m_nsThreadContexts=
tClass.declareField("m_nsThreadContexts");
m_nsThreadContexts.setType(tClass.forClass(java.util.Hashtable.class));
m_nsThreadContexts.setInitializer("new java.util.Hashtable()");
// And accessor, to let kids query current state
- synthetic.reflection.Method getNSURI =
+ org.apache.xalan.utils.synthetic.reflection.Method getNSURI =
tClass.declareMethod("getNamespaceForPrefix");
getNSURI.addParameter(tClass.forClass(java.lang.String.class),"nsprefix");
getNSURI.setReturnType(tClass.forClass(java.lang.String.class));
@@ -278,7 +278,7 @@
// public constructor: Copy values from original
// template object, pick up "uncompiled children"
// array from compilation/instantiation process.
- synthetic.reflection.Constructor ctor=
+ org.apache.xalan.utils.synthetic.reflection.Constructor ctor=
tClass.declareConstructor();
ctor.setModifiers(java.lang.reflect.Modifier.PUBLIC);
ctor.addParameter(tClass.forClass(ElemTemplate.class),"original");
@@ -304,7 +304,7 @@
// public void execute(TransformerImpl transformer,
// Node sourceNode, QName mode)
- synthetic.reflection.Method exec=
+ org.apache.xalan.utils.synthetic.reflection.Method exec=
tClass.declareMethod("execute");
exec.setModifiers(java.lang.reflect.Modifier.PUBLIC);
exec.addParameter(
@@ -383,12 +383,12 @@
interpretVector.copyInto(eteParms);
// Instantiate -- note that this will be a singleton,
// as each template is probably unique
- synthetic.reflection.Constructor c=
+ org.apache.xalan.utils.synthetic.reflection.Constructor c=
tClass.getConstructor(ctor.getParameterTypes());
Object[] parms={source,eteParms};
instance=(ElemTemplate)c.newInstance(parms);
}
- catch(synthetic.SynthesisException e)
+ catch(org.apache.xalan.utils.synthetic.SynthesisException e)
{
System.out.println("CompilingStylesheetHandler class synthesis
error");
e.printStackTrace();
@@ -690,11 +690,11 @@
+"java.io.StringWriter "+sw+";\n"
+"try\n{\n"
- +"org.apache.xml.serialize.SerializerFactory
"+sfactory+"=org.apache.xml.serialize.SerializerFactory.getSerializerFactory(\"text\");\n"
+ +"org.apache.xml.org.apache.serialize.SerializerFactory
"+sfactory+"=org.apache.xml.org.apache.serialize.SerializerFactory.getSerializerFactory(\"text\");\n"
+sw+"=new java.io.StringWriter();\n"
- +"org.apache.xml.serialize.OutputFormat "+format+"=new
org.apache.xml.serialize.OutputFormat();\n"
+ +"org.apache.xml.org.apache.serialize.OutputFormat
"+format+"=new org.apache.xml.org.apache.serialize.OutputFormat();\n"
+format+".setPreserveSpace(true);\n"
- +"org.apache.xml.serialize.Serializer
"+serializer+"="+sfactory+".makeSerializer("+sw+","+format+");\n"
+ +"org.apache.xml.org.apache.serialize.Serializer
"+serializer+"="+sfactory+".makeSerializer("+sw+","+format+");\n"
+shandler+"="+serializer+".asContentHandler();\n"
+"}\ncatch (java.io.IOException "+ioe+")\n{\n"
+"throw new org.xml.sax.SAXException("+ioe+");\n}\n"
@@ -897,8 +897,8 @@
// name and output is written to the directory that file
// would be found in (possibly relative). However, "."
// is treated as being found in itself rather than in "..".
- // TODO: ***** A more elegant version of this should be moved into
synthetic.Class?
- Class compileSyntheticClass(synthetic.Class tClass, String classLocation)
+ // TODO: ***** A more elegant version of this should be moved into
org.apache.xalan.utils.synthetic.Class?
+ Class compileSyntheticClass(org.apache.xalan.utils.synthetic.Class tClass,
String classLocation)
{
Class resolved=null;
// Write class relative to specified starting location
@@ -1031,7 +1031,7 @@
tClass.getName());
e.printStackTrace();
}
- catch(synthetic.SynthesisException e)
+ catch(org.apache.xalan.utils.synthetic.SynthesisException e)
{
System.err.println("ERR: Synthetic class realization failed for
"+
tClass.getName());
1.2 +4 -4
xml-xalan/java/src/org/apache/xalan/processor/CompilingStylesheetProcessor.java
Index: CompilingStylesheetProcessor.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/CompilingStylesheetProcessor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CompilingStylesheetProcessor.java 2000/09/20 23:33:09 1.1
+++ CompilingStylesheetProcessor.java 2000/10/13 02:33:09 1.2
@@ -64,10 +64,10 @@
import org.w3c.dom.Node;
-import trax.Processor;
-import trax.ProcessorException;
-import trax.Templates;
-import trax.TemplatesBuilder;
+import org.apache.trax.Processor;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.Templates;
+import org.apache.trax.TemplatesBuilder;
/**
* The StylesheetProcessor, which implements the TRaX Processor
1.4 +1 -1
xml-xalan/java/src/org/apache/xalan/processor/ProcessorImport.java
Index: ProcessorImport.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorImport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ProcessorImport.java 2000/08/07 21:32:04 1.3
+++ ProcessorImport.java 2000/10/13 02:33:09 1.4
@@ -69,7 +69,7 @@
import org.xml.sax.EntityResolver;
import java.net.URL;
import java.io.IOException;
-import trax.URIResolver;
+import org.apache.trax.URIResolver;
import org.w3c.dom.Node;
/**
1.6 +1 -1
xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java
Index: ProcessorInclude.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ProcessorInclude.java 2000/10/11 03:36:03 1.5
+++ ProcessorInclude.java 2000/10/13 02:33:09 1.6
@@ -68,7 +68,7 @@
import java.net.URL;
import java.io.IOException;
import org.xml.sax.helpers.XMLReaderFactory;
-import trax.URIResolver;
+import org.apache.trax.URIResolver;
import org.w3c.dom.Node;
import org.apache.xalan.utils.SystemIDResolver;
1.3 +1 -1
xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java
Index: ProcessorOutputElem.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProcessorOutputElem.java 2000/10/02 02:43:06 1.2
+++ ProcessorOutputElem.java 2000/10/13 02:33:09 1.3
@@ -56,7 +56,7 @@
*/
package org.apache.xalan.processor;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
import java.util.Hashtable;
import org.apache.xalan.templates.OutputFormatExtended;
import org.apache.xalan.templates.StylesheetRoot;
1.12 +4 -4
xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java
Index: StylesheetHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- StylesheetHandler.java 2000/10/13 00:34:45 1.11
+++ StylesheetHandler.java 2000/10/13 02:33:09 1.12
@@ -65,10 +65,10 @@
import org.apache.xalan.templates.ElemUnknown;
import org.apache.xalan.utils.NodeConsumer;
import org.apache.xalan.utils.XMLCharacterRecognizer;
-import trax.ProcessorException;
-import trax.TemplatesBuilder;
-import trax.Templates;
-import trax.TransformException;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.TemplatesBuilder;
+import org.apache.trax.Templates;
+import org.apache.trax.TransformException;
import org.apache.xpath.XPath;
import org.apache.xpath.XPathFactory;
import org.apache.xpath.compiler.XPathParser;
1.9 +4 -4
xml-xalan/java/src/org/apache/xalan/processor/StylesheetProcessor.java
Index: StylesheetProcessor.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetProcessor.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StylesheetProcessor.java 2000/10/11 22:57:21 1.8
+++ StylesheetProcessor.java 2000/10/13 02:33:09 1.9
@@ -68,10 +68,10 @@
import org.apache.xalan.utils.TreeWalker;
import org.apache.xalan.utils.SystemIDResolver;
-import trax.Processor;
-import trax.ProcessorException;
-import trax.Templates;
-import trax.TemplatesBuilder;
+import org.apache.trax.Processor;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.Templates;
+import org.apache.trax.TemplatesBuilder;
import java.io.IOException;
import java.io.InputStream;
1.12 +1 -1
xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java
Index: SourceTreeHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SourceTreeHandler.java 2000/10/13 00:34:45 1.11
+++ SourceTreeHandler.java 2000/10/13 02:33:11 1.12
@@ -17,7 +17,7 @@
import org.xml.sax.SAXException;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
-import trax.Transformer;
+import org.apache.trax.Transformer;
/**
* This class handles SAX2 parse events to create a source
1.14 +3 -3
xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
Index: ElemTemplateElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ElemTemplateElement.java 2000/10/13 00:34:46 1.13
+++ ElemTemplateElement.java 2000/10/13 02:33:11 1.14
@@ -78,11 +78,11 @@
import org.apache.xpath.VariableStack;
// TRaX imports
-import trax.Templates;
+import org.apache.trax.Templates;
// Serializer imports
-import serialize.OutputFormat;
-import serialize.Serializer;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.Serializer;
// DOM Imports
import org.w3c.dom.Node;
1.10 +1 -1
xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java
Index: FuncDocument.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FuncDocument.java 2000/10/09 23:25:19 1.9
+++ FuncDocument.java 2000/10/13 02:33:12 1.10
@@ -88,7 +88,7 @@
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-import trax.TransformException;
+import org.apache.trax.TransformException;
/**
* <meta name="usage" content="advanced"/>
1.6 +1 -1
xml-xalan/java/src/org/apache/xalan/templates/FuncFormatNumb.java
Index: FuncFormatNumb.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/FuncFormatNumb.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FuncFormatNumb.java 2000/08/28 18:43:09 1.5
+++ FuncFormatNumb.java 2000/10/13 02:33:12 1.6
@@ -76,7 +76,7 @@
import org.w3c.dom.Node;
-import trax.TransformException;
+import org.apache.trax.TransformException;
/**
1.7 +4 -4
xml-xalan/java/src/org/apache/xalan/templates/OutputFormatExtended.java
Index: OutputFormatExtended.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/OutputFormatExtended.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- OutputFormatExtended.java 2000/10/02 23:42:33 1.6
+++ OutputFormatExtended.java 2000/10/13 02:33:12 1.7
@@ -56,7 +56,7 @@
*/
package org.apache.xalan.templates;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
import java.util.Vector;
import org.w3c.dom.Document;
@@ -227,7 +227,7 @@
if(m_shouldRecordHasBeenSet)
m_cdataElementsHasBeenSet = true;
int n = elements.size();
- serialize.QName[] qnames = new QName[n];
+ org.apache.serialize.QName[] qnames = new QName[n];
for(int i = 0; i < n; i++)
{
qnames[i] = (QName)elements.elementAt(i);
@@ -238,7 +238,7 @@
/**
* The cdata-section-elements attribute.
*/
- public void setCdataSectionElements(serialize.QName[] elements)
+ public void setCdataSectionElements(org.apache.serialize.QName[] elements)
{
if(m_shouldRecordHasBeenSet)
m_cdataElementsHasBeenSet = true;
@@ -399,7 +399,7 @@
*
* @param nonEscapingElements List of unescaped element tag names
*/
- public void setNonEscapingElements( serialize.QName[] nonEscapingElements )
+ public void setNonEscapingElements( org.apache.serialize.QName[]
nonEscapingElements )
{
// TODO: Need to work on this.
if(m_shouldRecordHasBeenSet)
1.10 +2 -2
xml-xalan/java/src/org/apache/xalan/templates/StylesheetComposed.java
Index: StylesheetComposed.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/StylesheetComposed.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StylesheetComposed.java 2000/10/11 22:11:01 1.9
+++ StylesheetComposed.java 2000/10/13 02:33:12 1.10
@@ -59,10 +59,10 @@
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
-import trax.ProcessorException;
+import org.apache.trax.ProcessorException;
import org.apache.xpath.XPath;
import org.apache.xalan.utils.QName;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xpath.XPathContext;
import org.w3c.dom.Node;
1.12 +5 -5
xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java
Index: StylesheetRoot.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- StylesheetRoot.java 2000/10/03 19:38:05 1.11
+++ StylesheetRoot.java 2000/10/13 02:33:12 1.12
@@ -63,7 +63,7 @@
import org.xml.sax.*;
import org.xml.sax.helpers.*;
-import serialize.*;
+import org.apache.serialize.*;
import org.apache.xalan.utils.*;
import org.apache.xpath.*;
@@ -72,9 +72,9 @@
import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xalan.res.XSLMessages;
import org.apache.xalan.transformer.TransformerImpl;
-import trax.Transformer;
-import trax.ProcessorException;
-import trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.Templates;
/**
* <meta name="usage" content="general"/>
@@ -145,7 +145,7 @@
* @see <a href="http://www.w3.org/TR/xslt#output">output in XSLT
Specification</a>
* @return A OutputProperties object that may be mutated.
*
- * @see org.xml.serialize.OutputFormat
+ * @see org.xml.org.apache.serialize.OutputFormat
*/
public OutputFormat getOutputFormat()
{
1.2 +1 -1
xml-xalan/java/src/org/apache/xalan/transformer/MsgMgr.java
Index: MsgMgr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/MsgMgr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MsgMgr.java 2000/06/19 16:53:05 1.1
+++ MsgMgr.java 2000/10/13 02:33:12 1.2
@@ -61,7 +61,7 @@
import org.xml.sax.Locator;
import org.xml.sax.ErrorHandler;
import org.w3c.dom.Node;
-import trax.TransformException;
+import org.apache.trax.TransformException;
/**
* This class will manage error messages, warning messages, and other types
of
1.17 +1 -1
xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java
Index: ResultTreeHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ResultTreeHandler.java 2000/10/13 00:34:47 1.16
+++ ResultTreeHandler.java 2000/10/13 02:33:12 1.17
@@ -88,7 +88,7 @@
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
-import serialize.SerializerHandler;
+import org.apache.serialize.SerializerHandler;
/**
* This class is a layer between the direct calls to the result
1.2 +4 -4
xml-xalan/java/src/org/apache/xalan/transformer/SerializerSwitcher.java
Index: SerializerSwitcher.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/SerializerSwitcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SerializerSwitcher.java 2000/10/13 00:34:47 1.1
+++ SerializerSwitcher.java 2000/10/13 02:33:13 1.2
@@ -61,10 +61,10 @@
import org.apache.xalan.templates.StylesheetRoot;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
-import serialize.Serializer;
-import serialize.SerializerFactory;
-import serialize.Method;
-import serialize.OutputFormat;
+import org.apache.serialize.Serializer;
+import org.apache.serialize.SerializerFactory;
+import org.apache.serialize.Method;
+import org.apache.serialize.OutputFormat;
import org.apache.xalan.templates.OutputFormatExtended;
/**
1.2 +1 -1
xml-xalan/java/src/org/apache/xalan/transformer/TransformState.java
Index: TransformState.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformState.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransformState.java 2000/07/23 17:17:01 1.1
+++ TransformState.java 2000/10/13 02:33:13 1.2
@@ -4,7 +4,7 @@
import org.apache.xalan.templates.ElemTemplateElement;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.NodeIterator;
-import trax.Transformer;
+import org.apache.trax.Transformer;
/**
* This interface is meant to be used by a consumer of
1.32 +16 -16
xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- TransformerImpl.java 2000/10/13 00:34:47 1.31
+++ TransformerImpl.java 2000/10/13 02:33:13 1.32
@@ -107,10 +107,10 @@
import org.apache.xpath.DOM2Helper;
// Serializer Imports
-import serialize.OutputFormat;
-import serialize.Serializer;
-import serialize.SerializerFactory;
-import serialize.Method;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.Serializer;
+import org.apache.serialize.SerializerFactory;
+import org.apache.serialize.Method;
// DOM Imports
import org.w3c.dom.Attr;
@@ -133,10 +133,10 @@
import org.xml.sax.SAXNotSupportedException;
// TRaX Imports
-import trax.Result;
-import trax.Transformer;
-import trax.TransformException;
-import trax.URIResolver;
+import org.apache.trax.Result;
+import org.apache.trax.Transformer;
+import org.apache.trax.TransformException;
+import org.apache.trax.URIResolver;
// Imported JAVA API for XML Parsing 1.0 classes
import javax.xml.parsers.DocumentBuilder;
@@ -329,13 +329,13 @@
Exception e = getExceptionThrown();
if(null != e)
{
- if(e instanceof trax.TransformException)
- throw (trax.TransformException)e;
+ if(e instanceof org.apache.trax.TransformException)
+ throw (org.apache.trax.TransformException)e;
else if(e instanceof org.apache.xalan.utils.WrappedRuntimeException)
- throw new trax.TransformException(
+ throw new org.apache.trax.TransformException(
((org.apache.xalan.utils.WrappedRuntimeException)e).getException());
else
- throw new trax.TransformException(e);
+ throw new org.apache.trax.TransformException(e);
}
else if(null != m_resultTreeHandler)
{
@@ -671,8 +671,8 @@
}
catch(SAXException se)
{
- if(se instanceof trax.TransformException)
- throw (trax.TransformException)se;
+ if(se instanceof org.apache.trax.TransformException)
+ throw (org.apache.trax.TransformException)se;
else
throw new TransformException(se);
}
@@ -735,7 +735,7 @@
* properties will override properties set in the templates
* with xsl:output.
*
- * @see org.xml.serialize.OutputFormat
+ * @see org.xml.org.apache.serialize.OutputFormat
*/
public void setOutputFormat(OutputFormat oformat)
{
@@ -745,7 +745,7 @@
/**
* Get the output properties used for the transformation.
*
- * @see org.xml.serialize.OutputFormat
+ * @see org.xml.org.apache.serialize.OutputFormat
*/
public OutputFormat getOutputFormat()
{
1.5 +1 -1 xml-xalan/java/src/org/apache/xalan/utils/QName.java
Index: QName.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/utils/QName.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- QName.java 2000/10/02 16:33:07 1.4
+++ QName.java 2000/10/13 02:33:14 1.5
@@ -75,7 +75,7 @@
* is used as the name of the object. The default namespace is not used for
* unprefixed names."
*/
-public class QName extends serialize.QName implements java.io.Serializable
+public class QName extends org.apache.serialize.QName implements
java.io.Serializable
{
/**
* The XML namespace.
1.8 +1 -1 xml-xalan/java/src/org/apache/xalan/utils/TreeWalker.java
Index: TreeWalker.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/utils/TreeWalker.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TreeWalker.java 2000/10/09 23:25:20 1.7
+++ TreeWalker.java 2000/10/13 02:33:14 1.8
@@ -63,7 +63,7 @@
import org.apache.xpath.DOMHelper;
import org.apache.xalan.utils.NodeConsumer;
-import serialize.SerializerHandler;
+import org.apache.serialize.SerializerHandler;
/**
* <meta name="usage" content="advanced"/>
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/Class.java
Index: Class.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.utils.synthetic;
import org.apache.xalan.utils.synthetic.SynthesisException;
import org.apache.xalan.utils.synthetic.reflection.Constructor;
import org.apache.xalan.utils.synthetic.reflection.Method;
import org.apache.xalan.utils.synthetic.reflection.Field;
import java.lang.reflect.Modifier;
/* ***** WORK NEEDED:
Factories/Libraries: We currently have forClass and
forName(request reified, complain if no real class),
and declareClass (request unreified, create unreified
if it doesn't exist). What about ther user expectations
-- should we have a full matrix, rather than asking
users to write wrappers?
Reflection doesn't tell us about deprecation. If we want
that info, MFC advises mousing our way into the bytecodes.
(Ugh). Should we at least model that for synthetics?
*/
/**
org.apache.xalan.utils.synthetic.Class is a mutable equivalent of
java.lang.Class.
Instances represent classes and interfaces in a running Java
application, or class descriptions under construction. In the
former case, org.apache.xalan.utils.synthetic.Class operates as a proxy for
the
"real" java.lang.Class object; in the latter, it consults
data structures defined in the
org.apache.xalan.utils.synthetic.reflection.* package.
<p>
Unlike java.lang.Class, org.apache.xalan.utils.synthetic.Class has a pair
of factories
(fromName and fromClass). It can also be switched from synthetic
to proxy operation after construction, by setting the realClass
property; this is intended to allow these definitions to be
"compiled in place".
<p>
For convenient use, org.apache.xalan.utils.synthetic.Class implements an
extended
version of the java.lang.Class API -- but is not a subclass
thereof, since java.lang.Class is Final (presumably for
security reasons).
<p>
DEVELOPMENT NOTE: Methods not yet implemented will throw
IllegalStateException
<p>
I've added code to convert primitive names into their TYPEs,
to accept foo[] as a synonym for [Lfoo, and to generate
the right thing on output (getJava[Short]Name).
Useful extension for code generation from Java-like
source. We may want to factor these and toSource out, making
org.apache.xalan.utils.synthetic.Class addess only the JVM level and
providing
subclasses or access tools that handle language syntax
(Java source, NetRexx source, etc.)
@since 2000/2/10
@see java.lang.class
@see defineClass
*/
public class Class extends Object implements java.io.Serializable
{
/** Class descriptions currently existing.*/
private static java.util.Hashtable global_classtable=new
java.util.Hashtable();
/**fully-qualified path.classname */
private java.lang.String name;
/** Actual Java class object. When present, all interactions
are redirected to it. Allows our Class to function as a
wrapper for the Java version (in lieu of subclassing or
a shared Interface), and allows "in-place compilation"
to replace a generated description with an
directly runnable class.
*/
private java.lang.Class realclass = null;
private int modifiers;
private boolean isInterface=false;
private Class superclass=null;
private Class declaringclass=null;
private Class[] interfaces=new Class[0];
private Class[] allclasses=new Class[0];
private Class[] declaredclasses=new Class[0];
private Constructor[] allconstructors=new Constructor[0];
private Constructor[] declaredconstructors=new Constructor[0];
private Method[] allmethods=new Method[0];
private Method[] declaredmethods=new Method[0];
private Field[] allfields=new Field[0];
private Field[] declaredfields=new Field[0];
private Class[] innerclasses=new Class[0];
/**
* Construct a synthetic class as proxy/wrapper for an existing
* Java Class. Non-public; most folks should use
* .forName and .forClass to request these wrappers, so they
* get the shared instances.
* <p>
* Creation date: (12-25-99 12:16:15 PM)
* @param realclass java.lang.Class
*/
Class(java.lang.Class realclass)
{
this(realclass.getName());
try
{
setRealClass(realclass);
}
catch(SynthesisException e)
{
e.printStackTrace();
}
}
/**
* Construct a named-but-empty synthetic Class object.
* Non-public; most folks should use
* .forName and .forClass to request these wrappers, so they
* get the shared instances.
* <p>
* Creation date: (12-25-99 12:15:23 PM)
* @param name java.lang.String
*/
Class(String fullname)
{
this.name=fullname;
global_classtable.put(fullname,this);
}
/**
Returns the synthetic Class object associated with the "real"
class specified, creating one if it didn't already exist.
<p>
For example, the following code fragment returns
the runtime Class descriptor for the class named
mypackage.MyClass.
<code>
Class t =
Class.forName(java.lang.Class.forName("mypackage.MyClass"))
</code>
<p>
Note that if the user has manually created a
org.apache.xalan.utils.synthetic.Class
with the same name before this call is issued, that object
will be found instead. See also the declareClass call.
<p>
***** We need a better way to declare/define array classes,
given a class object (synthetic or not).
@param cls the desired Java class.
@return the synthetic Class descriptor for the specified class.
*/
public static Class forClass(java.lang.Class cls)
{
if(cls==null)
return null;
Class ret=(Class)(global_classtable.get(cls.getName()));
if(null==ret)
ret=new Class(cls);
return ret;
}
/** Like forName, but if the classname doesn't have a package
prefix we first attempt to look it up as one of our own
inner clases. As with forName, if this can not be resolved
we throw an exception.
*/
public Class forNameInContext(String classname)
throws ClassNotFoundException
{
for(int i=innerclasses.length-1;i>=0;--i)
if(classname.equals(innerclasses[i].getShortName()) )
return innerclasses[i];
return forName(classname);
}
/**
Returns the synthetic Class object associated with the class
with the given fully-qualified name. If there isn't one, this
method attempts to locate, load and link the standard java Class.
If it succeeds, it returns a wrapped version of the Class object
representing the class. If it fails, the method throws a
ClassNotFoundException.
<p>
For example, the following code fragment returns
the runtime Class descriptor for the class named
mypackage.MyClass -- either as a synthetic or as
a standard Java class.
<code>
Class t =
Class.forName("mypackage.MyClass")
</code>
<p>
***** I've added support for arrays -- assuming any name
that ends with ']' is an array. It probably needs to be
made smarter, possibly via a subclass of
org.apache.xalan.utils.synthetic.Class.
@param className the fully qualified name of the desired class.
@return the synthetic Class descriptor for the class with the specified
name.
@throws ClassNotFoundException if the class could not be found.
*/
public static Class forName(String className) throws ClassNotFoundException
{
// ***** Experimental support for array syntax expressed
// per Java source rather than per JVM type formalism.
// Simpleminded, asssumes balanced []'s.
if(className.endsWith("]"))
{
StringBuffer arrayname=new StringBuffer();
for(int i=className.indexOf('[');
i!=-1;
i=className.indexOf('[',i+1) )
arrayname.append('[');
// Convert the classname to array-formalism
// Primitives have letters; objects are Lname;
// (Don't ask why long is spelled with a J and
// object is spelled with an L...)
String classname=className.substring(0,className.indexOf('['));
if("byte".equals(classname))
arrayname.append('B');
else if("char".equals(classname))
arrayname.append('C');
else if("double".equals(classname))
arrayname.append('D');
else if("float".equals(classname))
arrayname.append('F');
else if("int".equals(classname))
arrayname.append('I');
else if("long".equals(classname))
arrayname.append('J');
else if("short".equals(classname))
arrayname.append('S');
else if("boolean".equals(classname))
arrayname.append('Z');
else
arrayname.append('L')
.append(classname)
.append(';');
// Tail-call.
return forName(arrayname.toString());
}
Class ret=(Class)(global_classtable.get(className));
if(null==ret)
{
// ***** Experimental support for Java primitives
// Seems to me that mapping them into the "Type" is
// probably most useful
if("boolean".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Boolean.TYPE;
}
else if("byte".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Byte.TYPE;
}
else if("char".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Character.TYPE;
}
else if("short".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Short.TYPE;
}
else if("int".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Integer.TYPE;
}
else if("long".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Long.TYPE;
}
else if("float".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Float.TYPE;
}
else if("double".equals(className))
{
ret=new Class(className);
ret.realclass=java.lang.Double.TYPE;
}
else if("void".equals(className))
{
// ***** Void is an "absence of type". We might want to create
// a special object to represent it. This is a placeholder.
ret=new Class(className);
ret.realclass=java.lang.Class.forName("java.lang.Object");
}
// Other classes are just wrappered. Unknown classes throw a
// ClassNotFoundException; the user can switch to declareClass()
// if they're sure that an unreified class is OK.
else
ret=new Class(java.lang.Class.forName(className));
}
return ret;
}
/** Start to create a synthetic Class with the given fully-qualified
name. If a Class by that name already exists, and it is not
reified, it will be returned instead. If a reified Class _does_
exist, we throw a synthesis exception.
@param className the fully qualified name of the desired class.
@return the synthetic Class descriptor for the class with the specified
name.
@throws SynthesisException
if the class has been reified. */
public static Class declareClass(String className) throws SynthesisException
{
Class ret=(Class)(global_classtable.get(className));
if(null==ret)
ret=new Class(className);
if(ret.realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
return ret;
}
/** Start to create a synthetic Class with the given fully-qualified
name. If a Class by that name already exists,whether reified or
not, it will be removed from the table and replaced by the new synthesis.
***** NOTE THAT the replacement will not affect classes which
have already refernced the old version. We could change that by
having everyone reference everyone else via an indirection table.
@param className the fully qualified name of the desired class.
@return the synthetic Class descriptor for the class with the specified
name.
*/
public static Class reallyDeclareClass(String className)
{
Class ret=(Class)(global_classtable.get(className));
if(null!=ret)
global_classtable.remove(ret);
ret=new Class(className);
return ret;
}
/**
Returns an array containing Class objects
representing all the public classes and interfaces
that are members of the class represented by this
Class object. This includes public class and
interface members inherited from superclasses and
public class and interface members declared by the
class. Returns an array of length 0 if the class has
no public member classes or interfaces, or if this
Class object represents a primitive type.
<p>
NOTE: In a significant number of existing Java environments,
this method is not implemented by the official Class object
and always returns an empty array. So if you don't get any
useful information from a proxied java.lang.Class, don't
be surprised. I'm not sure if someone decided it was a
potential security issue, or if Sun was lazy and everyone
else followed suit.
<p>
ALSO NOTE: The above spec, as taken from java.lang.Class,
doesn't provide any good way to distinguish the immediate
superclass from all other superclasses. That makes it only
marginally useful, which is no doubt one of the reasons folks
have declined to implement it.
*/
public Class[] getClasses()
{
if(realclass!=null && allclasses==null)
{
java.lang.Class[] realDE=realclass.getClasses();
allclasses=new Class[realDE.length];
for(int i=0;i<realDE.length;++i)
allclasses[i]=forClass(realDE[i]);
}
return allclasses;
}
/**
Determines the class loader for the class.
@return
the class loader that created the class or
interface represented by this object, or null
if the org.apache.xalan.utils.synthetic.Class was not created by a class
loader.
@see
ClassLoader
*/
public ClassLoader getClassLoader()
{
return (realclass==null) ? null : realclass.getClassLoader();
}
/**
If this class represents an array type, returns the
Class object representing the component type of
the array; otherwise returns null.
<p>
NOTE: Since org.apache.xalan.utils.synthetic.Class doesn't yet attempt to
model array
types, this will currently return false unless we are
proxying such a type.
@see Array
*/
public Class getComponentType()
{
return realclass == null ? null : new Class(realclass.getComponentType());
}
/**
Returns a Constructor object that reflects the
specified public constructor of the class
represented by this Class object. The
parameterTypes parameter is an array of Class
objects that identify the constructor's formal
parameter types, in declared order.
<p>
The constructor to reflect is located by searching
all the constructors of the class represented by this
Class object for a public constructor with the
exactly the same formal parameter types.
@throws NoSuchMethodException
if a matching method is not found.
@throws SecurityException
if access to the information is denied.
@see
Constructor
*/
public Constructor getConstructor(Class parameterTypes[])
throws NoSuchMethodException, SecurityException, SynthesisException
{
if(realclass==null)
throw new SynthesisException(SynthesisException.UNREIFIED);
java.lang.Class[] real=new java.lang.Class[parameterTypes.length];
for(int i=0;i<parameterTypes.length;++i)
if( (real[i]=parameterTypes[i].getRealClass()) == null)
throw new SynthesisException(SynthesisException.UNREIFIED);
return new Constructor(realclass.getConstructor(real),this);
}
/**
Returns an array containing Constructor objects
reflecting all the public constructors of the class
represented by this Class object. An array of length
0 is returned if the class has no public
constructors.
@throws SecurityException
if access to the information is denied.
@see
Constructor
*/
public Constructor[] getConstructors() throws SecurityException
{
if(realclass!=null && allconstructors==null)
{
java.lang.reflect.Constructor[] realDC=realclass.getConstructors();
allconstructors=new Constructor[realDC.length];
for(int i=0;i<realDC.length;++i)
allconstructors[i]=new Constructor(realDC[i],this);
}
return allconstructors;
}
/**
This method is not implemented in VAJAVA 3.0
<p>
Returns an array of Class objects reflecting all the
classes and interfaces declared as members of the
class represented by this Class object. This
includes public, protected, default (package)
access, and private classes and interfaces declared
by the class, but excludes inherited classes and
interfaces. Returns an array of length 0 if the class
declares no classes or interfaces as members, or if
this Class object represents a primitive type.
@throws SecurityException
if access to the information is denied.
*/
public Class[] getDeclaredClasses() throws SecurityException
{
// ***** This should really be a single class plus declared interfaces.
if(realclass!=null && declaredclasses==null)
{
java.lang.Class[] realDE=realclass.getDeclaredClasses();
declaredclasses=new Class[realDE.length];
for(int i=0;i<realDE.length;++i)
{
declaredclasses[i]=forClass(realDE[i]);
if(!realDE[i].isInterface())
superclass=declaredclasses[i];
}
}
return declaredclasses;
}
/**
Adds an "extends" description for the class or
interface represented by this Class object
@throws SynthesisException
if the class has been reified.
@see
class
*/
public void addExtends(Class newclass)
throws SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
Class[] scratch=new Class[declaredclasses.length+1];
System.arraycopy(declaredclasses,0,scratch,0,declaredclasses.length);
scratch[declaredclasses.length]=newclass;
declaredclasses=scratch;
}
/**
Returns a Constructor object that reflects the
specified declared constructor of the class or
interface represented by this Class object. The
parameterTypes parameter is an array of Class
objects that identify the constructor's formal
parameter types, in declared order.
@throws NoSuchMethodException
if a matching method is not found.
@throws SecurityException
if access to the information is denied.
@see
Constructor
*/
public Constructor getDeclaredConstructor(Class parameterTypes[]) throws
NoSuchMethodException, SecurityException
{
throw new java.lang.IllegalStateException();
}
/**
Adds a Constructor description for the class or
interface represented by this Class object
@throws SynthesisException
if the class has been reified.
@see
Constructor
*/
public Constructor declareConstructor()
throws SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
Constructor newctor=new Constructor(this);
Constructor[] scratch=new Constructor[declaredconstructors.length+1];
System.arraycopy(declaredconstructors,0,scratch,0,declaredconstructors.length);
scratch[declaredconstructors.length]=newctor;
declaredconstructors=scratch;
scratch=new Constructor[allconstructors.length+1];
System.arraycopy(allconstructors,0,scratch,0,allconstructors.length);
scratch[allconstructors.length]=newctor;
allconstructors=scratch;
return newctor;
}
/**
* State that this class implements a specified interface.
* This does not yet update allMethods or otherwise
* attempt to inherit data.
*
* @param newifce org.apache.xalan.utils.synthetic.Class representing the
interface we want to add.
* @exception org.apache.xalan.utils.synthetic.SynthesisException if the
Class isn't an interface
* @see setSuperClass
* @see declareConstructor
* @see declareMethod
* @see declareField
*/
public Class declareInterface(Class newifce)
throws SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
if(!newifce.isInterface())
throw new
SynthesisException(SynthesisException.SYNTAX,newifce.getName()+" isn't an
interface");
Class[] scratch=new Class[interfaces.length+1];
System.arraycopy(interfaces,0,scratch,0,interfaces.length);
scratch[interfaces.length]=newifce;
interfaces=scratch;
scratch=new Class[allclasses.length+1];
System.arraycopy(allclasses,0,scratch,0,allclasses.length);
scratch[allclasses.length]=newifce;
allclasses=scratch;
return newifce;
}
/**
Returns an array of Constructor objects reflecting
all the constructors declared by the class
represented by this Class object. These are public,
protected, default (package) access, and private
constructors. Returns an array of length 0 if this
Class object represents an interface or a primitive
type.
<p>
See The Java Language Specification, section 8.2.
@throws SecurityException
if access to the information is denied.
@see
Constructor
*/
public Constructor[] getDeclaredConstructors() throws SecurityException
{
if(realclass!=null && declaredconstructors==null)
{
java.lang.reflect.Constructor[]
realDC=realclass.getDeclaredConstructors();
declaredconstructors=new Constructor[realDC.length];
for(int i=0;i<realDC.length;++i)
declaredconstructors[i]=new Constructor(realDC[i],this);
}
return declaredconstructors;
}
/**
Returns a Field object that reflects the specified
declared field of the class or interface represented
by this Class object. The name parameter is a
String that specifies the simple name of the desired
field.
@throws NoSuchFieldException
if a field with the specified name is not found.
@throws SecurityException
if access to the information is denied.
@see
Field
*/
public Field getDeclaredField(String name) throws NoSuchFieldException,
SecurityException
{
throw new java.lang.IllegalStateException();
}
/**
Adds a Field description for the class or
interface represented by this Class object
@throws SynthesisException
if the class has been reified.
@see
Constructor
*/
public Field declareField(String name)
throws SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
Field newfield=new Field(name,this);
Field[] scratch=new Field[declaredfields.length+1];
System.arraycopy(declaredfields,0,scratch,0,declaredfields.length);
scratch[declaredfields.length]=newfield;
declaredfields=scratch;
scratch=new Field[allfields.length+1];
System.arraycopy(allfields,0,scratch,0,allfields.length);
scratch[allfields.length]=newfield;
allfields=scratch;
return newfield;
}
/**
Returns an array of Field objects reflecting all the
fields declared by the class or interface represented
by this Class object. This includes public,
protected, default (package) access, and private
fields, but excludes inherited fields. Returns an
array of length 0 if the class or interface declares
no fields, or if this Class object represents a
primitive type. See The Java Language
Specification, sections 8.2 and 8.3.
@throws SecurityException
if access to the information is denied.
@see
Field
*/
public Field[] getDeclaredFields() throws SecurityException
{
if(realclass!=null && declaredfields==null)
{
java.lang.reflect.Field[] realDF=realclass.getDeclaredFields();
declaredfields=new Field[realDF.length];
for(int i=0;i<realDF.length;++i)
declaredfields[i]=new Field(realDF[i],this);
}
return declaredfields;
}
/**
Returns a Method object that reflects the specified
declared method of the class or interface
represented by this Class object. The name
parameter is a String that specifies the simple
name of the desired method, and the
parameterTypes parameter is an array of Class
objects that identify the method's formal parameter
types, in declared order.
@throws NoSuchMethodException
if a matching method is not found.
@throws SecurityException
if access to the information is denied.
@see
Method
*/
public Method getDeclaredMethod(String name, Class parameterTypes[])
throws NoSuchMethodException, SecurityException
{
throw new java.lang.IllegalStateException();
}
/**
Adds a Method description for the class or
interface represented by this Class object
@throws SynthesisException
if the class has been reified.
@see
Constructor
*/
public Method declareMethod(String name)
throws SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
Method newMethod=new Method(name,this);
Method[] scratch=new Method[declaredmethods.length+1];
System.arraycopy(declaredmethods,0,scratch,0,declaredmethods.length);
scratch[declaredmethods.length]=newMethod;
declaredmethods=scratch;
scratch=new Method[allmethods.length+1];
System.arraycopy(allmethods,0,scratch,0,allmethods.length);
scratch[allmethods.length]=newMethod;
allmethods=scratch;
return newMethod;
}
/**
Returns an array of Method objects reflecting all
the methods declared by the class or interface
represented by this Class object. This includes
public, protected, default (package) access, and
private methods, but excludes inherited methods.
Returns an array of length 0 if the class or interface
declares no methods, or if this Class object
represents a primitive type.
<p>
See The Java Language Specification, section 8.2.
@throws SecurityException
if access to the information is denied.
@see
Method
*/
public Method[] getDeclaredMethods() throws SecurityException
{
if(realclass!=null && declaredmethods==null)
{
java.lang.reflect.Method[] realDM=realclass.getDeclaredMethods();
declaredmethods=new Method[realDM.length];
for(int i=0;i<realDM.length;++i)
declaredmethods[i]=new Method(realDM[i],this);
}
return declaredmethods;
}
/**
This method is not implemented in VAJava 3.0
<p>
If the class or interface represented by this Class
object is a member of another class, returns the
Class object representing the class of which it is a
member (its declaring class). Returns null if this
class or interface is not a member of any other
class.
*/
public Class getDeclaringClass()
{
if(realclass!=null && declaringclass==null)
{
java.lang.Class dc=realclass.getDeclaringClass();
if(dc==null)
declaringclass=null;
else
declaringclass=forClass(dc);
}
return declaringclass;
}
/**
Declare that this class is an inner class of another.
*/
private void addInnerClass(Class newclass)
throws SynthesisException
{
if (realclass != null)
throw new SynthesisException(SynthesisException.REIFIED);
if(newclass.getDeclaringClass()!=this)
throw new SynthesisException(SynthesisException.WRONG_OWNER);
Class[] scratch=new Class[innerclasses.length+1];
System.arraycopy(innerclasses,0,scratch,0,innerclasses.length);
scratch[innerclasses.length]=newclass;
innerclasses=scratch;
}
/**
* Declare a class contained within this class. This doesn't
* address anonymous classes (those go inside method bodies
* and similar code), just local classes.
* <p>
* ***** This requires lookup methods that operate in the
* context of a specific class, and per-class registries!
*
* @param className Local name of inner class to create. This should _not_
be a
* qualified name, unlike the normal forName() call. Its
* hierarchy is established by the class within which it is
* created.
* @return org.apache.xalan.utils.synthetic.Class object for the contained
class.
* @exception org.apache.xalan.utils.synthetic.SynthesisException if class
could not be created.
* @since 2/2000
* @see forName
*/
public Class declareInnerClass(String className)
throws SynthesisException
{
if (realclass != null)
throw new SynthesisException(SynthesisException.REIFIED);
String relativeName=getName()+"$"+className;
Class newclass=(Class)(global_classtable.get(relativeName));
if(newclass!=null)
throw new SynthesisException(SynthesisException.SYNTAX,"Inner class
"+name+" already exists");
newclass=new Class(className);
newclass.declaringclass=this;
Class[] scratch=new Class[innerclasses.length+1];
System.arraycopy(innerclasses,0,scratch,0,innerclasses.length);
scratch[innerclasses.length]=newclass;
innerclasses=scratch;
return newclass;
}
/**
* Fetch a list of classes contained within this class.
* This doesn't address anonymous classes (those go
* inside method bodies and similar code), just local classes.
*
* @return org.apache.xalan.utils.synthetic.Class[] object for the
contained classes.
* This may be empty if none such exist, or if the class is
* reified (since reflection doesn't report this information).
* @since 3/2000
* @see forName
*/
public Class[] getInnerClasses()
{
return innerclasses;
}
/**
Returns a Field object that reflects the specified
public member field of the class or interface
represented by this Class object. The name
parameter is a String specifying the simple name of
the desired field.
<p>
The field to be reflected is located by searching all
the member fields of the class or interface
represented by this Class object for a public field
with the specified name.
<p>
See The Java Language Specification, sections 8.2
and 8.3.
@throws NoSuchFieldException
if a field with the specified name is not
found.
@throws SecurityException
if access to the information is denied.
@see
Field
*/
public Field getField(String name) throws NoSuchFieldException,
SecurityException
{
throw new java.lang.IllegalStateException();
}
/**
Returns an array containing Field objects
reflecting all the accessible public fields of the
class or interface represented by this Class object.
Returns an array of length 0 if the class or interface
has no accessible public fields, or if it represents
an array type or a primitive type.
<p>
Specifically, if this Class object represents a class,
returns the public fields of this class and of all its
superclasses. If this Class object represents an
interface, returns the fields of this interface and of
all its superinterfaces. If this Class object
represents an array type or a primitive type, returns
an array of length 0.
<p>
The implicit length field for array types is not
reflected by this method. User code should use the
methods of class Array to manipulate arrays.
<p>
See The Java Language Specification, sections 8.2
and 8.3.
@throws SecurityException
if access to the information is denied.
@see Field
*/
public Field[] getFields() throws SecurityException
{
if(realclass!=null && allfields==null)
{
java.lang.reflect.Field[] realDF=realclass.getFields();
allfields=new Field[realDF.length];
for(int i=0;i<realDF.length;++i)
allfields[i]=new Field(realDF[i],this);
}
return allfields;
}
/**
Determines the interfaces implemented by the
class or interface represented by this object.
<p>
If this object represents a class, the return value is
an array containing objects representing all
interfaces implemented by the class. The order of
the interface objects in the array corresponds to the
order of the interface names in the implements
clause of the declaration of the class represented by
this object.
<p>
If this object represents an interface, the array
contains objects representing all interfaces
extended by the interface. The order of the
interface objects in the array corresponds to the
order of the interface names in the extends clause
of the declaration of the interface represented by
this object.
<p>
If the class or interface implements no interfaces,
the method returns an array of length 0.
@return
an array of interfaces implemented by this
class.
*/
public Class[] getInterfaces()
{
if(realclass!=null && interfaces==null)
{
java.lang.Class[] realI=realclass.getInterfaces();
interfaces=new Class[realI.length];
for(int i=0;i<realI.length;++i)
interfaces[i]=forClass(realI[i]);
}
return interfaces;
}
/**
Adds an "implements" description for the class or
interface represented by this Class object
@throws SynthesisException
if the class has been reified.
@see
class
*/
public void addImplements(Class newclass)
throws SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
Class[] scratch=new Class[interfaces.length+1];
System.arraycopy(interfaces,0,scratch,0,interfaces.length);
scratch[interfaces.length]=newclass;
interfaces=scratch;
}
/**
Returns a Method object that reflects the specified
public member method of the class or interface
represented by this Class object. The name
parameter is a String specifying the simple name
the desired method, and the parameterTypes
parameter is an array of Class objects that identify
the method's formal parameter types, in declared
order.
<p>
The method to reflect is located by searching all
the member methods of the class or interface
represented by this Class object for a public
method with the specified name and exactly the
same formal parameter types.
<p>
See The Java Language Specification, sections 8.2
and 8.4.
@throws NoSuchMethodException
if a matching method is not found.
@throws SecurityException
if access to the information is denied.
@see
Method
*/
public Method getMethod(String name, Class parameterTypes[]) throws
NoSuchMethodException, SecurityException
{
throw new java.lang.IllegalStateException();
}
/**
Returns an array containing Method objects
reflecting all the public member methods of the
class or interface represented by this Class object,
including those declared by the class or interface
and and those inherited from superclasses and
superinterfaces. Returns an array of length 0 if the
class or interface has no public member methods.
<p>
See The Java Language Specification, sections 8.2
and 8.4.
@throws SecurityException
if access to the information is denied.
@see Method
**/
public Method[] getMethods() throws SecurityException
{
if(realclass!=null && allmethods==null)
{
java.lang.reflect.Method[] realDM=realclass.getMethods();
allmethods=new Method[realDM.length];
for(int i=0;i<realDM.length;++i)
allmethods[i]=new Method(realDM[i],this);
}
return allmethods;
}
/**
Returns the Java language modifiers for this class
or interface, encoded in an integer. The modifiers
consist of the Java Virtual Machine's constants for
public, protected, private, final, and interface; they
should be decoded using the methods of class
Modifier.
The modifier encodings are defined in The Java
Virtual Machine Specification, table 4.1.
See Also:
java.lang.reflect.Modifier
*/
public int getModifiers()
{
return modifiers;
}
/**
Set the Java language modifiers for this class
or interface, encoded in an integer. The modifiers
consist of the Java Virtual Machine's constants for
public, protected, private, final, and interface; they
should be decoded using the methods of class
Modifier.
The modifier encodings are defined in The Java
Virtual Machine Specification, table 4.1.
See Also:
java.lang.reflect.Modifier
*/
public void setModifiers(int modifiers) throws SynthesisException
{
if(this.realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.modifiers=modifiers;
}
/**
* Retrieve the fully-qualified classname. If it's an array,
* it will be returned in JVM syntax, not Java syntax.
*
* @return java.lang.String
* @since 12/95
* @see getShortName
* @see getJavaName
* @see getJavaShortName
*/
public java.lang.String getName() {
return name;
}
/**
* Like getName, but back-convert array notation escapes.
* ***** DOESN'T YET HANDLE ARRAYS OF PRIMITIVES!
*
* @return java.lang.String
* @since 3/2000
* @see getName
* @see getJavaShortName
*/
public java.lang.String getJavaName() {
if(name.charAt(0)!='[')
return name;
// Object array syntax is [Ltypename;
// add another [ for each level of array
int count=name.lastIndexOf('[');
StringBuffer jname=new StringBuffer(name.substring(count+2));
// Trim the trailing ';'
jname.setLength(jname.length()-1);
while(count-->=0)
jname.append("[]");
return jname.toString();
}
/**
* Extract just the local name of this class, minus the package
* prefix.
*
* ***** I don't think this handles array types properly yet.
*
* @return java.lang.String
* @since 12/99
* @see getName
* @see getPackageName
* @see getJavaName
* @see getJavaShortName
*/
public java.lang.String getShortName() {
int start=name.lastIndexOf(".");
if(start!=0 || name.charAt(0)=='.')
++start;
if(declaringclass!=null)
{
int d=name.lastIndexOf('$', start);
if(d!=0)
start=d+1;
}
return name.substring(start);
}
/**
* Like getShortName, but back-convert array notation escapes.
* ***** DOESN'T YET HANDLE ARRAYS OF PRIMITIVES!
*
* @return java.lang.String
* @since 3/2000
* @see getJavaName
* @see getShortName
*/
public java.lang.String getJavaShortName() {
String shortname=getShortName();
if(shortname.charAt(0)!='[')
return shortname;
// Object array syntax is [Ltypename;
// add another [ for each level of array
int count=shortname.lastIndexOf('[');
StringBuffer jname=new StringBuffer(shortname.substring(count+2));
// Trim the trailing ';'
jname.setLength(jname.length()-1);
while(count-->=0)
jname.append("[]");
return jname.toString();
}
/**
* Extract the package name for this class.
* ***** I don't think this handles array classes properly yet.
*
* @return java.lang.String
* @since 12/95
* @see getName
* @see getShortName
* @see getJavaName
* @see getJavaShortName
*/
public java.lang.String getPackageName() {
int start=name.lastIndexOf(".");
return name.substring(0,start);
}
/**
* If this synthetic class is a wrapper for a "real"
* java.lang.Class -- either because it was instantiated as such
* or because it has been compiled -- this method will return
* that class. Otherwise it returns null.
* Creation date: (12-25-99 12:26:01 PM)
* @return org.apache.xalan.utils.synthetic.Class
*/
public java.lang.Class getRealClass() {
return realclass;
}
/**
* This call is intended to allow an existing
org.apache.xalan.utils.synthetic.Class
* to be switched from purely descriptive mode to proxy mode
* ("reified").
* The primary intent is to allow a org.apache.xalan.utils.synthetic.Class
to be
* "compiled in place"
* <p>
* This should have the side-effect of limiting further mutation
* of the org.apache.xalan.utils.synthetic.Class to things which can not be
obtained
* from the real Class object, to avoid "lying" to the user
* <p>
* NOTE: Not all information defined by the Java libraries is
* in fact available in all Java environments. We assume the
* calls will work; if they return null or empty lists, there's
* nothing we can do about it. Note that this may mean that a
* reified class tells us less about itself than the
* synthetic description used to generate it.
* <p>
* Creation date: (12-25-99 12:26:01 PM)
* @param java.lang.class realclass nonsynthetic Class object to proxy
*/
public void setRealClass(java.lang.Class realclass)
throws SynthesisException
{
if(this.realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.realclass=realclass;
this.modifiers=realclass.getModifiers();
this.isInterface=realclass.isInterface();
// DEFERRED -- set them null now, reconstruct when requested
this.declaringclass=null;
this.interfaces=null;
this.declaredconstructors=null;
this.allconstructors=null;
this.declaredmethods=null;
this.allmethods=null;
this.declaredfields=null;
this.allfields=null;
this.declaredclasses=null;
this.allclasses=null;
this.superclass=null;
}
/**
* Set the superclass for this synthetic class.
* Object is equivalent to Null.
* Creation date: (12-25-99 12:26:01 PM)
* @return org.apache.xalan.utils.synthetic.Class
*/
public void setSuperClass(Class superclass)
throws SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.superclass=superclass;
}
/**
* Set the superclass for this synthetic class.
* Creation date: (12-25-99 12:26:01 PM)
* @return org.apache.xalan.utils.synthetic.Class
*/
public void setSuperClass(java.lang.Class superclass)
throws ClassNotFoundException,SynthesisException
{
if(realclass!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.superclass=Class.forClass(superclass);
}
/**
Finds a resource with the specified name. The
rules for searching for resources associated with a
given class are implemented by the class loader of
the class.
<p>
The Class methods delegate to ClassLoader
methods, after applying a naming convention: if
the resource name starts with "/", it is used as is.
Otherwise, the name of the package is prepended,
after converting "." to "/".
@param
name - the string representing the resource to
be found.
@return
the URL object having the specified name, or
null if no resource with the specified name
is found.
@see ClassLoader
@see getResourceAsStream
*/
public java.net.URL getResource(String name)
{
throw new java.lang.IllegalStateException();
}
/**
Finds a resource with a given name. Will return
null if no resource with this name is found. The
rules for searching a resources associated with a
given class are implemented by the ClassLoader of
the class.
<p>
The Class methods delegate to ClassLoader
methods, after applying a naming convention: if
the resource name starts with "/", it is used as is.
Otherwise, the name of the package is prepended,
after converting "." to "/".
@param
name - the string representing the resource to
be found
@return
the InputStream object having the
specified name, or null if no resource with
the specified name is found.
@see ClassLoader
@see getResource
*/
public java.io.InputStream getResourceAsStream(String name)
{
throw new java.lang.IllegalStateException();
}
/**
Get the signers of this class.
*/
public Object[] getSigners()
{
throw new java.lang.IllegalStateException();
}
/**
If this object represents any class other than the
class Object, then the object that represents the
superclass of that class is returned.
<p>
If this object is the one that represents the class
Object or this object represents an interface, null is
returned.
@return
the superclass of the class represented by this
object.
*/
public Class getSuperclass()
{
if(realclass!=null && superclass==null)
{
superclass=forClass(realclass.getSuperclass());
// getDeclaredClasses(); // Sets superclass as a side-effect
}
if(superclass==null)
superclass=forClass(Object.class);
return superclass;
}
/**
If this Class object represents an array type, returns
true, otherwise returns false.
*/
public boolean isArray()
{
return realclass!=null && realclass.isArray();
}
/**
Determines if the class or interface represented by
this Class object is either the same as, or is a
superclass or superinterface of, the class or
interface represented by the specified Class
parameter. It returns true if so, false otherwise. If
this Class object represents a primitive type,
returns true if the specified Class parameter is
exactly this Class object, false otherwise.
<p>
Specifically, this method tests whether the type
represented by the specified Class parameter can
be converted to the type represented by this Class
object via an identity conversion or via a widening
reference conversion. See The Java Language
Specification, sections 5.1.1 and 5.1.4 , for details.
@throws NullPointerException if the specified Class parameter is null.
*/
public boolean isAssignableFrom(Class cls)
{
if(realclass!=null && cls.realclass!=null)
return realclass.isAssignableFrom(cls.realclass);
throw new java.lang.IllegalStateException ();
}
/**
Determines if the class or interface represented by
this Class object is either the same as, or is a
superclass or superinterface of, the class or
interface represented by the specified Class
parameter. It returns true if so, false otherwise. If
this Class object represents a primitive type,
returns true if the specified Class parameter is
exactly this Class object, false otherwise.
<p>
Specifically, this method tests whether the type
represented by the specified Class parameter can
be converted to the type represented by this Class
object via an identity conversion or via a widening
reference conversion. See The Java Language
Specification, sections 5.1.1 and 5.1.4 , for details.
@throws NullPointerException if the specified Class parameter is null.
*/
public boolean isAssignableFrom(java.lang.Class cls)
{
if(realclass!=null)
return realclass.isAssignableFrom((java.lang.Class)cls);
throw new java.lang.IllegalStateException ();
}
/**
This method is the dynamic equivalent of the Java
language instanceof operator. The method
returns true if the specified Object argument is
non-null and can be cast to the reference type
represented by this Class object without raising a
ClassCastException. It returns false otherwise.
<p>
Specifically, if this Class object represents a
declared class, returns true if the specified Object
argument is an instance of the represented class (or
of any of its subclasses); false otherwise. If this
Class object represents an array class, returns true
if the specified Object argument can be converted
to an object of the array type by an identity
conversion or by a widening reference conversion;
false otherwise. If this Class object represents an
interface, returns true if the class or any superclass
of the specified Object argument implements this
interface; false otherwise. If this Class object
represents a primitive type, returns false.
@param obj The object to check
*/
public boolean isInstance(Object obj)
{
if (realclass!=null)
return realclass.isInstance(obj);
// Scan inheritances? (reliable).
// Check name? (not reliable).
throw new java.lang.IllegalStateException();
}
/**
Determines if the specified Class object represents
an interface type.
@return
true if this object represents an interface;
false otherwise.
*/
public boolean isInterface()
{
return (realclass != null) ? realclass.isInterface() : isInterface;
}
/**
Assert that the specified Class object represents
an interface type. Can't be changed after real class loaded.
@param
true if this object represents an interface;
false otherwise.
*/
public void isInterface(boolean isInterface)
throws SynthesisException
{
if(realclass == null)
this.isInterface=isInterface;
else if (realclass.isInterface()!=isInterface)
throw new SynthesisException(SynthesisException.REIFIED);
}
/**
Determines if the specified Class object represents
a primitive Java type.
<p>
There are nine predefined Class objects to
represent the eight primitive Java types and void.
These are created by the Java Virtual Machine, and
have the same names as the primitive types that
they represent, namely boolean, byte, char, short,
int, long, float, and double, and void.
<p>
These objects may only be accessed via the
following public static final variables, and are the
only Class objects for which this method returns
true.
*/
public boolean isPrimitive()
{
return realclass!=null && realclass.isPrimitive();
}
/**
Creates a new instance of a class.
@return
a newly allocated instance of the class
represented by this object. This is done
exactly as if by a new expression with an
empty argument list.
@throws IllegalAccessException
if the class or initializer is not accessible.
@throws InstantiationException
if an application tries to instantiate an
abstract class or an interface, or if the
instantiation fails for some other reason.
*/
public Object newInstance() throws InstantiationException,
IllegalAccessException
{
throw new java.lang.IllegalStateException();
}
/**
Converts the object to a string. The string
representation is the string "class" or
"interface" followed by a space and then the
fully qualified name of the class. If this Class
object represents a primitive type, returns the
name of the primitive type.
<p>
***** Should this say "synthetic" as well as "class" or
"interface"? Or should that be gated on whether we're proxy
to a realclass?
@return a string representation of this class object.
*/
public String toString()
{
if (realclass != null)
return realclass.toString();
else
if (isInterface())
return "interface " + name;
else
return "class " + name;
}
/** Convenience for writing to, eg, System.out */
public void toSource(java.io.OutputStream out,int depth)
{
java.io.PrintWriter writer=new java.io.PrintWriter(out);
toSource(writer,depth);
}
/**
Converts the object to a Java code stream. The string
representation is as full a Java definition of the class
as we are able to achieve. If this Class
object represents a primitive type, returns the
name of the primitive type.
*/
public void toSource(java.io.PrintWriter out,int depth)
{
String tab=tabset(depth);
if (realclass != null)
out.println(tab+"/** Code back-generated from a \"real\" Class;
accuracy limited by reflection APIs. */");
else
out.println(tab+"/** Code generated via
org.apache.xalan.utils.synthetic.Class */");
/* Package should not be printed for inner classes */
if (getDeclaringClass()==null)
out.println(tab+"package "+getPackageName()+";");
out.print(tab+Modifier.toString(getModifiers()));
if (isInterface())
out.print(" interface ");
else
out.print(" class ");
out.println(getJavaShortName());
if(superclass!=null)
{
out.print('\n'+tab+" extends "+superclass.getJavaName());
}
Class[] ext=getInterfaces();
if(ext!=null & ext.length>0)
{
// Interfaces extend other interfaces,
// Classes implement interfaces.
out.print('\n'+tab+
(isInterface ? " extends " : " implements ")+
ext[0].getName());
for(int i=1;i<ext.length;++i)
{
out.print(", "+ext[i].getJavaName());
}
out.print("\n");
}
out.print(tab+"{\n");
tab=tabset(++depth);
// Fields--------------------------------
Field[] fields=null;
try
{
fields=getDeclaredFields();
} catch(SecurityException e)
{ out.println(tab+"//SecurityException retrieving fields"); }
if(fields!=null)
{
for(int i=0;i<fields.length;++i)
out.println(tab+fields[i].toSource());
}
// Constructors--------------------------
Constructor[] ctors=null;
try
{
ctors=getDeclaredConstructors();
} catch(SecurityException e)
{ out.println(tab+"//SecurityException retrieving ctors"); }
if(ctors!=null)
{
for(int i=0;i<ctors.length;++i)
out.print(ctors[i].toSource(tab));
}
// Methods-------------------------------
Method[] methods=null;
try
{
methods=getDeclaredMethods();
} catch(SecurityException e)
{ out.println(tab+"//SecurityException retrieving methods"); }
if(methods!=null)
{
for(int i=0;i<methods.length;++i)
{
out.print('\n');
out.print(methods[i].toSource(tab));
}
}
// Inner classes --------------------------------
Class[] inners=getInnerClasses();
if(inners!=null)
{
for(int i=0;i<inners.length;++i)
{
out.print('\n');
inners[i].toSource(out,depth);
}
}
// Done------------------------------
tab=tabset(--depth);
out.print(tab+"}\n");
out.flush();
}
private String tabset(int depth)
{
StringBuffer t=new StringBuffer();
while(depth-- >0)
t.append(" ");
return t.toString();
}
// Ignores any keywords we don't recognize
static final int[] val=
{Modifier.ABSTRACT,Modifier.FINAL,Modifier.INTERFACE,
Modifier.NATIVE,Modifier.PRIVATE,Modifier.PROTECTED,
Modifier.PUBLIC,Modifier.STATIC,Modifier.SYNCHRONIZED,
Modifier.TRANSIENT,Modifier.VOLATILE};
static final String[] kwd=
{"abstract","final","interface",
"native","private","protected",
"public","static","synchronized",
"transient","volatile"};
static public int modifierFromString(String t)
{
for(int i=0;i<kwd.length;++i)
if(kwd[i].equals(t))
return val[i];
return 0;
}
static public int modifiersFromString(String s)
{
int mods=0;
java.util.StringTokenizer parts=new java.util.StringTokenizer(s);
while(parts.hasMoreTokens())
{
String t=parts.nextToken();
mods|=modifierFromString(t);
}
return mods;
}
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/JavaUtils.java
Index: JavaUtils.java
===================================================================
/* $Id: JavaUtils.java,v 1.1 2000/10/13 02:33:14 sboag Exp $ */
package org.apache.xalan.utils.synthetic;
import java.io.IOException;
public class JavaUtils
{
// Debug flag - generates debug stuff if true.
private static boolean debug = false;
// Temporarily copied from JavaEngine...
private static boolean cantLoadCompiler=false; // One-time flag for
following
// ADDED BY JKESS; callers want control over the -g option.
public static void setDebug(boolean newDebug)
{
debug=newDebug;
}
public static boolean JDKcompile(String fileName, String classPath)
{
if (debug)
{
System.err.println ("JavaEngine: Compiling " + fileName);
System.err.println ("JavaEngine: Classpath is " + classPath);
}
String option = debug ? "-g" : "-O";
if(!cantLoadCompiler)
{
String args[] = {
option,
"-classpath",
classPath,
fileName
};
try
{
return new sun.tools.javac.Main(System.err, "javac").compile(args);
}
catch (Throwable th)
{
System.err.println("WARNING: Unable to load Java 1.1 compiler.");
System.err.println("\tSwitching to command-line invocation.");
cantLoadCompiler=true;
}
}
// Can't load javac; try exec'ing it.
String args[] = {
"javac",
option,
"-classpath",
classPath,
fileName
};
try
{
Process p=java.lang.Runtime.getRuntime().exec(args);
p.waitFor();
return(p.exitValue()!=0);
}
catch(IOException e)
{
System.err.println("ERROR: IO exception during exec(javac).");
}
catch(SecurityException e)
{
System.err.println("ERROR: Unable to create subprocess to exec(javac).");
}
catch(InterruptedException e)
{
System.err.println("ERROR: Wait for exec(javac) was interrupted.");
}
return false;
}
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/SynthesisException.java
Index: SynthesisException.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.utils.synthetic;
public class SynthesisException
extends Exception
{
int code;
// Manefest constants
public static final int SYNTAX=0;
public static final int UNSUPPORTED=1;
public static final int REIFIED=2;
public static final int UNREIFIED=3;
public static final int WRONG_OWNER=4;
public static final String[] errToString =
{
"(Syntax error; specific message should be passed in)",
"Feature not yet supported",
"Can't change features of 'real' class",
"Can't yet instantiate/invoke without 'real' class",
"Can't add Member to an object other than its declarer",
};
public SynthesisException(int code)
{
super(errToString[code]);
this.code=code;
}
public SynthesisException(int code, String msg)
{
super(msg);
this.code=code;
}
int getCode() {return code;}
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/TestDriver.java
Index: TestDriver.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/** Test driver for org.apache.xalan.utils.synthetic.Class and
org.apache.xalan.utils.synthetic.reflection.*
<p>
toSource should probably be factored out into a separate
java generator class, so we could generate other languages as well.
*/
package org.apache.xalan.utils.synthetic;
import org.apache.xalan.utils.synthetic.Class;
import org.apache.xalan.utils.synthetic.reflection.*;
public class TestDriver
{
public static int sampleField=32;
private boolean inTest=false;
public static void main(String[] args)
{
// Proxy a class
try
{
System.out.println("Proxying java.awt.Frame...");
Class myC=Class.forName("java.awt.Frame");
myC.toSource(System.out,0);
System.out.println("\nProxying
org.apache.xalan.utils.synthetic.TestDriver...");
myC=Class.forName("com.ibm.org.apache.xalan.utils.synthetic.TestDriver");
myC.toSource(System.out,0);
}
catch(ClassNotFoundException e)
{
System.out.println("Couldn't proxy: ");
e.printStackTrace();
}
// Start getting serious
try
{
System.out.println("\nBuild a new beast...");
Class
myC=Class.declareClass("com.ibm.org.apache.xalan.utils.synthetic.BuildMe");
Class inner=myC.declareInnerClass("island");
inner.addExtends(Class.forName("java.lang.String"));
Method m=inner.declareMethod("getValue");
m.setReturnType(Class.forName("java.lang.String"));
m.getBody().append("return toString();");
myC.toSource(System.out,0);
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SynthesisException e)
{
e.printStackTrace();
}
catch(IllegalStateException e)
{
System.out.println("Unwritten function: "+e);
e.printStackTrace();
}
}
public static void dumpClass(Class C)
{
System.out.println("toString(): "+C);
System.out.println("\tisPrimitive(): "+C.isPrimitive());
System.out.println("\tisInterface(): "+C.isInterface());
System.out.println("\tisInstance(\"foo\"): "+C.isInstance("foo"));
System.out.println("\tisArray(): "+C.isArray());
System.out.println("\tgetRealClass(): "+C.getRealClass());
}
public void quickcheck()
{
Inner a=new Inner();
a.setTest(!a.getTest());
}
private class Inner
{
public boolean getTest()
{
return inTest;
}
public void setTest(boolean test)
{
inTest=test;
}
}
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/reflection/Constructor.java
Index: Constructor.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.utils.synthetic.reflection;
import java.lang.reflect.InvocationTargetException;
import org.apache.xalan.utils.synthetic.SynthesisException;
/**
Constructor provides information about, and access to, a
single constructor for a class.
Constructor permits widening conversions to occur when
matching the actual parameters to newInstance() with
the underlying constructor's formal parameters, but
throws an IllegalArgumentException if a narrowing
conversion would occur.
@see Member
@see Class
@see getConstructors
@see getConstructor
@see getDeclaredConstructors
*/
public class Constructor
extends EntryPoint
implements Member
{
/**
Actual Java class object. When present, all interactions
are redirected to it. Allows our Class to function as a
wrapper for the Java version (in lieu of subclassing or
a shared Interface), and allows "in-place compilation"
to replace a generated description with an
directly runnable class.
*/
private org.apache.xalan.utils.synthetic.Class declaringclass = null;
private java.lang.reflect.Constructor realconstructor = null;
private org.apache.xalan.utils.synthetic.Class[] parametertypes;
private String[] parameternames;
private org.apache.xalan.utils.synthetic.Class[] exceptiontypes;
private int modifiers;
/**
* Insert the method's description here.
* <p>
* Creation date: (12-27-99 2:31:39 PM)
* @param realConstructor java.lang.reflect.Constructor
*/
public Constructor(org.apache.xalan.utils.synthetic.Class declaringclass)
{
super(declaringclass);
}
/**
* Insert the method's description here.
* <p>
* Creation date: (12-27-99 2:31:39 PM)
* @param realConstructor java.lang.reflect.Constructor
*/
public Constructor(java.lang.reflect.Constructor
ctor,org.apache.xalan.utils.synthetic.Class declaringclass)
{
super(ctor,declaringclass);
}
/**
* Insert the method's description here.
* <p>
* Creation date: (12-27-99 2:31:39 PM)
* @param realConstructor java.lang.reflect.Constructor
*/
public Constructor(java.lang.reflect.Constructor realconstructor)
{
super(realconstructor);
}
/**
Returns a hashcode for this Constructor. The
hashcode is the same as the hashcode for the
underlying constructor's declaring class name.
*/
public int hashCode()
{
return getDeclaringClass().getName().hashCode();
}
/**
Uses the constructor represented by this
Constructor object to create and initialize a new
instance of the constructor's declaring class, with
the specified initialization parameters. Individual
parameters are automatically unwrapped to match
primitive formal parameters, and both primitive
and reference parameters are subject to widening
conversions as necessary. Returns the newly
created and initialized object.
<p>
Creation proceeds with the following steps, in
order:
<p>
If the class that declares the underlying constructor
represents an abstract class, the creation throws an
InstantiationException.
<p>
If this Constructor object enforces Java language
access control and the underlying constructor is
inaccessible, the creation throws an
IllegalAccessException.
<p>
If the number of actual parameters supplied via
initargs is different from the number of formal
parameters required by the underlying constructor,
the creation throws an IllegalArgumentException.
<p>
A new instance of the constructor's declaring class
is created, and its fields are initialized to their
default initial values.
<p>
For each actual parameter in the supplied initargs
array:
<p>
If the corresponding formal parameter has a
primitive type, an unwrapping conversion is
attempted to convert the object value to a value of
the primitive type. If this attempt fails, the
creation throws an IllegalArgumentException.
<p>
If, after possible unwrapping, the parameter value
cannot be converted to the corresponding formal
parameter type by an identity or widening
conversion, the creation throws an
IllegalArgumentException.
<p>
Control transfers to the underlying constructor to
initialize the new instance. If the constructor
completes abruptly by throwing an exception, the
exception is placed in an
InvocationTargetException and thrown in turn to
the caller of newInstance.
<p>
If the constructor completes normally, returns the
newly created and initialized instance.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the number of actual and formal
parameters differ, or if an unwrapping
conversion fails.
@throws InstantiationException
if the class that declares the underlying
constructor represents an abstract class.
@throws InvocationTargetException
if the underlying constructor throws an
exception.
*/
public Object newInstance(Object initargs[])
throws InstantiationException, IllegalAccessException,
IllegalArgumentException,
java.lang.reflect.InvocationTargetException
{
if(realep!=null)
return ((java.lang.reflect.Constructor)realep).newInstance(initargs);
else
throw new InstantiationException("Un-reified
org.apache.xalan.utils.synthetic.Class doesn't yet support invocation");
}
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/reflection/EntryPoint.java
Index: EntryPoint.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.utils.synthetic.reflection;
import java.lang.reflect.InvocationTargetException;
import org.apache.xalan.utils.synthetic.SynthesisException;
/***** OPEN ISSUES:
Reflection doesn't tell us about deprecation; if we want
that info, MFC advises mousing our way into the class (ugh).
Should we at least model that for synthetics?
*/
/**
API/behaviors shared between Constructors and Methods.
They're mostly similar, except for what they proxy and
a few specific calls (name, invoke/getInstance).
*/
abstract public class EntryPoint
implements Member
{
protected Object realep;
private org.apache.xalan.utils.synthetic.Class declaringclass = null;
protected org.apache.xalan.utils.synthetic.Class returntype = null;
private String[] parameternames=new String[0];
private org.apache.xalan.utils.synthetic.Class[] parametertypes=new
org.apache.xalan.utils.synthetic.Class[0];
private org.apache.xalan.utils.synthetic.Class[] exceptiontypes=new
org.apache.xalan.utils.synthetic.Class[0];;
private int modifiers;
protected String name=null; // for Methods
// For synthesis:
private StringBuffer body=null;
private String language=null;
// For reifying:
Class[] realE,realP;
/**
* Insert the method's description here.
* <p>
* Creation date: (12-27-99 2:31:39 PM)
* @param realConstructor java.lang.reflect.Constructor
*/
public EntryPoint(org.apache.xalan.utils.synthetic.Class declaringclass)
{
this.declaringclass=declaringclass;
}
/** Nonpublic constructor. Wrap this to appropriate "real" type */
protected EntryPoint(Object ep,org.apache.xalan.utils.synthetic.Class
declaringclass)
throws IllegalArgumentException
{
realep=ep;
this.declaringclass=declaringclass;
if(ep instanceof java.lang.reflect.Method)
{
java.lang.reflect.Method m=(java.lang.reflect.Method)ep;
if(declaringclass==null)
{
declaringclass=org.apache.xalan.utils.synthetic.Class.forClass(m.getDeclaringClass());
}
name=m.getName();
modifiers=m.getModifiers();
returntype=org.apache.xalan.utils.synthetic.Class.forClass(m.getReturnType());
realP=m.getParameterTypes();
realE=m.getExceptionTypes();
}
else if(ep instanceof java.lang.reflect.Constructor)
{
java.lang.reflect.Constructor c=(java.lang.reflect.Constructor)ep;
if(declaringclass==null)
{
declaringclass=org.apache.xalan.utils.synthetic.Class.forClass(c.getDeclaringClass());
}
name=declaringclass.getShortName();
modifiers=c.getModifiers();
returntype=declaringclass;
realP=c.getParameterTypes();
realE=c.getExceptionTypes();
}
else
throw new IllegalArgumentException();
}
/** Nonpublic constructor. Wrap this to appropriate "real" type */
protected EntryPoint(Object ep)
throws IllegalArgumentException
{
this(ep,null);
}
/**
Compares this against the specified
object. Returns true if the objects are the same.
Two EntryPoints are the same if they were
declared by the same class, have the same name
(or are both ctors) and have the same
formal parameter types.
*/
public boolean equals(Object obj)
{
EntryPoint otherep=null;
if (obj instanceof EntryPoint)
otherep=(EntryPoint)obj;
else if (obj instanceof java.lang.reflect.Constructor ||
obj instanceof java.lang.reflect.Method)
otherep = (EntryPoint)obj;
return (otherep!=null
&& ((this instanceof Constructor && otherep instanceof Constructor)
||
(this instanceof Method && otherep instanceof Method &&
this.getName().equals(otherep.getName()) ))
&& otherep.getDeclaringClass().equals(declaringclass)
&& otherep.getParameterTypes().equals(parametertypes));
}
/**
Returns the Class object representing the class that
declares the constructor represented by this
Constructor object.
*/
public org.apache.xalan.utils.synthetic.Class getDeclaringClass()
{
return declaringclass;
}
/**
Returns the Class object representing the class that
will be returned by this EntryPoint. Needed by the Method
API, but made meaningful for Constructors as well.
*/
public org.apache.xalan.utils.synthetic.Class getReturnType()
{
return returntype;
}
/**
Returns an array of Class objects that represent the
types of the checked exceptions thrown by the
underlying constructor represented by this
Constructor object. Returns an array of length 0 if
the constructor throws no checked exceptions.
*/
public org.apache.xalan.utils.synthetic.Class[] getExceptionTypes()
{
if(realep!=null && exceptiontypes==null)
{
exceptiontypes=new org.apache.xalan.utils.synthetic.Class[realE.length];
for(int i=0;i<realE.length;++i)
exceptiontypes[i]=org.apache.xalan.utils.synthetic.Class.forClass(realE[i]);
realE=null;
}
return exceptiontypes;
}
public void addExceptionType(org.apache.xalan.utils.synthetic.Class
exception)
throws SynthesisException
{
if(realep!=null)
throw new SynthesisException(SynthesisException.REIFIED);
org.apache.xalan.utils.synthetic.Class[] e=new
org.apache.xalan.utils.synthetic.Class[exceptiontypes.length+1];
System.arraycopy(exceptiontypes,0,e,0,exceptiontypes.length);
e[exceptiontypes.length]=exception;
exceptiontypes=e;
}
/**
Returns the Java language modifiers for the
constructor represented by this Constructor object,
as an integer. The Modifier class should be used to
decode the modifiers.
@see
Modifier
*/
public int getModifiers()
{
return modifiers;
}
/**
* Member method. C'tor's name is always that of the defining class.
* Methods have a "real" name.
* Creation date: (12-25-99 1:32:06 PM)
* @return java.lang.String
*/
public java.lang.String getName() {
if(this instanceof Constructor)
return declaringclass.getShortName();
return name;
}
/**
* Member method. C'tor's name is always that of the defining class.
* Methods have a "real" name.
* Creation date: (12-25-99 1:32:06 PM)
* @return java.lang.String
*/
public void setName(String name)
throws SynthesisException
{
if(realep!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.name=name;
}
/**
Returns an array of Class objects that represent the
formal parameter types, in declaration order, of the
constructor represented by this Constructor object.
Returns an array of length 0 if the underlying
constructor takes no parameters.
*/
public org.apache.xalan.utils.synthetic.Class[] getParameterTypes()
{
if(realep!=null && parametertypes==null)
{
parametertypes=new
org.apache.xalan.utils.synthetic.Class[realP.length];
for(int i=0;i<realP.length;++i)
parametertypes[i]=org.apache.xalan.utils.synthetic.Class.forClass(realP[i]);
realP=null;
}
return parametertypes;
}
public String[] getParameterNames()
{
return parameternames;
}
public void addParameter(org.apache.xalan.utils.synthetic.Class type,String
name)
throws SynthesisException
{
if(realep!=null)
throw new SynthesisException(SynthesisException.REIFIED);
org.apache.xalan.utils.synthetic.Class[] types=new
org.apache.xalan.utils.synthetic.Class[parametertypes.length+1];
System.arraycopy(parametertypes,0,types,0,parametertypes.length);
types[parametertypes.length]=type;
parametertypes=types;
String[] names=new String[parameternames.length+1];
System.arraycopy(parameternames,0,names,0,parameternames.length);
names[parameternames.length]=name;
parameternames=names;
}
/**
Returns a hashcode for this Constructor. The
hashcode is the same as the hashcode for the
underlying constructor's declaring class name,
xor'ed (for Methods) with the method name.
(Implemented in the subclasses rather than here.)
*/
abstract public int hashCode();
/**
Assert the Class object representing the class that
declares the constructor represented by this
Constructor object.
*/
public void setDeclaringClass(org.apache.xalan.utils.synthetic.Class
declaringClass)
throws SynthesisException
{
if(realep!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.declaringclass=declaringClass;
}
/**
***** Should only be accepted before a "real" entrypoint is bound.
* Creation date: (12-25-99 1:28:28 PM)
* @return int
* @param modifiers int
*/
public void setModifiers(int modifiers)
throws SynthesisException
{
if(realep!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.modifiers=modifiers;
}
/**
Return a string describing this Constructor. The
string is formatted as the constructor access
modifiers, if any, followed by the fully-qualified
name of the declaring class, followed by a
parenthesized, comma-separated list of the
constructor's formal parameter types. For example:
<code>
public java.util.Hashtable(int,float)
</code>
<p>
The only possible modifiers for constructors are
the access modifiers public, protected or
private. Only one of these may appear, or none
if the constructor has default (package) access.
<p>
Methods will also display their checked exceptions.
*/
public String toString()
{
StringBuffer sb=
new StringBuffer(java.lang.reflect.Modifier.toString(getModifiers()));
if(this instanceof org.apache.xalan.utils.synthetic.reflection.Method)
sb.append(' ').append(getReturnType())
.append(getDeclaringClass().getName())
.append('.').append(getName());
else
sb.append(getDeclaringClass().getName());
sb.append('(');
org.apache.xalan.utils.synthetic.Class[] p=getParameterTypes();
if(p!=null && p.length>0)
{
sb.append(p[0].getName());
for(int i=1;i<p.length;++i)
sb.append(',').append(p[i].getName());
}
sb.append(')');
if(this instanceof org.apache.xalan.utils.synthetic.reflection.Method)
{
p=getExceptionTypes();
if(p!=null && p.length>0)
{
sb.append(" throws ").append(p[0].getName());
for(int i=1;i<p.length;++i)
sb.append(',').append(p[i].getName());
}
}
return sb.toString();
}
/** Extension: For synthesis, we need a place to hang a
method body.
*/
public void setBody(String language,StringBuffer body)
throws SynthesisException
{
if(realep!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.language=language;
this.body=body;
}
/** Extension: For synthesis, we need a place to hang a
method body. Note that this returns a mutable object,
for editing etc. Slightly sloppy first cut.
*/
public StringBuffer getBody()
{
if(body==null)
body=new StringBuffer();
return body;
}
/** Extension: For synthesis, we need a place to hang a
method body.
*/
public String getLanguage()
{
return language;
}
/** Generate Java code
*/
public String toSource(String basetab)
{
StringBuffer sb=new StringBuffer();
sb.append(basetab)
.append(java.lang.reflect.Modifier.toString(getModifiers()));
if(this instanceof org.apache.xalan.utils.synthetic.reflection.Method)
{
if (returntype!=null)
sb.append(" ").append(getReturnType().getJavaName());
else
sb.append(" void");
}
sb.append(" ").append(getName())
.append("(");
org.apache.xalan.utils.synthetic.Class[] types=getParameterTypes();
if(types!=null & types.length>0)
{
sb.append(types[0].getJavaName());
if(parameternames!=null)
sb.append(' ').append(parameternames[0]);
for(int i=1;i<types.length;++i)
{
sb.append(',').append(types[i].getJavaName());
if(parameternames!=null)
sb.append(' ').append(parameternames[i]);
}
}
sb.append(')');
types=getExceptionTypes();
if(types!=null & types.length>0)
{
sb.append(" throws ").append(types[0].getJavaName());
for(int i=1;i<types.length;++i)
{
sb.append(',').append(types[i].getJavaName());
}
}
if(body==null)
sb.append("; // No method body available\n");
else
{
sb.append("\n"+basetab+"{\n");
if(language==null || "java".equals(language))
{
sb.append(basetab+"// ***** Should prettyprint this code...\n");
sb.append(basetab+body+"\n");
}
else
{
sb.append(basetab+"// ***** Generate BSF invocation!?\n");
}
sb.append(basetab+"}\n");
}
return sb.toString();
}
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/reflection/Field.java
Index: Field.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.utils.synthetic.reflection;
import org.apache.xalan.utils.synthetic.Class;
import org.apache.xalan.utils.synthetic.SynthesisException;
/**
A Field provides information about, and dynamic access
to, a single field of a class or an interface. The reflected
field may be a class (static) field or an instance field.
<p>
A Field permits widening conversions to occur during a
get or set access operation, but throws an
IllegalArgumentException if a narrowing conversion
would occur.
@see Member
@see Class
@see getFields
@see getField
@see getDeclaredFields
@see getDeclaredField
**/
public class Field
extends Object
implements Member
{
public String name, initializer=null;
int modifiers;
java.lang.reflect.Field realfield=null;
Class declaringClass,type;
/** Proxy constructor */
public Field(java.lang.reflect.Field realfield,
org.apache.xalan.utils.synthetic.Class declaringClass)
{
this(realfield.getName(),declaringClass);
this.realfield=realfield;
this.type=org.apache.xalan.utils.synthetic.Class.forClass(realfield.getType());
}
/** Synthesis constructor */
public Field(String name,org.apache.xalan.utils.synthetic.Class
declaringClass)
{
this.name=name;
this.declaringClass=declaringClass;
}
/**
Compares this Field against the specified object.
Returns true if the objects are the same. Two
Fields are the same if they were declared by the
same class and have the same name and type.
*/
public boolean equals(Object obj)
{
if(realfield!=null)
return realfield.equals(obj);
else if(obj instanceof Field)
{
Field objf=(Field)obj;
return(declaringClass.equals(objf.declaringClass) &&
name.equals(objf.name) && type.equals(objf.type) );
}
else return false;
}
/**
Returns the value of the field represented by this
Field, on the specified object. The value is
automatically wrapped in an object if it has a
primitive type.
<p>
The underlying field's value is obtained as follows:
<p>
If the underlying field is a static field, the object
argument is ignored; it may be null.
<p>
Otherwise, the underlying field is an instance
field. If the specified object argument is null, the
method throws a NullPointerException. If the
specified object is not an instance of the class or
interface declaring the underlying field, the
method throws an IllegalArgumentException.
<p>
If this Field object enforces Java language access
control, and the underlying field is inaccessible,
the method throws an IllegalAccessException.
<p>
Otherwise, the value is retrieved from the
underlying instance or static field. If the field has a
primitive type, the value is wrapped in an object
before being returned, otherwise it is returned as
is.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field.
@throws NullPointerException
if the specified object is null.
*/
public Object get(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.get(obj);
throw new java.lang.IllegalStateException();
}
/**
Get the value of a field as a boolean on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public boolean getBoolean(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getBoolean(obj);
throw new java.lang.IllegalStateException();
}
/**
Get the value of a field as a byte on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public byte getByte(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getByte(obj);
throw new java.lang.IllegalStateException();
}
/**
Get the value of a field as a char on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public char getChar(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getChar(obj);
throw new java.lang.IllegalStateException();
}
/**
Returns the Class object representing the class or
interface that declares the field represented by this
Field object.
*/
public org.apache.xalan.utils.synthetic.Class getDeclaringClass()
{
if(realfield!=null)
return
org.apache.xalan.utils.synthetic.Class.forClass(realfield.getDeclaringClass());
throw new java.lang.IllegalStateException();
}
/**
Get the value of a field as a double on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public double getDouble(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getDouble(obj);
throw new java.lang.IllegalStateException();
}
/**
Get the value of a field as a float on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public float getFloat(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getFloat(obj);
throw new java.lang.IllegalStateException();
}
/**
Get the value of a field as a int on specified object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public int getInt(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getInt(obj);
throw new java.lang.IllegalStateException();
}
/**
Get the value of a field as a long on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public long getLong(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getLong(obj);
throw new java.lang.IllegalStateException();
}
/**
Returns the Java language modifiers for the field
represented by this Field object, as an integer. The
Modifier class should be used to decode the
modifiers.
@see
Modifier
*/
public int getModifiers()
{
if(realfield!=null)
modifiers=realfield.getModifiers();
return modifiers;
}
public String getInitializer()
{
return initializer;
}
public void setInitializer(String i)
throws SynthesisException
{
if(realfield!=null)
throw new SynthesisException(SynthesisException.REIFIED);
initializer=i;
}
/**
* Insert the method's description here.
* Creation date: (12-25-99 2:02:26 PM)
* @return java.lang.String
*/
public java.lang.String getName() {
return name;
}
/**
Get the value of a field as a short on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the field value cannot be converted to the
return type by a widening conversion.
@see
get
*/
public short getShort(Object obj) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
return realfield.getShort(obj);
throw new java.lang.IllegalStateException();
}
/**
Returns a Class object that identifies the declared
type for the field represented by this Field object.
*/
public Class getType()
{
if(realfield!=null)
type=Class.forClass(realfield.getType());
return type;
}
public void setType(org.apache.xalan.utils.synthetic.Class type)
throws SynthesisException
{
if(realfield!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.type=type;
}
/**
Returns a hashcode for this Field. This is
computed as the exclusive-or of the hashcodes for
the underlying field's declaring class name and its
name.
*/
public int hashCode()
{
if(realfield!=null)
return realfield.hashCode();
else
return declaringClass.getName().hashCode() ^
name.hashCode();
}
/**
Sets the field represented by this Field object on
the specified object argument to the specified new
value. The new value is automatically unwrapped
if the underlying field has a primitive type.
The operation proceeds as follows:
If the underlying field is static, the object
argument is ignored; it may be null.
Otherwise the underlying field is an instance field.
If the specified object argument is null, the
method throws a NullPointerException. If the
specified object argument is not an instance of the
class or interface declaring the underlying field,
the method throws an IllegalArgumentException.
If this Field object enforces Java language access
control, and the underlying field is inaccessible,
the method throws an IllegalAccessException.
If the underlying field is final, the method throws
an IllegalAccessException.
If the underlying field is of a primitive type, an
unwrapping conversion is attempted to convert the
new value to a value of a primitive type. If this
attempt fails, the method throws an
IllegalArgumentException.
If, after possible unwrapping, the new value
cannot be converted to the type of the underlying
field by an identity or widening conversion, the
method throws an IllegalArgumentException.
The field is set to the possibly unwrapped and
widened new value.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@throws NullPointerException
if the specified object is null.
*/
public void set(Object obj,Object value) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
realfield.set(obj,value);
throw new java.lang.IllegalStateException();
}
/**
Set the value of a field as a boolean on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setBoolean(Object obj,boolean z) throws
IllegalArgumentException, IllegalAccessException
{
if(realfield!=null)
realfield.setBoolean(obj,z);
throw new java.lang.IllegalStateException();
}
/**
Set the value of a field as a byte on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setByte(Object obj, byte b) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
realfield.setByte(obj,b);
throw new java.lang.IllegalStateException();
}
/**
Set the value of a field as a char on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setChar(Object obj, char c) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
realfield.setChar(obj,c);
throw new java.lang.IllegalStateException();
}
/**
Returns the Class object representing the class that
declares the constructor represented by this
Constructor object.
*/
public void setDeclaringClass(org.apache.xalan.utils.synthetic.Class
declaringClass)
{
this.declaringClass=declaringClass;
}
/**
Set the value of a field as a double on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setDouble(Object obj, double d) throws
IllegalArgumentException, IllegalAccessException
{
if(realfield!=null)
realfield.setDouble(obj,d);
throw new java.lang.IllegalStateException();
}
/**
Set the value of a field as a float on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setFloat(Object obj, float f) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
realfield.setFloat(obj,f);
throw new java.lang.IllegalStateException();
}
/**
Set the value of a field as an int on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setInt(Object obj, int i) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
realfield.setInt(obj,i);
throw new java.lang.IllegalStateException();
}
/**
Set the value of a field as a long on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setLong(Object obj, long l) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
realfield.setLong(obj,l);
throw new java.lang.IllegalStateException();
}
/**
* Insert the method's description here.
* Creation date: (12-25-99 1:28:28 PM)
* @return int
* @param modifiers int
*/
public void setModifiers(int modifiers)
throws SynthesisException
{
if(realfield!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.modifiers=modifiers;
}
/**
Set the value of a field as a short on specified
object.
@throws IllegalAccessException
if the underlying constructor is inaccessible.
@throws IllegalArgumentException
if the specified object is not an instance of
the class or interface declaring the
underlying field, or if an unwrapping
conversion fails.
@see
set
*/
public void setShort(Object obj, short s) throws IllegalArgumentException,
IllegalAccessException
{
if(realfield!=null)
realfield.setShort(obj,s);
throw new java.lang.IllegalStateException();
}
/**
Return a string describing this Field. The format is
the access modifiers for the field, if any, followed
by the field type, followed by a space, followed by
the fully-qualified name of the class declaring the
field, followed by a period, followed by the name
of the field. For example:
<code>
public static final int java.lang.Thread.MIN_PRIORITY
private int java.io.FileDescriptor.fd
</code>
The modifiers are placed in canonical order as
specified by "The Java Language Specification".
This is public, protected or private first,
and then other modifiers in the following order:
static, final, transient, volatile.
*/
public String toString()
{
if(realfield!=null)
return realfield.toString();
throw new java.lang.IllegalStateException();
}
/** Output the Field as Java sourcecode
*/
public String toSource()
{
StringBuffer sb=
new StringBuffer(java.lang.reflect.Modifier.toString(getModifiers()) )
.append(' ')
.append(getType().getJavaName())
.append(' ')
.append(getName());
String i=getInitializer();
if(i!=null && i.length()>0)
sb.append('=').append(i);
sb.append(';');
return sb.toString();
}
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/reflection/Member.java
Index: Member.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.utils.synthetic.reflection;
import org.apache.xalan.utils.synthetic.SynthesisException;
/**
Member is an interface that reflects identifying
information about a single member (a field or a method)
or a constructor.
<p>
Note that this is <strong>not</strong> currently derived from
java.lang.reflect.Member, due to questions about how to handle
declarignClass.
@see Field
@see Method
@see Constructor
@see org.apache.xalan.utils.synthetic.Class
@see java.lang.reflect.Member
*/
public interface Member
{
/**
Returns the Class object representing the class or
interface that declares the member or constructor
represented by this Member.
*/
public abstract org.apache.xalan.utils.synthetic.Class getDeclaringClass();
/**
Returns the Java language modifiers for the
member or constructor represented by this
Member, as an integer. The Modifier class should
be used to decode the modifiers in the integer.
@see Modifier
**/
public abstract int getModifiers();
/**
Returns the Class object representing the class or
interface that declares the member or constructor
represented by this Member.
*/
public abstract void setDeclaringClass(org.apache.xalan.utils.synthetic.Class
declaringClass)
throws SynthesisException;
/**
Returns the Java language modifiers for the
member or constructor represented by this
Member, as an integer. The Modifier class should
be used to decode the modifiers in the integer.
@see Modifier
**/
public abstract void setModifiers(int modifiers)
throws SynthesisException;
}
1.1
xml-xalan/java/src/org/apache/xalan/utils/synthetic/reflection/Method.java
Index: Method.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.utils.synthetic.reflection;
import java.lang.reflect.InvocationTargetException;
import org.apache.xalan.utils.synthetic.SynthesisException;
/**
A Method provides information about, and access to, a
single method on a class or interface. The reflected
method may be a class method or an instance method
(including an abstract method).
<p>
A Method permits widening conversions to occur when
matching the actual parameters to invokewith the
underlying method's formal parameters, but it throws an
IllegalArgumentException if a narrowing conversion
would occur.
<p>
***** Need to add method body, a la Matt's codebuffer.
That may or may not imply retaining the final return value
separately and passing in a how-to-use-it mechanism...?
@see Member
@see Class
@see getMethods
@see getMethod
@see getDeclaredMethods
@see getDeclaredMethod
*/
public class Method
extends EntryPoint
implements Member
{
/**
* Insert the method's description here.
* <p>
* Creation date: (12-27-99 2:31:39 PM)
* @param realConstructor java.lang.reflect.Constructor
*/
public Method(String name,org.apache.xalan.utils.synthetic.Class
declaringclass)
{
super(declaringclass);
this.name=name;
}
/**
* Insert the method's description here.
* <p>
* Creation date: (12-27-99 2:31:39 PM)
* @param realConstructor java.lang.reflect.Constructor
*/
public Method(java.lang.reflect.Method
ctor,org.apache.xalan.utils.synthetic.Class declaringclass)
{
super(ctor,declaringclass);
}
/**
* Insert the method's description here.
* <p>
* Creation date: (12-27-99 2:31:39 PM)
* @param realConstructor java.lang.reflect.Constructor
*/
public Method(java.lang.reflect.Method realmethod)
{
super(realmethod);
}
/**
Returns a hashcode for this Method. The hashcode
is computed as the exclusive-or of the hashcodes
for the underlying method's declaring class name
and the method's name.
*/
/**
Returns a hashcode for this Constructor. The
hashcode for a Method is the hashcode for the
underlying constructor's declaring class name,
XORed with the name of this method.
*/
public int hashCode()
{
return getDeclaringClass().getName().hashCode()
^
getName().hashCode();
}
/**
Invokes the underlying method represented by this
Method object, on the specified object with the
specified parameters. Individual parameters are
automatically unwrapped to match primitive
formal parameters, and both primitive and
reference parameters are subject to widening
conversions as necessary. The value returned by
the underlying method is automatically wrapped
in an object if it has a primitive type.
Method invocation proceeds with the following
steps, in order:
If the underlying method is static, then the
specified object argument is ignored. It may be
null.
Otherwise, the method is an instance method. If
the specified object argument is null, the
invocation throws a NullPointerException.
Otherwise, if the specified object argument is not
an instance of the class or interface declaring the
underlying method, the invocation throws an
IllegalArgumentException.
If this Method object enforces Java language access
control and the underlying method is inaccessible,
the invocation throws an IllegalAccessException.
If the number of actual parameters supplied via
args is different from the number of formal
parameters required by the underlying method, the
invocation throws an IllegalArgumentException.
For each actual parameter in the supplied args
array:
If the corresponding formal parameter has a
primitive type, an unwrapping conversion is
attempted to convert the object value to a value of
a primitive type. If this attempt fails, the
invocation throws an IllegalArgumentException.
If, after possible unwrapping, the parameter value
cannot be converted to the corresponding formal
parameter type by an identity or widening
conversion, the invocation throws an
IllegalArgumentException.
If the underlying method is an instance method, it
is invoked using dynamic method lookup as
documented in The Java Language Specification,
section 15.11.4.4; in particular, overriding based
on the runtime type of the target object will occur.
If the underlying method is static, it is invoked as
exactly the method on the declaring class.
Control transfers to the underlying method. If the
method completes abruptly by throwing an
exception, the exception is placed in an
InvocationTargetException and thrown in turn to
the caller of invoke.
If the method completes normally, the value it
returns is returned to the caller of invoke; if the
value has a primitive type, it is first appropriately
wrapped in an object. If the underlying method
return type is void, the invocation returns null.
Throws: IllegalAccessException
if the underlying method is inaccessible.
Throws: IllegalArgumentException
if the number of actual and formal
parameters differ, or if an unwrapping
conversion fails.
Throws: InvocationTargetException
if the underlying method throws an
exception.
Throws: NullPointerException
if the specified object is null.
*/
public Object invoke(Object obj, Object args[])
throws IllegalAccessException, IllegalArgumentException,
java.lang.reflect.InvocationTargetException
{
if(realep!=null)
return ((java.lang.reflect.Method)realep).invoke(obj,args);
else
throw new IllegalAccessException("Un-reified
org.apache.xalan.utils.synthetic.Class doesn't yet support invocation");
}
public void setReturnType(org.apache.xalan.utils.synthetic.Class returntype)
throws SynthesisException
{
if(realep!=null)
throw new SynthesisException(SynthesisException.REIFIED);
this.returntype=returntype;
}
}
1.2 +2 -2
xml-xalan/java/src/org/apache/xalan/xpath/xml/ProblemListenerDefault.java
Index: ProblemListenerDefault.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xpath/xml/ProblemListenerDefault.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProblemListenerDefault.java 2000/07/25 16:05:41 1.1
+++ ProblemListenerDefault.java 2000/10/13 02:33:15 1.2
@@ -59,7 +59,7 @@
import org.w3c.dom.*;
import org.xml.sax.ErrorHandler;
-import trax.ProcessorException;
+import org.apache.trax.ProcessorException;
/**
* <meta name="usage" content="general"/>
@@ -125,7 +125,7 @@
String msg, String id, int lineNo, int charOffset)
throws org.xml.sax.SAXException
{
- m_errorHandler.error(new trax.ProcessorException(msg));
+ m_errorHandler.error(new org.apache.trax.ProcessorException(msg));
return false;
}
1.11 +9 -10 xml-xalan/java/src/org/apache/xalan/xslt/Process.java
Index: Process.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/Process.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Process.java 2000/10/11 03:36:10 1.10
+++ Process.java 2000/10/13 02:33:15 1.11
@@ -97,11 +97,11 @@
import org.apache.xalan.trace.TraceManager;
// Needed TRaX classes
-import trax.Result;
-import trax.Processor;
-import trax.ProcessorFactoryException;
-import trax.Transformer;
-import trax.Templates;
+import org.apache.trax.Result;
+import org.apache.trax.Processor;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.Transformer;
+import org.apache.trax.Templates;
// Needed SAX classes
import org.xml.sax.InputSource;
@@ -117,9 +117,9 @@
import org.w3c.dom.Document;
// Needed Serializer classes
-import serialize.OutputFormat;
-import serialize.Serializer;
-import serialize.SerializerFactory;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.Serializer;
+import org.apache.serialize.SerializerFactory;
/**
@@ -194,8 +194,7 @@
}
catch(ProcessorFactoryException pfe)
{
- if(doStackDumpOnError)
- pfe.printStackTrace(dumpWriter);
+ pfe.printStackTrace(dumpWriter);
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL,
null)); //"XSL Process was not successful.");
processor = null; // shut up compiler
System.exit(-1);
1.4 +1 -1
xml-xalan/java/src/org/apache/xalan/xslt/StylesheetHandler.java
Index: StylesheetHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/StylesheetHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StylesheetHandler.java 2000/07/28 17:25:10 1.3
+++ StylesheetHandler.java 2000/10/13 02:33:15 1.4
@@ -79,7 +79,7 @@
* Instance constructor...
*/
public StylesheetHandler(XSLTEngineImpl processor, Stylesheet
stylesheetTree)
- throws trax.ProcessorException
+ throws org.apache.trax.ProcessorException
{
super(processor.getProcessor());
}
1.3 +2 -2
xml-xalan/java/src/org/apache/xalan/xslt/StylesheetRoot.java
Index: StylesheetRoot.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/StylesheetRoot.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StylesheetRoot.java 2000/10/02 02:43:11 1.2
+++ StylesheetRoot.java 2000/10/13 02:33:15 1.3
@@ -62,8 +62,8 @@
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
-import trax.ProcessorException;
-import serialize.*;
+import org.apache.trax.ProcessorException;
+import org.apache.serialize.*;
/**
* <meta name="usage" content="general"/>
1.2 +1 -1
xml-xalan/java/src/org/apache/xalan/xslt/XSLProcessorContext.java
Index: XSLProcessorContext.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/XSLProcessorContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSLProcessorContext.java 2000/07/25 16:05:44 1.1
+++ XSLProcessorContext.java 2000/10/13 02:33:15 1.2
@@ -75,7 +75,7 @@
public XSLProcessorContext (XSLTEngineImpl processor,
Stylesheet stylesheetTree,
Node sourceTree, Node sourceNode, QName mode)
- throws trax.TransformException, trax.ProcessorException
+ throws org.apache.trax.TransformException,
org.apache.trax.ProcessorException
{
super((TransformerImpl)(processor.getProcessor().getTemplatesBuilder().getTemplates().newTransformer()),
stylesheetTree,
1.3 +6 -6
xml-xalan/java/src/org/apache/xalan/xslt/XSLTEngineImpl.java
Index: XSLTEngineImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSLTEngineImpl.java 2000/07/28 17:12:59 1.2
+++ XSLTEngineImpl.java 2000/10/13 02:33:15 1.3
@@ -73,12 +73,12 @@
import org.xml.sax.helpers.*;
import org.xml.sax.ext.*;
-import trax.Transformer;
-import trax.Processor;
-import trax.TransformException;
-import trax.ProcessorException;
-import trax.ProcessorFactoryException;
-import trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Processor;
+import org.apache.trax.TransformException;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.Templates;
import java.util.*;
import java.net.*;
1.3 +1 -1
xml-xalan/java/src/org/apache/xalan/xslt/XSLTProcessor.java
Index: XSLTProcessor.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/XSLTProcessor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSLTProcessor.java 2000/10/02 02:43:11 1.2
+++ XSLTProcessor.java 2000/10/13 02:33:16 1.3
@@ -79,7 +79,7 @@
import org.xml.sax.SAXException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
import org.xml.sax.ext.LexicalHandler;
/**
1.2 +3 -3
xml-xalan/java/src/org/apache/xalan/xslt/XSLTProcessorFactory.java
Index: XSLTProcessorFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/XSLTProcessorFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSLTProcessorFactory.java 2000/07/25 16:05:44 1.1
+++ XSLTProcessorFactory.java 2000/10/13 02:33:16 1.2
@@ -58,9 +58,9 @@
import org.apache.xalan.xpath.xml.XMLParserLiaison;
import org.apache.xpath.XPathFactory;
-import trax.Processor;
-import trax.ProcessorFactoryException;
-import trax.Templates;
+import org.apache.trax.Processor;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.Templates;
import org.apache.xalan.utils.TreeWalker;
/**
1.3 +1 -1
xml-xalan/java/src/org/apache/xalan/xslt/XSLTResultTarget.java
Index: XSLTResultTarget.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/XSLTResultTarget.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSLTResultTarget.java 2000/10/12 23:28:32 1.2
+++ XSLTResultTarget.java 2000/10/13 02:33:16 1.3
@@ -64,7 +64,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import org.xml.sax.DocumentHandler;
-import trax.Result;
+import org.apache.trax.Result;
/**
* <meta name="usage" content="general"/>
1.4 +6 -6
xml-xalan/java/src/org/apache/xml/serialize/transition/BaseMarkupSerializer.java
Index: BaseMarkupSerializer.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/BaseMarkupSerializer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseMarkupSerializer.java 2000/10/13 00:34:48 1.3
+++ BaseMarkupSerializer.java 2000/10/13 02:33:17 1.4
@@ -94,10 +94,10 @@
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.ext.DeclHandler;
-import serialize.OutputFormat;
-import serialize.Serializer;
-import serialize.DOMSerializer;
-import serialize.SerializerHandler;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.Serializer;
+import org.apache.serialize.DOMSerializer;
+import org.apache.serialize.SerializerHandler;
/**
* Base class for a serializer supporting both DOM and SAX pretty
@@ -138,7 +138,7 @@
* another element.
*
*
- * @version $Revision: 1.3 $ $Date: 2000/10/13 00:34:48 $
+ * @version $Revision: 1.4 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see Serializer
* @see DOMSerializer
@@ -1080,7 +1080,7 @@
// By definition this will happen if the node is a document,
// document fragment, etc. Just serialize its contents. It will
- // work well for other nodes that we do not know how to
serialize.
+ // work well for other nodes that we do not know how to
org.apache.serialize.
child = node.getFirstChild();
while ( child != null ) {
serializeNode( child );
1.3 +2 -2
xml-xalan/java/src/org/apache/xml/serialize/transition/HTMLSerializer.java
Index: HTMLSerializer.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/HTMLSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HTMLSerializer.java 2000/10/02 23:41:44 1.2
+++ HTMLSerializer.java 2000/10/13 02:33:17 1.3
@@ -81,7 +81,7 @@
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
/**
* Implements an HTML/XHTML serializer supporting both DOM and SAX
@@ -117,7 +117,7 @@
* </ul>
*
*
- * @version $Revision: 1.2 $ $Date: 2000/10/02 23:41:44 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see Serializer
*/
1.3 +2 -2
xml-xalan/java/src/org/apache/xml/serialize/transition/IndentPrinter.java
Index: IndentPrinter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/IndentPrinter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IndentPrinter.java 2000/10/02 23:41:44 1.2
+++ IndentPrinter.java 2000/10/13 02:33:17 1.3
@@ -63,13 +63,13 @@
import java.io.StringWriter;
import java.io.IOException;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
/**
* Extends [EMAIL PROTECTED] Printer} and adds support for indentation and
line
* wrapping.
*
- * @version $Revision: 1.2 $ $Date: 2000/10/02 23:41:44 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
class IndentPrinter
1.2 +2 -2
xml-xalan/java/src/org/apache/xml/serialize/transition/LineSeparator.java
Index: LineSeparator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/LineSeparator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LineSeparator.java 2000/10/02 02:43:13 1.1
+++ LineSeparator.java 2000/10/13 02:33:17 1.2
@@ -58,10 +58,10 @@
package org.apache.xml.serialize.transition;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
/**
- * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
+ * @version $Revision: 1.2 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see OutputFormat
*/
1.2 +2 -2
xml-xalan/java/src/org/apache/xml/serialize/transition/Method.java
Index: Method.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/Method.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Method.java 2000/10/02 02:43:13 1.1
+++ Method.java 2000/10/13 02:33:17 1.2
@@ -58,10 +58,10 @@
package org.apache.xml.serialize.transition;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
/**
- * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
+ * @version $Revision: 1.2 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see OutputFormat
*/
1.5 +2 -2
xml-xalan/java/src/org/apache/xml/serialize/transition/Printer.java
Index: Printer.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/Printer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Printer.java 2000/10/04 18:29:50 1.4
+++ Printer.java 2000/10/13 02:33:17 1.5
@@ -63,7 +63,7 @@
import java.io.StringWriter;
import java.io.IOException;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
/**
* The printer is responsible for sending text to the output stream
@@ -71,7 +71,7 @@
* [EMAIL PROTECTED] IndentPrinter} supports indentation and line wrapping by
* extending this class.
*
- * @version $Revision: 1.4 $ $Date: 2000/10/04 18:29:50 $
+ * @version $Revision: 1.5 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public class Printer
1.2 +4 -4
xml-xalan/java/src/org/apache/xml/serialize/transition/SerializerFactoryImpl.java
Index: SerializerFactoryImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/SerializerFactoryImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SerializerFactoryImpl.java 2000/10/02 02:43:13 1.1
+++ SerializerFactoryImpl.java 2000/10/13 02:33:17 1.2
@@ -63,16 +63,16 @@
import java.io.Writer;
import java.io.UnsupportedEncodingException;
-import serialize.OutputFormat;
-import serialize.SerializerFactory;
-import serialize.Serializer;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.SerializerFactory;
+import org.apache.serialize.Serializer;
/**
* Default serializer factory can construct serializers for the three
* markup serializers (XML, HTML, XHTML ).
*
*
- * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
+ * @version $Revision: 1.2 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:Scott_Boag/CAM/[EMAIL PROTECTED]">Scott Boag</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
1.2 +3 -3
xml-xalan/java/src/org/apache/xml/serialize/transition/TextSerializer.java
Index: TextSerializer.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/TextSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TextSerializer.java 2000/10/02 02:43:13 1.1
+++ TextSerializer.java 2000/10/13 02:33:17 1.2
@@ -70,7 +70,7 @@
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
/**
* Implements a text serializer supporting both DOM and SAX
@@ -91,7 +91,7 @@
* org.xml.sax.DocumentHandler#endDocument}.
*
*
- * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
+ * @version $Revision: 1.2 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see Serializer
*/
@@ -363,7 +363,7 @@
// By definition this will happen if the node is a document,
// document fragment, etc. Just serialize its contents. It will
- // work well for other nodes that we do not know how to
serialize.
+ // work well for other nodes that we do not know how to
org.apache.serialize.
child = node.getFirstChild();
while ( child != null ) {
serializeNode( child );
1.2 +2 -2
xml-xalan/java/src/org/apache/xml/serialize/transition/XHTMLSerializer.java
Index: XHTMLSerializer.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/XHTMLSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XHTMLSerializer.java 2000/10/02 02:43:13 1.1
+++ XHTMLSerializer.java 2000/10/13 02:33:17 1.2
@@ -63,7 +63,7 @@
import java.io.Writer;
import java.io.UnsupportedEncodingException;
-import serialize.OutputFormat;
+import org.apache.serialize.OutputFormat;
/**
* Implements an XHTML serializer supporting both DOM and SAX
@@ -71,7 +71,7 @@
* Serializer} or [EMAIL PROTECTED] BaseMarkupSerializer}.
*
*
- * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
+ * @version $Revision: 1.2 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see Serializer
*/
1.3 +3 -3
xml-xalan/java/src/org/apache/xml/serialize/transition/XMLSerializer.java
Index: XMLSerializer.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/XMLSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLSerializer.java 2000/10/05 17:03:48 1.2
+++ XMLSerializer.java 2000/10/13 02:33:17 1.3
@@ -78,8 +78,8 @@
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
-import serialize.OutputFormat;
-import serialize.QName;
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.QName;
/**
* Implements an XML serializer supporting both DOM and SAX pretty
@@ -106,7 +106,7 @@
* spaces at beginning of line will be stripped.
*
*
- * @version $Revision: 1.2 $ $Date: 2000/10/05 17:03:48 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/13 02:33:17 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
* @see Serializer
*/
1.2 +1 -1 xml-xalan/java/src/org/apache/xpath/Expression.java
Index: Expression.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/Expression.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Expression.java 2000/07/05 14:44:26 1.1
+++ Expression.java 2000/10/13 02:33:18 1.2
@@ -6,7 +6,7 @@
import org.apache.xpath.res.XPATHErrorResources;
import org.apache.xalan.res.XSLMessages;
import org.xml.sax.ErrorHandler;
-import trax.ProcessorException;
+import org.apache.trax.ProcessorException;
public abstract class Expression
{
1.8 +2 -2
xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java
Index: SourceTreeManager.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SourceTreeManager.java 2000/10/09 23:25:21 1.7
+++ SourceTreeManager.java 2000/10/13 02:33:19 1.8
@@ -65,8 +65,8 @@
import org.w3c.dom.Node;
import org.w3c.dom.Document;
-import trax.URIResolver;
-import trax.TransformException;
+import org.apache.trax.URIResolver;
+import org.apache.trax.TransformException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
1.6 +4 -4 xml-xalan/java/src/org/apache/xpath/XPath.java
Index: XPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPath.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XPath.java 2000/10/10 00:56:29 1.5
+++ XPath.java 2000/10/13 02:33:19 1.6
@@ -80,7 +80,7 @@
import org.apache.xpath.objects.*;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
-import trax.TransformException;
+import org.apache.trax.TransformException;
import org.apache.xpath.patterns.NodeTest;
/**
@@ -198,13 +198,13 @@
}
catch(Exception e)
{
- if(e instanceof trax.TransformException)
- throw (trax.TransformException)e;
+ if(e instanceof org.apache.trax.TransformException)
+ throw (org.apache.trax.TransformException)e;
else
{
while(e instanceof org.apache.xalan.utils.WrappedRuntimeException)
e =
((org.apache.xalan.utils.WrappedRuntimeException)e).getException();
- throw new trax.TransformException("Error in XPath", m_locator, e);
+ throw new org.apache.trax.TransformException("Error in XPath",
m_locator, e);
}
}
finally
1.5 +2 -2 xml-xalan/java/src/org/apache/xpath/XPathContext.java
Index: XPathContext.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XPathContext.java 2000/10/09 23:25:21 1.4
+++ XPathContext.java 2000/10/13 02:33:19 1.5
@@ -91,8 +91,8 @@
import org.xml.sax.Locator;
// TRaX imports
-import trax.URIResolver;
-import trax.TransformException;
+import org.apache.trax.URIResolver;
+import org.apache.trax.TransformException;
// Temporary!!!
import org.apache.xalan.extensions.ExtensionsTable;
1.6 +1 -1
xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java
Index: Compiler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Compiler.java 2000/10/08 03:43:20 1.5
+++ Compiler.java 2000/10/13 02:33:19 1.6
@@ -33,7 +33,7 @@
import org.apache.xalan.utils.QName;
import org.apache.xalan.utils.PrefixResolver;
-import trax.ProcessorException;
+import org.apache.trax.ProcessorException;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
1.3 +1 -1
xml-xalan/java/src/org/apache/xpath/compiler/XPathParser.java
Index: XPathParser.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/XPathParser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XPathParser.java 2000/09/12 19:17:33 1.2
+++ XPathParser.java 2000/10/13 02:33:19 1.3
@@ -68,7 +68,7 @@
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.Locator;
-import trax.ProcessorException;
+import org.apache.trax.ProcessorException;
/**
* <meta name="usage" content="general"/>