foray-commit Mailing List for FOray (Page 307)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(4) |
Dec
(23) |
| 2026 |
Jan
(119) |
Feb
(335) |
Mar
(103) |
Apr
(43) |
May
(154) |
Jun
(107) |
Jul
(187) |
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2006-05-26 22:36:44
|
Revision: 7289 Author: victormote Date: 2006-05-26 15:36:29 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7289&view=rev Log Message: ----------- Clean up build problem. aXSL is not supposed to have access to any logging. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java trunk/foray/foray-render/src/java/org/foray/render/Renderer.java trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java Modified: trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -33,6 +33,8 @@ import org.axsl.common.Constants; import org.axsl.fontR.FontConsumer; +import org.apache.commons.logging.Log; + import java.awt.Color; /** @@ -40,8 +42,8 @@ */ public abstract class PrintRenderer extends Renderer { - public PrintRenderer(OutputConfig renderConfig) { - super(renderConfig); + public PrintRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -69,6 +69,7 @@ import org.axsl.graphicR.GraphicException; import org.apache.batik.bridge.BridgeContext; +import org.apache.commons.logging.Log; import java.awt.Color; import java.awt.Rectangle; @@ -89,8 +90,8 @@ /** * Constructor. */ - public Renderer(OutputConfig renderConfig) { - super(renderConfig); + public Renderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } public void setAreaTree(AreaTree areaTree) { Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -28,6 +28,8 @@ import org.axsl.areaR.PageArea; +import org.apache.commons.logging.Log; + import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.IOException; @@ -44,8 +46,9 @@ private int mode = EVEN_AND_ALL; private PrinterJob printerJob; - public AWTPrintRenderer(OutputConfig renderConfig, PrinterJob printerJob) { - super(renderConfig); + public AWTPrintRenderer(Log logger, OutputConfig renderConfig, + PrinterJob printerJob) { + super(logger, renderConfig); this.printerJob = printerJob; startNumber = getIntProperty("start", 1) - 1; Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -49,6 +49,7 @@ import org.apache.batik.bridge.GVTBuilder; import org.apache.batik.bridge.ViewBox; import org.apache.batik.gvt.GraphicsNode; +import org.apache.commons.logging.Log; import org.w3c.dom.Document; import org.w3c.dom.svg.SVGDocument; @@ -147,8 +148,8 @@ */ protected Component parent; - public AWTRenderer(OutputConfig renderConfig) { - super(renderConfig); + public AWTRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -48,6 +48,8 @@ import org.axsl.graphicR.Graphic; import org.axsl.graphicR.GraphicException; +import org.apache.commons.logging.Log; + import java.awt.Color; import java.awt.Rectangle; import java.awt.color.ColorSpace; @@ -80,8 +82,8 @@ /** * Create the PCL renderer */ - public PCLRenderer(OutputConfig renderConfig) { - super(renderConfig); + public PCLRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -61,6 +61,8 @@ import org.axsl.pdfW.PDFPathPaint; import org.axsl.pdfW.PDFUtility; +import org.apache.commons.logging.Log; + import java.awt.Color; import java.awt.Rectangle; import java.awt.geom.Line2D; @@ -83,8 +85,9 @@ /** * Create a PDF renderer. */ - public PDFRenderer(OutputConfig renderConfig, PDFDocument document) { - super(renderConfig); + public PDFRenderer(Log logger, OutputConfig renderConfig, + PDFDocument document) { + super(logger, renderConfig); this.pdfDoc = document; } Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -58,6 +58,7 @@ import org.apache.batik.bridge.ViewBox; import org.apache.batik.ext.awt.g2d.GraphicContext; import org.apache.batik.gvt.GraphicsNode; +import org.apache.commons.logging.Log; import org.w3c.dom.Document; import org.w3c.dom.svg.SVGDocument; @@ -156,8 +157,8 @@ */ private HashMap fontMap = new HashMap(); - public PSRenderer(OutputConfig renderConfig) { - super(renderConfig); + public PSRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -49,6 +49,7 @@ import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.svg2svg.SVGTranscoder; +import org.apache.commons.logging.Log; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; @@ -101,8 +102,8 @@ protected float currentGreen = 0; protected float currentBlue = 0; - public SVGRenderer(OutputConfig renderConfig) { - super(renderConfig); + public SVGRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -39,6 +39,8 @@ import org.axsl.graphicR.Graphic; import org.axsl.graphicR.GraphicException; +import org.apache.commons.logging.Log; + import org.w3c.dom.svg.SVGSVGElement; import java.awt.Color; @@ -95,8 +97,8 @@ public boolean suppressGraphics = false; boolean firstPage = false; - public TXTRenderer(OutputConfig renderConfig) { - super(renderConfig); + public TXTRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } void addStr(int row, int col, String str, boolean ischar) { Modified: trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -57,6 +57,8 @@ import org.axsl.fontR.FontConsumer; import org.axsl.graphicR.Graphic; +import org.apache.commons.logging.Log; + import java.awt.Color; import java.awt.Rectangle; import java.io.IOException; @@ -82,8 +84,8 @@ */ protected PrintWriter writer; - public XMLRenderer(OutputConfig renderConfig) { - super(renderConfig); + public XMLRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } public void render(PageArea page) throws IOException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:36:26
|
Revision: 7288 Author: victormote Date: 2006-05-26 15:36:22 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7288&view=rev Log Message: ----------- Clean up build problem. aXSL is not supposed to have access to any logging. Modified Paths: -------------- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java Modified: trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2006-05-26 22:23:53 UTC (rev 7287) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2006-05-26 22:36:22 UTC (rev 7288) @@ -160,7 +160,6 @@ Application.getDeveloperURLShort()); this.outputTarget.setStrokeSVGText(getConfiguration() .optionStrokeSVGText()); - this.outputTarget.setLogger(this.getLogger()); this.outputTarget.setFontConsumer(this.getFontConsumer()); // Start the renderer. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:24:14
|
Revision: 7287 Author: victormote Date: 2006-05-26 15:23:53 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7287&view=rev Log Message: ----------- Move remaining core files from the app module to the core module. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java Modified: trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -31,7 +31,9 @@ * Modified to use streaming API by Mark Lillywhite, mar...@in... */ +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.foray.render.awt.AWTRenderer; Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,7 +24,10 @@ package org.foray.app; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.SessionConfig; import org.foray.layout.LayoutStrategy; import org.foray.output.OutputConfig; Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -1,328 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.common.XMLParser; -import org.foray.core.DocumentInputSource; -import org.foray.core.DocumentReader; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; - -import org.axsl.areaW.AreaTreeFactory; -import org.axsl.fontR.FontConsumer; -import org.axsl.fontR.FontServer; -import org.axsl.graphicR.GraphicServer; -import org.axsl.layout.LayoutFactory; -import org.axsl.text.TextServer; - -import org.apache.commons.logging.Log; - -import org.w3c.dom.Document; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; - -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.sax.SAXResult; - -/** - * This class manages the process of parsing an input FO document and creating - * an FOTree. - */ -public class FOrayDocument { - - /** The "parent" FOraySession. */ - private FOraySession session; - - /** - * The SAX InputSource that encapsulates the document to be parsed. - * Should be null if the JAXP constructor was used. - */ - private InputSource inputSource; - - /** - * The JAXP Transformer that should be used to handle an XSLT transformation - * on the input. - * Should be null if the SAX constructor was used. - */ - private Transformer jaxpTransformer; - - /** - * The JAXP Source that encapsulates the document to be parsed. - * Should be null if the SAX constructor was used. - */ - private Source jaxpSource; - - /** - * The JAXP Result encapsulating our FOTreeBuilder. - * Should be null if the SAX constructor was used. - */ - private SAXResult jaxpResult; - - /** The collection of FOrayTarget "children". */ - private ArrayList targetList = new ArrayList(); - - /** The FO tree builder, which handles the SAX events. */ - private org.axsl.foR.FOTree treeBuilder; - - private FOrayTarget currentTarget; - - /** Array of bytes listing unsupported FO objects. */ - protected byte[] unsupportedObjects; - - /** Array of shorts listing unsupported FO properties. */ - protected short[] unsupportedProperties; - - /** The SAX parser. */ - private XMLReader parser; - - /** - * Private constructor used only by the other constructors. - * @param session The parent FOraySession. - */ - private FOrayDocument(FOraySession session) { - this.session = session; - session.registerDocument(this); - treeBuilder = this.session.getFOTreeServer().makeFOTree(); - } - - /** - * Standard constructor. Accepts a SAX InputSource as input. - * @param session The parent FOraySession. - * @param inputSource A SAX InputSource. - * @param parser A SAX parser. - */ - public FOrayDocument(FOraySession session, InputSource inputSource, - XMLReader parser) { - this(session); - this.inputSource = inputSource; - this.parser = parser; - this.parser.setContentHandler(treeBuilder); - } - - /** - * Constructor for processing a DOM Document. It creates its own parser. - * @param session The parent FOraySession. - * @param domDocument A DOM Document. - */ - public FOrayDocument (FOraySession session, Document domDocument) - throws FOrayException { - this(session); - this.inputSource = new DocumentInputSource(domDocument); - this.parser = new DocumentReader(); - this.parser.setContentHandler(treeBuilder); - } - - /** - * Constructor for processing a JAXP Transformer. - * @param session The parent FOraySession. - * @param jaxpTransformer A JAXP Transformer. - */ - public FOrayDocument (FOraySession session, Transformer jaxpTransformer, - Source jaxpSource) throws FOrayException { - this(session); - this.jaxpTransformer = jaxpTransformer; - this.jaxpSource = jaxpSource; - this.jaxpResult = new SAXResult(this.treeBuilder); - } - - /** - * Registers a FOrayTarget instance that this FOrayDocument should process. - * @param target The FOrayTarget instance that should be processed. - */ - protected void registerTarget(FOrayTarget target) { - if (target == null) { - return; - } - this.targetList.add(target); - } - - /** - * Returns the tree builder (a SAX ContentHandler). - * - * Used in situations where SAX is used but not via a FOray-invoked - * SAX parser, i.e. where some upstream process wishes to be in control - * of the parsing and event-firing, usually because there is a pipeline of - * processes that are both SAX consumers and producers. Cocoon is one - * example of such a system. - */ - public ContentHandler getContentHandler() { - return this.treeBuilder; - } - - /** - * Returns the JAXP SAXResult (which encapsulates a SAX ContentHandler). - * - * See {@link #getContentHandler()} for the use-case. - */ - public SAXResult getJAXPResult() { - return this.jaxpResult; - } - - public void setTarget(FOrayTarget target) throws FOrayException { - if (target.getDocument() != this) { - throw new FOrayException("FOrayTarget not a child of this " - + "FOrayDocument."); - } - this.currentTarget = target; - } - - public synchronized void process() throws FOrayException { - // Get the FOrayTarget to process. - FOrayTarget target = (FOrayTarget) targetList.get(0); - processTarget(target); - } - - /** - * Build the formatting object tree from the input. - */ - public synchronized void processTarget(FOrayTarget target) - throws FOrayException { - this.setTarget(target); - this.treeBuilder.setFontConsumer(this.getFontConsumer()); - try { - if (this.jaxpTransformer == null) { - // Regular SAX Input - parser.parse(this.inputSource); - } else { - // SAX Events generated by a JAXP Transformer - jaxpTransformer.transform(this.jaxpSource, jaxpResult); - } - } catch (SAXException e) { - if (e.getException() instanceof FOrayException) { - throw (FOrayException)e.getException(); - } - throw new FOrayException(e); - } catch (TransformerException e) { - if (e.getException() instanceof FOrayException) { - throw (FOrayException)e.getException(); - } - throw new FOrayException(e); - } catch (IOException e) { - throw new FOrayException(e); - } finally { - cleanup(currentTarget); - } - } - - public void cleanup(FOrayTarget target) { - } - - /** - * Dumps an error - */ - public void dumpError(Exception e) { - if (! this.getConfiguration().optionVerbosity().equals("debug")) { - return; - } - Log log = getLogger(); - if (e instanceof SAXException) { - log.error(e.getMessage()); - if (((SAXException)e).getException() != null) { - log.error(((SAXException)e).getException().getMessage()); - } - } else if (e instanceof FOrayException) { - e.printStackTrace(); - if (((FOrayException)e).getException() != null) { - log.error(((FOrayException)e).getException().getMessage()); - } - } else { - log.error(e.getMessage()); - } - } - - /** - * Runs the formatting and renderering process using the previously set - * inputsource and outputstream - */ - public synchronized void run() - throws IOException, FOrayException { - if (this.inputSource == null) { - throw new FOrayException("InputSource is not set."); - } - - if (this.parser == null) { - throw new FOrayException("Invalid Parser."); - } - process(); - } - - public Log getLogger() { - return this.session.getLogger(); - } - - public FontServer getFontServer() { - return this.session.getFontServer(); - } - - public String getParserClassName() { - return XMLParser.getParserClassName(); - } - - /** - * Required by FOTreeControl interface. - * @return The base URL that should be used for finding external files, like - * graphical images, etc. - */ - public URL getBaseURL() { - return getConfiguration().optionBaseDirectory(); - } - - public FontConsumer getFontConsumer() { - return this.currentTarget.getFontConsumer(); - } - - public TextServer getTextServer() { - return session.getTextServer(); - } - - public GraphicServer getGraphicServer() { - return session.getGraphicServer(); - } - - public SessionConfig getConfiguration() { - return session.getConfiguration(); - } - - public org.axsl.foR.FOTree getFOTreeBuilder() { - return this.treeBuilder; - } - - public AreaTreeFactory getAreaTreeFactory() { - return this.session.getAreaTreeFactory(); - } - - public LayoutFactory getLayoutFactory() { - return this.session.getLayoutFactory(); - } - -} Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -1,268 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.core.Application; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; - -import org.axsl.areaW.AreaTreeFactory; -import org.axsl.foR.FOTreeFactory; -import org.axsl.fontR.FontServer; -import org.axsl.graphicR.GraphicServer; -import org.axsl.layout.LayoutFactory; -import org.axsl.text.TextServer; - -import org.apache.commons.logging.Log; - -import org.xml.sax.EntityResolver; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * The ancestor class for all FOray processing. All classes that start - * FOray processing need to create a FOraySession, one or more FOrayDocument - * instances, and one or more FOrayTarget instances for each FOrayDocument, - * then run the FOraySession process() method. - * This process is illustrated and documented in the source code for - * the CommandLineStarter.run() method. - * - * After instantiating FOraySession, additional Namespace instances can - * be registered with the session through the addNamespace method. Custom - * Namespaces can also be added to the system resources, and these are - * automatically registered at runtime. - * - * The input document is identified to the FOrayDocument as it is instantiated. - * There are two constructors, one for SAX input, and the other for DOM input. - * The Renderer, LayoutStrategy, and output document are identified to the - * FOrayTarget as it is instantiated. - */ -public class FOraySession { - - /** The collection of FOrayDocument instances that will be processed. */ - private ArrayList documentList = new ArrayList(); - - /** An logger to be used for this session. */ - private Log log; - - /** A FontServer instance to be used for this session. */ - private FontServer fontServer; - - /** A TextServer instance to be used for this session. */ - private TextServer textServer; - - /** A GraphicServer instance to be used for this session. */ - private GraphicServer graphicServer; - - /** */ - private FOTreeFactory foTreeFactory; - - private AreaTreeFactory areaTreeFactory; - - private LayoutFactory layoutFactory; - - /** A SessionConfig instance to be used for this session. */ - private SessionConfig configuration; - - /** The EntityResolver to be used when parsing XML (resolves XML catalogs, - * etc. */ - private EntityResolver entityResolver; - - /** - * Constructor. - * @param logger The (optional) logger that should be used for this - * session. If null is passed, a default Logger will be created. - * @param configuration The Configuration instance that should be used - * with this session. - * @param fontServer The (optional) FontServer instance that should be used - * for this session. If null is passed, then a FontServer instance will be - * created by this FOraySession. If an instance is passed, it needs to be - * fully configured and ready to be used. - * @param textServer The (optional) TextServer instance that should be used - * for this session. If null is passed, then a TextServer instance will be - * created by this FOraySession. If an instance is passed, it needs to be - * fully configured and ready to be used. - * @param graphicServer The (optional) GraphicServer instance that should - * be used for this session. If null is passed, then a GraphicServer - * instance will be created by this FOray Session. If an instance is passed, - * it needs to be fully configured and ready to be used. - */ - public FOraySession(Log logger, SessionConfig configuration, - FontServer fontServer, TextServer textServer, - GraphicServer graphicServer, FOTreeFactory foTreeFactory, - AreaTreeFactory areaTreeFactory, LayoutFactory layoutFactory) - throws FOrayException { - /* Validate Logger. */ - if (logger == null) { - throw new FOrayException("Logger required for FOraySession."); - } - this.log = logger; - log.info(Application.getVersion()); - - /* Validate Configuration. */ - this.configuration = configuration; - if (this.configuration == null) { - this.configuration = new SessionConfig(logger); - } - - /* Validate FontServer. */ - if (fontServer == null) { - throw new FOrayException("FontServer required for FOraySession."); - } - this.fontServer = fontServer; - setupFontServer(); - - /* Validate TextServer. */ - if (textServer == null) { - throw new FOrayException("TextServer required for FOraySession."); - } - this.textServer = textServer; - - /* Validate GraphicServer. */ - if (graphicServer == null) { - throw new FOrayException("GraphicServer required for " - + "FOraySession."); - } - this.graphicServer = graphicServer; - - /* Validate FOTreeFactory. */ - if (foTreeFactory == null) { - throw new FOrayException("FOTreeFactory required for " - + "FOraySession."); - } - this.foTreeFactory = foTreeFactory; - - /* Validate AreaTreeFactory. */ - if (areaTreeFactory == null) { - throw new FOrayException("AreaTreeFactory required for " - + "FOraySession."); - } - this.areaTreeFactory = areaTreeFactory; - - /* Validate LayoutFactory. */ - if (layoutFactory == null) { - throw new FOrayException("LayoutFactory required for " - + "FOraySession."); - } - this.layoutFactory = layoutFactory; - } - - public Log getLogger() { - return log; - } - - /** - * Registers a FOrayDocument instance that this FOraySession should process. - * @param document The FOrayDocument instance that should be processed. - */ - protected void registerDocument(FOrayDocument document) { - if (document == null) { - return; - } - this.documentList.add(document); - } - - /** - * Sets up a FontServer instance if there is not one already. - */ - private void setupFontServer() { - if (log.isDebugEnabled()) { - String[] systemFontFamilies = fontServer.getSystemFontFamilyList(); - if (systemFontFamilies != null) { - log.debug("Java font family names:"); - for (int i = 0; i < systemFontFamilies.length; i++) { - log.debug(" " + systemFontFamilies[i]); - } - } - java.awt.Font[] systemFonts = fontServer.getSystemFontList(); - if (systemFonts != null) { - log.debug("Java font names:"); - for (int i = 0; i < systemFonts.length; i++) { - log.debug(" " + systemFonts[i].getFontName()); - } - } - } - } - - /** - * @return The FontServer instance that is being used in this session. - */ - public FontServer getFontServer() { - return this.fontServer; - } - - public TextServer getTextServer() { - return this.textServer; - } - - public GraphicServer getGraphicServer() { - return this.graphicServer; - } - - public SessionConfig getConfiguration() { - return this.configuration; - } - - /** - * Iterates through the collection of FOrayDocuments to be processed, and - * processes each one. - */ - public void process() throws FOrayException { - Iterator iter = documentList.iterator(); - while (iter.hasNext()) { - FOrayDocument document = (FOrayDocument) iter.next(); - document.process(); - } - } - - public FOTreeFactory getFOTreeServer() { - return this.foTreeFactory; - } - - /** - * Sets the EntityResolver that should be used to resolve XML entities. - * @param entityResolver The EntityResolver that should be set. - */ - public void setEntityResolver(EntityResolver entityResolver) { - this.entityResolver = entityResolver; - } - - /** - * @return The EntityResolver that should be used to resolve XML entities. - */ - public EntityResolver getEntityResolver() { - return this.entityResolver; - } - - public AreaTreeFactory getAreaTreeFactory() { - return this.areaTreeFactory; - } - - public LayoutFactory getLayoutFactory() { - return this.layoutFactory; - } - -} Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -1,462 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.core.Application; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; -import org.axsl.output.OutputTarget; -import org.axsl.output.Renderer; - -import org.axsl.areaR.AreaRException; -import org.axsl.areaR.PageArea; -import org.axsl.areaW.AreaTreeEvent; -import org.axsl.areaW.AreaTreeFactory; -import org.axsl.areaW.AreaTreeListener; -import org.axsl.areaW.AreaWException; -import org.axsl.foR.FOTreeEvent; -import org.axsl.foR.FOTreeListener; -import org.axsl.foR.fo.PageSequence; -import org.axsl.fontR.FontConsumer; -import org.axsl.fontR.FontServer; -import org.axsl.layout.Layout; -import org.axsl.layout.LayoutException; -import org.axsl.layout.LayoutFactory; -import org.axsl.text.TextServer; - -import org.apache.commons.logging.Log; - -import org.xml.sax.SAXException; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; - -/** - This class acts as a bridge between the XML:FO parser - and the formatting/rendering classes. It will queue - PageSequences up until all the IDs required by them - are satisfied, at which time it will render the - pages.<P> - - StreamRenderer is created by Driver and called from - FOTreeBuilder when a PageSequence is created, - and AreaTree when a Page is formatted.<P> -*/ -public class FOrayTarget implements FOTreeListener, AreaTreeListener { - private static final boolean MEM_PROFILE_WITH_GC = false; - - /** The "parent" FOrayDocument instance. */ - private FOrayDocument document; - - /** This will provide some statistics. */ - private Runtime runtime = Runtime.getRuntime(); - - /** Keep track of the number of pages rendered. */ - int pageCount = 0; - - /** Keep track of heap memory allocated, for statistical purposes. */ - private long initialMemory; - - /** Keep track of time used by renderer. */ - private long startTime; - - /** - * The stream to which this rendering is to be written. <B>Note</B> that - * some renderers do not render to a stream, and that this member can - * therefore be null. - */ - private OutputStream outputStream; - - /** The renderer being used. */ - private OutputTarget outputTarget; - - /** - * The list of pages waiting to be renderered. In general, pages waiting - * to be rendered are doing so because they have unresolved "ref-id" items - * on them. - */ - private ArrayList renderQueue = new ArrayList(); - - /** - * Keeps track of how many page-sequence objects have been processed. - * Used in messages to the users. - */ - private int pageSequenceCount; - - /** The LayoutStrategy implementation to be used for this target. */ - private Layout layout; - - private org.axsl.areaW.AreaTree areaTree; - - private FontConsumer fontConsumer; - - public FOrayTarget(FOrayDocument document, OutputTarget outputTarget, - Layout layout, OutputStream outputStream) - throws FOrayException { - // Validate the FOrayDocument. - this.document = document; - if (this.document == null) { - throw new FOrayException("A FOrayDocument is required to create" - + "a FOrayTarget"); - } - document.registerTarget(this); - - // Register this FOrayTarget as a listener for FO Tree events. - document.getFOTreeBuilder().registerListener(this); - - // Validate the OutputTarget. - this.outputTarget = outputTarget; - if (this.outputTarget == null) { - throw new FOrayException("OutputTarget has not been set."); - } - - // Validate the LayoutStrategy. If null, create a default one. - this.layout = layout; - if (this.layout == null) { - this.layout = this.getLayoutFactory().makeLayout(); - } - - // Validate the OutputStream. - this.outputStream = outputStream; - if (this.outputTarget.outputStreamRequired() - && outputStream == null) { - throw new FOrayException("OutputStream is required."); - } - - /* Obtain a FontConsumer instance. */ - FontServer server = getFontServer(); - this.fontConsumer = server.makeFontConsumer(); - this.fontConsumer.setFontSources(this.getOutputTarget() - .getFontSources()); - - /* Finish configuring the OutputTarget. */ - this.outputTarget.setOutputStream(this.getOutputStream()); - this.outputTarget.setApplicationName( - Application.getApplicationName()); - this.outputTarget.setApplicationNameShort( - Application.getApplicationNameShort()); - this.outputTarget.setApplicationVersion(Application.getVersion()); - this.outputTarget.setDeveloperURLShort( - Application.getDeveloperURLShort()); - this.outputTarget.setStrokeSVGText(getConfiguration() - .optionStrokeSVGText()); - this.outputTarget.setLogger(this.getLogger()); - this.outputTarget.setFontConsumer(this.getFontConsumer()); - - // Start the renderer. - startRenderer(); - } - - public void startRenderer() throws FOrayException { - pageCount = 0; - - if (MEM_PROFILE_WITH_GC) { - System.gc(); // This takes time but gives better results - } - - initialMemory = runtime.totalMemory() - runtime.freeMemory(); - startTime = System.currentTimeMillis(); - try { - outputTarget.startOutput(); - } catch (IOException e) { - throw new FOrayException(e); - } - } - - public void stopRenderer() throws SAXException { - /* - Force the processing of any more queue elements, - even if they are not resolved. - */ - try { - processQueue(true); - outputTarget.stopOutput(); - } catch (AreaRException e) { - throw new SAXException(e); - } - catch (IOException e) { - throw new SAXException(e); - } - - if (MEM_PROFILE_WITH_GC) { - System.gc(); // This takes time but gives better results - } - - long memoryNow = runtime.totalMemory() - runtime.freeMemory(); - long memoryUsed = (memoryNow - initialMemory) / 1024L; - - getLogger().debug("Initial heap size: " + (initialMemory/1024L) + "Kb"); - getLogger().debug("Current heap size: " + (memoryNow/1024L) + "Kb"); - getLogger().debug("Total memory used: " + memoryUsed + "Kb"); - - if (!MEM_PROFILE_WITH_GC) { - getLogger().debug(" Memory use is indicative; no GC was " - + "performed"); - getLogger().debug(" These figures should not be used " - + "comparatively"); - } - - long timeUsed = System.currentTimeMillis() - startTime; - - getLogger().debug("Total time used: " + timeUsed + "ms"); - getLogger().debug("Pages rendered: " + pageCount); - if (pageCount != 0) { - getLogger().debug("Avg render time: " + (timeUsed / pageCount) - + "ms/page"); - } - } - - /** - Format the PageSequence. The PageSequence - formats Pages and adds them to the AreaTree, - which subsequently calls the StreamRenderer - instance (this) again to render the page. - At this time the page might be printed - or it might be queued. A page might not - be renderable immediately if the IDReferences - are not all valid. In this case we defer - the rendering until they are all valid. - */ - public void render(PageSequence pageSequence) throws FOrayException { - pageSequenceCount ++; - getLogger().info("Starting layout of page-sequence " - + pageSequenceCount + "."); - if (this.outputTarget instanceof Renderer) { - Renderer renderer = (Renderer) this.outputTarget; - org.axsl.areaR.AreaTree areaTreeR = getRenderedAreaTree(); - renderer.setAreaTree(areaTreeR); - org.axsl.areaW.PageCollection pageCollection = - areaTree.makePageCollection(pageSequence); - try { - layout.formatPageSequence(pageCollection); - } catch (AreaWException e) { - throw new FOrayException(e); - } catch (LayoutException e) { - throw new FOrayException(e); - } - try { - processQueue(false); - } catch (AreaRException e1) { - throw new FOrayException(e1); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - getLogger().info("Ending page-sequence " + pageSequenceCount + ": " - + pageCollection.getPageCount() + " pages produced."); - } - } - - private org.axsl.areaW.AreaTree getCreatedAreaTree() { - if (this.areaTree == null) { - this.areaTree = this.getAreaTreeFactory().makeAreaTree( - this.document.getFOTreeBuilder().getRootFObj()); - this.areaTree.registerListener(this); - } - return this.areaTree; - } - - private org.axsl.areaR.AreaTree getRenderedAreaTree() - throws FOrayException { - org.axsl.areaW.AreaTree areaTreeW = getCreatedAreaTree(); - if (! (areaTreeW instanceof org.axsl.areaR.AreaTree)) { - throw new FOrayException("Area Tree cannot be rendered."); - } - return (org.axsl.areaR.AreaTree) areaTreeW; - } - - public void pageComplete(AreaTreeEvent event) { - org.axsl.areaW.PageArea page = event.getPage(); - org.axsl.areaR.PageArea pageToRender = (PageArea) page; - try { - queuePage(pageToRender); - } catch (AreaWException e) { - /* TODO: Do something better with this. */ - e.printStackTrace(); - } - } - - public synchronized void queuePage(PageArea page) throws AreaWException { - /* - * We run the pages through a queue because any page page that contains - * an unresolved ref-id prevents subsequent pages from being rendered. - * So, first we add them to the queue. Then, we check to see if - * anything in the queue can be processed. - */ -// try { - renderQueue.add(page); - /* - The just-added entry could (possibly) resolve the - waiting entries, so we try to process the queue - now to see. - */ -// processQueue(false); -// } catch (IOException e) { -// throw new FOrayException(e); -// } - pageCount++; - } - - /** - Try to process the queue from the first entry forward. - If an entry can't be processed, then the queue can't - move forward, so return. - */ - private synchronized void processQueue(boolean force) - throws AreaRException, IOException { - if (! (this.outputTarget instanceof Renderer)) { - return; - } - Renderer renderer = (Renderer) this.outputTarget; - while (renderQueue.size() > 0) { - PageArea page = (PageArea) renderQueue.get(0); - if (force || page.firstUnresolvedRefId() == null) { - renderer.render(page); - renderQueue.remove(0); - } else { - return; - } - } - } - - /** - * Return the logger to be used. (Required by the FontConsumer interface). - */ - public Log getLogger() { - return document.getLogger(); - } - - /** - * Required by the FOTreeListener interface. It handles an - * FOTreeEvent that is fired when an FObj object has been completed. We - * do not need to do anything with it, so we ignore it. - * @param event The FOTreeEvent that was fired. - */ - public void foFObjComplete(FOTreeEvent event) { - } - - /** - * Required by the FOTreeListener interface. It handles an - * FOTreeEvent that is fired when a PageSequence object has been completed. - * @param event the FOTreeEvent that was fired - */ - public void foPageSequenceComplete(FOTreeEvent event) { - try { - boolean shouldRender = this.getConfiguration().isModeRender(); - if (shouldRender) { - render(event.getPageSequence()); - } - } catch (FOrayException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * Required by the FOTreeListener interface. It handles an FOTreeEvent that - * is fired when the Document has been completely parsed. - * @param event the FOTreeEvent that was fired - */ - public void foDocumentComplete(FOTreeEvent event) { - org.axsl.foR.fo.Root rootFObj = document.getFOTreeBuilder() - .getRootFObj(); - try { - getCreatedAreaTree().layoutDocumentNodes(rootFObj); - } catch (AreaWException e1) { - getLogger().error("Error in layout of Document nodes."); - e1.printStackTrace(); - } - try { - stopRenderer(); - } catch (SAXException e) { - e.printStackTrace(); - } - } - - /** - * Tell FOTreeBuilder that we don't want the FObj-complete events. - */ - public boolean wantsFObjCompleteEvents() { - return false; - } - - public FontConsumer getFontConsumer() { - return this.fontConsumer; - } - - public FontServer getFontServer() { - return this.document.getFontServer(); - } - - public TextServer getTextServer() { - return document.getTextServer(); - } - - public OutputStream getOutputStream() { - return this.outputStream; - } - - public OutputTarget getOutputTarget() { - return this.outputTarget; - } - - public SessionConfig getConfiguration() { - return document.getConfiguration(); - } - - public Layout getLayoutStrategy() { - return this.layout; - } - - /** - * Closes the OutputStream, if any. - * This method is part of the external API, and should <em>not</em> be - * run automatically, because the OutputStream may be under the control of - * an external process that wishes to leave it open and do some more - * processing to it. - */ - public void cleanup() { - if (this.outputStream != null) { - try { - this.outputStream.close(); - } catch (Exception e) { - } - } - } - - public FOrayDocument getDocument() { - return this.document; - } - - public AreaTreeFactory getAreaTreeFactory() { - return this.document.getAreaTreeFactory(); - } - - public LayoutFactory getLayoutFactory() { - return this.document.getLayoutFactory(); - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -26,6 +26,7 @@ import org.foray.common.Logging; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,14 +24,14 @@ package org.foray.app.ant; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.Options; import org.foray.app.OutputTargetFactory; import org.foray.app.Starter; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,13 +24,13 @@ package org.foray.app.test; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.core.TraxInputHandler; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -34,12 +34,12 @@ import javax.xml.transform.TransformerException; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.core.Application; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.render.awt.AWTRenderer; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,13 +24,13 @@ package org.foray.demo.embed; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,12 +24,12 @@ package org.foray.demo.embed; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.SessionConfig; import org.foray.demo.embed.model.ProjectTeam; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,12 +24,12 @@ package org.foray.demo.embed; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.SessionConfig; import org.axsl.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,13 +24,13 @@ package org.foray.demo.servlet; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,11 +24,11 @@ package org.foray.demo.servlet; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.render.awt.AWTPrintRenderer; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,11 +24,11 @@ package org.foray.demo.servlet; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.axsl.output.OutputTarget; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:23:51
|
Revision: 7286 Author: victormote Date: 2006-05-26 15:23:35 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7286&view=rev Log Message: ----------- Move remaining core files from the app module to the core module. Modified Paths: -------------- trunk/foray/foray-core/.classpath Added Paths: ----------- trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java Modified: trunk/foray/foray-core/.classpath =================================================================== --- trunk/foray/foray-core/.classpath 2006-05-26 22:18:04 UTC (rev 7285) +++ trunk/foray/foray-core/.classpath 2006-05-26 22:23:35 UTC (rev 7286) @@ -4,5 +4,14 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslArea-W"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslFont-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslFO-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslGraphic-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslText"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslArea-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslCommon"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Copied: trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java (from rev 7278, trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java 2006-05-26 22:23:35 UTC (rev 7286) @@ -0,0 +1,324 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.foray.common.XMLParser; + +import org.axsl.areaW.AreaTreeFactory; +import org.axsl.fontR.FontConsumer; +import org.axsl.fontR.FontServer; +import org.axsl.graphicR.GraphicServer; +import org.axsl.layout.LayoutFactory; +import org.axsl.text.TextServer; + +import org.apache.commons.logging.Log; + +import org.w3c.dom.Document; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; + +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.sax.SAXResult; + +/** + * This class manages the process of parsing an input FO document and creating + * an FOTree. + */ +public class FOrayDocument { + + /** The "parent" FOraySession. */ + private FOraySession session; + + /** + * The SAX InputSource that encapsulates the document to be parsed. + * Should be null if the JAXP constructor was used. + */ + private InputSource inputSource; + + /** + * The JAXP Transformer that should be used to handle an XSLT transformation + * on the input. + * Should be null if the SAX constructor was used. + */ + private Transformer jaxpTransformer; + + /** + * The JAXP Source that encapsulates the document to be parsed. + * Should be null if the SAX constructor was used. + */ + private Source jaxpSource; + + /** + * The JAXP Result encapsulating our FOTreeBuilder. + * Should be null if the SAX constructor was used. + */ + private SAXResult jaxpResult; + + /** The collection of FOrayTarget "children". */ + private ArrayList targetList = new ArrayList(); + + /** The FO tree builder, which handles the SAX events. */ + private org.axsl.foR.FOTree treeBuilder; + + private FOrayTarget currentTarget; + + /** Array of bytes listing unsupported FO objects. */ + protected byte[] unsupportedObjects; + + /** Array of shorts listing unsupported FO properties. */ + protected short[] unsupportedProperties; + + /** The SAX parser. */ + private XMLReader parser; + + /** + * Private constructor used only by the other constructors. + * @param session The parent FOraySession. + */ + private FOrayDocument(FOraySession session) { + this.session = session; + session.registerDocument(this); + treeBuilder = this.session.getFOTreeServer().makeFOTree(); + } + + /** + * Standard constructor. Accepts a SAX InputSource as input. + * @param session The parent FOraySession. + * @param inputSource A SAX InputSource. + * @param parser A SAX parser. + */ + public FOrayDocument(FOraySession session, InputSource inputSource, + XMLReader parser) { + this(session); + this.inputSource = inputSource; + this.parser = parser; + this.parser.setContentHandler(treeBuilder); + } + + /** + * Constructor for processing a DOM Document. It creates its own parser. + * @param session The parent FOraySession. + * @param domDocument A DOM Document. + */ + public FOrayDocument (FOraySession session, Document domDocument) + throws FOrayException { + this(session); + this.inputSource = new DocumentInputSource(domDocument); + this.parser = new DocumentReader(); + this.parser.setContentHandler(treeBuilder); + } + + /** + * Constructor for processing a JAXP Transformer. + * @param session The parent FOraySession. + * @param jaxpTransformer A JAXP Transformer. + */ + public FOrayDocument (FOraySession session, Transformer jaxpTransformer, + Source jaxpSource) throws FOrayException { + this(session); + this.jaxpTransformer = jaxpTransformer; + this.jaxpSource = jaxpSource; + this.jaxpResult = new SAXResult(this.treeBuilder); + } + + /** + * Registers a FOrayTarget instance that this FOrayDocument should process. + * @param target The FOrayTarget instance that should be processed. + */ + protected void registerTarget(FOrayTarget target) { + if (target == null) { + return; + } + this.targetList.add(target); + } + + /** + * Returns the tree builder (a SAX ContentHandler). + * + * Used in situations where SAX is used but not via a FOray-invoked + * SAX parser, i.e. where some upstream process wishes to be in control + * of the parsing and event-firing, usually because there is a pipeline of + * processes that are both SAX consumers and producers. Cocoon is one + * example of such a system. + */ + public ContentHandler getContentHandler() { + return this.treeBuilder; + } + + /** + * Returns the JAXP SAXResult (which encapsulates a SAX ContentHandler). + * + * See {@link #getContentHandler()} for the use-case. + */ + public SAXResult getJAXPResult() { + return this.jaxpResult; + } + + public void setTarget(FOrayTarget target) throws FOrayException { + if (target.getDocument() != this) { + throw new FOrayException("FOrayTarget not a child of this " + + "FOrayDocument."); + } + this.currentTarget = target; + } + + public synchronized void process() throws FOrayException { + // Get the FOrayTarget to process. + FOrayTarget target = (FOrayTarget) targetList.get(0); + processTarget(target); + } + + /** + * Build the formatting object tree from the input. + */ + public synchronized void processTarget(FOrayTarget target) + throws FOrayException { + this.setTarget(target); + this.treeBuilder.setFontConsumer(this.getFontConsumer()); + try { + if (this.jaxpTransformer == null) { + // Regular SAX Input + parser.parse(this.inputSource); + } else { + // SAX Events generated by a JAXP Transformer + jaxpTransformer.transform(this.jaxpSource, jaxpResult); + } + } catch (SAXException e) { + if (e.getException() instanceof FOrayException) { + throw (FOrayException)e.getException(); + } + throw new FOrayException(e); + } catch (TransformerException e) { + if (e.getException() instanceof FOrayException) { + throw (FOrayException)e.getException(); + } + throw new FOrayException(e); + } catch (IOException e) { + throw new FOrayException(e); + } finally { + cleanup(currentTarget); + } + } + + public void cleanup(FOrayTarget target) { + } + + /** + * Dumps an error + */ + public void dumpError(Exception e) { + if (! this.getConfiguration().optionVerbosity().equals("debug")) { + return; + } + Log log = getLogger(); + if (e instanceof SAXException) { + log.error(e.getMessage()); + if (((SAXException)e).getException() != null) { + log.error(((SAXException)e).getException().getMessage()); + } + } else if (e instanceof FOrayException) { + e.printStackTrace(); + if (((FOrayException)e).getException() != null) { + log.error(((FOrayException)e).getException().getMessage()); + } + } else { + log.error(e.getMessage()); + } + } + + /** + * Runs the formatting and renderering process using the previously set + * inputsource and outputstream + */ + public synchronized void run() + throws IOException, FOrayException { + if (this.inputSource == null) { + throw new FOrayException("InputSource is not set."); + } + + if (this.parser == null) { + throw new FOrayException("Invalid Parser."); + } + process(); + } + + public Log getLogger() { + return this.session.getLogger(); + } + + public FontServer getFontServer() { + return this.session.getFontServer(); + } + + public String getParserClassName() { + return XMLParser.getParserClassName(); + } + + /** + * Required by FOTreeControl interface. + * @return The base URL that should be used for finding external files, like + * graphical images, etc. + */ + public URL getBaseURL() { + return getConfiguration().optionBaseDirectory(); + } + + public FontConsumer getFontConsumer() { + return this.currentTarget.getFontConsumer(); + } + + public TextServer getTextServer() { + return session.getTextServer(); + } + + public GraphicServer getGraphicServer() { + return session.getGraphicServer(); + } + + public SessionConfig getConfiguration() { + return session.getConfiguration(); + } + + public org.axsl.foR.FOTree getFOTreeBuilder() { + return this.treeBuilder; + } + + public AreaTreeFactory getAreaTreeFactory() { + return this.session.getAreaTreeFactory(); + } + + public LayoutFactory getLayoutFactory() { + return this.session.getLayoutFactory(); + } + +} Copied: trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java (from rev 7285, trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java 2006-05-26 22:23:35 UTC (rev 7286) @@ -0,0 +1,265 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + + +import org.axsl.areaW.AreaTreeFactory; +import org.axsl.foR.FOTreeFactory; +import org.axsl.fontR.FontServer; +import org.axsl.graphicR.GraphicServer; +import org.axsl.layout.LayoutFactory; +import org.axsl.text.TextServer; + +import org.apache.commons.logging.Log; + +import org.xml.sax.EntityResolver; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * The ancestor class for all FOray processing. All classes that start + * FOray processing need to create a FOraySession, one or more FOrayDocument + * instances, and one or more FOrayTarget instances for each FOrayDocument, + * then run the FOraySession process() method. + * This process is illustrated and documented in the source code for + * the CommandLineStarter.run() method. + * + * After instantiating FOraySession, additional Namespace instances can + * be registered with the session through the addNamespace method. Custom + * Namespaces can also be added to the system resources, and these are + * automatically registered at runtime. + * + * The input document is identified to the FOrayDocument as it is instantiated. + * There are two constructors, one for SAX input, and the other for DOM input. + * The Renderer, LayoutStrategy, and output document are identified to the + * FOrayTarget as it is instantiated. + */ +public class FOraySession { + + /** The collection of FOrayDocument instances that will be processed. */ + private ArrayList documentList = new ArrayList(); + + /** An logger to be used for this session. */ + private Log log; + + /** A FontServer instance to be used for this session. */ + private FontServer fontServer; + + /** A TextServer instance to be used for this session. */ + private TextServer textServer; + + /** A GraphicServer instance to be used for this session. */ + private GraphicServer graphicServer; + + /** */ + private FOTreeFactory foTreeFactory; + + private AreaTreeFactory areaTreeFactory; + + private LayoutFactory layoutFactory; + + /** A SessionConfig instance to be used for this session. */ + private SessionConfig configuration; + + /** The EntityResolver to be used when parsing XML (resolves XML catalogs, + * etc. */ + private EntityResolver entityResolver; + + /** + * Constructor. + * @param logger The (optional) logger that should be used for this + * session. If null is passed, a default Logger will be created. + * @param configuration The Configuration instance that should be used + * with this session. + * @param fontServer The (optional) FontServer instance that should be used + * for this session. If null is passed, then a FontServer instance will be + * created by this FOraySession. If an instance is passed, it needs to be + * fully configured and ready to be used. + * @param textServer The (optional) TextServer instance that should be used + * for this session. If null is passed, then a TextServer instance will be + * created by this FOraySession. If an instance is passed, it needs to be + * fully configured and ready to be used. + * @param graphicServer The (optional) GraphicServer instance that should + * be used for this session. If null is passed, then a GraphicServer + * instance will be created by this FOray Session. If an instance is passed, + * it needs to be fully configured and ready to be used. + */ + public FOraySession(Log logger, SessionConfig configuration, + FontServer fontServer, TextServer textServer, + GraphicServer graphicServer, FOTreeFactory foTreeFactory, + AreaTreeFactory areaTreeFactory, LayoutFactory layoutFactory) + throws FOrayException { + /* Validate Logger. */ + if (logger == null) { + throw new FOrayException("Logger required for FOraySession."); + } + this.log = logger; + log.info(Application.getVersion()); + + /* Validate Configuration. */ + this.configuration = configuration; + if (this.configuration == null) { + this.configuration = new SessionConfig(logger); + } + + /* Validate FontServer. */ + if (fontServer == null) { + throw new FOrayException("FontServer required for FOraySession."); + } + this.fontServer = fontServer; + setupFontServer(); + + /* Validate TextServer. */ + if (textServer == null) { + throw new FOrayException("TextServer required for FOraySession."); + } + this.textServer = textServer; + + /* Validate GraphicServer. */ + if (graphicServer == null) { + throw new FOrayException("GraphicServer required for " + + "FOraySession."); + } + this.graphicServer = graphicServer; + + /* Validate FOTreeFactory. */ + if (foTreeFactory == null) { + throw new FOrayException("FOTreeFactory required for " + + "FOraySession."); + } + this.foTreeFactory = foTreeFactory; + + /* Validate AreaTreeFactory. */ + if (areaTreeFactory == null) { + throw new FOrayException("AreaTreeFactory required for " + + "FOraySession."); + } + this.areaTreeFactory = areaTreeFactory; + + /* Validate LayoutFactory. */ + if (layoutFactory == null) { + throw new FOrayException("LayoutFactory required for " + + "FOraySession."); + } + this.layoutFactory = layoutFactory; + } + + public Log getLogger() { + return log; + } + + /** + * Registers a FOrayDocument instance that this FOraySession should process. + * @param document The FOrayDocument instance that should be processed. + */ + protected void registerDocument(FOrayDocument document) { + if (document == null) { + return; + } + this.documentList.add(document); + } + + /** + * Sets up a FontServer instance if there is not one already. + */ + private void setupFontServer() { + if (log.isDebugEnabled()) { + String[] systemFontFamilies = fontServer.getSystemFontFamilyList(); + if (systemFontFamilies != null) { + log.debug("Java font family names:"); + for (int i = 0; i < systemFontFamilies.length; i++) { + log.debug(" " + systemFontFamilies[i]); + } + } + java.awt.Font[] systemFonts = fontServer.getSystemFontList(); + if (systemFonts != null) { + log.debug("Java font names:"); + for (int i = 0; i < systemFonts.length; i++) { + log.debug(" " + systemFonts[i].getFontName()); + } + } + } + } + + /** + * @return The FontServer instance that is being used in this session. + */ + public FontServer getFontServer() { + return this.fontServer; + } + + public TextServer getTextServer() { + return this.textServer; + } + + public GraphicServer getGraphicServer() { + return this.graphicServer; + } + + public SessionConfig getConfiguration() { + return this.configuration; + } + + /** + * Iterates through the collection of FOrayDocuments to be processed, and + * processes each one. + */ + public void process() throws FOrayException { + Iterator iter = documentList.iterator(); + while (iter.hasNext()) { + FOrayDocument document = (FOrayDocument) iter.next(); + document.process(); + } + } + + public FOTreeFactory getFOTreeServer() { + return this.foTreeFactory; + } + + /** + * Sets the EntityResolver that should be used to resolve XML entities. + * @param entityResolver The EntityResolver that should be set. + */ + public void setEntityResolver(EntityResolver entityResolver) { + this.entityResolver = entityResolver; + } + + /** + * @return The EntityResolver that should be used to resolve XML entities. + */ + public EntityResolver getEntityResolver() { + return this.entityResolver; + } + + public AreaTreeFactory getAreaTreeFactory() { + return this.areaTreeFactory; + } + + public LayoutFactory getLayoutFactory() { + return this.layoutFactory; + } + +} Copied: trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java (from rev 7279, trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2006-05-26 22:23:35 UTC (rev 7286) @@ -0,0 +1,459 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.axsl.output.OutputTarget; +import org.axsl.output.Renderer; + +import org.axsl.areaR.AreaRException; +import org.axsl.areaR.PageArea; +import org.axsl.areaW.AreaTreeEvent; +import org.axsl.areaW.AreaTreeFactory; +import org.axsl.areaW.AreaTreeListener; +import org.axsl.areaW.AreaWException; +import org.axsl.foR.FOTreeEvent; +import org.axsl.foR.FOTreeListener; +import org.axsl.foR.fo.PageSequence; +import org.axsl.fontR.FontConsumer; +import org.axsl.fontR.FontServer; +import org.axsl.layout.Layout; +import org.axsl.layout.LayoutException; +import org.axsl.layout.LayoutFactory; +import org.axsl.text.TextServer; + +import org.apache.commons.logging.Log; + +import org.xml.sax.SAXException; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; + +/** + This class acts as a bridge between the XML:FO parser + and the formatting/rendering classes. It will queue + PageSequences up until all the IDs required by them + are satisfied, at which time it will render the + pages.<P> + + StreamRenderer is created by Driver and called from + FOTreeBuilder when a PageSequence is created, + and AreaTree when a Page is formatted.<P> +*/ +public class FOrayTarget implements FOTreeListener, AreaTreeListener { + private static final boolean MEM_PROFILE_WITH_GC = false; + + /** The "parent" FOrayDocument instance. */ + private FOrayDocument document; + + /** This will provide some statistics. */ + private Runtime runtime = Runtime.getRuntime(); + + /** Keep track of the number of pages rendered. */ + int pageCount = 0; + + /** Keep track of heap memory allocated, for statistical purposes. */ + private long initialMemory; + + /** Keep track of time used by renderer. */ + private long startTime; + + /** + * The stream to which this rendering is to be written. <B>Note</B> that + * some renderers do not render to a stream, and that this member can + * therefore be null. + */ + private OutputStream outputStream; + + /** The renderer being used. */ + private OutputTarget outputTarget; + + /** + * The list of pages waiting to be renderered. In general, pages waiting + * to be rendered are doing so because they have unresolved "ref-id" items + * on them. + */ + private ArrayList renderQueue = new ArrayList(); + + /** + * Keeps track of how many page-sequence objects have been processed. + * Used in messages to the users. + */ + private int pageSequenceCount; + + /** The LayoutStrategy implementation to be used for this target. */ + private Layout layout; + + private org.axsl.areaW.AreaTree areaTree; + + private FontConsumer fontConsumer; + + public FOrayTarget(FOrayDocument document, OutputTarget outputTarget, + Layout layout, OutputStream outputStream) + throws FOrayException { + // Validate the FOrayDocument. + this.document = document; + if (this.document == null) { + throw new FOrayException("A FOrayDocument is required to create" + + "a FOrayTarget"); + } + document.registerTarget(this); + + // Register this FOrayTarget as a listener for FO Tree events. + document.getFOTreeBuilder().registerListener(this); + + // Validate the OutputTarget. + this.outputTarget = outputTarget; + if (this.outputTarget == null) { + throw new FOrayException("OutputTarget has not been set."); + } + + // Validate the LayoutStrategy. If null, create a default one. + this.layout = layout; + if (this.layout == null) { + this.layout = this.getLayoutFactory().makeLayout(); + } + + // Validate the OutputStream. + this.outputStream = outputStream; + if (this.outputTarget.outputStreamRequired() + && outputStream == null) { + throw new FOrayException("OutputStream is required."); + } + + /* Obtain a FontConsumer instance. */ + FontServer server = getFontServer(); + this.fontConsumer = server.makeFontConsumer(); + this.fontConsumer.setFontSources(this.getOutputTarget() + .getFontSources()); + + /* Finish configuring the OutputTarget. */ + this.outputTarget.setOutputStream(this.getOutputStream()); + this.outputTarget.setApplicationName( + Application.getApplicationName()); + this.outputTarget.setApplicationNameShort( + Application.getApplicationNameShort()); + this.outputTarget.setApplicationVersion(Application.getVersion()); + this.outputTarget.setDeveloperURLShort( + Application.getDeveloperURLShort()); + this.outputTarget.setStrokeSVGText(getConfiguration() + .optionStrokeSVGText()); + this.outputTarget.setLogger(this.getLogger()); + this.outputTarget.setFontConsumer(this.getFontConsumer()); + + // Start the renderer. + startRenderer(); + } + + public void startRenderer() throws FOrayException { + pageCount = 0; + + if (MEM_PROFILE_WITH_GC) { + System.gc(); // This takes time but gives better results + } + + initialMemory = runtime.totalMemory() - runtime.freeMemory(); + startTime = System.currentTimeMillis(); + try { + outputTarget.startOutput(); + } catch (IOException e) { + throw new FOrayException(e); + } + } + + public void stopRenderer() throws SAXException { + /* + Force the processing of any more queue elements, + even if they are not resolved. + */ + try { + processQueue(true); + outputTarget.stopOutput(); + } catch (AreaRException e) { + throw new SAXException(e); + } + catch (IOException e) { + throw new SAXException(e); + } + + if (MEM_PROFILE_WITH_GC) { + System.gc(); // This takes time but gives better results + } + + long memoryNow = runtime.totalMemory() - runtime.freeMemory(); + long memoryUsed = (memoryNow - initialMemory) / 1024L; + + getLogger().debug("Initial heap size: " + (initialMemory/1024L) + "Kb"); + getLogger().debug("Current heap size: " + (memoryNow/1024L) + "Kb"); + getLogger().debug("Total memory used: " + memoryUsed + "Kb"); + + if (!MEM_PROFILE_WITH_GC) { + getLogger().debug(" Memory use is indicative; no GC was " + + "performed"); + getLogger().debug(" These figures should not be used " + + "comparatively"); + } + + long timeUsed = System.currentTimeMillis() - startTime; + + getLogger().debug("Total time used: " + timeUsed + "ms"); + getLogger().debug("Pages rendered: " + pageCount); + if (pageCount != 0) { + getLogger().debug("Avg render time: " + (timeUsed / pageCount) + + "ms/page"); + } + } + + /** + Format the PageSequence. The PageSequence + formats Pages and adds them to the AreaTree, + which subsequently calls the StreamRenderer + instance (this) again to render the page. + At this time the page might be printed + or it might be queued. A page might not + be renderable immediately if the IDReferences + are not all valid. In this case we defer + the rendering until they are all valid. + */ + public void render(PageSequence pageSequence) throws FOrayException { + pageSequenceCount ++; + getLogger().info("Starting layout of page-sequence " + + pageSequenceCount + "."); + if (this.outputTarget instanceof Renderer) { + Renderer renderer = (Renderer) this.outputTarget; + org.axsl.areaR.AreaTree areaTreeR = getRenderedAreaTree(); + renderer.setAreaTree(areaTreeR); + org.axsl.areaW.PageCollection pageCollection = + areaTree.makePageCollection(pageSequence); + try { + layout.formatPageSequence(pageCollection); + } catch (AreaWException e) { + throw new FOrayException(e); + } catch (LayoutException e) { + throw new FOrayException(e); + } + try { + processQueue(false); + } catch (AreaRException e1) { + throw new FOrayException(e1); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + getLogger().info("Ending page-sequence " + pageSequenceCount + ": " + + pageCollection.getPageCount() + " pages produced."); + } + } + + private org.axsl.areaW.AreaTree getCreatedAreaTree() { + if (this.areaTree == null) { + this.areaTree = this.getAreaTreeFactory().makeAreaTree( + this.document.getFOTreeBuilder().getRootFObj()); + this.areaTree.registerListener(this); + } + return this.areaTree; + } + + private org.axsl.areaR.AreaTree getRenderedAreaTree() + throws FOrayException { + org.axsl.areaW.AreaTree areaTreeW = getCreatedAreaTree(); + if (! (areaTreeW instanceof org.axsl.areaR.AreaTree)) { + throw new FOrayException("Area Tree cannot be rendered."); + } + return (org.axsl.areaR.AreaTree) areaTreeW; + } + + public void pageComplete(AreaTreeEvent event) { + org.axsl.areaW.PageArea page = event.getPage(); + org.axsl.areaR.PageArea pageToRender = (PageArea) page; + try { + queuePage(pageToRender); + } catch (AreaWException e) { + /* TODO: Do something better with this. */ + e.printStackTrace(); + } + } + + public synchronized void queuePage(PageArea page) throws AreaWException { + /* + * We run the pages through a queue because any page page that contains + * an unresolved ref-id prevents subsequent pages from being rendered. + * So, first we add them to the queue. Then, we check to see if + * anything in the queue can be processed. + */ +// try { + renderQueue.add(page); + /* + The just-added entry could (possibly) resolve the + waiting entries, so we try to process the queue + now to see. + */ +// processQueue(false); +// } catch (IOException e) { +// throw new FOrayException(e); +// } + pageCount++; + } + + /** + Try to process the queue from the first entry forward. + If an entry can't be processed, then the queue can't + move forward, so return. + */ + private synchronized void processQueue(boolean force) + throws AreaRException, IOException { + if (! (this.outputTarget instanceof Renderer)) { + return; + } + Renderer renderer = (Renderer) this.outputTarget; + while (renderQueue.size() > 0) { + PageArea page = (PageArea) renderQueue.get(0); + if (force || page.firstUnresolvedRefId() == null) { + renderer.render(page); + renderQueue.remove(0); + } else { + return; + } + } + } + + /** + * Return the logger to be used. (Required by the FontConsumer interface). + */ + public Log getLogger() { + return document.getLogger(); + } + + /** + * Required by the FOTreeListener interface. It handles an + * FOTreeEvent that is fired when an FObj object has been completed. We + * do not need to do anything with it, so we ignore it. + * @param event The FOTreeEvent that was fired. + */ + public void foFObjComplete(FOTreeEvent event) { + } + + /** + * Required by the FOTreeListener interface. It handles an + * FOTreeEvent that is fired when a PageSequence object has been completed. + * @param event the FOTreeEvent that was fired + */ + public void foPageSequenceComplete(FOTreeEvent event) { + try { + boolean shouldRender = this.getConfiguration().isModeRender(); + if (shouldRender) { + render(event.getPageSequence()); + } + } catch (FOrayException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * Required by the FOTreeListener interface. It handles an FOTreeEvent that + * is fired when the Document has been completely parsed. + * @param event the FOTreeEvent that was fired + */ + public void foDocumentComplete(FOTreeEvent event) { + org.axsl.foR.fo.Root rootFObj = document.getFOTreeBuilder() + .getRootFObj(); + try { + getCreatedAreaTree().layoutDocumentNodes(rootFObj); + } catch (AreaWException e1) { + getLogger().error("Error in layout of Document nodes."); + e1.printStackTrace(); + } + try { + stopRenderer(); + } catch (SAXException e) { + e.printStackTrace(); + } + } + + /** + * Tell FOTreeBuilder that we don't want the FObj-complete events. + */ + public boolean wantsFObjCompleteEvents() { + return false; + } + + public FontConsumer getFontConsumer() { + return this.fontConsumer; + } + + public FontServer getFontServer() { + return this.document.getFontServer(); + } + + public TextServer getTextServer() { + return document.getTextServer(); + } + + public OutputStream getOutputStream() { + return this.outputStream; + } + + public OutputTarget getOutputTarget() { + return this.outputTarget; + } + + public SessionConfig getConfiguration() { + return document.getConfiguration(); + } + + public Layout getLayoutStrategy() { + return this.layout; + } + + /** + * Closes the OutputStream, if any. + * This method is part of the external API, and should <em>not</em> be + * run automatically, because the OutputStream may be under the control of + * an external process that wishes to leave it open and do some more + * processing to it. + */ + public void cleanup() { + if (this.outputStream != null) { + try { + this.outputStream.close(); + } catch (Exception e) { + } + } + } + + public FOrayDocument getDocument() { + return this.document; + } + + public AreaTreeFactory getAreaTreeFactory() { + return this.document.getAreaTreeFactory(); + } + + public LayoutFactory getLayoutFactory() { + return this.document.getLayoutFactory(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:18:15
|
Revision: 7285 Author: victormote Date: 2006-05-26 15:18:04 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7285&view=rev Log Message: ----------- Move some of the FOray-specific bootstrapping logic out of FOraySession and into FOraySpecific. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:15:02 UTC (rev 7284) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:18:04 UTC (rev 7285) @@ -97,7 +97,7 @@ sessionConfig, graphicServer, textServer); AreaTreeFactory areaTreeFactory = FOraySpecific.makeAreaTreeFactory( logger, textServer); - LayoutFactory layoutFactory = null; + LayoutFactory layoutFactory = FOraySpecific.makeLayoutFactory(logger); FOraySession session = new FOraySession(logger, sessionConfig, fontServer, textServer, graphicServer, foTreeServer, areaTreeFactory, layoutFactory); Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:15:02 UTC (rev 7284) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:18:04 UTC (rev 7285) @@ -27,7 +27,6 @@ import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; -import org.foray.pioneer.PioneerFactory; import org.axsl.areaW.AreaTreeFactory; import org.axsl.foR.FOTreeFactory; @@ -163,8 +162,12 @@ } this.areaTreeFactory = areaTreeFactory; + /* Validate LayoutFactory. */ + if (layoutFactory == null) { + throw new FOrayException("LayoutFactory required for " + + "FOraySession."); + } this.layoutFactory = layoutFactory; - setupLayoutFactory(); } public Log getLogger() { @@ -215,16 +218,6 @@ return this.textServer; } - /** - * Sets up a LayoutFactory if there is not one already. - */ - private void setupLayoutFactory() { - if (this.layoutFactory != null) { - return; - } - this.layoutFactory = new PioneerFactory(this.getLogger()); - } - public GraphicServer getGraphicServer() { return this.graphicServer; } Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:15:02 UTC (rev 7284) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:18:04 UTC (rev 7285) @@ -32,6 +32,7 @@ import org.foray.font.FOrayFontServer; import org.foray.fotree.FOrayFOTreeServer; import org.foray.graphic.FOrayGraphicServer; +import org.foray.pioneer.PioneerFactory; import org.axsl.areaW.AreaTreeFactory; import org.axsl.foR.FOTreeFactory; @@ -126,8 +127,9 @@ return new FOrayAreaTreeFactory(logger, textServer); } - public static LayoutFactory makeLayoutFactory() throws FOrayException { - return null; + public static LayoutFactory makeLayoutFactory(Log logger) + throws FOrayException { + return new PioneerFactory(logger); } public static EntityResolver makeEntityResolver( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:15:15
|
Revision: 7284 Author: victormote Date: 2006-05-26 15:15:02 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7284&view=rev Log Message: ----------- Move some of the FOray-specific bootstrapping logic out of FOraySession and into FOraySpecific. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:10:46 UTC (rev 7283) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:15:02 UTC (rev 7284) @@ -95,7 +95,8 @@ GraphicServer graphicServer = FOraySpecific.makeGraphicServer(logger); FOTreeFactory foTreeServer = FOraySpecific.makeFOTreeFactory(logger, sessionConfig, graphicServer, textServer); - AreaTreeFactory areaTreeFactory = null; + AreaTreeFactory areaTreeFactory = FOraySpecific.makeAreaTreeFactory( + logger, textServer); LayoutFactory layoutFactory = null; FOraySession session = new FOraySession(logger, sessionConfig, fontServer, textServer, graphicServer, foTreeServer, Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:10:46 UTC (rev 7283) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:15:02 UTC (rev 7284) @@ -21,10 +21,9 @@ */ /* $Id$ */ - + package org.foray.app; -import org.foray.area.FOrayAreaTreeFactory; import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; @@ -157,8 +156,13 @@ } this.foTreeFactory = foTreeFactory; + /* Validate AreaTreeFactory. */ + if (areaTreeFactory == null) { + throw new FOrayException("AreaTreeFactory required for " + + "FOraySession."); + } this.areaTreeFactory = areaTreeFactory; - setupAreaTreeFactory(); + this.layoutFactory = layoutFactory; setupLayoutFactory(); } @@ -212,17 +216,6 @@ } /** - * Sets up an AreaTreeFactory if there is not one already. - */ - private void setupAreaTreeFactory() { - if (this.areaTreeFactory != null) { - return; - } - this.areaTreeFactory = new FOrayAreaTreeFactory(this.getLogger(), - this.getTextServer()); - } - - /** * Sets up a LayoutFactory if there is not one already. */ private void setupLayoutFactory() { Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:10:46 UTC (rev 7283) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:15:02 UTC (rev 7284) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.area.FOrayAreaTreeFactory; import org.foray.common.Logging; import org.foray.common.XMLParser; import org.foray.core.FOrayException; @@ -120,9 +121,9 @@ return urls; } - public static AreaTreeFactory makeAreaTreeFactory() - throws FOrayException { - return null; + public static AreaTreeFactory makeAreaTreeFactory(Log logger, + TextServer textServer) throws FOrayException { + return new FOrayAreaTreeFactory(logger, textServer); } public static LayoutFactory makeLayoutFactory() throws FOrayException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:10:54
|
Revision: 7283 Author: victormote Date: 2006-05-26 15:10:46 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7283&view=rev Log Message: ----------- Move some of the FOray-specific bootstrapping logic out of FOraySession and into FOraySpecific. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:01:44 UTC (rev 7282) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:10:46 UTC (rev 7283) @@ -93,7 +93,8 @@ TextServer textServer = FOraySpecific.makeTextServer(logger, sessionConfig); GraphicServer graphicServer = FOraySpecific.makeGraphicServer(logger); - FOTreeFactory foTreeServer = null; + FOTreeFactory foTreeServer = FOraySpecific.makeFOTreeFactory(logger, + sessionConfig, graphicServer, textServer); AreaTreeFactory areaTreeFactory = null; LayoutFactory layoutFactory = null; FOraySession session = new FOraySession(logger, sessionConfig, Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:01:44 UTC (rev 7282) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:10:46 UTC (rev 7283) @@ -28,7 +28,6 @@ import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; -import org.foray.fotree.FOrayFOTreeServer; import org.foray.pioneer.PioneerFactory; import org.axsl.areaW.AreaTreeFactory; @@ -42,8 +41,6 @@ import org.xml.sax.EntityResolver; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; import java.util.Iterator; @@ -83,7 +80,7 @@ private GraphicServer graphicServer; /** */ - private FOTreeFactory foTreeServer; + private FOTreeFactory foTreeFactory; private AreaTreeFactory areaTreeFactory; @@ -117,7 +114,7 @@ */ public FOraySession(Log logger, SessionConfig configuration, FontServer fontServer, TextServer textServer, - GraphicServer graphicServer, FOTreeFactory foTreeServer, + GraphicServer graphicServer, FOTreeFactory foTreeFactory, AreaTreeFactory areaTreeFactory, LayoutFactory layoutFactory) throws FOrayException { /* Validate Logger. */ @@ -146,15 +143,20 @@ } this.textServer = textServer; - /* Validate TextServer. */ + /* Validate GraphicServer. */ if (graphicServer == null) { throw new FOrayException("GraphicServer required for " + "FOraySession."); } this.graphicServer = graphicServer; - this.foTreeServer = foTreeServer; - setupFOTreeServer(); + /* Validate FOTreeFactory. */ + if (foTreeFactory == null) { + throw new FOrayException("FOTreeFactory required for " + + "FOraySession."); + } + this.foTreeFactory = foTreeFactory; + this.areaTreeFactory = areaTreeFactory; setupAreaTreeFactory(); this.layoutFactory = layoutFactory; @@ -210,19 +212,6 @@ } /** - * Sets up a FOTreeServer if there is not one already. - */ - private void setupFOTreeServer() { - if (this.foTreeServer != null) { - return; - } - this.foTreeServer = new FOrayFOTreeServer(this.getLogger(), - this.getGraphicServer(), this.getTextServer(), - this.buildGraphicSearchPath(), - getConfiguration().optionCacheGraphics()); - } - - /** * Sets up an AreaTreeFactory if there is not one already. */ private void setupAreaTreeFactory() { @@ -243,21 +232,6 @@ this.layoutFactory = new PioneerFactory(this.getLogger()); } - /** - * - */ - private URL[] buildGraphicSearchPath() { - URL[] urls = new URL[3]; - urls[0] = getConfiguration().getBaseDocument(); - urls[1] = getConfiguration().optionBaseDirectory(); - try { - urls[2] = new URL(System.getProperty("user.dir")); - } catch (MalformedURLException e) { - // Ignore this -- just leave the null value in the array - } - return urls; - } - public GraphicServer getGraphicServer() { return this.graphicServer; } @@ -279,7 +253,7 @@ } public FOTreeFactory getFOTreeServer() { - return this.foTreeServer; + return this.foTreeFactory; } /** Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:01:44 UTC (rev 7282) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:10:46 UTC (rev 7283) @@ -29,6 +29,7 @@ import org.foray.core.FOrayException; import org.foray.core.SessionConfig; import org.foray.font.FOrayFontServer; +import org.foray.fotree.FOrayFOTreeServer; import org.foray.graphic.FOrayGraphicServer; import org.axsl.areaW.AreaTreeFactory; @@ -44,6 +45,7 @@ import org.xml.sax.EntityResolver; +import java.net.MalformedURLException; import java.net.URL; /** @@ -97,16 +99,27 @@ return new FOrayGraphicServer(logger, XMLParser.getParserClassName()); } - public static FOTreeFactory makeFOTreeFactory(GraphicServer graphicServer, - TextServer textServer, URL[] graphicSearchPath) + public static FOTreeFactory makeFOTreeFactory(Log logger, + SessionConfig configuration, GraphicServer graphicServer, + TextServer textServer) throws FOrayException { - return null; -// return new FOrayFOTreeServer(this.getLogger(), -// graphicServer, textServer, graphicSearchPath,Wi -// getConfiguration().optionCacheGraphics()); -// + URL[] graphicSearchPath = buildGraphicSearchPath(configuration); + return new FOrayFOTreeServer(logger, graphicServer, textServer, + graphicSearchPath, configuration.optionCacheGraphics()); } + private static URL[] buildGraphicSearchPath(SessionConfig configuration) { + URL[] urls = new URL[3]; + urls[0] = configuration.getBaseDocument(); + urls[1] = configuration.optionBaseDirectory(); + try { + urls[2] = new URL(System.getProperty("user.dir")); + } catch (MalformedURLException e) { + // Ignore this -- just leave the null value in the array + } + return urls; + } + public static AreaTreeFactory makeAreaTreeFactory() throws FOrayException { return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:01:49
|
Revision: 7282 Author: victormote Date: 2006-05-26 15:01:44 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7282&view=rev Log Message: ----------- Move some of the FOray-specific bootstrapping logic out of FOraySession and into FOraySpecific. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 21:54:55 UTC (rev 7281) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:01:44 UTC (rev 7282) @@ -90,8 +90,9 @@ Log logger = FOraySpecific.makeLogger(sessionConfig); FontServer fontServer = FOraySpecific.makeFontServer(logger, sessionConfig); - TextServer textServer = null; - GraphicServer graphicServer = null; + TextServer textServer = FOraySpecific.makeTextServer(logger, + sessionConfig); + GraphicServer graphicServer = FOraySpecific.makeGraphicServer(logger); FOTreeFactory foTreeServer = null; AreaTreeFactory areaTreeFactory = null; LayoutFactory layoutFactory = null; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 21:54:55 UTC (rev 7281) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:01:44 UTC (rev 7282) @@ -25,17 +25,14 @@ package org.foray.app; import org.foray.area.FOrayAreaTreeFactory; -import org.foray.common.XMLParser; import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; import org.foray.fotree.FOrayFOTreeServer; -import org.foray.graphic.FOrayGraphicServer; import org.foray.pioneer.PioneerFactory; import org.axsl.areaW.AreaTreeFactory; import org.axsl.foR.FOTreeFactory; -import org.axsl.fontR.FontException; import org.axsl.fontR.FontServer; import org.axsl.graphicR.GraphicServer; import org.axsl.layout.LayoutFactory; @@ -123,30 +120,39 @@ GraphicServer graphicServer, FOTreeFactory foTreeServer, AreaTreeFactory areaTreeFactory, LayoutFactory layoutFactory) throws FOrayException { + /* Validate Logger. */ if (logger == null) { throw new FOrayException("Logger required for FOraySession."); } this.log = logger; log.info(Application.getVersion()); + /* Validate Configuration. */ this.configuration = configuration; if (this.configuration == null) { this.configuration = new SessionConfig(logger); } + /* Validate FontServer. */ if (fontServer == null) { throw new FOrayException("FontServer required for FOraySession."); } this.fontServer = fontServer; - try { - setupFontServer(); - } catch (FontException e) { - throw new FOrayException(e); + setupFontServer(); + + /* Validate TextServer. */ + if (textServer == null) { + throw new FOrayException("TextServer required for FOraySession."); } this.textServer = textServer; - setupTextServer(); + + /* Validate TextServer. */ + if (graphicServer == null) { + throw new FOrayException("GraphicServer required for " + + "FOraySession."); + } this.graphicServer = graphicServer; - setupGraphicServer(); + this.foTreeServer = foTreeServer; setupFOTreeServer(); this.areaTreeFactory = areaTreeFactory; @@ -173,7 +179,7 @@ /** * Sets up a FontServer instance if there is not one already. */ - private void setupFontServer() throws FontException { + private void setupFontServer() { if (log.isDebugEnabled()) { String[] systemFontFamilies = fontServer.getSystemFontFamilyList(); if (systemFontFamilies != null) { @@ -199,35 +205,11 @@ return this.fontServer; } - /** - * Sets up a TextServer if there is not one already. - */ - private void setupTextServer() { - if (this.textServer != null) { - return; - } - URL hyphenationDir = this.configuration - .optionHyphenationBaseDirectory(); - this.textServer = new org.foray.text.TextServer(getLogger(), - hyphenationDir); - } - public TextServer getTextServer() { return this.textServer; } /** - * Sets up a GraphicServer if there is not one already. - */ - private void setupGraphicServer() { - if (this.graphicServer != null) { - return; - } - this.graphicServer = new FOrayGraphicServer(getLogger(), - XMLParser.getParserClassName()); - } - - /** * Sets up a FOTreeServer if there is not one already. */ private void setupFOTreeServer() { Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 21:54:55 UTC (rev 7281) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:01:44 UTC (rev 7282) @@ -90,7 +90,6 @@ SessionConfig configuration) throws FOrayException { URL hyphenationDir = configuration.optionHyphenationBaseDirectory(); return new org.foray.text.TextServer(logger, hyphenationDir); - } public static GraphicServer makeGraphicServer(Log logger) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 21:55:06
|
Revision: 7281 Author: victormote Date: 2006-05-26 14:54:55 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7281&view=rev Log Message: ----------- Move some of the FOray-specific bootstrapping logic out of FOraySession and into FOraySpecific. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 21:27:20 UTC (rev 7280) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 21:54:55 UTC (rev 7281) @@ -86,9 +86,10 @@ */ /* Set Logger to null so that new one will be created at the right * verbosity level. */ - Log logger = null; SessionConfig sessionConfig = this.options.getSessionConfig(); - FontServer fontServer = null; + Log logger = FOraySpecific.makeLogger(sessionConfig); + FontServer fontServer = FOraySpecific.makeFontServer(logger, + sessionConfig); TextServer textServer = null; GraphicServer graphicServer = null; FOTreeFactory foTreeServer = null; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 21:27:20 UTC (rev 7280) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 21:54:55 UTC (rev 7281) @@ -25,12 +25,10 @@ package org.foray.app; import org.foray.area.FOrayAreaTreeFactory; -import org.foray.common.Logging; import org.foray.common.XMLParser; import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; -import org.foray.font.FOrayFontServer; import org.foray.fotree.FOrayFOTreeServer; import org.foray.graphic.FOrayGraphicServer; import org.foray.pioneer.PioneerFactory; @@ -44,7 +42,6 @@ import org.axsl.text.TextServer; import org.apache.commons.logging.Log; -import org.apache.xerces.util.XMLCatalogResolver; import org.xml.sax.EntityResolver; @@ -102,10 +99,6 @@ * etc. */ private EntityResolver entityResolver; - /** Indicates whether an attempt has been made to create a default - * EntityResolver. If so, it should not be attempted again. */ - private boolean entityResolverCreated = false; - /** * Constructor. * @param logger The (optional) logger that should be used for this @@ -130,19 +123,20 @@ GraphicServer graphicServer, FOTreeFactory foTreeServer, AreaTreeFactory areaTreeFactory, LayoutFactory layoutFactory) throws FOrayException { - this.log = logger; - if (this.log == null) { - if (configuration.optionVerbosity().equals("debug")) { - this.log = Logging.makeDebugLogger(); - } else { - this.log = Logging.makeDefaultLogger(); - } + if (logger == null) { + throw new FOrayException("Logger required for FOraySession."); } + this.log = logger; log.info(Application.getVersion()); + this.configuration = configuration; if (this.configuration == null) { this.configuration = new SessionConfig(logger); } + + if (fontServer == null) { + throw new FOrayException("FontServer required for FOraySession."); + } this.fontServer = fontServer; try { setupFontServer(); @@ -180,17 +174,6 @@ * Sets up a FontServer instance if there is not one already. */ private void setupFontServer() throws FontException { - if (this.fontServer != null) { - return; - } - FOrayFontServer forayFontServer = new FOrayFontServer(getLogger()); - forayFontServer.setBaseFontURL( - this.configuration.optionFontBaseDirectory()); - forayFontServer.setBaseURL(this.configuration.optionBaseDirectory()); - forayFontServer.setEntityResolver(this.getEntityResolver()); - forayFontServer.setup(this.configuration.optionFontConfiguration(), - null); - this.fontServer = forayFontServer; if (log.isDebugEnabled()) { String[] systemFontFamilies = fontServer.getSystemFontFamilyList(); if (systemFontFamilies != null) { @@ -329,22 +312,6 @@ * @return The EntityResolver that should be used to resolve XML entities. */ public EntityResolver getEntityResolver() { - if (this.entityResolver != null) { - return this.entityResolver; - } - if (this.entityResolverCreated) { - return null; - } - this.entityResolverCreated = true; - String catalog = this.configuration.optionXMLCatalog(); - if (catalog == null) { - return null; - } - String [] catalogs = {catalog}; - XMLCatalogResolver resolver = new XMLCatalogResolver(); - resolver.setPreferPublic(true); - resolver.setCatalogList(catalogs); - this.entityResolver = resolver; return this.entityResolver; } Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 21:27:20 UTC (rev 7280) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 21:54:55 UTC (rev 7281) @@ -40,6 +40,7 @@ import org.axsl.text.TextServer; import org.apache.commons.logging.Log; +import org.apache.xerces.util.XMLCatalogResolver; import org.xml.sax.EntityResolver; @@ -69,8 +70,8 @@ } public static FontServer makeFontServer(Log logger, - SessionConfig configuration, EntityResolver entityResolver) - throws FOrayException { + SessionConfig configuration) throws FOrayException { + EntityResolver entityResolver = makeEntityResolver(configuration); FOrayFontServer forayFontServer = new FOrayFontServer(logger); forayFontServer.setBaseFontURL( configuration.optionFontBaseDirectory()); @@ -97,7 +98,7 @@ return new FOrayGraphicServer(logger, XMLParser.getParserClassName()); } - public FOTreeFactory makeFOTreeFactory(GraphicServer graphicServer, + public static FOTreeFactory makeFOTreeFactory(GraphicServer graphicServer, TextServer textServer, URL[] graphicSearchPath) throws FOrayException { return null; @@ -107,13 +108,26 @@ // } - public AreaTreeFactory makeAreaTreeFactory() + public static AreaTreeFactory makeAreaTreeFactory() throws FOrayException { return null; } - public LayoutFactory makeLayoutFactory() throws FOrayException { + public static LayoutFactory makeLayoutFactory() throws FOrayException { return null; } + public static EntityResolver makeEntityResolver( + SessionConfig configuration) { + String catalog = configuration.optionXMLCatalog(); + if (catalog == null) { + return null; + } + String [] catalogs = {catalog}; + XMLCatalogResolver resolver = new XMLCatalogResolver(); + resolver.setPreferPublic(true); + resolver.setCatalogList(catalogs); + return resolver; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 21:27:24
|
Revision: 7280 Author: victormote Date: 2006-05-26 14:27:20 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7280&view=rev Log Message: ----------- Remove duplicate set of constants. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 21:19:36 UTC (rev 7279) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 21:27:20 UTC (rev 7280) @@ -44,30 +44,12 @@ */ public class CommandLineOptions { - /* input / output not set */ + /* input not set */ private static final int NOT_SET = 0; /* input: fo file */ private static final int FO_INPUT = 1; /* input: xml+xsl file */ private static final int XSLT_INPUT = 2; - /* output: pdf file */ - private static final int PDF_OUTPUT = 1; - /* output: screen using swing */ - private static final int AWT_OUTPUT = 2; - /* output: mif file */ - private static final int MIF_OUTPUT = 3; - /* output: sent swing rendered file to printer */ - private static final int PRINT_OUTPUT = 4; - /* output: pcl file */ - private static final int PCL_OUTPUT = 5; - /* output: postscript file */ - private static final int PS_OUTPUT = 6; - /* output: text file */ - private static final int TXT_OUTPUT = 7; - /* output: svg file */ - private static final int SVG_OUTPUT = 8; - /* output: XML area tree */ - private static final int AREA_OUTPUT = 9; /* user configuration file */ URL userConfigFile = null; @@ -217,11 +199,11 @@ return true; } if (args[currentArgument].equals("-awt")) { - setOutputMode(AWT_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_AWT); return true; } if (args[currentArgument].equals("-pdf")) { - setOutputMode(PDF_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_PDF); if ((currentArgument + 1 == args.length) || (args[currentArgument + 1].charAt(0) == '-')) { throw new FOrayException("you must specify the pdf output " @@ -232,7 +214,7 @@ return true; } if (args[currentArgument].equals("-mif")) { - setOutputMode(MIF_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_MIF); if ((currentArgument + 1 == args.length) || (args[currentArgument + 1].charAt(0) == '-')) { throw new FOrayException("you must specify the mif output " @@ -243,7 +225,7 @@ return true; } if (args[currentArgument].equals("-print")) { - setOutputMode(PRINT_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_PRINT); // show print help if (currentArgument + 1 < args.length) { if (args[currentArgument + 1].equals("help")) { @@ -254,7 +236,7 @@ return true; } if (args[currentArgument].equals("-pcl")) { - setOutputMode(PCL_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_PCL); if ((currentArgument + 1 == args.length) || (args[currentArgument + 1].charAt(0) == '-')) { throw new FOrayException("you must specify the pdf output " @@ -265,7 +247,7 @@ return true; } if (args[currentArgument].equals("-ps")) { - setOutputMode(PS_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_PS); if ((currentArgument + 1 == args.length) || (args[currentArgument + 1].charAt(0) == '-')) { throw new FOrayException("you must specify the PostScript " @@ -276,7 +258,7 @@ return true; } if (args[currentArgument].equals("-txt")) { - setOutputMode(TXT_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_TXT); if ((currentArgument + 1 == args.length) || (args[currentArgument + 1].charAt(0) == '-')) { throw new FOrayException("you must specify the text output " @@ -287,7 +269,7 @@ return true; } if (args[currentArgument].equals("-svg")) { - setOutputMode(SVG_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_SVG); if ((currentArgument + 1 == args.length) || (args[currentArgument + 1].charAt(0) == '-')) { throw new FOrayException("you must specify the svg output " @@ -302,7 +284,7 @@ inputmode = FO_INPUT; fofile = new File(args[currentArgument]); } else if (outputmode == NOT_SET) { - outputmode = PDF_OUTPUT; + outputmode = OutputTargetFactory.RENDER_PDF; outfile = new File(args[currentArgument]); } else { throw new FOrayException("Don't know what to do with " @@ -311,7 +293,7 @@ return true; } if (args[currentArgument].equals("-at")) { - setOutputMode(AREA_OUTPUT); + setOutputMode(OutputTargetFactory.RENDER_XML); if ((currentArgument + 1 == args.length) || (args[currentArgument + 1].charAt(0) == '-')) { throw new FOrayException("you must specify the area-tree " @@ -427,30 +409,7 @@ * type. */ public int getOutputType() throws FOrayException { - switch (outputmode) { - case NOT_SET: - throw new FOrayException("Renderer has not been set!"); - case PDF_OUTPUT: - return OutputTargetFactory.RENDER_PDF; - case AWT_OUTPUT: - return OutputTargetFactory.RENDER_AWT; - case MIF_OUTPUT: - return OutputTargetFactory.RENDER_MIF; - case PRINT_OUTPUT: - return OutputTargetFactory.RENDER_PRINT; - case PCL_OUTPUT: - return OutputTargetFactory.RENDER_PCL; - case PS_OUTPUT: - return OutputTargetFactory.RENDER_PS; - case TXT_OUTPUT: - return OutputTargetFactory.RENDER_TXT; - case SVG_OUTPUT: - return OutputTargetFactory.RENDER_SVG; - case AREA_OUTPUT: - return OutputTargetFactory.RENDER_XML; - default: - throw new FOrayException("Invalid Renderer setting!"); - } + return outputmode; } /** @@ -478,7 +437,7 @@ public Starter getStarter() throws FOrayException { Starter starter = null; switch (outputmode) { - case AWT_OUTPUT: + case OutputTargetFactory.RENDER_AWT: try { starter = new AWTStarter(log, getSessionConfig(), getRendererOptions(), this); @@ -489,7 +448,7 @@ throw new FOrayException("AWTStarter could not be loaded.", e); } break; - case PRINT_OUTPUT: + case OutputTargetFactory.RENDER_PRINT: try { starter = new PrintStarter(log, getSessionConfig(), getRendererOptions(), this); @@ -647,49 +606,47 @@ } log.debug("Output mode: "); switch (outputmode) { - case NOT_SET: - log.debug("not set"); - break; - case PDF_OUTPUT: + case OutputTargetFactory.RENDER_PDF: log.debug("pdf"); log.debug("output file: " + outfile.toString()); break; - case AWT_OUTPUT: + case OutputTargetFactory.RENDER_AWT: log.debug("awt on screen"); if (outfile != null) { log.error("awt mode, but outfile is set:"); log.debug("out file: " + outfile.toString()); } break; - case MIF_OUTPUT: + case OutputTargetFactory.RENDER_MIF: log.debug("mif"); log.debug("output file: " + outfile.toString()); break; - case PRINT_OUTPUT: + case OutputTargetFactory.RENDER_PRINT: log.debug("print directly"); if (outfile != null) { log.error("print mode, but outfile is set:"); log.error("out file: " + outfile.toString()); } break; - case PCL_OUTPUT: + case OutputTargetFactory.RENDER_PCL: log.debug("pcl"); log.debug("output file: " + outfile.toString()); break; - case PS_OUTPUT: + case OutputTargetFactory.RENDER_PS: log.debug("PostScript"); log.debug("output file: " + outfile.toString()); break; - case TXT_OUTPUT: + case OutputTargetFactory.RENDER_TXT: log.debug("txt"); log.debug("output file: " + outfile.toString()); break; - case SVG_OUTPUT: + case OutputTargetFactory.RENDER_SVG: log.debug("svg"); log.debug("output file: " + outfile.toString()); break; default: - log.debug("unknown input type"); + log.debug("not set"); + break; } log.debug("OPTIONS"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 21:19:54
|
Revision: 7279 Author: victormote Date: 2006-05-26 14:19:36 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7279&view=rev Log Message: ----------- Move more FOray-specific code to OutputTargetFactory. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -431,23 +431,23 @@ case NOT_SET: throw new FOrayException("Renderer has not been set!"); case PDF_OUTPUT: - return FOrayTarget.RENDER_PDF; + return OutputTargetFactory.RENDER_PDF; case AWT_OUTPUT: - return FOrayTarget.RENDER_AWT; + return OutputTargetFactory.RENDER_AWT; case MIF_OUTPUT: - return FOrayTarget.RENDER_MIF; + return OutputTargetFactory.RENDER_MIF; case PRINT_OUTPUT: - return FOrayTarget.RENDER_PRINT; + return OutputTargetFactory.RENDER_PRINT; case PCL_OUTPUT: - return FOrayTarget.RENDER_PCL; + return OutputTargetFactory.RENDER_PCL; case PS_OUTPUT: - return FOrayTarget.RENDER_PS; + return OutputTargetFactory.RENDER_PS; case TXT_OUTPUT: - return FOrayTarget.RENDER_TXT; + return OutputTargetFactory.RENDER_TXT; case SVG_OUTPUT: - return FOrayTarget.RENDER_SVG; + return OutputTargetFactory.RENDER_SVG; case AREA_OUTPUT: - return FOrayTarget.RENDER_XML; + return OutputTargetFactory.RENDER_XML; default: throw new FOrayException("Invalid Renderer setting!"); } Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -68,33 +68,6 @@ public class FOrayTarget implements FOTreeListener, AreaTreeListener { private static final boolean MEM_PROFILE_WITH_GC = false; - /** Render to PDF. OutputStream must be set. */ - public static final int RENDER_PDF = 1; - - /** Render to a GUI window. No OutputStream neccessary. */ - public static final int RENDER_AWT = 2; - - /** Render to MIF. OutputStream must be set. */ - public static final int RENDER_MIF = 3; - - /** Render to XML. OutputStream must be set. */ - public static final int RENDER_XML = 4; - - /** Render to PRINT. No OutputStream neccessary. */ - public static final int RENDER_PRINT = 5; - - /** Render to PCL. OutputStream must be set. */ - public static final int RENDER_PCL = 6; - - /** Render to Postscript. OutputStream must be set. */ - public static final int RENDER_PS = 7; - - /** Render to Text. OutputStream must be set. */ - public static final int RENDER_TXT = 8; - - /** Render to SVG. OutputStream must be set. */ - public static final int RENDER_SVG = 9; - /** The "parent" FOrayDocument instance. */ private FOrayDocument document; @@ -478,70 +451,6 @@ return this.document; } - /** - * Converts a String description of the desired Renderer to a valid - * renderer code. - * @param format The String description of the desired Renderer, either - * a mime type or a standard description. - * @return One of {@link #RENDER_PDF}, {@link #RENDER_AWT}, - * {@link #RENDER_MIF}, {@link #RENDER_XML}, {@link #RENDER_PRINT}, - * {@link #RENDER_PCL}, {@link #RENDER_PS}, {@link #RENDER_TXT}, - * {@link #RENDER_SVG}, or -1 if the input is not valid. - */ - public static int getRendererType(String format) { - if ((format == null) - || format.equalsIgnoreCase("application/pdf") - || format.equalsIgnoreCase("pdf")) { - return RENDER_PDF; - } - if (format.equalsIgnoreCase("application/postscript") - || format.equalsIgnoreCase("ps")) { - return RENDER_PS; - } - if (format.equalsIgnoreCase("application/vnd.mif") - || format.equalsIgnoreCase("mif")) { - return RENDER_MIF; - } - if (format.equalsIgnoreCase("application/vnd.gp-PCL") - || format.equalsIgnoreCase("pcl")) { - return RENDER_PCL; - } - if (format.equalsIgnoreCase("text/plain") - || format.equalsIgnoreCase("txt")) { - return RENDER_TXT; - } - if (format.equalsIgnoreCase("text/xml") - || format.equalsIgnoreCase("at") - || format.equalsIgnoreCase("xml")) { - return RENDER_XML; - } - return -1; - } - - public static String getMimeExtension(int rendererType) { - switch (rendererType) { - case RENDER_PDF: { - return ".pdf"; - } - case RENDER_PS: { - return ".ps"; - } - case RENDER_MIF: { - return ".mif"; - } - case RENDER_PCL: { - return ".pcl"; - } - case RENDER_TXT: { - return ".txt"; - } - case RENDER_XML: { - return ".xml"; - } - } - return null; - } - public AreaTreeFactory getAreaTreeFactory() { return this.document.getAreaTreeFactory(); } Modified: trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -46,6 +46,33 @@ */ public class OutputTargetFactory { + /** Render to PDF. OutputStream must be set. */ + public static final int RENDER_PDF = 1; + + /** Render to a GUI window. No OutputStream neccessary. */ + public static final int RENDER_AWT = 2; + + /** Render to MIF. OutputStream must be set. */ + public static final int RENDER_MIF = 3; + + /** Render to XML. OutputStream must be set. */ + public static final int RENDER_XML = 4; + + /** Render to PRINT. No OutputStream neccessary. */ + public static final int RENDER_PRINT = 5; + + /** Render to PCL. OutputStream must be set. */ + public static final int RENDER_PCL = 6; + + /** Render to Postscript. OutputStream must be set. */ + public static final int RENDER_PS = 7; + + /** Render to Text. OutputStream must be set. */ + public static final int RENDER_TXT = 8; + + /** Render to SVG. OutputStream must be set. */ + public static final int RENDER_SVG = 9; + /** * Private constructor (should not be instantiated). */ @@ -74,35 +101,35 @@ OutputConfig outputOptions, Log logger) throws FOrayException { OutputTarget renderer = null; switch (rendererType) { - case FOrayTarget.RENDER_AWT: { + case RENDER_AWT: { renderer = new AWTRenderer(outputOptions); break; } - case FOrayTarget.RENDER_PRINT: { + case RENDER_PRINT: { throw new FOrayException("Print renderer cannot be instantiated " + "from the standard method."); } - case FOrayTarget.RENDER_PCL: { + case RENDER_PCL: { renderer = new PCLRenderer(outputOptions); break; } - case FOrayTarget.RENDER_PS: { + case RENDER_PS: { renderer = new PSRenderer(outputOptions); break; } - case FOrayTarget.RENDER_TXT: { + case RENDER_TXT: { renderer = new TXTRenderer(outputOptions); break; } - case FOrayTarget.RENDER_MIF: { + case RENDER_MIF: { renderer = new MIFConverter(outputOptions); break; } - case FOrayTarget.RENDER_XML: { + case RENDER_XML: { renderer = new XMLRenderer(outputOptions); break; } - case FOrayTarget.RENDER_SVG: { + case RENDER_SVG: { renderer = new SVGRenderer(outputOptions); break; } @@ -118,4 +145,68 @@ return renderer; } + /** + * Converts a String description of the desired Renderer to a valid + * renderer code. + * @param format The String description of the desired Renderer, either + * a mime type or a standard description. + * @return One of {@link #RENDER_PDF}, {@link #RENDER_AWT}, + * {@link #RENDER_MIF}, {@link #RENDER_XML}, {@link #RENDER_PRINT}, + * {@link #RENDER_PCL}, {@link #RENDER_PS}, {@link #RENDER_TXT}, + * {@link #RENDER_SVG}, or -1 if the input is not valid. + */ + public static int getRendererType(String format) { + if ((format == null) + || format.equalsIgnoreCase("application/pdf") + || format.equalsIgnoreCase("pdf")) { + return RENDER_PDF; + } + if (format.equalsIgnoreCase("application/postscript") + || format.equalsIgnoreCase("ps")) { + return RENDER_PS; + } + if (format.equalsIgnoreCase("application/vnd.mif") + || format.equalsIgnoreCase("mif")) { + return RENDER_MIF; + } + if (format.equalsIgnoreCase("application/vnd.gp-PCL") + || format.equalsIgnoreCase("pcl")) { + return RENDER_PCL; + } + if (format.equalsIgnoreCase("text/plain") + || format.equalsIgnoreCase("txt")) { + return RENDER_TXT; + } + if (format.equalsIgnoreCase("text/xml") + || format.equalsIgnoreCase("at") + || format.equalsIgnoreCase("xml")) { + return RENDER_XML; + } + return -1; + } + + public static String getMimeExtension(int rendererType) { + switch (rendererType) { + case RENDER_PDF: { + return ".pdf"; + } + case RENDER_PS: { + return ".ps"; + } + case RENDER_MIF: { + return ".mif"; + } + case RENDER_PCL: { + return ".pcl"; + } + case RENDER_TXT: { + return ".txt"; + } + case RENDER_XML: { + return ".xml"; + } + } + return null; + } + } Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -24,7 +24,7 @@ package org.foray.app.ant; -import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.app.Starter; import org.foray.common.Logging; import org.foray.core.FOrayException; @@ -262,12 +262,12 @@ } protected int getRendererType() { - return FOrayTarget.getRendererType(getFormat()); + return OutputTargetFactory.getRendererType(getFormat()); } protected String getFileExtension() { int rendererType = getRendererType(); - String extension = FOrayTarget.getMimeExtension(rendererType); + String extension = OutputTargetFactory.getMimeExtension(rendererType); return extension; } Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -268,7 +268,7 @@ FOrayDocument document = new FOrayDocument(session, inputHandler.getInputSource(), parser); - if (this.task.getRendererType() == FOrayTarget.RENDER_XML) { + if (this.task.getRendererType() == OutputTargetFactory.RENDER_XML) { this.outputConfig.parseOption("fineDetail", "true", SessionConfig.PRECEDENCE_DEFAULT); } Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -287,9 +287,9 @@ outname + (outputPDF ? ".pdf" : ".at.xml")))); int rendererType = -1; if (outputPDF) { - rendererType = FOrayTarget.RENDER_PDF; + rendererType = OutputTargetFactory.RENDER_PDF; } else { - rendererType = FOrayTarget.RENDER_XML; + rendererType = OutputTargetFactory.RENDER_XML; } OutputConfig renderOptions = new OutputConfig(log); Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -61,7 +61,7 @@ //Setup Renderer OutputTarget renderer = OutputTargetFactory.makeOutputTarget( - FOrayTarget.RENDER_PDF, null, session.getLogger()); + OutputTargetFactory.RENDER_PDF, null, session.getLogger()); //Setup FOrayTarget OutputStream out = new FileOutputStream(pdf); Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -76,7 +76,7 @@ //Setup Renderer OutputTarget renderer = OutputTargetFactory.makeOutputTarget( - FOrayTarget.RENDER_PDF, null, session.getLogger()); + OutputTargetFactory.RENDER_PDF, null, session.getLogger()); //Setup FOrayTarget OutputStream out = new FileOutputStream(pdf); Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -75,7 +75,7 @@ //Setup Renderer OutputTarget renderer = OutputTargetFactory.makeOutputTarget( - FOrayTarget.RENDER_PDF, null, session.getLogger()); + OutputTargetFactory.RENDER_PDF, null, session.getLogger()); //Setup FOrayTarget OutputStream out = new FileOutputStream(pdf); Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -169,7 +169,7 @@ // Setup the Renderer OutputTarget renderer = OutputTargetFactory.makeOutputTarget( - FOrayTarget.RENDER_PDF, null, session.getLogger()); + OutputTargetFactory.RENDER_PDF, null, session.getLogger()); // Setup FOrayTarget ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -212,7 +212,7 @@ // Setup the Renderer OutputTarget renderer = OutputTargetFactory.makeOutputTarget( - FOrayTarget.RENDER_PDF, null, session.getLogger()); + OutputTargetFactory.RENDER_PDF, null, session.getLogger()); // Setup FOrayTarget ByteArrayOutputStream output = new ByteArrayOutputStream(); Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -27,11 +27,12 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.core.FOrayException; import org.foray.core.InputHandler; import org.foray.render.awt.AWTPrintRenderer; -import java.awt.print.PrinterJob ; +import java.awt.print.PrinterJob; import java.io.File; import java.io.PrintWriter; @@ -72,7 +73,7 @@ } protected int getRendererType() { - return FOrayTarget.RENDER_PRINT; + return OutputTargetFactory.RENDER_PRINT; } /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 21:13:18 UTC (rev 7278) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 21:19:36 UTC (rev 7279) @@ -73,7 +73,7 @@ } protected int getRendererType() { - return FOrayTarget.RENDER_PDF; + return OutputTargetFactory.RENDER_PDF; } /** @@ -121,7 +121,7 @@ throws FOrayException { // Setup the Renderer OutputTarget renderer = OutputTargetFactory.makeOutputTarget( - FOrayTarget.RENDER_PDF, null, document.getLogger()); + OutputTargetFactory.RENDER_PDF, null, document.getLogger()); // Setup FOrayTarget ByteArrayOutputStream output = new ByteArrayOutputStream(); FOrayTarget target = new FOrayTarget(document, renderer, null, output); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 21:13:34
|
Revision: 7278 Author: victormote Date: 2006-05-26 14:13:18 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7278&view=rev Log Message: ----------- Split the Renderer creation logic into a separate class. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Added Paths: ----------- trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -124,8 +124,8 @@ */ int outputType = commandLineOptions.getOutputType(); OutputConfig outputOptions = this.outputConfig; - OutputTarget outputTarget = document.makeOutputTarget(outputType, - outputOptions); + OutputTarget outputTarget = OutputTargetFactory.makeOutputTarget( + outputType, outputOptions, session.getLogger()); /* * Instantiate and configure the FOrayTarget(s). Multiple targets can Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -29,23 +29,12 @@ import org.foray.core.DocumentReader; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; -import org.foray.output.MIFConverter; -import org.foray.output.OutputConfig; -import org.foray.render.awt.AWTRenderer; -import org.foray.render.pcl.PCLRenderer; -import org.foray.render.pdf.PDFRenderer; -import org.foray.render.ps.PSRenderer; -import org.foray.render.svg.SVGRenderer; -import org.foray.render.txt.TXTRenderer; -import org.foray.render.xml.XMLRenderer; import org.axsl.areaW.AreaTreeFactory; import org.axsl.fontR.FontConsumer; import org.axsl.fontR.FontServer; import org.axsl.graphicR.GraphicServer; import org.axsl.layout.LayoutFactory; -import org.axsl.output.OutputTarget; -import org.axsl.pdfW.PDFDocument; import org.axsl.text.TextServer; import org.apache.commons.logging.Log; @@ -328,73 +317,6 @@ return this.treeBuilder; } - /** - * Factory method that makes a new Renderer instance for the standard - * renderers. - * @param rendererType The integral id for the Renderer that should be - * used. Must be one of: - * <ul> - * <li>RENDER_PDF - * <li>RENDER_AWT - * <li>RENDER_MIF - * <li>RENDER_XML - * <li>RENDER_PCL - * <li>RENDER_PS - * <li>RENDER_TXT - * <li>RENDER_SVG - * </ul> - * @param outputOptions Map containing the options to be used with the - * Renderer. - */ - public OutputTarget makeOutputTarget(int rendererType, - OutputConfig outputOptions) throws FOrayException { - OutputTarget renderer = null; - switch (rendererType) { - case FOrayTarget.RENDER_AWT: { - renderer = new AWTRenderer(outputOptions); - break; - } - case FOrayTarget.RENDER_PRINT: { - throw new FOrayException("Print renderer cannot be instantiated " - + "from the standard method."); - } - case FOrayTarget.RENDER_PCL: { - renderer = new PCLRenderer(outputOptions); - break; - } - case FOrayTarget.RENDER_PS: { - renderer = new PSRenderer(outputOptions); - break; - } - case FOrayTarget.RENDER_TXT: { - renderer = new TXTRenderer(outputOptions); - break; - } - case FOrayTarget.RENDER_MIF: { - renderer = new MIFConverter(outputOptions); - break; - } - case FOrayTarget.RENDER_XML: { - renderer = new XMLRenderer(outputOptions); - break; - } - case FOrayTarget.RENDER_SVG: { - renderer = new SVGRenderer(outputOptions); - break; - } - default: { - PDFDocument document = new org.foray.pdf.object.PDFDocument( - getLogger()); - renderer = new PDFRenderer(outputOptions, document); - break; - } - } - if (renderer == null) { - throw new FOrayException("Unable to create renderer."); - } - return renderer; - } - public AreaTreeFactory getAreaTreeFactory() { return this.session.getAreaTreeFactory(); } Added: trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java (rev 0) +++ trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -0,0 +1,121 @@ +/* + * Copyright 2006 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.app; + +import org.foray.core.FOrayException; +import org.foray.output.MIFConverter; +import org.foray.output.OutputConfig; +import org.foray.render.awt.AWTRenderer; +import org.foray.render.pcl.PCLRenderer; +import org.foray.render.pdf.PDFRenderer; +import org.foray.render.ps.PSRenderer; +import org.foray.render.svg.SVGRenderer; +import org.foray.render.txt.TXTRenderer; +import org.foray.render.xml.XMLRenderer; + +import org.axsl.output.OutputTarget; +import org.axsl.pdfW.PDFDocument; + +import org.apache.commons.logging.Log; + +/** + * This class manages the process of parsing an input FO document and creating + * an FOTree. + */ +public class OutputTargetFactory { + + /** + * Private constructor (should not be instantiated). + */ + private OutputTargetFactory() { + } + + /** + * Factory method that makes a new Renderer instance for the standard + * renderers. + * @param rendererType The integral id for the Renderer that should be + * used. Must be one of: + * <ul> + * <li>RENDER_PDF + * <li>RENDER_AWT + * <li>RENDER_MIF + * <li>RENDER_XML + * <li>RENDER_PCL + * <li>RENDER_PS + * <li>RENDER_TXT + * <li>RENDER_SVG + * </ul> + * @param outputOptions Map containing the options to be used with the + * Renderer. + */ + public static OutputTarget makeOutputTarget(int rendererType, + OutputConfig outputOptions, Log logger) throws FOrayException { + OutputTarget renderer = null; + switch (rendererType) { + case FOrayTarget.RENDER_AWT: { + renderer = new AWTRenderer(outputOptions); + break; + } + case FOrayTarget.RENDER_PRINT: { + throw new FOrayException("Print renderer cannot be instantiated " + + "from the standard method."); + } + case FOrayTarget.RENDER_PCL: { + renderer = new PCLRenderer(outputOptions); + break; + } + case FOrayTarget.RENDER_PS: { + renderer = new PSRenderer(outputOptions); + break; + } + case FOrayTarget.RENDER_TXT: { + renderer = new TXTRenderer(outputOptions); + break; + } + case FOrayTarget.RENDER_MIF: { + renderer = new MIFConverter(outputOptions); + break; + } + case FOrayTarget.RENDER_XML: { + renderer = new XMLRenderer(outputOptions); + break; + } + case FOrayTarget.RENDER_SVG: { + renderer = new SVGRenderer(outputOptions); + break; + } + default: { + PDFDocument document = new org.foray.pdf.object.PDFDocument(logger); + renderer = new PDFRenderer(outputOptions, document); + break; + } + } + if (renderer == null) { + throw new FOrayException("Unable to create renderer."); + } + return renderer; + } + +} Property changes on: trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -28,6 +28,7 @@ import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.Options; +import org.foray.app.OutputTargetFactory; import org.foray.app.Starter; import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; @@ -271,8 +272,9 @@ this.outputConfig.parseOption("fineDetail", "true", SessionConfig.PRECEDENCE_DEFAULT); } - OutputTarget outputTarget = document.makeOutputTarget( - this.task.getRendererType(), this.outputConfig); + OutputTarget outputTarget = OutputTargetFactory.makeOutputTarget( + this.task.getRendererType(), this.outputConfig, + session.getLogger()); new FOrayTarget(document, outputTarget, null, out); session.process(); Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -27,6 +27,7 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; @@ -296,8 +297,8 @@ SessionConfig.PRECEDENCE_DEFAULT); renderOptions.parseOption("consistentOutput", "true", SessionConfig.PRECEDENCE_DEFAULT); - OutputTarget renderer = document.makeOutputTarget(rendererType, - renderOptions); + OutputTarget renderer = OutputTargetFactory.makeOutputTarget( + rendererType, renderOptions, session.getLogger()); new FOrayTarget(document, renderer, null, bos); Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -27,6 +27,7 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; @@ -50,24 +51,24 @@ // Setup FOraySession SessionConfig config = new SessionConfig(getLogger()); - FOraySession driver = new FOraySession(getLogger(), config, null, null, + FOraySession session = new FOraySession(getLogger(), config, null, null, null, null, null, null); // Setup FOrayDocument InputHandler inputHandler = new FOInputHandler(getLogger(), fo); - FOrayDocument document = new FOrayDocument(driver, + FOrayDocument document = new FOrayDocument(session, inputHandler.getInputSource(), inputHandler.getParser()); //Setup Renderer - OutputTarget renderer = document.makeOutputTarget( - FOrayTarget.RENDER_PDF, null); + OutputTarget renderer = OutputTargetFactory.makeOutputTarget( + FOrayTarget.RENDER_PDF, null, session.getLogger()); //Setup FOrayTarget OutputStream out = new FileOutputStream(pdf); new FOrayTarget(document, renderer, null, out); // Start the processing. - driver.process(); + session.process(); } Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -27,6 +27,7 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; @@ -56,7 +57,7 @@ // Setup FOraySession SessionConfig config = new SessionConfig(getLogger()); - FOraySession driver = new FOraySession(getLogger(), config, null, null, + FOraySession session = new FOraySession(getLogger(), config, null, null, null, null, null, null); // Setup FOrayDocument @@ -70,18 +71,19 @@ * Create the FOrayDocument using the JAXP constructor. Resulting SAX * events (the generated FO) will be piped through to FOray. */ - FOrayDocument document = new FOrayDocument(driver, transformer, source); + FOrayDocument document = new FOrayDocument(session, transformer, + source); //Setup Renderer - OutputTarget renderer = document.makeOutputTarget( - FOrayTarget.RENDER_PDF, null); + OutputTarget renderer = OutputTargetFactory.makeOutputTarget( + FOrayTarget.RENDER_PDF, null, session.getLogger()); //Setup FOrayTarget OutputStream out = new FileOutputStream(pdf); new FOrayTarget(document, renderer, null, out); // Start the processing. - driver.process(); + session.process(); } Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -27,6 +27,7 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; @@ -55,7 +56,7 @@ // Setup FOraySession SessionConfig config = new SessionConfig(getLogger()); - FOraySession driver = new FOraySession(getLogger(), config, null, null, + FOraySession session = new FOraySession(getLogger(), config, null, null, null, null, null, null); // Setup FOrayDocument @@ -69,18 +70,19 @@ * Create the FOrayDocument using the JAXP constructor. Resulting SAX * events (the generated FO) will be piped through to FOray. */ - FOrayDocument document = new FOrayDocument(driver, transformer, source); + FOrayDocument document = new FOrayDocument(session, transformer, + source); //Setup Renderer - OutputTarget renderer = document.makeOutputTarget( - FOrayTarget.RENDER_PDF, null); + OutputTarget renderer = OutputTargetFactory.makeOutputTarget( + FOrayTarget.RENDER_PDF, null, session.getLogger()); //Setup FOrayTarget OutputStream out = new FileOutputStream(pdf); new FOrayTarget(document, renderer, null, out); // Start the processing. - driver.process(); + session.process(); } public static void main(String[] args) { Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -27,6 +27,7 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; @@ -167,8 +168,8 @@ FOrayDocument document = setupSAXDocument(session, inputHandler); // Setup the Renderer - OutputTarget renderer = document.makeOutputTarget( - FOrayTarget.RENDER_PDF, null); + OutputTarget renderer = OutputTargetFactory.makeOutputTarget( + FOrayTarget.RENDER_PDF, null, session.getLogger()); // Setup FOrayTarget ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -210,8 +211,8 @@ source); // Setup the Renderer - OutputTarget renderer = document.makeOutputTarget( - FOrayTarget.RENDER_PDF, null); + OutputTarget renderer = OutputTargetFactory.makeOutputTarget( + FOrayTarget.RENDER_PDF, null, session.getLogger()); // Setup FOrayTarget ByteArrayOutputStream output = new ByteArrayOutputStream(); Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 20:55:16 UTC (rev 7277) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 21:13:18 UTC (rev 7278) @@ -27,6 +27,7 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.app.OutputTargetFactory; import org.foray.core.FOrayException; import org.foray.core.InputHandler; @@ -119,8 +120,8 @@ private FOrayTarget setupTarget(FOrayDocument document) throws FOrayException { // Setup the Renderer - OutputTarget renderer = document.makeOutputTarget( - FOrayTarget.RENDER_PDF, null); + OutputTarget renderer = OutputTargetFactory.makeOutputTarget( + FOrayTarget.RENDER_PDF, null, document.getLogger()); // Setup FOrayTarget ByteArrayOutputStream output = new ByteArrayOutputStream(); FOrayTarget target = new FOrayTarget(document, renderer, null, output); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 20:55:30
|
Revision: 7277 Author: victormote Date: 2006-05-26 13:55:16 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7277&view=rev Log Message: ----------- Remove more dependencies on FOray output/render modules. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -28,7 +28,6 @@ import org.foray.core.SessionConfig; import org.foray.layout.LayoutStrategy; import org.foray.output.OutputConfig; -import org.foray.output.OutputTarget; import org.foray.pioneer.PioneerLS; import org.axsl.areaW.AreaTreeFactory; @@ -36,6 +35,7 @@ import org.axsl.fontR.FontServer; import org.axsl.graphicR.GraphicServer; import org.axsl.layout.LayoutFactory; +import org.axsl.output.OutputTarget; import org.axsl.text.TextServer; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -31,7 +31,6 @@ import org.foray.core.SessionConfig; import org.foray.output.MIFConverter; import org.foray.output.OutputConfig; -import org.foray.output.OutputTarget; import org.foray.render.awt.AWTRenderer; import org.foray.render.pcl.PCLRenderer; import org.foray.render.pdf.PDFRenderer; @@ -45,6 +44,7 @@ import org.axsl.fontR.FontServer; import org.axsl.graphicR.GraphicServer; import org.axsl.layout.LayoutFactory; +import org.axsl.output.OutputTarget; import org.axsl.pdfW.PDFDocument; import org.axsl.text.TextServer; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -34,8 +34,9 @@ import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; -import org.foray.output.OutputTarget; +import org.axsl.output.OutputTarget; + import org.apache.commons.logging.Log; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -34,8 +34,9 @@ import org.foray.core.SessionConfig; import org.foray.core.TraxInputHandler; import org.foray.output.OutputConfig; -import org.foray.output.OutputTarget; +import org.axsl.output.OutputTarget; + import org.apache.commons.logging.Log; import org.w3c.dom.Document; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -24,11 +24,6 @@ package org.foray.demo.embed; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; @@ -37,8 +32,14 @@ import org.foray.core.FOrayException; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; -import org.foray.output.OutputTarget; +import org.axsl.output.OutputTarget; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + /** * This class demonstrates the conversion of an FO file to PDF using FOray. */ Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -24,27 +24,27 @@ package org.foray.demo.embed; +import org.foray.app.FOrayDocument; +import org.foray.app.FOraySession; +import org.foray.app.FOrayTarget; +import org.foray.core.Application; +import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; +import org.foray.demo.embed.model.ProjectTeam; + +import org.axsl.output.OutputTarget; + import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.OutputStream; -import java.io.IOException; +import javax.xml.transform.Source; import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerException; -import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; -import org.foray.output.OutputTarget; - -import org.foray.core.Application; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; -import org.foray.demo.embed.model.ProjectTeam; - /** * This class demonstrates the conversion of an arbitrary object file to a * PDF using JAXP (XSLT) and FOray (XSL:FO). Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -24,25 +24,26 @@ package org.foray.demo.embed; +import org.foray.app.FOrayDocument; +import org.foray.app.FOraySession; +import org.foray.app.FOrayTarget; +import org.foray.core.Application; +import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; + +import org.axsl.output.OutputTarget; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import javax.xml.transform.Source; import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerException; -import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; -import org.foray.core.Application; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; -import org.foray.output.OutputTarget; - /** * This class demonstrates the conversion of an XML file to PDF using * JAXP (XSLT) and FOray (XSL:FO). Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -32,8 +32,9 @@ import org.foray.core.FOrayException; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; -import org.foray.output.OutputTarget; +import org.axsl.output.OutputTarget; + import org.apache.commons.logging.Log; import java.io.ByteArrayOutputStream; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 20:48:35 UTC (rev 7276) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 20:55:16 UTC (rev 7277) @@ -29,8 +29,9 @@ import org.foray.app.FOrayTarget; import org.foray.core.FOrayException; import org.foray.core.InputHandler; -import org.foray.output.OutputTarget; +import org.axsl.output.OutputTarget; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 20:48:50
|
Revision: 7276 Author: victormote Date: 2006-05-26 13:48:35 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7276&view=rev Log Message: ----------- Use new axsl methods to reduce dependencies on FOray output and render modules. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java trunk/foray/foray-render/src/java/org/foray/render/Renderer.java Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 20:14:53 UTC (rev 7275) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 20:48:35 UTC (rev 7276) @@ -27,8 +27,8 @@ import org.foray.core.Application; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; -import org.foray.output.OutputTarget; -import org.foray.render.Renderer; +import org.axsl.output.OutputTarget; +import org.axsl.output.Renderer; import org.axsl.areaR.AreaRException; import org.axsl.areaR.PageArea; Modified: trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java =================================================================== --- trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java 2006-05-26 20:14:53 UTC (rev 7275) +++ trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java 2006-05-26 20:48:35 UTC (rev 7276) @@ -28,7 +28,6 @@ import org.apache.commons.logging.Log; -import java.io.IOException; import java.io.OutputStream; /** @@ -66,33 +65,6 @@ return this.fontConsumer; } - /** - * Hook allowing the OutputTarget to initialize itself and prepare to - * render pages. - * @throws IOException For problems writing the output. - */ - public abstract void startOutput() throws IOException; - - /** - * Hook allowing the OutputTarget to clean up. - * @throws IOException For problems writing the output. - */ - public abstract void stopOutput() throws IOException; - - /** - * Indicates which font sources can be used by this OutputTarget. - * @return The array of valid font sources that can be used by this - * OutputTarget. - * Valid array values are {@link FontConsumer#FONT_SOURCE_FREE_STANDING} and - * {@link FontConsumer#FONT_SOURCE_SYSTEM}. - * The order of the array signifies the order of preference for selection - * purposes. - * For example, if both system fonts and free-standing fonts can be used, - * but free-standing fonts are preferred, the array should contain - * { FONT_SOURCE_FREE_STANDING, FONT_SOURCE_SYSTEM }; - */ - public abstract int[] getFontSources() ; - public void setOutputStream(OutputStream stream) { this.outputStream = stream; } @@ -102,7 +74,7 @@ } /** - * @return True iff an OutputStream is required by this target. + * {@inheritDoc} * Subclasses that do not need an OutputStream should override this. */ public boolean outputStreamRequired() { @@ -117,7 +89,7 @@ } /** - * @param applicationName The applicationName to set. + * {@inheritDoc} */ public void setApplicationName(String applicationName) { this.applicationName = applicationName; @@ -134,7 +106,7 @@ } /** - * @param applicationNameShort The applicationNameShort to set. + * {@inheritDoc} */ public void setApplicationNameShort(String applicationNameShort) { this.applicationNameShort = applicationNameShort; @@ -149,7 +121,7 @@ } /** - * @param applicationVersion The applicationVersion to set. + * {@inheritDoc} */ public void setApplicationVersion(String applicationVersion) { this.applicationVersion = applicationVersion; @@ -165,7 +137,7 @@ } /** - * @param developerURLShort The developerURLShort to set. + * {@inheritDoc} */ public void setDeveloperURLShort(String developerURLShort) { this.developerURLShort = developerURLShort; @@ -184,7 +156,7 @@ } /** - * @param logger The logger to set. + * {@inheritDoc} */ public void setLogger(Log logger) { this.logger = logger; Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2006-05-26 20:14:53 UTC (rev 7275) +++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2006-05-26 20:48:35 UTC (rev 7276) @@ -81,7 +81,8 @@ * Subclasses produce output in some format from an AreaTree or AreaTree * fragment. */ -public abstract class Renderer extends OutputTarget { +public abstract class Renderer extends OutputTarget + implements org.axsl.output.Renderer { AreaTree areaTree; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 20:15:11
|
Revision: 7275 Author: victormote Date: 2006-05-26 13:14:53 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7275&view=rev Log Message: ----------- 1. Implement new axsl interface for output. 2. Adjust module dependencies. Modified Paths: -------------- trunk/foray/foray-app/.classpath trunk/foray/foray-output/.classpath trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java trunk/foray/foray-render/.classpath Modified: trunk/foray/foray-app/.classpath =================================================================== --- trunk/foray/foray-app/.classpath 2006-05-26 19:57:41 UTC (rev 7274) +++ trunk/foray/foray-app/.classpath 2006-05-26 20:14:53 UTC (rev 7275) @@ -33,5 +33,6 @@ <classpathentry combineaccessrules="false" kind="src" path="/FOrayLayout"/> <classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayCore"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-output/.classpath =================================================================== --- trunk/foray/foray-output/.classpath 2006-05-26 19:57:41 UTC (rev 7274) +++ trunk/foray/foray-output/.classpath 2006-05-26 20:14:53 UTC (rev 7275) @@ -10,5 +10,6 @@ <classpathentry kind="src" path="/axslCommon"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayMIF"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java =================================================================== --- trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java 2006-05-26 19:57:41 UTC (rev 7274) +++ trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java 2006-05-26 20:14:53 UTC (rev 7275) @@ -34,7 +34,7 @@ /** * Abstract superclass for all Renderers and Converters. */ -public abstract class OutputTarget { +public abstract class OutputTarget implements org.axsl.output.OutputTarget { OutputStream outputStream; public String applicationName; Modified: trunk/foray/foray-render/.classpath =================================================================== --- trunk/foray/foray-render/.classpath 2006-05-26 19:57:41 UTC (rev 7274) +++ trunk/foray/foray-render/.classpath 2006-05-26 20:14:53 UTC (rev 7275) @@ -15,5 +15,6 @@ <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry kind="src" path="/axslPDF-W"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayPS"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 19:57:57
|
Revision: 7274 Author: victormote Date: 2006-05-26 12:57:41 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7274&view=rev Log Message: ----------- Remove dependency of core module on the output module. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/Configuration.java trunk/foray/foray-core/.classpath trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java Modified: trunk/foray/foray-common/src/java/org/foray/common/Configuration.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/Configuration.java 2006-05-26 19:24:09 UTC (rev 7273) +++ trunk/foray/foray-common/src/java/org/foray/common/Configuration.java 2006-05-26 19:57:41 UTC (rev 7274) @@ -190,7 +190,7 @@ * @return True if the option was successfully added, false if it does not * belong in this Configuration implementation. */ - protected abstract boolean parseOption(String key, String value, + public abstract boolean parseOption(String key, String value, int precedenceValue); /** Modified: trunk/foray/foray-core/.classpath =================================================================== --- trunk/foray/foray-core/.classpath 2006-05-26 19:24:09 UTC (rev 7273) +++ trunk/foray/foray-core/.classpath 2006-05-26 19:57:41 UTC (rev 7274) @@ -4,6 +4,5 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/> - <classpathentry combineaccessrules="false" kind="src" path="/FOrayOutput"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java 2006-05-26 19:24:09 UTC (rev 7273) +++ trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java 2006-05-26 19:57:41 UTC (rev 7274) @@ -24,7 +24,7 @@ package org.foray.core; -import org.foray.output.OutputConfig; +import org.foray.common.Configuration; import org.apache.commons.logging.Log; @@ -57,7 +57,7 @@ // store the result configuration private SessionConfig sessionConfig; - private OutputConfig outputConfig; + private Configuration outputConfig; // stores key for new config entry private String key = ""; @@ -88,7 +88,7 @@ * should be sent. */ public ConfigurationParser(SessionConfig sessionConfig, - OutputConfig outputConfig, InputSource source, Log logger) + Configuration outputConfig, InputSource source, Log logger) throws FOrayException { this.sessionConfig = sessionConfig; this.outputConfig = outputConfig; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 19:24:25
|
Revision: 7273 Author: victormote Date: 2006-05-26 12:24:09 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7273&view=rev Log Message: ----------- Move more classes to core package. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/Options.java trunk/foray/foray-core/.classpath Added Paths: ----------- trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java Deleted: trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 19:14:47 UTC (rev 7272) +++ trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 19:24:09 UTC (rev 7273) @@ -1,249 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; -import org.foray.output.OutputConfig; - -import org.apache.commons.logging.Log; - -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; - -import java.io.IOException; - -import javax.xml.parsers.SAXParserFactory; - -/** - * SAX2 Handler which retrieves the configuration information and stores them - * in Configuration. - * Normally this class doesn't need to be accessed directly. - */ -public class ConfigurationParser extends DefaultHandler { - /* - * TODO: These should all be changed to boolean values. - */ - private static final int OUT = 0; - private static final int IN_KEY = 2; - private static final int IN_VALUE = 4; - - // state of parser - private int status = OUT; - - // store the result configuration - private SessionConfig sessionConfig; - private OutputConfig outputConfig; - - // stores key for new config entry - private String key = ""; - - // stores string value - private String value = ""; - - /** - * locator for line number information - */ - private Locator locator; - - /** inputsource for configuration file */ - private InputSource filename; - - /** The logger that should be used by this parser. */ - private Log logger; - - /** - * Constructor. - * @param sessionConfig The SessionConfig instance which should be updated - * with general options found in the configuration file. - * @param outputConfig The RenderConfig instance which should be updated - * with renderer-specific options found in the configuration file. - * @param source the SAX InputSource which encapsulates the configuration - * file XML that should be parsed. - * @param logger The logger to which errors and other messages - * should be sent. - */ - public ConfigurationParser(SessionConfig sessionConfig, - OutputConfig outputConfig, InputSource source, Log logger) - throws FOrayException { - this.sessionConfig = sessionConfig; - this.outputConfig = outputConfig; - this.filename = source; - this.logger = logger; - if (this.sessionConfig == null) { - throw new FOrayException("Session Configuration is null."); - } - if (this.outputConfig == null) { - throw new FOrayException("Output Configuration is null."); - } - } - - /** - * Parses the encapsulated SAX InputSource and updates the encapsulated - * Configuration instances accordingly. - * @throws FOrayException If there are errors parsing the input. - */ - public void parseDocument() throws FOrayException { - XMLReader parser = createParser(); - parser.setContentHandler(this); - try { - parser.parse(filename); - } catch (SAXException e) { - if (e.getException() instanceof FOrayException) { - throw (FOrayException)e.getException(); - } - throw new FOrayException(e); - } catch (IOException e) { - throw new FOrayException(e); - } - } - - /** - * creates a SAX parser - * - * @return the created SAX parser - */ - private XMLReader createParser() throws FOrayException { - try { - SAXParserFactory spf = javax.xml.parsers.SAXParserFactory - .newInstance(); - spf.setNamespaceAware(true); - XMLReader xmlReader = spf.newSAXParser().getXMLReader(); - logger.info("Config: Using " - + xmlReader.getClass().getName() + " as SAX2 Parser."); - return xmlReader; - } catch (javax.xml.parsers.ParserConfigurationException e) { - throw new FOrayException(e); - } catch (SAXException e) { - throw new FOrayException(e); - } - } - - public void startDocument() { - } - - /** - * Set the locator which is used to report the position of the element - * in the source document. - */ - public void setDocumentLocator(Locator locator) { - this.locator = locator; - } - - /** - * extracts the element and attribute name and sets the fitting status and - * datatype values - */ - public void startElement(String uri, String localName, String qName, - Attributes attributes) { - if (localName.equals("key")) { - status += IN_KEY; - return; - } - if (localName.equals("value")) { - status += IN_VALUE; - return; - } - if (localName.equals("entry")) { - return; - } - if (localName.equals("foray-config")) { - return; - } - // to make sure that user knows about false tag - logger.error(getFormattedLocation() + "\nUnknown tag in " - + "configuration file: " + localName); - } // end startElement - - /** - * stores subentries or entries into their hashes (map for subentries, - * configuration for entry) - */ - public void endElement(String uri, String localName, String qName) { - if (localName.equals("entry")) { - this.store(key, value); - status = OUT; - key = ""; - value = ""; - } else if (localName.equals("key")) { - status -= IN_KEY; - } else if (localName.equals("value")) { - status -= IN_VALUE; - } - } - - /** - * extracts characters from text nodes and puts them into their respective - * variables - */ - public void characters(char[] ch, int start, int length) { - char characters[] = new char[length]; - System.arraycopy(ch, start, characters, 0, length); - String text = new String(characters); - switch (status) { - case IN_KEY: - key = text; - break; - case IN_VALUE: - value = text; - break; - } - } // end characters - - /** - * stores configuration entry into configuration Map according to the role - * - * @param key a string containing the key value for the configuration - * @param value a string containing the value for the configuration - */ - private void store(String key, String value) { - // Try the SessionConfig first. - if (this.sessionConfig.parseOption(key, value, - SessionConfig.PRECEDENCE_CONFIG_FILE)) { - return; - } - // Now try the OutputConfig. - this.outputConfig.parseOption(key, value, - SessionConfig.PRECEDENCE_CONFIG_FILE); - } - - /** - * Put the location information in a format suitable for logging and error - * messages. - * @return The location information, formatted. - */ - private String getFormattedLocation() { - if (locator == null) { - return ""; - } - return locator.getSystemId() + ":" + locator.getLineNumber() + ":" - + locator.getColumnNumber(); - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/Options.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 19:14:47 UTC (rev 7272) +++ trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 19:24:09 UTC (rev 7273) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.ConfigurationParser; import org.foray.core.FOrayException; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; Modified: trunk/foray/foray-core/.classpath =================================================================== --- trunk/foray/foray-core/.classpath 2006-05-26 19:14:47 UTC (rev 7272) +++ trunk/foray/foray-core/.classpath 2006-05-26 19:24:09 UTC (rev 7273) @@ -4,5 +4,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayOutput"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Copied: trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java (from rev 7268, trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/ConfigurationParser.java 2006-05-26 19:24:09 UTC (rev 7273) @@ -0,0 +1,247 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.foray.output.OutputConfig; + +import org.apache.commons.logging.Log; + +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; + +import java.io.IOException; + +import javax.xml.parsers.SAXParserFactory; + +/** + * SAX2 Handler which retrieves the configuration information and stores them + * in Configuration. + * Normally this class doesn't need to be accessed directly. + */ +public class ConfigurationParser extends DefaultHandler { + /* + * TODO: These should all be changed to boolean values. + */ + private static final int OUT = 0; + private static final int IN_KEY = 2; + private static final int IN_VALUE = 4; + + // state of parser + private int status = OUT; + + // store the result configuration + private SessionConfig sessionConfig; + private OutputConfig outputConfig; + + // stores key for new config entry + private String key = ""; + + // stores string value + private String value = ""; + + /** + * locator for line number information + */ + private Locator locator; + + /** inputsource for configuration file */ + private InputSource filename; + + /** The logger that should be used by this parser. */ + private Log logger; + + /** + * Constructor. + * @param sessionConfig The SessionConfig instance which should be updated + * with general options found in the configuration file. + * @param outputConfig The RenderConfig instance which should be updated + * with renderer-specific options found in the configuration file. + * @param source the SAX InputSource which encapsulates the configuration + * file XML that should be parsed. + * @param logger The logger to which errors and other messages + * should be sent. + */ + public ConfigurationParser(SessionConfig sessionConfig, + OutputConfig outputConfig, InputSource source, Log logger) + throws FOrayException { + this.sessionConfig = sessionConfig; + this.outputConfig = outputConfig; + this.filename = source; + this.logger = logger; + if (this.sessionConfig == null) { + throw new FOrayException("Session Configuration is null."); + } + if (this.outputConfig == null) { + throw new FOrayException("Output Configuration is null."); + } + } + + /** + * Parses the encapsulated SAX InputSource and updates the encapsulated + * Configuration instances accordingly. + * @throws FOrayException If there are errors parsing the input. + */ + public void parseDocument() throws FOrayException { + XMLReader parser = createParser(); + parser.setContentHandler(this); + try { + parser.parse(filename); + } catch (SAXException e) { + if (e.getException() instanceof FOrayException) { + throw (FOrayException)e.getException(); + } + throw new FOrayException(e); + } catch (IOException e) { + throw new FOrayException(e); + } + } + + /** + * creates a SAX parser + * + * @return the created SAX parser + */ + private XMLReader createParser() throws FOrayException { + try { + SAXParserFactory spf = javax.xml.parsers.SAXParserFactory + .newInstance(); + spf.setNamespaceAware(true); + XMLReader xmlReader = spf.newSAXParser().getXMLReader(); + logger.info("Config: Using " + + xmlReader.getClass().getName() + " as SAX2 Parser."); + return xmlReader; + } catch (javax.xml.parsers.ParserConfigurationException e) { + throw new FOrayException(e); + } catch (SAXException e) { + throw new FOrayException(e); + } + } + + public void startDocument() { + } + + /** + * Set the locator which is used to report the position of the element + * in the source document. + */ + public void setDocumentLocator(Locator locator) { + this.locator = locator; + } + + /** + * extracts the element and attribute name and sets the fitting status and + * datatype values + */ + public void startElement(String uri, String localName, String qName, + Attributes attributes) { + if (localName.equals("key")) { + status += IN_KEY; + return; + } + if (localName.equals("value")) { + status += IN_VALUE; + return; + } + if (localName.equals("entry")) { + return; + } + if (localName.equals("foray-config")) { + return; + } + // to make sure that user knows about false tag + logger.error(getFormattedLocation() + "\nUnknown tag in " + + "configuration file: " + localName); + } // end startElement + + /** + * stores subentries or entries into their hashes (map for subentries, + * configuration for entry) + */ + public void endElement(String uri, String localName, String qName) { + if (localName.equals("entry")) { + this.store(key, value); + status = OUT; + key = ""; + value = ""; + } else if (localName.equals("key")) { + status -= IN_KEY; + } else if (localName.equals("value")) { + status -= IN_VALUE; + } + } + + /** + * extracts characters from text nodes and puts them into their respective + * variables + */ + public void characters(char[] ch, int start, int length) { + char characters[] = new char[length]; + System.arraycopy(ch, start, characters, 0, length); + String text = new String(characters); + switch (status) { + case IN_KEY: + key = text; + break; + case IN_VALUE: + value = text; + break; + } + } // end characters + + /** + * stores configuration entry into configuration Map according to the role + * + * @param key a string containing the key value for the configuration + * @param value a string containing the value for the configuration + */ + private void store(String key, String value) { + // Try the SessionConfig first. + if (this.sessionConfig.parseOption(key, value, + SessionConfig.PRECEDENCE_CONFIG_FILE)) { + return; + } + // Now try the OutputConfig. + this.outputConfig.parseOption(key, value, + SessionConfig.PRECEDENCE_CONFIG_FILE); + } + + /** + * Put the location information in a format suitable for logging and error + * messages. + * @return The location information, formatted. + */ + private String getFormattedLocation() { + if (locator == null) { + return ""; + } + return locator.getSystemId() + ":" + locator.getLineNumber() + ":" + + locator.getColumnNumber(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 19:14:56
|
Revision: 7272 Author: victormote Date: 2006-05-26 12:14:47 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7272&view=rev Log Message: ----------- Add some javadoc. Added Paths: ----------- trunk/foray/foray-core/src/java/org/foray/core/package.html Added: trunk/foray/foray-core/src/java/org/foray/core/package.html =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/package.html (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/package.html 2006-05-26 19:14:47 UTC (rev 7272) @@ -0,0 +1,6 @@ +<html> +<title>org.foray.core Package</title> +<body> +<p>The core processing classes for the application as a whole.</p> +</body> +</html> Property changes on: trunk/foray/foray-core/src/java/org/foray/core/package.html ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 19:01:13
|
Revision: 7271 Author: victormote Date: 2006-05-26 12:00:37 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7271&view=rev Log Message: ----------- Move more classes to core package. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/Options.java trunk/foray/foray-app/src/java/org/foray/app/Starter.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Added Paths: ----------- trunk/foray/foray-core/src/java/org/foray/core/DocumentInputSource.java trunk/foray/foray-core/src/java/org/foray/core/DocumentReader.java trunk/foray/foray-core/src/java/org/foray/core/FOInputHandler.java trunk/foray/foray-core/src/java/org/foray/core/InputHandler.java trunk/foray/foray-core/src/java/org/foray/core/TraxInputHandler.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/DocumentInputSource.java trunk/foray/foray-app/src/java/org/foray/app/DocumentReader.java trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -25,8 +25,11 @@ package org.foray.app; import org.foray.common.Logging; +import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; +import org.foray.core.TraxInputHandler; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Deleted: trunk/foray/foray-app/src/java/org/foray/app/DocumentInputSource.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/DocumentInputSource.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/DocumentInputSource.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -1,59 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.w3c.dom.Document; -import org.xml.sax.InputSource; - -/** - * This is an InputSource to be used with DocumentReader. - * - * @author Kelly A Campbell - * - */ - -public class DocumentInputSource extends InputSource { - private Document _document; - - public DocumentInputSource() { - super(); - } - - public DocumentInputSource(Document document) { - this(); - _document = document; - } - - public Document getDocument() { - return _document; - } - - public void setDocument(Document document) { - _document = document; - } - -} - - Deleted: trunk/foray/foray-app/src/java/org/foray/app/DocumentReader.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/DocumentReader.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/DocumentReader.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -1,515 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - - -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.xml.sax.ContentHandler; -import org.xml.sax.DTDHandler; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.AttributesImpl; - -import java.io.IOException; - -/** - * This presents a DOM as an XMLReader to make it easy to use a Document - * with a SAX-based implementation. - * - * @author Kelly A Campbell - * - */ - -public class DocumentReader implements XMLReader { - - // ////////////////////////////////////////////////////////////////// - // Configuration. - // ////////////////////////////////////////////////////////////////// - private boolean _namespaces = true; - private boolean _namespace_prefixes = true; - - - /** - * Look up the value of a feature. - * - * <p>The feature name is any fully-qualified URI. It is - * possible for an XMLReader 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 - * performing validation or expanding external entities.</p> - * - * <p>All XMLReaders are required to recognize the - * http://xml.org/sax/features/namespaces and the - * http://xml.org/sax/features/namespace-prefixes feature names.</p> - * - * <p>Some feature values may be available only in specific - * contexts, such as before, during, or after a parse.</p> - * - * <p>Typical usage is something like this:</p> - * - * <pre> - * XMLReader r = new MySAXDriver(); - * - * // try to activate validation - * try { - * r.setFeature("http://xml.org/sax/features/validation", true); - * } catch (SAXException e) { - * getLogger().error("Cannot activate validation."); - * } - * - * // register event handlers - * r.setContentHandler(new MyContentHandler()); - * r.setErrorHandler(new MyErrorHandler()); - * - * // parse the first document - * try { - * r.parse("http://www.foo.com/mydoc.xml"); - * } catch (IOException e) { - * getLogger().error("I/O exception reading XML document"); - * } catch (SAXException e) { - * getLogger().error("XML exception reading document."); - * } - * </pre> - * - * <p>Implementors are free (and encouraged) to invent their own features, - * using names built on their own URIs.</p> - * - * @param name The feature name, which is a fully-qualified URI. - * @return The current state of the feature (true or false). - * @exception SAXNotRecognizedException When the - * XMLReader does not recognize the feature name. - * @exception SAXNotSupportedException When the - * XMLReader recognizes the feature name but - * cannot determine its value at this time. - * @see #setFeature - */ - public boolean getFeature(String name) - throws SAXNotRecognizedException, SAXNotSupportedException { - if ("http://xml.org/sax/features/namespaces".equals(name)) { - return _namespaces; - } else if ( - "http://xml.org/sax/features/namespace-prefixes".equals(name)) { - return _namespace_prefixes; - } else { - throw new SAXNotRecognizedException("Feature '" + name - + "' not recognized or supported by Document2SAXAdapter"); - } - - } - - /** - * Set the state of a feature. - * - * <p>The feature name is any fully-qualified URI. It is - * possible for an XMLReader 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> - * - * <p>All XMLReaders are required to support setting - * http://xml.org/sax/features/namespaces to true and - * http://xml.org/sax/features/namespace-prefixes to false.</p> - * - * <p>Some feature values may be immutable or mutable only - * in specific contexts, such as before, during, or after - * a parse.</p> - * - * @param name The feature name, which is a fully-qualified URI. - * @param value The requested state of the feature (true or false). - * @exception SAXNotRecognizedException When the - * XMLReader does not recognize the feature name. - * @exception SAXNotSupportedException When the - * XMLReader recognizes the feature name but - * cannot set the requested value. - * @see #getFeature - */ - public void setFeature(String name, boolean value) - throws SAXNotRecognizedException, SAXNotSupportedException { - if ("http://xml.org/sax/features/namespaces".equals(name)) { - _namespaces = value; - } else if ( - "http://xml.org/sax/features/namespace-prefixes".equals(name)) { - _namespace_prefixes = value; - } else { - throw new SAXNotRecognizedException("Feature '" + name - + "' not recognized or supported by Document2SAXAdapter"); - } - - } - - - - /** - * Look up the value of a property. - * - * <p>The property name is any fully-qualified URI. It is - * possible for an XMLReader to recognize a property name but - * to be unable to return its state; this is especially true - * in the case of an adapter for a SAX1 Parser.</p> - * - * <p>XMLReaders are not required to recognize any specific - * property names, though an initial core set is documented for - * SAX2.</p> - * - * <p>Some property values may be available only in specific - * contexts, such as before, during, or after a parse.</p> - * - * <p>Implementors are free (and encouraged) to invent their own properties, - * using names built on their own URIs.</p> - * - * @param name The property name, which is a fully-qualified URI. - * @return The current value of the property. - * @exception SAXNotRecognizedException When the - * XMLReader does not recognize the property name. - * @exception SAXNotSupportedException When the - * XMLReader recognizes the property name but - * cannot determine its value at this time. - * @see #setProperty - */ - public Object getProperty(String name) - throws SAXNotRecognizedException, SAXNotSupportedException { - throw new SAXNotRecognizedException("Property '" + name - + "' not recognized or supported by Document2SAXAdapter"); - } - - /** - * Set the value of a property. - * - * <p>The property name is any fully-qualified URI. It is - * possible for an XMLReader to recognize a property name but - * to be unable to set its value; this is especially true - * in the case of an adapter for a SAX1 Parser.</p> - * - * <p>XMLReaders are not required to recognize setting - * any specific property names, though a core set is provided with - * SAX2.</p> - * - * <p>Some property values may be immutable or mutable only - * in specific contexts, such as before, during, or after - * a parse.</p> - * - * <p>This method is also the standard mechanism for setting - * extended handlers.</p> - * - * @param name The property name, which is a fully-qualified URI. - * @param value The requested value for the property. - * @exception SAXNotRecognizedException When the - * XMLReader does not recognize the property name. - * @exception SAXNotSupportedException When the - * XMLReader recognizes the property name but - * cannot set the requested value. - */ - public void setProperty(String name, Object value) - throws SAXNotRecognizedException, SAXNotSupportedException { - throw new SAXNotRecognizedException("Property '" + name - + "' not recognized or supported by Document2SAXAdapter"); - } - - - - // ////////////////////////////////////////////////////////////////// - // Event handlers. - // ////////////////////////////////////////////////////////////////// - private EntityResolver _entityResolver = null; - private DTDHandler _dtdHandler = null; - private ContentHandler _contentHandler = null; - private ErrorHandler _errorHandler = null; - - - /** - * 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. - * @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; - } - - - - /** - * Allow an application to register a DTD event handler. - * - * <p>If the application does not register a DTD handler, all DTD - * events reported by the SAX parser will be silently ignored.</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 DTD handler. - * @see #getDTDHandler - */ - public void setDTDHandler(DTDHandler handler) { - _dtdHandler = handler; - } - - - - /** - * Return the current DTD handler. - * - * @return The current DTD handler, or null if none - * has been registered. - * @see #setDTDHandler - */ - public DTDHandler getDTDHandler() { - return _dtdHandler; - } - - - - /** - * Allow an application to register a content event handler. - * - * <p>If the application does not register a content handler, all - * content events reported by the SAX parser will be silently - * ignored.</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 content handler. - * @see #getContentHandler - */ - public void setContentHandler(ContentHandler handler) { - _contentHandler = handler; - } - - /** - * Return the current content handler. - * - * @return The current content handler, or null if none - * has been registered. - * @see #setContentHandler - */ - public ContentHandler getContentHandler() { - return _contentHandler; - } - - - - /** - * 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. - * @see #getErrorHandler - */ - public void setErrorHandler(ErrorHandler 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; - } - - - - // ////////////////////////////////////////////////////////////////// - // Parsing. - // ////////////////////////////////////////////////////////////////// - - /** - * Parse an XML DOM document. - * @param input The input source for the top-level of the XML document. - * @exception SAXException Any SAX exception, possibly - * wrapping another exception. - * @exception IOException An IO exception from the parser, - * possibly from a byte stream or character stream - * supplied by the application. - * @see org.xml.sax.InputSource - * @see #parse(String) - * @see #setEntityResolver - * @see #setDTDHandler - * @see #setContentHandler - * @see #setErrorHandler - */ - public void parse(InputSource input) throws IOException, SAXException { - if (input instanceof DocumentInputSource) { - Document document = ((DocumentInputSource)input).getDocument(); - if (_contentHandler == null) { - throw new SAXException("ContentHandler is null. Please use " - + "setContentHandler()"); - } - - /* most of this code is modified from John Cowan's */ - - Node currentNode; - AttributesImpl currentAtts; - - /* temporary array for making Strings into character arrays */ - char[] array = null; - - currentAtts = new AttributesImpl(); - - /* start at the document element */ - currentNode = document; - while (currentNode != null) { - switch (currentNode.getNodeType()) { - case Node.DOCUMENT_NODE: - _contentHandler.startDocument(); - break; - case Node.CDATA_SECTION_NODE: - case Node.TEXT_NODE: - String data = currentNode.getNodeValue(); - int datalen = data.length(); - if (array == null || array.length < datalen) { - /* - * if the array isn't big enough, make a new - * one - */ - array = new char[datalen]; - } - data.getChars(0, datalen, array, 0); - _contentHandler.characters(array, 0, datalen); - break; - case Node.PROCESSING_INSTRUCTION_NODE: - _contentHandler.processingInstruction( - currentNode.getNodeName(), - currentNode.getNodeValue()); - break; - case Node.ELEMENT_NODE: - NamedNodeMap map = currentNode.getAttributes(); - currentAtts.clear(); - for (int i = map.getLength() - 1; i >= 0; i--) { - Attr att = (Attr)map.item(i); - currentAtts.addAttribute(att.getNamespaceURI(), - att.getLocalName(), - att.getName(), "CDATA", - att.getValue()); - } - _contentHandler.startElement(currentNode.getNamespaceURI(), - currentNode.getLocalName(), - currentNode.getNodeName(), - currentAtts); - break; - } - - Node nextNode = currentNode.getFirstChild(); - if (nextNode != null) { - currentNode = nextNode; - continue; - } - - while (currentNode != null) { - switch (currentNode.getNodeType()) { - case Node.DOCUMENT_NODE: - _contentHandler.endDocument(); - break; - case Node.ELEMENT_NODE: - _contentHandler.endElement( - currentNode.getNamespaceURI(), - currentNode.getLocalName(), - currentNode.getNodeName()); - break; - } - - nextNode = currentNode.getNextSibling(); - if (nextNode != null) { - currentNode = nextNode; - break; - } - - currentNode = currentNode.getParentNode(); - } - } - - } else { - throw new SAXException("DocumentReader only supports parsing of a " - + "DocumentInputSource"); - } - - } - - - - /** - * DocumentReader requires a DocumentInputSource, so this is not implements - * and simply throws a SAXException. - * Use parse(DocumentInputSource) instead - * - * @param systemId The system identifier (URI). - * @exception SAXException Any SAX exception, possibly - * wrapping another exception. - * @exception IOException An IO exception from the parser, - * possibly from a byte stream or character stream - * supplied by the application. - * @see #parse(InputSource) - */ - public void parse(String systemId) throws IOException, SAXException { - throw new SAXException("DocumentReader only supports parsing of a " - + "DocumentInputSource"); - } - -} Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -1,68 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - - -import org.foray.core.FOrayException; - -import org.apache.commons.logging.Log; - -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; - -import java.io.File; -import java.io.IOException; -import java.net.URL; - -/** - * Manages input if it is an xsl:fo file - */ -public class FOInputHandler extends InputHandler { - - File fofile = null; - URL foURL = null; - - public FOInputHandler (Log logger, File fofile) { - super(logger); - this.fofile = fofile; - } - - public FOInputHandler (Log logger, URL url) { - super(logger); - this.foURL = url; - } - - public InputSource getInputSource () throws IOException { - if (fofile != null) { - return super.fileInputSource(fofile); - } - return super.urlInputSource(foURL); - } - - public XMLReader getParser() throws FOrayException { - return super.createParser(); - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -25,6 +25,8 @@ package org.foray.app; import org.foray.common.XMLParser; +import org.foray.core.DocumentInputSource; +import org.foray.core.DocumentReader; import org.foray.core.FOrayException; import org.foray.core.SessionConfig; import org.foray.output.MIFConverter; Deleted: trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -1,103 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - - -import org.foray.core.FOrayException; - -import org.apache.commons.logging.Log; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.xml.parsers.SAXParserFactory; - -public abstract class InputHandler { - - Log logger; - - public abstract InputSource getInputSource() throws IOException ; - public abstract XMLReader getParser() throws FOrayException; - - public InputHandler(Log logger) { - this.logger = logger; - } - - public static InputSource urlInputSource(URL url) throws IOException { - return new InputSource(url.openStream()); - } - - /** - * create an InputSource from a File - * - * @param file the File - * @return the InputSource created - */ - public static InputSource fileInputSource(File file) { - /* this code adapted from James Clark's in XT */ - String path = file.getAbsolutePath(); - String fSep = System.getProperty("file.separator"); - if (fSep != null && fSep.length() == 1) { - path = path.replace(fSep.charAt(0), '/'); - } - if (path.length() > 0 && path.charAt(0) != '/') { - path = '/' + path; - } - try { - return new InputSource(new URL("file", null, path).toString()); - } catch (MalformedURLException e) { - throw new Error("unexpected MalformedURLException"); - } - } - - /** - * creates a SAX parser - * - * @return the created SAX parser - */ - protected XMLReader createParser() throws FOrayException { - try { - SAXParserFactory spf - = javax.xml.parsers.SAXParserFactory.newInstance(); - spf.setNamespaceAware(true); - XMLReader xmlReader = spf.newSAXParser().getXMLReader(); - this.logger.info("FO Parsing: Using " - + xmlReader.getClass().getName() + " as SAX2 Parser."); - return xmlReader; - } catch (javax.xml.parsers.ParserConfigurationException e) { - throw new FOrayException(e); - } catch (SAXException e) { - throw new FOrayException(e); - } - } - -} - Modified: trunk/foray/foray-app/src/java/org/foray/app/Options.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; Modified: trunk/foray/foray-app/src/java/org/foray/app/Starter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; Deleted: trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -1,179 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - - - -import org.foray.core.FOrayException; - -import org.apache.commons.logging.Log; - -import org.xml.sax.InputSource; -import org.xml.sax.XMLFilter; -import org.xml.sax.XMLReader; - -import java.io.File; - -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.stream.StreamSource; - -/** - * XSLTInputHandler basically takes an xml source and transforms it with - * an xslt source and the resulting xsl:fo document is input for FOray. - */ -public class TraxInputHandler extends InputHandler { - private Transformer transformer; - private StreamSource xmlSource; - private Source xsltSource; - - public TraxInputHandler(Log logger, File xmlfile, File xsltfile) - throws FOrayException { - super(logger); - xmlSource = new StreamSource(xmlfile); - xsltSource = new StreamSource(xsltfile); - initTransformer(); - } - - public TraxInputHandler(Log logger, String xmlURL, String xsltURL) - throws FOrayException { - super(logger); - this.xmlSource = new StreamSource(xmlURL); - this.xsltSource = new StreamSource(xsltURL); - initTransformer(); - } - - public TraxInputHandler(Log logger, InputSource xmlSource, - InputSource xsltSource) throws FOrayException { - super(logger); - this.xmlSource = new StreamSource(xmlSource.getByteStream(), - xmlSource.getSystemId()); - this.xsltSource = new StreamSource(xsltSource.getByteStream(), - xsltSource.getSystemId()); - initTransformer(); - } - - private void initTransformer() throws FOrayException { - try { - transformer = TransformerFactory.newInstance().newTransformer( - xsltSource); - } - catch(Exception ex) { - throw new FOrayException(ex); - } - } - - /** - * Overwrites the method of the super class to return the xmlfile. - * Use run(Driver driver) instead. - * @deprecated - */ - public InputSource getInputSource() { - InputSource is = new InputSource(); - is.setByteStream(xmlSource.getInputStream()); - is.setSystemId(xmlSource.getSystemId()); - return is; - } - - /** - * Overwrites this method of the super class and returns an - * XMLFilter instead of a simple XMLReader which allows chaining - * of transformations. - * Use run(Driver driver) instead. - * @deprecated - * - */ - public XMLReader getParser() throws FOrayException { - return getXMLFilter(xsltSource); - } - - /** - * Creates from the transformer an instance of an XMLFilter which - * then can be used in a chain with the XMLReader passed to Driver. This way - * during the conversion of the xml file + xslt stylesheet the resulting - * data is fed into FOary. This should help to avoid memory problems - * @param xsltSource An xslt stylesheet. - * @return An XMLFilter which can be chained together with other XMLReaders - * or XMLFilters. - */ - private XMLFilter getXMLFilter(Source xsltSource) - throws FOrayException { - try { - // Instantiate a TransformerFactory. - TransformerFactory tFactory = TransformerFactory.newInstance(); - // Determine whether the TransformerFactory supports the - // use of SAXSource and SAXResult - if (tFactory.getFeature(SAXSource.FEATURE) - && tFactory.getFeature(SAXResult.FEATURE)) { - // Cast the TransformerFactory to SAXTransformerFactory. - SAXTransformerFactory saxTFactory = - ((SAXTransformerFactory)tFactory); - // Create an XMLFilter for each stylesheet. - XMLFilter xmlfilter = - saxTFactory.newXMLFilter(xsltSource); - - // Create an XMLReader. - XMLReader parser = createParser(); - if (parser == null) { - throw new FOrayException("Unable to create SAX parser"); - } - - // xmlFilter uses the XMLReader as its reader. - xmlfilter.setParent(parser); - return xmlfilter; - } - throw new FOrayException("Your parser doesn't support the " - + "features SAXSource and SAXResult.\n" - + "Use an XSL parser which supports TrAX"); - } catch (Exception ex) { - throw new FOrayException(ex); - } - } - - - /** - * Creates from the transformer an instance of an XMLFilter which - * then can be used in a chain with the XMLReader passed to Driver. This way - * during the conversion of the xml file + xslt stylesheet the resulting - * data is fed into FOray. This should help to avoid memory problems - * @param xmlfile The xmlfile containing the text data - * @param xsltfile An xslt stylesheet - * @return XMLFilter an XMLFilter which can be chained together with other - * XMLReaders or XMLFilters - */ - public XMLFilter getXMLFilter(File xmlfile, File xsltfile) - throws FOrayException { - return getXMLFilter(new StreamSource(xsltfile)); - } - - public void setParameter(String name, Object value) { - transformer.setParameter(name, value); - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -24,14 +24,14 @@ package org.foray.app.ant; -import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; import org.foray.app.Options; import org.foray.app.Starter; +import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -24,15 +24,15 @@ package org.foray.app.test; -import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; -import org.foray.app.TraxInputHandler; import org.foray.common.Logging; +import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; +import org.foray.core.TraxInputHandler; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -34,13 +34,13 @@ import javax.xml.transform.TransformerException; -import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; import org.foray.core.Application; +import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -29,13 +29,13 @@ import java.io.IOException; import java.io.OutputStream; -import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; import org.foray.core.Application; +import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -24,13 +24,13 @@ package org.foray.demo.servlet; -import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; import org.foray.common.Logging; +import org.foray.core.FOInputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -27,8 +27,8 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.render.awt.AWTPrintRenderer; import java.awt.print.PrinterJob ; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 18:34:03 UTC (rev 7270) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -27,8 +27,8 @@ import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; import org.foray.core.FOrayException; +import org.foray.core.InputHandler; import org.foray.output.OutputTarget; import java.io.ByteArrayOutputStream; Copied: trunk/foray/foray-core/src/java/org/foray/core/DocumentInputSource.java (from rev 7265, trunk/foray/foray-app/src/java/org/foray/app/DocumentInputSource.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/DocumentInputSource.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/DocumentInputSource.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -0,0 +1,59 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +/** + * This is an InputSource to be used with DocumentReader. + * + * @author Kelly A Campbell + * + */ + +public class DocumentInputSource extends InputSource { + private Document _document; + + public DocumentInputSource() { + super(); + } + + public DocumentInputSource(Document document) { + this(); + _document = document; + } + + public Document getDocument() { + return _document; + } + + public void setDocument(Document document) { + _document = document; + } + +} + + Copied: trunk/foray/foray-core/src/java/org/foray/core/DocumentReader.java (from rev 7265, trunk/foray/foray-app/src/java/org/foray/app/DocumentReader.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/DocumentReader.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/DocumentReader.java 2006-05-26 19:00:37 UTC (rev 7271) @@ -0,0 +1,515 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + + +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.xml.sax.ContentHandler; +import org.xml.sax.DTDHandler; +import org.xml.sax.EntityResolver; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.AttributesImpl; + +import java.io.IOException; + +/** + * This presents a DOM as an XMLReader to make it easy to use a Document + * with a SAX-based implementation. + * + * @author Kelly A Campbell + * + */ + +public class DocumentReader implements XMLReader { + + // ////////////////////////////////////////////////////////////////// + // Configuration. + // ////////////////////////////////////////////////////////////////// + private boolean _namespaces = true; + private boolean _namespace_prefixes = true; + + + /** + * Look up the value of a feature. + * + * <p>The feature name is any fully-qualified URI. It is + * possible for an XMLReader 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 + * performing validation or expanding external entities.</p> + * + * <p>All XMLReaders are required to recognize the + * http://xml.org/sax/features/namespaces and the + * http://xml.org/sax/features/namespace-prefixes feature names.</p> + * + * <p>Some feature values may be available only in specific + * contexts, such as before, during, or after a parse.</p> + * + * <p>Typical usage is something like this:</p> + * + * <pre> + * XMLReader r = new MySAXDriver(); + * + * // try to activate validation + * try { + * r.setFeature("http://xml.org/sax/features/validation", true); + * } catch (SAXException e) { + * getLogger().error("Cannot activate validation."); + * } + * + * // register event handlers + * r.setContentHandler(new MyContentHandler()); + * r.setErrorHandler(new MyErrorHandler()); + * + * // parse the first document + * try { + * r.parse("http://www.foo.com/mydoc.xml"); + * } catch (IOException e) { + * getLogger().error("I/O exception reading XML document"); + * } catch (SAXException e) { + * getLogger().error("XML exception reading document."); + * } + * </pre> + * + * <p>Implementors are free (and encouraged) to invent their own features, + * using names built on their own URIs.</p> + * + * @param name The feature name, which is a fully-qualified URI. + * @return The current state of the feature (true or false). + * @exception SAXNotRecognizedException When the + * XMLReader does not recognize the feature name. + * @exception SAXNotSupportedException When the + * XMLReader recognizes the feature name but + * cannot determine its value at this time. + * @see #setFeature + */ + public boolean getFeature(String name) + throws SAXNotRecognizedException, SAXNotSupportedException { + if ("http://xml.org/sax/features/namespaces".equals(name)) { + return _namespaces; + } else if ( + "http://xml.org/sax/features/namespace-prefixes".equals(name)) { + return _namespace_prefixes; + } else { + throw new SAXNotRecognizedException("Feature '" + name + + "' not recognized or supported by Document2SAXAdapter"); + } + + } + + /** + * Set the state of a feature. + * + * <p>The feature name is any fully-qualified URI. It is + * possible for an XMLReader 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> + * + * <p>All XMLReaders are required to support setting + * http://xml.org/sax/features/namespaces to true and + * http://xml.org/sax/features/namespace-prefixes to false.</p> + * + * <p>Some feature values may be immutable or mutable only + * in specific contexts, such as before, during, or after + * a parse.</p> + * + * @param name The feature name, which is a fully-qualified URI. + * @param value The requested state of the feature (true or false). + * @exception SAXNotRecognizedException When the + * XMLReader does not recognize the feature name. + * @exception SAXNotSupportedException When the + * XMLReader recognizes the feature name but + * cannot set the requested value. + * @see #getFeature + */ + public void setFeature(String name, boolean value) + throws SAXNotRecognizedException, SAXNotSupportedException { + if ("http://xml.org/sax/features/namespaces".equals(name)) { + _namespaces = value; + } else if ( + "http://xml.org/sax/features/namespace-prefixes".equals(name)) { + _namespace_prefixes = value; + } else { + throw new SAXNotRecognizedException("Feature '" + name + + "' not recognized or supported by Document2SAXAdapter"); + } + + } + + + + /** + * Look up the value of a property. + * + * <p>The property name is any fully-qualified URI. It is + * possible for an XMLReader to recognize a property name but + * to be unable to return its state; this is especially true + * in the case of an adapter for a SAX1 Parser.</p> + * + * <p>XMLReaders are not required to recognize any specific + * property names, though an initial core set is documented for + * SAX2.</p> + * + * <p>Some property values may be available only in specific + * contexts, such as before, during, or after a parse.</p> + * + * <p>Implementors are free (and encouraged) to invent their own properties, + * using names built on their own URIs.</p> + * + * @param name The property name, which is a fully-qualified URI. + * @return The current value of the property. + * @exception SAXNotRecognizedException When the + * XMLReader does not recognize the property name. + * @exception SAXNotSupportedException When the + * XMLReader recognizes the property name but + * cannot determine its value at this time. + * @see #setProperty + */ + public Object getProperty(String name) + throws SAXNotRecognizedException, SAXNotSupportedException { + throw new SAXNotRecognizedException("Property '" + name + + "' not recognized or supported by Document2SAXAdapter"); + } + + /** + * Set the value of a property. + * + * <p>The property name is any fully-qualified URI. It is + * possible for an XMLReader to recognize a property name but + * to be unable to set its value; this is especially true + * in the case of an adapter for a SAX1 Parser.</p> + * + * <p>XMLReaders are not required to recognize setting + * any specific property names, though a core set is provided with + * SAX2.</p> + * + * <p>Some property values may be immutable or mutable only + * in specific contexts, such as before, during, or after + * a parse.</p> + * + * <p>This method is also the standard mechanism for setting + * extended handlers.</p> + * + * @param name The property name, which is a fully-qualified URI. + * @param value The requested value for the property. + * @exception SAXNotRecognizedException When the + * XMLReader does not recognize the property name. + * @exception SAXNotSupportedException When the + * XMLReader recognizes the property name but + * cannot set the requested value. + */ + public void setProperty(String name, Object value) + throws SAXNotRecognizedException, SAXNotSupportedException { + throw new SAXNotRecognizedException("Property '" + name + + "' not recognized or supported by Document2SAXAdapter"); + } + + + + // ////////////////////////////////////////////////////////////////// + // Event handlers. + // ////////////////////////////////////////////////////////////////// + private EntityResolver _entityResolver = null; + private DTDHandler _dtdHandler = null; + private ContentHandler _contentHandler = null; + private ErrorHandler _errorHandler = null; + + + /** + * 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. + * @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; + } + + + + /** + * Allow an application to register a DTD event handler. + * + * <p>If the application does not register a DTD handler, all DTD + * events reported by the SAX parser will be silently ignored.</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 DTD handler. + * @see #getDTDHandler + */ + public void setDTDHandler(DTDHandler handler) { + _dtdHandler = handler; + } + + + + /** + * Return the current DTD handler. + * + * @return The current DTD handler, or null if none + * has been registered. + * @see #setDTDHandler + */ + public DTDHandler getDTDHandler() { + return _dtdHandler; + } + + + + /** + * Allow an application to register a content event handler. + * + * <p>If the application does not register a content handler, all + * content events reported by the SAX parser will be silently + * ignored.</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 content handler. + * @see #getContentHandler + */ + public void setContentHandler(ContentHandler handler) { + _contentHandler = handler; + } + + /** + * Return the current content handler. + * + * @return The current content handler, or null if none + * has been registered. + * @see #setContentHandler + */ + public ContentHandler getContentHandler() { + return _contentHandler; + } + + + + /** + * 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. + * @see #getErrorHandler + */ + public void setErrorHandler(ErrorHandler 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; + } + + + + // ////////////////////////////////////////////////////////////////// + // Parsing. + // ////////////////////////////////////////////////////////////////// + + /** + * Parse an XML DOM document. + * @param input The input source for the top-level of the XML document. + * @exception SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception IOException An IO exception from the parser, + * possibly from a byte stream or character stream + * supplied by the application. + * @see org.xml.sax.InputSource + * @see #parse(String) + * @see #setEntityResolver + * @see #setDTDHandler + * @see #setContentHandler + * @see #setErrorHandler + */ + public void parse(InputSource input) throws IOException, SAXException { + if (input instanceof DocumentInputSource) { + Document document = ((DocumentInputSource)input).getDocument(); + if (_contentHandler == null) { + throw new SAXException("ContentHandler is null. Please use " + + "setContentHa... [truncated message content] |
|
From: <vic...@us...> - 2006-05-26 18:34:29
|
Revision: 7270 Author: victormote Date: 2006-05-26 11:34:03 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7270&view=rev Log Message: ----------- Get build working for new core module. Modified Paths: -------------- trunk/foray/foray-app/scripts/build.xml trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java trunk/foray/scripts/build.xml Added Paths: ----------- trunk/foray/foray-core/.checkstyle trunk/foray/foray-core/.classpath trunk/foray/foray-core/.project trunk/foray/foray-core/scripts/ trunk/foray/foray-core/scripts/build.bat trunk/foray/foray-core/scripts/build.sh trunk/foray/foray-core/scripts/build.xml Modified: trunk/foray/foray-app/scripts/build.xml =================================================================== --- trunk/foray/foray-app/scripts/build.xml 2006-05-26 18:04:11 UTC (rev 7269) +++ trunk/foray/foray-app/scripts/build.xml 2006-05-26 18:34:03 UTC (rev 7270) @@ -43,6 +43,9 @@ <fileset dir="${foray.home}/foray-common/build/ant"> <include name="*.jar"/> </fileset> + <fileset dir="${foray.home}/foray-core/build/ant"> + <include name="*.jar"/> + </fileset> <fileset dir="${foray.home}/foray-font/build/ant"> <include name="*.jar"/> </fileset> Added: trunk/foray/foray-core/.checkstyle =================================================================== --- trunk/foray/foray-core/.checkstyle (rev 0) +++ trunk/foray/foray-core/.checkstyle 2006-05-26 18:34:03 UTC (rev 7270) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <fileset name="all" enabled="true" check-config-name="FOray Checkstyle" local="false"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> +</fileset-config> Added: trunk/foray/foray-core/.classpath =================================================================== --- trunk/foray/foray-core/.classpath (rev 0) +++ trunk/foray/foray-core/.classpath 2006-05-26 18:34:03 UTC (rev 7270) @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src/java"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/> + <classpathentry kind="output" path="build/eclipse"/> +</classpath> Added: trunk/foray/foray-core/.project =================================================================== --- trunk/foray/foray-core/.project (rev 0) +++ trunk/foray/foray-core/.project 2006-05-26 18:34:03 UTC (rev 7270) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>FOrayCore</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> + </natures> +</projectDescription> Added: trunk/foray/foray-core/scripts/build.bat =================================================================== --- trunk/foray/foray-core/scripts/build.bat (rev 0) +++ trunk/foray/foray-core/scripts/build.bat 2006-05-26 18:34:03 UTC (rev 7270) @@ -0,0 +1,27 @@ +@echo off + +echo "FOray Build System" +echo "------------------" + +IF "%JAVA_HOME%" == "" GOTO JAVA_HOME_ERR +IF "%ANT_HOME%" == "" GOTO ANT_HOME_ERR + +call %ANT_HOME%\bin\ant.bat %* + +GOTO END + +:JAVA_HOME_ERR + echo ERROR: JAVA_HOME not found in your environment. + echo + echo Please set the JAVA_HOME variable in your environment to match the + echo location of the Java Virtual Machine you want to use. +GOTO END + +:ANT_HOME_ERR + echo ERROR: ANT_HOME not found in your environment. + echo + echo Please set the ANT_HOME variable in your environment to match the + echo location of the root of your ANT installation. +GOTO END + +:END Added: trunk/foray/foray-core/scripts/build.sh =================================================================== --- trunk/foray/foray-core/scripts/build.sh (rev 0) +++ trunk/foray/foray-core/scripts/build.sh 2006-05-26 18:34:03 UTC (rev 7270) @@ -0,0 +1,29 @@ +#!/bin/sh + +# This file must be executable. + +echo +echo "FOray Build System" +echo "------------------" + +if [ "$JAVA_HOME" = "" ] +then + echo "ERROR: JAVA_HOME not found in your environment." + echo + echo "Please set the JAVA_HOME variable in your environment to match the" + echo "location of the Java Virtual Machine you want to use." + exit 1 +fi + +if [ "$ANT_HOME" = "" ] +then + echo "ERROR: ANT_HOME not found in your environment." + echo + echo "Please set the ANT_HOME variable in your environment to match the" + echo "location of the root of your ANT installation." + exit 1 +fi + +"$ANT_HOME"/bin/ant "$@" + +##### Last Line of $RCSfile$ ##### Property changes on: trunk/foray/foray-core/scripts/build.sh ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native Added: trunk/foray/foray-core/scripts/build.xml =================================================================== --- trunk/foray/foray-core/scripts/build.xml (rev 0) +++ trunk/foray/foray-core/scripts/build.xml 2006-05-26 18:34:03 UTC (rev 7270) @@ -0,0 +1,171 @@ +<?xml version="1.0"?> +<!-- $Id$ --> + +<project default="package" basedir="."> + + <!-- Set up a prefix to designate environment variables. --> + <property environment="env"/> + + <target name="env"> + <!-- If the environment variable FORAY_CONFIG is set, use it. --> + <condition property="foray.config" value="${env.FORAY_CONFIG}"> + <and> + <isset property="env.FORAY_CONFIG"/> + <available file="${env.FORAY_CONFIG}"/> + </and> + </condition> + <!-- Otherwise, set it to the FOray scripts directory. --> + <property name="foray.config" location="../../scripts"/> + <echo>foray.config: ${foray.config}</echo> + + <!-- Retrieve externally-configured properties. --> + <property file="${foray.config}/foray-build.properties"/> + + <!-- Get a default for {foray.home}. --> + <property name="foray.home" location="../.."/> + <echo>foray.home: ${foray.home}</echo> + + <!-- Set up dependent properties. --> + <property name="lib.dir" location="${foray.home}/lib"/> + <property name="axsl.build" location="${lib.dir}"/> + + <path id="libs-build-classpath"> + <fileset dir="${axsl.build}"> + <include name="**/axsl*.jar"/> + </fileset> + <fileset dir="${lib.dir}"> + <include name="axsl*.jar"/> + <include name="commons-logging.jar"/> + </fileset> + <fileset dir="${foray.home}/foray-common/build/ant"> + <include name="*.jar"/> + </fileset> + </path> + </target> + + <!-- =================================================================== --> + <!-- Initialization target --> + <!-- =================================================================== --> + <target name="init" depends="env"> + <tstamp/> + <property name="name" value="foray"/> + <property name="contact.info" + value="The FOray project http://www.foray.org"/> + <property name="module" value="core"/> + <property name="module.dir" value="${foray.home}/foray-${module}"/> + <property name="version" value="0.1"/> + <property name="src.dir" value="${module.dir}/src"/> + <property name="build.dir" value="${module.dir}/build/ant"/> + <property name="classes.dir" value="${build.dir}/classes"/> + <property name="debug" value="on"/> + <property name="optimize" value="off"/> + <property name="deprecation" value="off"/> + <property name="source" value="1.4"/> + </target> + + <!-- =================================================================== --> + <!-- Prepares the build directory --> + <!-- =================================================================== --> + <target name="prepare" depends="init"> + <!-- create directories --> + <echo message="Preparing the build directories"/> + <mkdir dir="${build.dir}"/> + <mkdir dir="${classes.dir}"/> + </target> + + <!-- =================================================================== --> + <!-- Compiles the source directory --> + <!-- =================================================================== --> + <target name="compile" depends="prepare"> + <echo message="Compiling the sources "/> + <!-- create directories --> + <mkdir dir="${build.dir}"/> + <javac srcdir="${src.dir}" + destdir="${classes.dir}" + debug="${debug}" + deprecation="${deprecation}" + optimize="${optimize}" + source="${source}" + > + <classpath refid="libs-build-classpath"/> + </javac> + </target> + + <!-- =================================================================== --> + <!-- Creates the class package --> + <!-- =================================================================== --> + <target name="package" depends="compile, style" + description="Generates the jar files (default target)"> + <echo message="Creating the jar file ${build.dir}/${name}.jar"/> + + <tstamp> + <format property="ts" pattern="yyyyMMdd-HHmmss-z"/> + </tstamp> + <jar jarfile="${build.dir}/${name}-${module}.jar" + basedir="${classes.dir}" + > + <manifest> + <attribute name="Implementation-Title" value="${name}-${module}"/> + <attribute name="Implementation-Version" value="${version}"/> + <attribute name="Implementation-Vendor" + value="${contact.info}"/> + </manifest> + </jar> + + </target> + + <target name="javadoc-api" depends="init" description="Creates API + documentation"> + <echo message="Producing the javadoc files "/> + <mkdir dir="${build.dir}/javadoc-api"/> + <javadoc + packagenames="org.foray.core" + sourcepath="${src.dir}/java" + destdir="${build.dir}/javadoc-api" + classpathref="libs-build-classpath" + author="true" + version="true" + windowtitle="FOray Core API" + doctitle="FOray Font API" + bottom="Copyright © 2006 The FOray Project. All Rights Reserved." + overview="${src.dir}/java/org/foray/core/overview.html" + use="true" + access="public" + failonerror="true"> + <classpath refid="libs-build-classpath"/> + <classpath> + <fileset dir="${lib.dir}"> + <include name="ant*.jar"/> + </fileset> + </classpath> + </javadoc> + </target> + + <!-- =================================================================== --> + <!-- Clean targets --> + <!-- =================================================================== --> + <target name="clean" depends="init" description="Cleans the build directory"> + <delete dir="${build.dir}"/> + </target> + + <!-- =================================================================== --> + <!-- Checkstyle --> + <!-- =================================================================== --> + <target name="style" depends="init" description="Runs checkstyle" + if="checkstyle.home"> + <taskdef name="checkstyle" + classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"> + <classpath> + <fileset dir="${checkstyle.home}"> + <include name="checkstyle-all-*.jar"/> + </fileset> + </classpath> + </taskdef> + <checkstyle config="../../scripts/checkstyle-config.xml"> + <fileset dir="${src.dir}" includes="**/*.java"/> + </checkstyle> + </target> + +</project> + +<!-- Last Line of $RCSfile$ --> Property changes on: trunk/foray/foray-core/scripts/build.xml ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native Modified: trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java 2006-05-26 18:04:11 UTC (rev 7269) +++ trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java 2006-05-26 18:34:03 UTC (rev 7270) @@ -25,7 +25,6 @@ package org.foray.core; import org.foray.common.Configuration; -import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; @@ -33,8 +32,7 @@ /** * Configuration implementation for those configuration items that are - * related to the FOraySession. Renderer-specific options are handled by - * {@link OutputConfig}. + * related to the FOraySession. */ public class SessionConfig extends Configuration { Modified: trunk/foray/scripts/build.xml =================================================================== --- trunk/foray/scripts/build.xml 2006-05-26 18:04:11 UTC (rev 7269) +++ trunk/foray/scripts/build.xml 2006-05-26 18:34:03 UTC (rev 7270) @@ -153,6 +153,12 @@ <property name="foray.config" value="${foray.config}"/> </ant> + <ant antfile="${foray.home}/foray-core/scripts/build.xml" + inheritall="false" + target="package"> + <property name="foray.config" value="${foray.config}"/> + </ant> + <ant antfile="${foray.home}/foray-app/scripts/build.xml" inheritall="false" target="package"> @@ -232,6 +238,10 @@ dir="${foray.home}/foray-render/build/ant/classes"> <include name="**"/> </fileset> + <fileset id="foray-core-classes" + dir="${foray.home}/foray-core/build/ant/classes"> + <include name="**"/> + </fileset> <fileset id="foray-app-classes" dir="${foray.home}/foray-app/build/ant/classes"> <include name="**"/> @@ -254,6 +264,7 @@ <fileset refid="foray-pioneer-classes"/> <fileset refid="foray-output-classes"/> <fileset refid="foray-render-classes"/> + <fileset refid="foray-core-classes"/> <fileset refid="foray-app-classes"/> <manifest> <attribute name="Implementation-Title" value="${name}-${module}"/> @@ -372,6 +383,7 @@ private="false"> <sourcepath> <pathelement path="${foray.home}/foray-app/src/java"/> + <pathelement path="${foray.home}/foray-core/src/java"/> <pathelement path="${foray.home}/foray-pretty/src/java"/> <pathelement path="${foray.home}/foray-common/src/java"/> <pathelement path="${foray.home}/foray-ps/src/java"/> @@ -393,6 +405,10 @@ <package name="org.foray.demo"/> <package name="org.foray.demo.*"/> </group> + <group title="The FOray Core Module"> + <package name="org.foray.core"/> + <package name="org.foray.core.*"/> + </group> <group title="The FOray Common Module"> <package name="org.foray.common"/> <package name="org.foray.common.*"/> @@ -530,6 +546,10 @@ inheritall="false" target="clean"/> + <ant antfile="${foray.home}/foray-core/scripts/build.xml" + inheritall="false" + target="clean"/> + <ant antfile="${foray.home}/foray-app/scripts/build.xml" inheritall="false" target="clean"/> @@ -581,6 +601,9 @@ <ant antfile="${foray.home}/foray-render/scripts/build.xml" inheritall="false" target="style"/> + <ant antfile="${foray.home}/foray-core/scripts/build.xml" + inheritall="false" + target="style"/> <ant antfile="${foray.home}/foray-app/scripts/build.xml" inheritall="false" target="style"/> @@ -588,4 +611,4 @@ </project> -<!-- Last Line of $RCSfile$ --> +<!-- Last Line of File --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 18:04:18
|
Revision: 7269 Author: victormote Date: 2006-05-26 11:04:11 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7269&view=rev Log Message: ----------- Remove unused method. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java Modified: trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 17:55:24 UTC (rev 7268) +++ trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 18:04:11 UTC (rev 7269) @@ -65,9 +65,4 @@ return super.createParser(); } - public void run(FOrayDocument driver) throws FOrayException { - throw new FOrayException("not implemented: FOInputHandler.run(Driver)"); - } - } - Modified: trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 17:55:24 UTC (rev 7268) +++ trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 18:04:11 UTC (rev 7269) @@ -47,8 +47,6 @@ public abstract InputSource getInputSource() throws IOException ; public abstract XMLReader getParser() throws FOrayException; - public abstract void run(FOrayDocument driver) throws FOrayException; - public InputHandler(Log logger) { this.logger = logger; } Modified: trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 17:55:24 UTC (rev 7268) +++ trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 18:04:11 UTC (rev 7269) @@ -172,15 +172,6 @@ return getXMLFilter(new StreamSource(xsltfile)); } - public void run(FOrayDocument document) throws FOrayException { - try { - transformer.transform(xmlSource, - new SAXResult(document.getContentHandler())); - } catch (Exception ex) { - throw new FOrayException(ex); - } - } - public void setParameter(String name, Object value) { transformer.setParameter(name, value); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 17:55:56
|
Revision: 7268 Author: victormote Date: 2006-05-26 10:55:24 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7268&view=rev Log Message: ----------- Move more classes to core package. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java trunk/foray/foray-app/src/java/org/foray/app/FOray.java trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java trunk/foray/foray-app/src/java/org/foray/app/Options.java trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java trunk/foray/foray-app/src/java/org/foray/app/Starter.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2XML.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2FO.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java Added Paths: ----------- trunk/foray/foray-core/src/java/org/foray/core/Application.java trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/Application.java trunk/foray/foray-app/src/java/org/foray/app/SessionConfig.java Property Changed: ---------------- trunk/foray/foray-core/ Modified: trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -32,6 +32,7 @@ */ import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; Deleted: trunk/foray/foray-app/src/java/org/foray/app/Application.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Application.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/Application.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -1,59 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -/** - * class representing the FOray Application itself. - */ -public class Application { - - /** Private constructor (should not be instantiated). */ - private Application() { - } - - public static String getApplicationName() { - return "FOray"; - } - - public static String getApplicationNameShort() { - return "FOray"; - } - - /** - * @return The current version of the application. - */ - public static String getVersion() { - return "0.2b1"; - } - - /** - * @return The shortened version of the URL to the home-page of the - * developer. - */ - public static String getDeveloperURLShort() { - return "www.foray.org"; - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -26,6 +26,7 @@ import org.foray.common.Logging; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.layout.LayoutStrategy; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOray.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -26,6 +26,7 @@ import org.foray.common.Logging; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -26,6 +26,7 @@ import org.foray.common.XMLParser; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.MIFConverter; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -27,7 +27,9 @@ import org.foray.area.FOrayAreaTreeFactory; import org.foray.common.Logging; import org.foray.common.XMLParser; +import org.foray.core.Application; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.font.FOrayFontServer; import org.foray.fotree.FOrayFOTreeServer; import org.foray.graphic.FOrayGraphicServer; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -27,6 +27,7 @@ import org.foray.common.Logging; import org.foray.common.XMLParser; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.font.FOrayFontServer; import org.foray.graphic.FOrayGraphicServer; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -24,7 +24,9 @@ package org.foray.app; +import org.foray.core.Application; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputTarget; import org.foray.render.Renderer; Modified: trunk/foray/foray-app/src/java/org/foray/app/Options.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -26,6 +26,7 @@ import org.foray.common.Logging; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Deleted: trunk/foray/foray-app/src/java/org/foray/app/SessionConfig.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/SessionConfig.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/SessionConfig.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -1,217 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.common.Configuration; -import org.foray.output.OutputConfig; - -import org.apache.commons.logging.Log; - -import java.net.URL; - -/** - * Configuration implementation for those configuration items that are - * related to the FOraySession. Renderer-specific options are handled by - * {@link OutputConfig}. - */ -public class SessionConfig extends Configuration { - - /** This is not really a configuration option, but is a permanent record - * of the original fo or xml file that was passed on the command line, - * if any. */ - URL baseDocument = null; - - public SessionConfig(Log logger) { - super(logger); - } - - public String getName() { - return "FOray Session Configuration"; - } - - /** - * Sets the default values that should be used unless overridden later. - */ - protected void setDefaults() { - URL baseDirectory = parseURLDirectory("base-directory", - System.getProperty("user.dir")); - - put("base-directory", baseDirectory, PRECEDENCE_DEFAULT); - put("cache-graphics", Boolean.FALSE, PRECEDENCE_DEFAULT); - put("dump-configuration", Boolean.FALSE, PRECEDENCE_DEFAULT); - put("font-base-directory", null, PRECEDENCE_DEFAULT); - // Skip font-configuration as it can be null. - // Skip hyphenation-base-directory as it is tied to base-directory. - put("language", "en", PRECEDENCE_DEFAULT); - put("stroke-svg-text", Boolean.TRUE, PRECEDENCE_DEFAULT); - put("verbosity", "normal", PRECEDENCE_DEFAULT); - put("xml-catalog", null, PRECEDENCE_DEFAULT); - put("mode", "render", PRECEDENCE_DEFAULT); - } - - public boolean parseOption(String key, String value, int precedenceValue) { - if (key.equals("cache-graphics") - || key.equals("dump-configuration") - || key.equals("stroke-svg-text")) { - // Boolean value. - Boolean booleanValue = this.parseBoolean(key, value); - put(key, booleanValue, precedenceValue); - return true; - } - if (key.equals("base-directory") - || key.equals("font-base-directory") - || key.equals("hyphenation-base-directory")) { - // URL for a directory. - URL baseDir = parseURLDirectory(key, value); - put (key, baseDir, precedenceValue); - return true; - } - if (key.equals("font-configuration")) { - // URL for a file. - URL baseDir = parseURLFile(key, value); - put (key, baseDir, precedenceValue); - return true; - } - if (key.equals("verbosity")) { - // Validated String. - if (value.equals("quiet") - || value.equals("normal") - || value.equals("debug")) { - put (key, value, precedenceValue); - return true; - } - } - if (key.equals("language")) { - // Unvalidated String. - put(key, value, precedenceValue); - return true; - } - if (key.equals("xml-catalog")) { - // Unvalidated String. - put(key, value, precedenceValue); - return true; - } - if (key.equals("mode")) { - // Validated String. - if (value.equals("render") - || value.equals("validate")) { - put (key, value, precedenceValue); - return true; - } - } - return false; - } - - public URL optionBaseDirectory() { - // Never null. - return (URL) getValue("base-directory"); - } - - public void setBaseDirectory(URL newBaseDir, int precedence) { - put ("base-directory", newBaseDir, precedence); - } - - public boolean optionCacheGraphics() { - // Never null. - return getBooleanValue("cache-graphics").booleanValue(); - } - - public boolean optionDumpConfiguration() { - // Never null. - return getBooleanValue("dump-configuration").booleanValue(); - } - - public URL optionFontBaseDirectory() { - URL value = (URL) getValue("font-base-directory"); - return value; - } - - /** - * @return The URL to the font-configuration file specified, or null if - * none was specified. - */ - public URL optionFontConfiguration() { - return (URL) getValue("font-configuration"); - } - - public URL optionHyphenationBaseDirectory() { - URL value = (URL) getValue("hyphenation-base-directory"); - if (value == null) { - return optionBaseDirectory(); - } - return value; - } - - public String optionLanguage() { - // Never null. - return getStringValue("language"); - } - - public boolean optionStrokeSVGText() { - // Never null. - return getBooleanValue("stroke-svg-text").booleanValue(); - } - - public String optionVerbosity() { - // Never null. - return getStringValue("verbosity"); - } - - public String optionXMLCatalog() { - // Can be null. - return getStringValue("xml-catalog"); - } - - /** - * Sets the path to the base document that should be used for finding - * resources with relative URLs. - * @param baseDocument The path to the base document. - */ - public void setBaseDocument(URL baseDocument) { - this.baseDocument = baseDocument; - } - - /** - * Returns the path to the base document that should be used for finding - * resources with relative URLs. - */ - public URL getBaseDocument() { - return this.baseDocument; - } - - public String getMode() { - // Never null. - return getStringValue("mode"); - } - - public boolean isModeRender() { - return getStringValue("mode").equals("render"); - } - - public boolean isModeValidate() { - return getStringValue("mode").equals("validate"); - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/Starter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -30,9 +30,9 @@ import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; import org.foray.app.Options; -import org.foray.app.SessionConfig; import org.foray.app.Starter; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -29,10 +29,10 @@ import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; -import org.foray.app.SessionConfig; import org.foray.app.TraxInputHandler; import org.foray.common.Logging; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -34,14 +34,14 @@ import javax.xml.transform.TransformerException; -import org.foray.app.Application; -import org.foray.app.SessionConfig; import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.Application; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; import org.foray.render.awt.viewer.SecureResourceBundle; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -29,14 +29,14 @@ import java.io.IOException; import java.io.OutputStream; -import org.foray.app.Application; -import org.foray.app.SessionConfig; import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.Application; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputTarget; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -35,14 +35,14 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.foray.app.Application; -import org.foray.app.SessionConfig; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.output.OutputTarget; +import org.foray.core.Application; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.demo.embed.model.ProjectTeam; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2XML.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2XML.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2XML.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -24,7 +24,7 @@ package org.foray.demo.embed; -import org.foray.app.Application; +import org.foray.core.Application; import org.foray.demo.embed.model.ProjectTeam; import org.foray.demo.embed.model.ProjectMember; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2FO.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2FO.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2FO.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -24,7 +24,7 @@ package org.foray.demo.embed; -import org.foray.app.Application; +import org.foray.core.Application; import java.io.File; import java.io.IOException; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -35,12 +35,12 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.foray.app.Application; -import org.foray.app.SessionConfig; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.core.Application; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputTarget; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 17:48:40 UTC (rev 7267) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -29,9 +29,9 @@ import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; -import org.foray.app.SessionConfig; import org.foray.common.Logging; import org.foray.core.FOrayException; +import org.foray.core.SessionConfig; import org.foray.output.OutputTarget; import org.apache.commons.logging.Log; Property changes on: trunk/foray/foray-core ___________________________________________________________________ Name: svn:ignore + build zzlocal Copied: trunk/foray/foray-core/src/java/org/foray/core/Application.java (from rev 7265, trunk/foray/foray-app/src/java/org/foray/app/Application.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/Application.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/Application.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -0,0 +1,59 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +/** + * class representing the FOray Application itself. + */ +public class Application { + + /** Private constructor (should not be instantiated). */ + private Application() { + } + + public static String getApplicationName() { + return "FOray"; + } + + public static String getApplicationNameShort() { + return "FOray"; + } + + /** + * @return The current version of the application. + */ + public static String getVersion() { + return "0.2b1"; + } + + /** + * @return The shortened version of the URL to the home-page of the + * developer. + */ + public static String getDeveloperURLShort() { + return "www.foray.org"; + } + +} Copied: trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java (from rev 7265, trunk/foray/foray-app/src/java/org/foray/app/SessionConfig.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java 2006-05-26 17:55:24 UTC (rev 7268) @@ -0,0 +1,217 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.foray.common.Configuration; +import org.foray.output.OutputConfig; + +import org.apache.commons.logging.Log; + +import java.net.URL; + +/** + * Configuration implementation for those configuration items that are + * related to the FOraySession. Renderer-specific options are handled by + * {@link OutputConfig}. + */ +public class SessionConfig extends Configuration { + + /** This is not really a configuration option, but is a permanent record + * of the original fo or xml file that was passed on the command line, + * if any. */ + URL baseDocument = null; + + public SessionConfig(Log logger) { + super(logger); + } + + public String getName() { + return "FOray Session Configuration"; + } + + /** + * Sets the default values that should be used unless overridden later. + */ + protected void setDefaults() { + URL baseDirectory = parseURLDirectory("base-directory", + System.getProperty("user.dir")); + + put("base-directory", baseDirectory, PRECEDENCE_DEFAULT); + put("cache-graphics", Boolean.FALSE, PRECEDENCE_DEFAULT); + put("dump-configuration", Boolean.FALSE, PRECEDENCE_DEFAULT); + put("font-base-directory", null, PRECEDENCE_DEFAULT); + // Skip font-configuration as it can be null. + // Skip hyphenation-base-directory as it is tied to base-directory. + put("language", "en", PRECEDENCE_DEFAULT); + put("stroke-svg-text", Boolean.TRUE, PRECEDENCE_DEFAULT); + put("verbosity", "normal", PRECEDENCE_DEFAULT); + put("xml-catalog", null, PRECEDENCE_DEFAULT); + put("mode", "render", PRECEDENCE_DEFAULT); + } + + public boolean parseOption(String key, String value, int precedenceValue) { + if (key.equals("cache-graphics") + || key.equals("dump-configuration") + || key.equals("stroke-svg-text")) { + // Boolean value. + Boolean booleanValue = this.parseBoolean(key, value); + put(key, booleanValue, precedenceValue); + return true; + } + if (key.equals("base-directory") + || key.equals("font-base-directory") + || key.equals("hyphenation-base-directory")) { + // URL for a directory. + URL baseDir = parseURLDirectory(key, value); + put (key, baseDir, precedenceValue); + return true; + } + if (key.equals("font-configuration")) { + // URL for a file. + URL baseDir = parseURLFile(key, value); + put (key, baseDir, precedenceValue); + return true; + } + if (key.equals("verbosity")) { + // Validated String. + if (value.equals("quiet") + || value.equals("normal") + || value.equals("debug")) { + put (key, value, precedenceValue); + return true; + } + } + if (key.equals("language")) { + // Unvalidated String. + put(key, value, precedenceValue); + return true; + } + if (key.equals("xml-catalog")) { + // Unvalidated String. + put(key, value, precedenceValue); + return true; + } + if (key.equals("mode")) { + // Validated String. + if (value.equals("render") + || value.equals("validate")) { + put (key, value, precedenceValue); + return true; + } + } + return false; + } + + public URL optionBaseDirectory() { + // Never null. + return (URL) getValue("base-directory"); + } + + public void setBaseDirectory(URL newBaseDir, int precedence) { + put ("base-directory", newBaseDir, precedence); + } + + public boolean optionCacheGraphics() { + // Never null. + return getBooleanValue("cache-graphics").booleanValue(); + } + + public boolean optionDumpConfiguration() { + // Never null. + return getBooleanValue("dump-configuration").booleanValue(); + } + + public URL optionFontBaseDirectory() { + URL value = (URL) getValue("font-base-directory"); + return value; + } + + /** + * @return The URL to the font-configuration file specified, or null if + * none was specified. + */ + public URL optionFontConfiguration() { + return (URL) getValue("font-configuration"); + } + + public URL optionHyphenationBaseDirectory() { + URL value = (URL) getValue("hyphenation-base-directory"); + if (value == null) { + return optionBaseDirectory(); + } + return value; + } + + public String optionLanguage() { + // Never null. + return getStringValue("language"); + } + + public boolean optionStrokeSVGText() { + // Never null. + return getBooleanValue("stroke-svg-text").booleanValue(); + } + + public String optionVerbosity() { + // Never null. + return getStringValue("verbosity"); + } + + public String optionXMLCatalog() { + // Can be null. + return getStringValue("xml-catalog"); + } + + /** + * Sets the path to the base document that should be used for finding + * resources with relative URLs. + * @param baseDocument The path to the base document. + */ + public void setBaseDocument(URL baseDocument) { + this.baseDocument = baseDocument; + } + + /** + * Returns the path to the base document that should be used for finding + * resources with relative URLs. + */ + public URL getBaseDocument() { + return this.baseDocument; + } + + public String getMode() { + // Never null. + return getStringValue("mode"); + } + + public boolean isModeRender() { + return getStringValue("mode").equals("render"); + } + + public boolean isModeValidate() { + return getStringValue("mode").equals("validate"); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 17:49:17
|
Revision: 7267 Author: victormote Date: 2006-05-26 10:48:40 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7267&view=rev Log Message: ----------- Move FOrayException class to new core package. Modified Paths: -------------- trunk/foray/foray-app/.classpath trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java trunk/foray/foray-app/src/java/org/foray/app/FOray.java trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java trunk/foray/foray-app/src/java/org/foray/app/Options.java trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java trunk/foray/foray-app/src/java/org/foray/app/Starter.java trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Added Paths: ----------- trunk/foray/foray-core/ trunk/foray/foray-core/src/ trunk/foray/foray-core/src/java/ trunk/foray/foray-core/src/java/org/ trunk/foray/foray-core/src/java/org/foray/ trunk/foray/foray-core/src/java/org/foray/core/ trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java Modified: trunk/foray/foray-app/.classpath =================================================================== --- trunk/foray/foray-app/.classpath 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/.classpath 2006-05-26 17:48:40 UTC (rev 7267) @@ -32,5 +32,6 @@ <classpathentry combineaccessrules="false" kind="src" path="/axslArea-W"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayLayout"/> <classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayCore"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -31,6 +31,7 @@ * Modified to use streaming API by Mark Lillywhite, mar...@in... */ +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.layout.LayoutStrategy; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,8 @@ package org.foray.app; +import org.foray.core.FOrayException; + import org.apache.commons.logging.Log; import org.xml.sax.InputSource; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOray.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.XMLParser; +import org.foray.core.FOrayException; import org.foray.output.MIFConverter; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -1,166 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.xml.sax.SAXException; - -import java.io.PrintStream; -import java.io.PrintWriter; -import java.lang.reflect.InvocationTargetException; - -/** - * Exception thrown when FOray has a problem. - */ -public class FOrayException extends Exception { - static final long serialVersionUID = 298590433713255908L; - - private static final String EXCEPTION_SEPARATOR = "\n---------\n"; - - private Throwable _exception; - private String contextMessage; - - /** - * Create a new FOray Exception - * - * @param message descriptive message - */ - public FOrayException(String message) { - super(message); - this.contextMessage = null; - } - - public FOrayException(String message, String contextMessage) { - super(message); - this.contextMessage = contextMessage; - } - - public FOrayException(Throwable e) { - super(e.getMessage()); - setException(e); - this.contextMessage = null; - } - - public FOrayException(Throwable e, String contextMessage) { - super(e.getMessage()); - setException(e); - this.contextMessage = contextMessage; - } - - public FOrayException(String message, Throwable e) { - super(message); - setException(e); - this.contextMessage = null; - } - - public FOrayException(String message, Throwable e, String contextMessage) { - super(message); - setException(e); - this.contextMessage = contextMessage; - } - - protected void setException(Throwable t) { - _exception = t; - } - - public Throwable getException() { - return _exception; - } - - public void setContextMessage(String contextMessage) { - this.contextMessage = contextMessage; - } - - public boolean isContextSet() { - return this.contextMessage != null; - } - - protected Throwable getRootException() { - Throwable result = _exception; - - if (result instanceof SAXException) { - result = ((SAXException)result).getException(); - } - if (result instanceof InvocationTargetException) { - result = - ((InvocationTargetException)result) - .getTargetException(); - } - if (result != _exception) { - return result; - } - return null; - } - - public String getMessage() { - if (this.contextMessage != null) { - return super.getMessage() + "\n" - + this.contextMessage; - } - return super.getMessage(); - } - - public void printStackTrace() { - synchronized (System.err) { - super.printStackTrace(); - if (_exception != null) { - System.err.println(EXCEPTION_SEPARATOR); - _exception.printStackTrace(); - } - if (getRootException() != null) { - System.err.println(EXCEPTION_SEPARATOR); - getRootException().printStackTrace(); - } - } - } - - public void printStackTrace(PrintStream stream) { - synchronized (stream) { - super.printStackTrace(stream); - if (_exception != null) { - stream.println(EXCEPTION_SEPARATOR); - _exception.printStackTrace(stream); - } - if (getRootException() != null) { - stream.println(EXCEPTION_SEPARATOR); - getRootException().printStackTrace(stream); - } - } - } - - public void printStackTrace(PrintWriter writer) { - synchronized (writer) { - super.printStackTrace(writer); - if (_exception != null) { - writer.println(EXCEPTION_SEPARATOR); - _exception.printStackTrace(writer); - } - if (getRootException() != null) { - writer.println(EXCEPTION_SEPARATOR); - getRootException().printStackTrace(writer); - } - } - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -27,6 +27,7 @@ import org.foray.area.FOrayAreaTreeFactory; import org.foray.common.Logging; import org.foray.common.XMLParser; +import org.foray.core.FOrayException; import org.foray.font.FOrayFontServer; import org.foray.fotree.FOrayFOTreeServer; import org.foray.graphic.FOrayGraphicServer; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,6 +26,7 @@ import org.foray.common.Logging; import org.foray.common.XMLParser; +import org.foray.core.FOrayException; import org.foray.font.FOrayFontServer; import org.foray.graphic.FOrayGraphicServer; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; import org.foray.render.Renderer; Modified: trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,8 @@ package org.foray.app; +import org.foray.core.FOrayException; + import org.apache.commons.logging.Log; import org.xml.sax.InputSource; Modified: trunk/foray/foray-app/src/java/org/foray/app/Options.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/Starter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,6 +26,8 @@ +import org.foray.core.FOrayException; + import org.apache.commons.logging.Log; import org.xml.sax.InputSource; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,10 +24,10 @@ package org.foray.app.ant; -import org.foray.app.FOrayException; import org.foray.app.FOrayTarget; import org.foray.app.Starter; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.apache.commons.logging.Log; import org.apache.tools.ant.BuildException; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,13 +26,13 @@ import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; import org.foray.app.Options; import org.foray.app.SessionConfig; import org.foray.app.Starter; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,13 +26,13 @@ import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; import org.foray.app.SessionConfig; import org.foray.app.TraxInputHandler; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -35,13 +35,13 @@ import javax.xml.transform.TransformerException; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; import org.foray.render.awt.viewer.SecureResourceBundle; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -30,13 +30,13 @@ import java.io.OutputStream; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -36,13 +36,13 @@ import javax.xml.transform.stream.StreamSource; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.output.OutputTarget; +import org.foray.core.FOrayException; import org.foray.demo.embed.model.ProjectTeam; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -36,11 +36,11 @@ import javax.xml.transform.stream.StreamSource; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,12 +26,12 @@ import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; import org.foray.app.SessionConfig; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,10 +25,10 @@ package org.foray.demo.servlet; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.render.awt.AWTPrintRenderer; import java.awt.print.PrinterJob ; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,10 +25,10 @@ package org.foray.demo.servlet; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; import java.io.ByteArrayOutputStream; Copied: trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java (from rev 7265, trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -0,0 +1,166 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.xml.sax.SAXException; + +import java.io.PrintStream; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; + +/** + * Exception thrown when FOray has a problem. + */ +public class FOrayException extends Exception { + static final long serialVersionUID = 298590433713255908L; + + private static final String EXCEPTION_SEPARATOR = "\n---------\n"; + + private Throwable _exception; + private String contextMessage; + + /** + * Create a new FOray Exception + * + * @param message descriptive message + */ + public FOrayException(String message) { + super(message); + this.contextMessage = null; + } + + public FOrayException(String message, String contextMessage) { + super(message); + this.contextMessage = contextMessage; + } + + public FOrayException(Throwable e) { + super(e.getMessage()); + setException(e); + this.contextMessage = null; + } + + public FOrayException(Throwable e, String contextMessage) { + super(e.getMessage()); + setException(e); + this.contextMessage = contextMessage; + } + + public FOrayException(String message, Throwable e) { + super(message); + setException(e); + this.contextMessage = null; + } + + public FOrayException(String message, Throwable e, String contextMessage) { + super(message); + setException(e); + this.contextMessage = contextMessage; + } + + protected void setException(Throwable t) { + _exception = t; + } + + public Throwable getException() { + return _exception; + } + + public void setContextMessage(String contextMessage) { + this.contextMessage = contextMessage; + } + + public boolean isContextSet() { + return this.contextMessage != null; + } + + protected Throwable getRootException() { + Throwable result = _exception; + + if (result instanceof SAXException) { + result = ((SAXException)result).getException(); + } + if (result instanceof InvocationTargetException) { + result = + ((InvocationTargetException)result) + .getTargetException(); + } + if (result != _exception) { + return result; + } + return null; + } + + public String getMessage() { + if (this.contextMessage != null) { + return super.getMessage() + "\n" + + this.contextMessage; + } + return super.getMessage(); + } + + public void printStackTrace() { + synchronized (System.err) { + super.printStackTrace(); + if (_exception != null) { + System.err.println(EXCEPTION_SEPARATOR); + _exception.printStackTrace(); + } + if (getRootException() != null) { + System.err.println(EXCEPTION_SEPARATOR); + getRootException().printStackTrace(); + } + } + } + + public void printStackTrace(PrintStream stream) { + synchronized (stream) { + super.printStackTrace(stream); + if (_exception != null) { + stream.println(EXCEPTION_SEPARATOR); + _exception.printStackTrace(stream); + } + if (getRootException() != null) { + stream.println(EXCEPTION_SEPARATOR); + getRootException().printStackTrace(stream); + } + } + } + + public void printStackTrace(PrintWriter writer) { + synchronized (writer) { + super.printStackTrace(writer); + if (_exception != null) { + writer.println(EXCEPTION_SEPARATOR); + _exception.printStackTrace(writer); + } + if (getRootException() != null) { + writer.println(EXCEPTION_SEPARATOR); + getRootException().printStackTrace(writer); + } + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 17:23:19
|
Revision: 7266 Author: victormote Date: 2006-05-26 10:23:07 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7266&view=rev Log Message: ----------- Move the FOraySpecific class to the app package and delete the specific package. Added Paths: ----------- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Removed Paths: ------------- trunk/foray/foray-specific/ Copied: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java (from rev 7265, trunk/foray/foray-specific/src/java/org/foray/specific/FOraySpecific.java) =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java (rev 0) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 17:23:07 UTC (rev 7266) @@ -0,0 +1,117 @@ +/* + * Copyright 2006 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.app; + +import org.foray.common.Logging; +import org.foray.common.XMLParser; +import org.foray.font.FOrayFontServer; +import org.foray.graphic.FOrayGraphicServer; + +import org.axsl.areaW.AreaTreeFactory; +import org.axsl.foR.FOTreeFactory; +import org.axsl.fontR.FontException; +import org.axsl.fontR.FontServer; +import org.axsl.graphicR.GraphicServer; +import org.axsl.layout.LayoutFactory; +import org.axsl.text.TextServer; + +import org.apache.commons.logging.Log; + +import org.xml.sax.EntityResolver; + +import java.net.URL; + +/** + * Utility class that creates FOray-specific implementations of the high-level + * objects for each module. + * The purpose of the methods in this class is to simplify the task of getting + * FOray started up in a standard manner without diminishing the flexibility + * of its pluggable nature. + */ +public class FOraySpecific { + + /** + * Private constructor, as this class should never be instantiated. + */ + private FOraySpecific() { + } + + public static Log makeLogger(SessionConfig configuration) { + if (configuration.optionVerbosity().equals("debug")) { + return Logging.makeDebugLogger(); + } else { + return Logging.makeDefaultLogger(); + } + } + + public static FontServer makeFontServer(Log logger, + SessionConfig configuration, EntityResolver entityResolver) + throws FOrayException { + FOrayFontServer forayFontServer = new FOrayFontServer(logger); + forayFontServer.setBaseFontURL( + configuration.optionFontBaseDirectory()); + forayFontServer.setBaseURL(configuration.optionBaseDirectory()); + forayFontServer.setEntityResolver(entityResolver); + try { + forayFontServer.setup(configuration.optionFontConfiguration(), + null); + } catch (FontException e) { + throw new FOrayException(e); + } + return forayFontServer; + } + + public static TextServer makeTextServer(Log logger, + SessionConfig configuration) throws FOrayException { + URL hyphenationDir = configuration.optionHyphenationBaseDirectory(); + return new org.foray.text.TextServer(logger, hyphenationDir); + + } + + public static GraphicServer makeGraphicServer(Log logger) + throws FOrayException { + return new FOrayGraphicServer(logger, XMLParser.getParserClassName()); + } + + public FOTreeFactory makeFOTreeFactory(GraphicServer graphicServer, + TextServer textServer, URL[] graphicSearchPath) + throws FOrayException { + return null; +// return new FOrayFOTreeServer(this.getLogger(), +// graphicServer, textServer, graphicSearchPath,Wi +// getConfiguration().optionCacheGraphics()); +// + } + + public AreaTreeFactory makeAreaTreeFactory() + throws FOrayException { + return null; + } + + public LayoutFactory makeLayoutFactory() throws FOrayException { + return null; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 17:09:28
|
Revision: 7265 Author: victormote Date: 2006-05-26 10:09:20 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7265&view=rev Log Message: ----------- Change to a static approach. Modified Paths: -------------- trunk/foray/foray-specific/src/java/org/foray/specific/FOraySpecific.java Modified: trunk/foray/foray-specific/src/java/org/foray/specific/FOraySpecific.java =================================================================== --- trunk/foray/foray-specific/src/java/org/foray/specific/FOraySpecific.java 2006-05-26 16:12:28 UTC (rev 7264) +++ trunk/foray/foray-specific/src/java/org/foray/specific/FOraySpecific.java 2006-05-26 17:09:20 UTC (rev 7265) @@ -26,6 +26,7 @@ import org.foray.app.FOrayException; import org.foray.app.SessionConfig; +import org.foray.common.Logging; import org.foray.common.XMLParser; import org.foray.font.FOrayFontServer; import org.foray.graphic.FOrayGraphicServer; @@ -44,21 +45,33 @@ import java.net.URL; +/** + * Utility class that creates FOray-specific implementations of the high-level + * objects for each module. + * The purpose of the methods in this class is to simplify the task of getting + * FOray started up in a standard manner without diminishing the flexibility + * of its pluggable nature. + */ public class FOraySpecific { - private Log logger; - - public FOraySpecific(Log logger) throws FOrayException { - this.logger = logger; + /** + * Private constructor, as this class should never be instantiated. + */ + private FOraySpecific() { } - public Log getLogger() { - return this.logger; + public static Log makeLogger(SessionConfig configuration) { + if (configuration.optionVerbosity().equals("debug")) { + return Logging.makeDebugLogger(); + } else { + return Logging.makeDefaultLogger(); + } } - public FontServer makeFontServer(SessionConfig configuration, - EntityResolver entityResolver) throws FOrayException { - FOrayFontServer forayFontServer = new FOrayFontServer(getLogger()); + public static FontServer makeFontServer(Log logger, + SessionConfig configuration, EntityResolver entityResolver) + throws FOrayException { + FOrayFontServer forayFontServer = new FOrayFontServer(logger); forayFontServer.setBaseFontURL( configuration.optionFontBaseDirectory()); forayFontServer.setBaseURL(configuration.optionBaseDirectory()); @@ -72,17 +85,16 @@ return forayFontServer; } - public TextServer makeTextServer(SessionConfig configuration) - throws FOrayException { + public static TextServer makeTextServer(Log logger, + SessionConfig configuration) throws FOrayException { URL hyphenationDir = configuration.optionHyphenationBaseDirectory(); - return new org.foray.text.TextServer(getLogger(), - hyphenationDir); + return new org.foray.text.TextServer(logger, hyphenationDir); } - public GraphicServer makeGraphicServer() throws FOrayException { - return new FOrayGraphicServer(getLogger(), - XMLParser.getParserClassName()); + public static GraphicServer makeGraphicServer(Log logger) + throws FOrayException { + return new FOrayGraphicServer(logger, XMLParser.getParserClassName()); } public FOTreeFactory makeFOTreeFactory(GraphicServer graphicServer, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |