KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > xtpdoc > LinkedChapterSection


1 /*
2  * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Emil Ong
28  */

29
30 package com.caucho.xtpdoc;
31
32 import com.caucho.config.Config;
33 import com.caucho.vfs.Path;
34 import com.caucho.vfs.Vfs;
35
36 import java.io.IOException JavaDoc;
37 import java.io.PrintWriter JavaDoc;
38 import java.util.logging.Logger JavaDoc;
39
40 public class LinkedChapterSection extends ChapterSection {
41   private static final Logger JavaDoc log = Logger.getLogger(Anchor.class.getName());
42   private String JavaDoc _link;
43
44   public void setLink(String JavaDoc link)
45   {
46     _link = link;
47   }
48
49   private Document configureDocument(Path xtpFile)
50   {
51     Document document = new Document(xtpFile, null);
52
53     try {
54       //org.w3c.dom.Node node = LooseToStrictHtml.looseToStrictHtml(xtpFile);
55

56       Config config = new Config();
57
58       config.configure(document, xtpFile);
59
60       return document;
61     } catch (Exception JavaDoc e) {
62       System.err.println("Error configuring document (" + xtpFile + "): " + e);
63
64       if (e.getCause() != null)
65         e.getCause().printStackTrace();
66       else
67         e.printStackTrace();
68
69       return null;
70     }
71   }
72
73   public void writeLaTeX(PrintWriter JavaDoc out)
74     throws IOException JavaDoc
75   {
76     Path xtpFile = Vfs.lookup(_link);
77     Document document = configureDocument(xtpFile);
78
79     try {
80       if (document != null)
81         document.writeLaTeX(out);
82     } catch (Exception JavaDoc e) {
83       System.err.println("Error configuring document (" + xtpFile + "): " + e);
84
85       if (e.getCause() != null)
86         e.getCause().printStackTrace();
87       else
88         e.printStackTrace();
89
90       return;
91     }
92   }
93
94   public void writeLaTeXEnclosed(PrintWriter JavaDoc out)
95     throws IOException JavaDoc
96   {
97     Path xtpFile = Vfs.lookup(_link);
98     Document document = configureDocument(xtpFile);
99
100     try {
101       if (document != null)
102         document.writeLaTeXEnclosed(out);
103     } catch (Exception JavaDoc e) {
104       System.err.println("Error configuring document (" + xtpFile + "): " + e);
105
106       if (e.getCause() != null)
107         e.getCause().printStackTrace();
108       else
109         e.printStackTrace();
110
111       return;
112     }
113   }
114 }
115
Popular Tags