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