src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java

changeset 1521
71f35e4b93a5
parent 1359
25e14ad23cef
child 1691
f10cffab99b4
equal deleted inserted replaced
1520:5c956be64b9e 1521:71f35e4b93a5
1 /* 1 /*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 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. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
59 LinkOutput linkOutput = getOutputInstance(); 59 LinkOutput linkOutput = getOutputInstance();
60 if (type.isPrimitive()) { 60 if (type.isPrimitive()) {
61 //Just a primitive. 61 //Just a primitive.
62 linkInfo.displayLength += type.typeName().length(); 62 linkInfo.displayLength += type.typeName().length();
63 linkOutput.append(type.typeName()); 63 linkOutput.append(type.typeName());
64 } else if (type.asAnnotatedType() != null) {
65 linkOutput.append(getTypeAnnotationLinks(linkInfo));
66 linkInfo.type = type.asAnnotatedType().underlyingType();
67 linkOutput.append(getLinkOutput(linkInfo));
68 return linkOutput;
64 } else if (type.asWildcardType() != null) { 69 } else if (type.asWildcardType() != null) {
65 //Wildcard type. 70 //Wildcard type.
66 linkInfo.isTypeBound = true; 71 linkInfo.isTypeBound = true;
67 linkInfo.displayLength += 1; 72 linkInfo.displayLength += 1;
68 linkOutput.append("?"); 73 linkOutput.append("?");
80 linkOutput.append(i > 0 ? ", " : " super "); 85 linkOutput.append(i > 0 ? ", " : " super ");
81 setBoundsLinkInfo(linkInfo, superBounds[i]); 86 setBoundsLinkInfo(linkInfo, superBounds[i]);
82 linkOutput.append(getLinkOutput(linkInfo)); 87 linkOutput.append(getLinkOutput(linkInfo));
83 } 88 }
84 } else if (type.asTypeVariable()!= null) { 89 } else if (type.asTypeVariable()!= null) {
90 linkOutput.append(getTypeAnnotationLinks(linkInfo));
85 linkInfo.isTypeBound = true; 91 linkInfo.isTypeBound = true;
86 //A type variable. 92 //A type variable.
87 Doc owner = type.asTypeVariable().owner(); 93 Doc owner = type.asTypeVariable().owner();
88 if ((! linkInfo.excludeTypeParameterLinks) && 94 if ((! linkInfo.excludeTypeParameterLinks) &&
89 owner instanceof ClassDoc) { 95 owner instanceof ClassDoc) {
173 * @param typeParam the type parameter to link to. 179 * @param typeParam the type parameter to link to.
174 */ 180 */
175 protected abstract LinkOutput getTypeParameterLink(LinkInfo linkInfo, 181 protected abstract LinkOutput getTypeParameterLink(LinkInfo linkInfo,
176 Type typeParam); 182 Type typeParam);
177 183
184 protected abstract LinkOutput getTypeAnnotationLink(LinkInfo linkInfo,
185 AnnotationDesc annotation);
186
178 /** 187 /**
179 * Return the links to the type parameters. 188 * Return the links to the type parameters.
180 * 189 *
181 * @param linkInfo the information about the link to construct. 190 * @param linkInfo the information about the link to construct.
182 * @return the links to the type parameters. 191 * @return the links to the type parameters.
224 output.append(getGreaterThanString()); 233 output.append(getGreaterThanString());
225 } 234 }
226 return output; 235 return output;
227 } 236 }
228 237
238 public LinkOutput getTypeAnnotationLinks(LinkInfo linkInfo) {
239 LinkOutput output = getOutputInstance();
240 if (linkInfo.type.asAnnotatedType() == null)
241 return output;
242 AnnotationDesc[] annotations = linkInfo.type.asAnnotatedType().annotations();
243 for (int i = 0; i < annotations.length; i++) {
244 if (i > 0) {
245 linkInfo.displayLength += 1;
246 output.append(" ");
247 }
248 output.append(getTypeAnnotationLink(linkInfo, annotations[i]));
249 }
250
251 linkInfo.displayLength += 1;
252 output.append(" ");
253 return output;
254 }
255
229 /** 256 /**
230 * Return &amp;lt;, which is used in type parameters. Override this 257 * Return &amp;lt;, which is used in type parameters. Override this
231 * if your doclet uses something different. 258 * if your doclet uses something different.
232 * 259 *
233 * @return return &amp;lt;, which is used in type parameters. 260 * @return return &amp;lt;, which is used in type parameters.

mercurial