Tue, 14 May 2013 10:14:54 -0700
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
Reviewed-by: darcy
1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.doclets.formats.html;
28 import java.io.IOException;
30 import com.sun.javadoc.*;
31 import com.sun.tools.javac.jvm.Profile;
32 import com.sun.tools.doclets.internal.toolkit.*;
33 import com.sun.tools.doclets.internal.toolkit.util.*;
35 /**
36 * The factory that returns HTML writers.
37 *
38 * <p><b>This is NOT part of any supported API.
39 * If you write code that depends on this, you do so at your own risk.
40 * This code and its internal interfaces are subject to change or
41 * deletion without notice.</b>
42 *
43 * @author Jamie Ho
44 * @since 1.5
45 */
46 public class WriterFactoryImpl implements WriterFactory {
48 private final ConfigurationImpl configuration;
50 public WriterFactoryImpl(ConfigurationImpl configuration) {
51 this.configuration = configuration;
52 }
54 /**
55 * {@inheritDoc}
56 */
57 public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception {
58 return new ConstantsSummaryWriterImpl(configuration);
59 }
61 /**
62 * {@inheritDoc}
63 */
64 public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc,
65 PackageDoc prevPkg, PackageDoc nextPkg) throws Exception {
66 return new PackageWriterImpl(configuration, packageDoc,
67 prevPkg, nextPkg);
68 }
70 /**
71 * {@inheritDoc}
72 */
73 public ProfileSummaryWriter getProfileSummaryWriter(Profile profile,
74 Profile prevProfile, Profile nextProfile) throws Exception {
75 return new ProfileWriterImpl(configuration, profile,
76 prevProfile, nextProfile);
77 }
79 /**
80 * {@inheritDoc}
81 */
82 public ProfilePackageSummaryWriter getProfilePackageSummaryWriter(PackageDoc packageDoc,
83 PackageDoc prevPkg, PackageDoc nextPkg, Profile profile) throws Exception {
84 return new ProfilePackageWriterImpl(configuration, packageDoc,
85 prevPkg, nextPkg, profile);
86 }
88 /**
89 * {@inheritDoc}
90 */
91 public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass,
92 ClassDoc nextClass, ClassTree classTree) throws IOException {
93 return new ClassWriterImpl(configuration, classDoc,
94 prevClass, nextClass, classTree);
95 }
97 /**
98 * {@inheritDoc}
99 */
100 public AnnotationTypeWriter getAnnotationTypeWriter(
101 AnnotationTypeDoc annotationType, Type prevType, Type nextType)
102 throws Exception {
103 return new AnnotationTypeWriterImpl(configuration,
104 annotationType, prevType, nextType);
105 }
107 /**
108 * {@inheritDoc}
109 */
110 public AnnotationTypeOptionalMemberWriter
111 getAnnotationTypeOptionalMemberWriter(
112 AnnotationTypeWriter annotationTypeWriter) throws Exception {
113 return new AnnotationTypeOptionalMemberWriterImpl(
114 (SubWriterHolderWriter) annotationTypeWriter,
115 annotationTypeWriter.getAnnotationTypeDoc());
116 }
118 /**
119 * {@inheritDoc}
120 */
121 public AnnotationTypeRequiredMemberWriter
122 getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
123 return new AnnotationTypeRequiredMemberWriterImpl(
124 (SubWriterHolderWriter) annotationTypeWriter,
125 annotationTypeWriter.getAnnotationTypeDoc());
126 }
128 /**
129 * {@inheritDoc}
130 */
131 public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter)
132 throws Exception {
133 return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
134 classWriter.getClassDoc());
135 }
137 /**
138 * {@inheritDoc}
139 */
140 public FieldWriterImpl getFieldWriter(ClassWriter classWriter)
141 throws Exception {
142 return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
143 classWriter.getClassDoc());
144 }
146 /**
147 * {@inheritDoc}
148 */
149 public PropertyWriterImpl getPropertyWriter(ClassWriter classWriter)
150 throws Exception {
151 return new PropertyWriterImpl((SubWriterHolderWriter) classWriter,
152 classWriter.getClassDoc());
153 }
155 /**
156 * {@inheritDoc}
157 */
158 public MethodWriterImpl getMethodWriter(ClassWriter classWriter)
159 throws Exception {
160 return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
161 classWriter.getClassDoc());
162 }
164 /**
165 * {@inheritDoc}
166 */
167 public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter)
168 throws Exception {
169 return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
170 classWriter.getClassDoc());
171 }
173 /**
174 * {@inheritDoc}
175 */
176 public MemberSummaryWriter getMemberSummaryWriter(
177 ClassWriter classWriter, int memberType)
178 throws Exception {
179 switch (memberType) {
180 case VisibleMemberMap.CONSTRUCTORS:
181 return getConstructorWriter(classWriter);
182 case VisibleMemberMap.ENUM_CONSTANTS:
183 return getEnumConstantWriter(classWriter);
184 case VisibleMemberMap.FIELDS:
185 return getFieldWriter(classWriter);
186 case VisibleMemberMap.PROPERTIES:
187 return getPropertyWriter(classWriter);
188 case VisibleMemberMap.INNERCLASSES:
189 return new NestedClassWriterImpl((SubWriterHolderWriter)
190 classWriter, classWriter.getClassDoc());
191 case VisibleMemberMap.METHODS:
192 return getMethodWriter(classWriter);
193 default:
194 return null;
195 }
196 }
198 /**
199 * {@inheritDoc}
200 */
201 public MemberSummaryWriter getMemberSummaryWriter(
202 AnnotationTypeWriter annotationTypeWriter, int memberType)
203 throws Exception {
204 switch (memberType) {
205 case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL:
206 return (AnnotationTypeOptionalMemberWriterImpl)
207 getAnnotationTypeOptionalMemberWriter(annotationTypeWriter);
208 case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED:
209 return (AnnotationTypeRequiredMemberWriterImpl)
210 getAnnotationTypeRequiredMemberWriter(annotationTypeWriter);
211 default:
212 return null;
213 }
214 }
216 /**
217 * {@inheritDoc}
218 */
219 public SerializedFormWriter getSerializedFormWriter() throws Exception {
220 return new SerializedFormWriterImpl(configuration);
221 }
222 }