Thu, 13 Jan 2011 21:28:38 -0800
7010528: javadoc performance regression
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2003, 2008, 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 com.sun.tools.doclets.internal.toolkit.*;
29 import com.sun.tools.doclets.internal.toolkit.util.*;
30 import com.sun.javadoc.*;
32 /**
33 * The factory that returns HTML writers.
34 *
35 * @author Jamie Ho
36 * @since 1.5
37 */
38 public class WriterFactoryImpl implements WriterFactory {
40 private ConfigurationImpl configuration;
42 public WriterFactoryImpl(ConfigurationImpl configuration) {
43 this.configuration = configuration;
44 }
46 /**
47 * {@inheritDoc}
48 */
49 public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception {
50 return new ConstantsSummaryWriterImpl(configuration);
51 }
53 /**
54 * {@inheritDoc}
55 */
56 public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc,
57 PackageDoc prevPkg, PackageDoc nextPkg) throws Exception {
58 return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc,
59 prevPkg, nextPkg);
60 }
62 /**
63 * {@inheritDoc}
64 */
65 public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass,
66 ClassDoc nextClass, ClassTree classTree)
67 throws Exception {
68 return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree);
69 }
71 /**
72 * {@inheritDoc}
73 */
74 public AnnotationTypeWriter getAnnotationTypeWriter(
75 AnnotationTypeDoc annotationType, Type prevType, Type nextType)
76 throws Exception {
77 return new AnnotationTypeWriterImpl(annotationType, prevType, nextType);
78 }
80 /**
81 * {@inheritDoc}
82 */
83 public AnnotationTypeOptionalMemberWriter
84 getAnnotationTypeOptionalMemberWriter(
85 AnnotationTypeWriter annotationTypeWriter) throws Exception {
86 return new AnnotationTypeOptionalMemberWriterImpl(
87 (SubWriterHolderWriter) annotationTypeWriter,
88 annotationTypeWriter.getAnnotationTypeDoc());
89 }
91 /**
92 * {@inheritDoc}
93 */
94 public AnnotationTypeRequiredMemberWriter
95 getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
96 return new AnnotationTypeRequiredMemberWriterImpl(
97 (SubWriterHolderWriter) annotationTypeWriter,
98 annotationTypeWriter.getAnnotationTypeDoc());
99 }
101 /**
102 * {@inheritDoc}
103 */
104 public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter)
105 throws Exception {
106 return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
107 classWriter.getClassDoc());
108 }
110 /**
111 * {@inheritDoc}
112 */
113 public FieldWriter getFieldWriter(ClassWriter classWriter)
114 throws Exception {
115 return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
116 classWriter.getClassDoc());
117 }
119 /**
120 * {@inheritDoc}
121 */
122 public MethodWriter getMethodWriter(ClassWriter classWriter)
123 throws Exception {
124 return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
125 classWriter.getClassDoc());
126 }
128 /**
129 * {@inheritDoc}
130 */
131 public ConstructorWriter getConstructorWriter(ClassWriter classWriter)
132 throws Exception {
133 return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
134 classWriter.getClassDoc());
135 }
137 /**
138 * {@inheritDoc}
139 */
140 public MemberSummaryWriter getMemberSummaryWriter(
141 ClassWriter classWriter, int memberType)
142 throws Exception {
143 switch (memberType) {
144 case VisibleMemberMap.CONSTRUCTORS:
145 return (ConstructorWriterImpl) getConstructorWriter(classWriter);
146 case VisibleMemberMap.ENUM_CONSTANTS:
147 return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter);
148 case VisibleMemberMap.FIELDS:
149 return (FieldWriterImpl) getFieldWriter(classWriter);
150 case VisibleMemberMap.INNERCLASSES:
151 return new NestedClassWriterImpl((SubWriterHolderWriter)
152 classWriter, classWriter.getClassDoc());
153 case VisibleMemberMap.METHODS:
154 return (MethodWriterImpl) getMethodWriter(classWriter);
155 default:
156 return null;
157 }
158 }
160 /**
161 * {@inheritDoc}
162 */
163 public MemberSummaryWriter getMemberSummaryWriter(
164 AnnotationTypeWriter annotationTypeWriter, int memberType)
165 throws Exception {
166 switch (memberType) {
167 case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL:
168 return (AnnotationTypeOptionalMemberWriterImpl)
169 getAnnotationTypeOptionalMemberWriter(annotationTypeWriter);
170 case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED:
171 return (AnnotationTypeRequiredMemberWriterImpl)
172 getAnnotationTypeRequiredMemberWriter(annotationTypeWriter);
173 default:
174 return null;
175 }
176 }
178 /**
179 * {@inheritDoc}
180 */
181 public SerializedFormWriter getSerializedFormWriter() throws Exception {
182 return new SerializedFormWriterImpl();
183 }
184 }