1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,198 @@ 1.4 +/* 1.5 + * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.doclets.formats.html; 1.30 + 1.31 +import com.sun.tools.doclets.internal.toolkit.*; 1.32 +import com.sun.tools.doclets.internal.toolkit.util.*; 1.33 +import com.sun.javadoc.*; 1.34 + 1.35 +/** 1.36 + * The factory that returns HTML writers. 1.37 + * 1.38 + * @author Jamie Ho 1.39 + * @since 1.5 1.40 + */ 1.41 +public class WriterFactoryImpl implements WriterFactory { 1.42 + 1.43 + private static WriterFactoryImpl instance; 1.44 + 1.45 + private ConfigurationImpl configuration; 1.46 + 1.47 + private WriterFactoryImpl(ConfigurationImpl configuration) { 1.48 + this.configuration = configuration; 1.49 + } 1.50 + 1.51 + /** 1.52 + * Return an instance of this factory. 1.53 + * 1.54 + * @return an instance of this factory. 1.55 + */ 1.56 + public static WriterFactoryImpl getInstance() { 1.57 + if (instance == null) { 1.58 + instance = new WriterFactoryImpl(ConfigurationImpl.getInstance()); 1.59 + } 1.60 + return instance; 1.61 + } 1.62 + 1.63 + /** 1.64 + * {@inheritDoc} 1.65 + */ 1.66 + public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception { 1.67 + return new ConstantsSummaryWriterImpl(configuration); 1.68 + } 1.69 + 1.70 + /** 1.71 + * {@inheritDoc} 1.72 + */ 1.73 + public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc, 1.74 + PackageDoc prevPkg, PackageDoc nextPkg) throws Exception { 1.75 + return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc, 1.76 + prevPkg, nextPkg); 1.77 + } 1.78 + 1.79 + /** 1.80 + * {@inheritDoc} 1.81 + */ 1.82 + public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass, 1.83 + ClassDoc nextClass, ClassTree classTree) 1.84 + throws Exception { 1.85 + return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree); 1.86 + } 1.87 + 1.88 + /** 1.89 + * {@inheritDoc} 1.90 + */ 1.91 + public AnnotationTypeWriter getAnnotationTypeWriter( 1.92 + AnnotationTypeDoc annotationType, Type prevType, Type nextType) 1.93 + throws Exception { 1.94 + return new AnnotationTypeWriterImpl(annotationType, prevType, nextType); 1.95 + } 1.96 + 1.97 + /** 1.98 + * {@inheritDoc} 1.99 + */ 1.100 + public AnnotationTypeOptionalMemberWriter 1.101 + getAnnotationTypeOptionalMemberWriter( 1.102 + AnnotationTypeWriter annotationTypeWriter) throws Exception { 1.103 + return new AnnotationTypeOptionalMemberWriterImpl( 1.104 + (SubWriterHolderWriter) annotationTypeWriter, 1.105 + annotationTypeWriter.getAnnotationTypeDoc()); 1.106 + } 1.107 + 1.108 + /** 1.109 + * {@inheritDoc} 1.110 + */ 1.111 + public AnnotationTypeRequiredMemberWriter 1.112 + getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception { 1.113 + return new AnnotationTypeRequiredMemberWriterImpl( 1.114 + (SubWriterHolderWriter) annotationTypeWriter, 1.115 + annotationTypeWriter.getAnnotationTypeDoc()); 1.116 + } 1.117 + 1.118 + /** 1.119 + * {@inheritDoc} 1.120 + */ 1.121 + public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter) 1.122 + throws Exception { 1.123 + return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter, 1.124 + classWriter.getClassDoc()); 1.125 + } 1.126 + 1.127 + /** 1.128 + * {@inheritDoc} 1.129 + */ 1.130 + public FieldWriter getFieldWriter(ClassWriter classWriter) 1.131 + throws Exception { 1.132 + return new FieldWriterImpl((SubWriterHolderWriter) classWriter, 1.133 + classWriter.getClassDoc()); 1.134 + } 1.135 + 1.136 + /** 1.137 + * {@inheritDoc} 1.138 + */ 1.139 + public MethodWriter getMethodWriter(ClassWriter classWriter) 1.140 + throws Exception { 1.141 + return new MethodWriterImpl((SubWriterHolderWriter) classWriter, 1.142 + classWriter.getClassDoc()); 1.143 + } 1.144 + 1.145 + /** 1.146 + * {@inheritDoc} 1.147 + */ 1.148 + public ConstructorWriter getConstructorWriter(ClassWriter classWriter) 1.149 + throws Exception { 1.150 + return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter, 1.151 + classWriter.getClassDoc()); 1.152 + } 1.153 + 1.154 + /** 1.155 + * {@inheritDoc} 1.156 + */ 1.157 + public MemberSummaryWriter getMemberSummaryWriter( 1.158 + ClassWriter classWriter, int memberType) 1.159 + throws Exception { 1.160 + switch (memberType) { 1.161 + case VisibleMemberMap.CONSTRUCTORS: 1.162 + return (ConstructorWriterImpl) getConstructorWriter(classWriter); 1.163 + case VisibleMemberMap.ENUM_CONSTANTS: 1.164 + return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter); 1.165 + case VisibleMemberMap.FIELDS: 1.166 + return (FieldWriterImpl) getFieldWriter(classWriter); 1.167 + case VisibleMemberMap.INNERCLASSES: 1.168 + return new NestedClassWriterImpl((SubWriterHolderWriter) 1.169 + classWriter, classWriter.getClassDoc()); 1.170 + case VisibleMemberMap.METHODS: 1.171 + return (MethodWriterImpl) getMethodWriter(classWriter); 1.172 + default: 1.173 + return null; 1.174 + } 1.175 + } 1.176 + 1.177 + /** 1.178 + * {@inheritDoc} 1.179 + */ 1.180 + public MemberSummaryWriter getMemberSummaryWriter( 1.181 + AnnotationTypeWriter annotationTypeWriter, int memberType) 1.182 + throws Exception { 1.183 + switch (memberType) { 1.184 + case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL: 1.185 + return (AnnotationTypeOptionalMemberWriterImpl) 1.186 + getAnnotationTypeOptionalMemberWriter(annotationTypeWriter); 1.187 + case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED: 1.188 + return (AnnotationTypeRequiredMemberWriterImpl) 1.189 + getAnnotationTypeRequiredMemberWriter(annotationTypeWriter); 1.190 + default: 1.191 + return null; 1.192 + } 1.193 + } 1.194 + 1.195 + /** 1.196 + * {@inheritDoc} 1.197 + */ 1.198 + public SerializedFormWriter getSerializedFormWriter() throws Exception { 1.199 + return new SerializedFormWriterImpl(); 1.200 + } 1.201 +}