KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.xml.stream.XMLStreamException;
33 import javax.xml.stream.XMLStreamWriter;
34 import java.io.IOException JavaDoc;
35 import java.io.PrintWriter JavaDoc;
36
37 public class Header {
38   private Document _document;
39   private String JavaDoc _product;
40   private String JavaDoc _version;
41   private String JavaDoc _title;
42   private String JavaDoc _author;
43   private String JavaDoc _date;
44   private Section _description;
45   private Keywords _keywords;
46   private String JavaDoc _tutorial;
47
48   public Header(Document document)
49   {
50     _document = document;
51   }
52
53   public void setProduct(String JavaDoc product)
54   {
55     _product = product;
56   }
57
58   public void setVersion(String JavaDoc version)
59   {
60     _version = version;
61   }
62
63   public void setTitle(String JavaDoc title)
64   {
65     _title = title;
66   }
67
68   public String JavaDoc getTitle()
69   {
70     return _title;
71   }
72
73   public void setDate(String JavaDoc date)
74   {
75     _date = date;
76   }
77
78   public void setAuthor(String JavaDoc author)
79   {
80     _author = author;
81   }
82
83   public void setResin2_0(String JavaDoc resin2_0)
84   {
85   }
86
87   public void setType(String JavaDoc type)
88   {
89   }
90
91   public void setTutorialStartPage(String JavaDoc startPage)
92   {
93     _tutorial = startPage;
94   }
95
96   public String JavaDoc getTutorialStartPage()
97   {
98     return _tutorial;
99   }
100
101   public void setLevel(String JavaDoc level)
102   {
103   }
104
105   public void setKeywords(Keywords keywords)
106   {
107     _keywords = keywords;
108   }
109
110   public ContentItem getDescription()
111   {
112     return _description;
113   }
114
115   public Section createDescription()
116   {
117     _description = new S1(_document);
118     return _description;
119   }
120
121   public void writeHtml(XMLStreamWriter out)
122     throws XMLStreamException
123   {
124     out.writeStartElement("head");
125
126     out.writeEmptyElement("meta");
127     out.writeAttribute("http-equiv", "Content-Type");
128     out.writeAttribute("content", "text/html; charset=utf-8");
129
130     if (_product != null) {
131       out.writeEmptyElement("meta");
132       out.writeAttribute("name", "product");
133       out.writeAttribute("content", _product);
134     }
135
136     if (_version != null) {
137       out.writeEmptyElement("meta");
138       out.writeAttribute("name", "version");
139       out.writeAttribute("content", _version);
140     }
141
142     if (_keywords != null) {
143       out.writeEmptyElement("meta");
144       out.writeAttribute("name", "keywords");
145       out.writeAttribute("content", _keywords.toString());
146     }
147
148     out.writeEmptyElement("link");
149     out.writeAttribute("rel", "STYLESHEET");
150     out.writeAttribute("type", "text/css");
151     out.writeAttribute("href", _document.getContextPath() + "/css/default.css");
152
153     out.writeStartElement("title");
154
155     NavigationItem nav = _document.getNavigation();
156
157     if (nav != null
158     && nav.getNavigation() != null
159     && nav.getNavigation().getSection() != null)
160       out.writeCharacters(nav.getNavigation().getSection());
161     
162     out.writeCharacters(_title);
163     out.writeEndElement(); // title
164

165     out.writeEndElement(); // head
166
}
167
168   public void writeLaTeXTop(PrintWriter JavaDoc out)
169     throws IOException JavaDoc
170   {
171     out.println("\\usepackage[margin=1in]{geometry}");
172     out.println("\\usepackage{url}");
173     out.println("\\usepackage{hyperref}");
174     out.println("\\usepackage{graphicx}");
175     out.println("\\usepackage{color}");
176     out.println("\\usepackage{colortbl}");
177     out.println("\\usepackage{fancyvrb}");
178     out.println("\\usepackage{listings}");
179     out.println();
180     out.println("\\definecolor{example-gray}{gray}{0.8}");
181     out.println("\\definecolor{results-gray}{gray}{0.6}");
182     out.println();
183     out.println("\\title{" + _title + "}");
184     //XXX: product & version
185
}
186
187   public void writeLaTeX(PrintWriter JavaDoc out)
188     throws IOException JavaDoc
189   {
190     out.println("\\section{" + _title + "}");
191
192     out.println("\\label{" + _document.getName() + "}");
193     out.println("\\hypertarget{" + _document.getName() + "}{}");
194   }
195
196   public void writeLaTeXEnclosed(PrintWriter JavaDoc out)
197     throws IOException JavaDoc
198   {
199     out.println("\\subsection{" + _title + "}");
200
201     out.println("\\label{" + _document.getName() + "}");
202     out.println("\\hypertarget{" + _document.getName() + "}{}");
203   }
204 }
205
Popular Tags