001: /*
002: * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.doclets.formats.html;
027:
028: import com.sun.tools.doclets.internal.toolkit.*;
029: import com.sun.tools.doclets.internal.toolkit.util.*;
030: import com.sun.javadoc.*;
031:
032: /**
033: * The factory that returns HTML writers.
034: *
035: * @author Jamie Ho
036: * @since 1.5
037: */
038: public class WriterFactoryImpl implements WriterFactory {
039:
040: private static WriterFactoryImpl instance;
041:
042: private ConfigurationImpl configuration;
043:
044: private WriterFactoryImpl(ConfigurationImpl configuration) {
045: this .configuration = configuration;
046: }
047:
048: /**
049: * Return an instance of this factory.
050: *
051: * @return an instance of this factory.
052: */
053: public static WriterFactoryImpl getInstance() {
054: if (instance == null) {
055: instance = new WriterFactoryImpl(ConfigurationImpl
056: .getInstance());
057: }
058: return instance;
059: }
060:
061: /**
062: * {@inheritDoc}
063: */
064: public ConstantsSummaryWriter getConstantsSummaryWriter()
065: throws Exception {
066: return new ConstantsSummaryWriterImpl(configuration);
067: }
068:
069: /**
070: * {@inheritDoc}
071: */
072: public PackageSummaryWriter getPackageSummaryWriter(
073: PackageDoc packageDoc, PackageDoc prevPkg,
074: PackageDoc nextPkg) throws Exception {
075: return new PackageWriterImpl(ConfigurationImpl.getInstance(),
076: packageDoc, prevPkg, nextPkg);
077: }
078:
079: /**
080: * {@inheritDoc}
081: */
082: public ClassWriter getClassWriter(ClassDoc classDoc,
083: ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
084: throws Exception {
085: return new ClassWriterImpl(classDoc, prevClass, nextClass,
086: classTree);
087: }
088:
089: /**
090: * {@inheritDoc}
091: */
092: public AnnotationTypeWriter getAnnotationTypeWriter(
093: AnnotationTypeDoc annotationType, Type prevType,
094: Type nextType) throws Exception {
095: return new AnnotationTypeWriterImpl(annotationType, prevType,
096: nextType);
097: }
098:
099: /**
100: * {@inheritDoc}
101: */
102: public AnnotationTypeOptionalMemberWriter getAnnotationTypeOptionalMemberWriter(
103: AnnotationTypeWriter annotationTypeWriter) throws Exception {
104: return new AnnotationTypeOptionalMemberWriterImpl(
105: (SubWriterHolderWriter) annotationTypeWriter,
106: annotationTypeWriter.getAnnotationTypeDoc());
107: }
108:
109: /**
110: * {@inheritDoc}
111: */
112: public AnnotationTypeRequiredMemberWriter getAnnotationTypeRequiredMemberWriter(
113: AnnotationTypeWriter annotationTypeWriter) throws Exception {
114: return new AnnotationTypeRequiredMemberWriterImpl(
115: (SubWriterHolderWriter) annotationTypeWriter,
116: annotationTypeWriter.getAnnotationTypeDoc());
117: }
118:
119: /**
120: * {@inheritDoc}
121: */
122: public EnumConstantWriter getEnumConstantWriter(
123: ClassWriter classWriter) throws Exception {
124: return new EnumConstantWriterImpl(
125: (SubWriterHolderWriter) classWriter, classWriter
126: .getClassDoc());
127: }
128:
129: /**
130: * {@inheritDoc}
131: */
132: public FieldWriter getFieldWriter(ClassWriter classWriter)
133: throws Exception {
134: return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
135: classWriter.getClassDoc());
136: }
137:
138: /**
139: * {@inheritDoc}
140: */
141: public MethodWriter getMethodWriter(ClassWriter classWriter)
142: throws Exception {
143: return new MethodWriterImpl(
144: (SubWriterHolderWriter) classWriter, classWriter
145: .getClassDoc());
146: }
147:
148: /**
149: * {@inheritDoc}
150: */
151: public ConstructorWriter getConstructorWriter(
152: ClassWriter classWriter) throws Exception {
153: return new ConstructorWriterImpl(
154: (SubWriterHolderWriter) classWriter, classWriter
155: .getClassDoc());
156: }
157:
158: /**
159: * {@inheritDoc}
160: */
161: public MemberSummaryWriter getMemberSummaryWriter(
162: ClassWriter classWriter, int memberType) throws Exception {
163: switch (memberType) {
164: case VisibleMemberMap.CONSTRUCTORS:
165: return (ConstructorWriterImpl) getConstructorWriter(classWriter);
166: case VisibleMemberMap.ENUM_CONSTANTS:
167: return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter);
168: case VisibleMemberMap.FIELDS:
169: return (FieldWriterImpl) getFieldWriter(classWriter);
170: case VisibleMemberMap.INNERCLASSES:
171: return new NestedClassWriterImpl(
172: (SubWriterHolderWriter) classWriter, classWriter
173: .getClassDoc());
174: case VisibleMemberMap.METHODS:
175: return (MethodWriterImpl) getMethodWriter(classWriter);
176: default:
177: return null;
178: }
179: }
180:
181: /**
182: * {@inheritDoc}
183: */
184: public MemberSummaryWriter getMemberSummaryWriter(
185: AnnotationTypeWriter annotationTypeWriter, int memberType)
186: throws Exception {
187: switch (memberType) {
188: case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL:
189: return (AnnotationTypeOptionalMemberWriterImpl) getAnnotationTypeOptionalMemberWriter(annotationTypeWriter);
190: case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED:
191: return (AnnotationTypeRequiredMemberWriterImpl) getAnnotationTypeRequiredMemberWriter(annotationTypeWriter);
192: default:
193: return null;
194: }
195: }
196:
197: /**
198: * {@inheritDoc}
199: */
200: public SerializedFormWriter getSerializedFormWriter()
201: throws Exception {
202: return new SerializedFormWriterImpl();
203: }
204: }
|