001 /*
002 * Copyright 1998-2006 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.taglets.*;
030 import com.sun.tools.doclets.internal.toolkit.util.*;
031 import com.sun.javadoc.*;
032 import java.util.*;
033
034 /**
035 * Generate serialized form for serializable fields.
036 * Documentation denoted by the tags <code>serial</code> and
037 * <code>serialField</code> is processed.
038 *
039 * @author Joe Fialli
040 */
041 public class HtmlSerialFieldWriter extends FieldWriterImpl
042 implements SerializedFormWriter.SerialFieldWriter {
043 ProgramElementDoc[] members = null;
044
045 private boolean printedOverallAnchor = false;
046
047 private boolean printedFirstMember = false;
048
049 public HtmlSerialFieldWriter(SubWriterHolderWriter writer,
050 ClassDoc classdoc) {
051 super(writer, classdoc);
052 }
053
054 public List<FieldDoc> members(ClassDoc cd) {
055 return Util.asList(cd.serializableFields());
056 }
057
058 protected void printTypeLinkNoDimension(Type type) {
059 ClassDoc cd = type.asClassDoc();
060 //Linking to package private classes in serialized for causes
061 //broken links. Don't link to them.
062 if (type.isPrimitive() || cd.isPackagePrivate()) {
063 print(type.typeName());
064 } else {
065 writer.printLink(new LinkInfoImpl(
066 LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type));
067 }
068 }
069
070 public void writeHeader(String heading) {
071 if (! printedOverallAnchor) {
072 writer.anchor("serializedForm");
073 printedOverallAnchor = true;
074 writer.printTableHeadingBackground(heading);
075 writer.println();
076 if (heading.equals(
077 configuration().getText("doclet.Serialized_Form_class"))) {
078 writer.dl();
079 }
080 } else {
081 writer.printTableHeadingBackground(heading);
082 writer.println();
083 }
084 }
085
086 public void writeMemberHeader(ClassDoc fieldType, String fieldTypeStr,
087 String fieldDimensions, String fieldName) {
088 if (printedFirstMember) {
089 writer.printMemberHeader();
090 }
091 printedFirstMember = true;
092 writer.h3();
093 writer.print(fieldName);
094 writer.h3End();
095 writer.pre();
096 if (fieldType == null) {
097 writer.print(fieldTypeStr);
098 } else {
099 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIAL_MEMBER,
100 fieldType));
101 }
102 print(fieldDimensions + ' ');
103 strong(fieldName);
104 writer.preEnd();
105 writer.dl();
106 }
107
108 /**
109 * Write the deprecated information for this member.
110 *
111 * @param field the field to document.
112 */
113 public void writeMemberDeprecatedInfo(FieldDoc field) {
114 print(((TagletOutputImpl)
115 (new DeprecatedTaglet()).getTagletOutput(field,
116 writer.getTagletWriterInstance(false))).toString());
117 }
118
119 /**
120 * Write the description text for this member.
121 *
122 * @param field the field to document.
123 */
124 public void writeMemberDescription(FieldDoc field) {
125 if (field.inlineTags().length > 0) {
126 writer.dd();
127 writer.printInlineComment(field);
128 }
129 Tag[] tags = field.tags("serial");
130 if (tags.length > 0) {
131 writer.dt();
132 writer.dd();
133 writer.printInlineComment(field, tags[0]);
134 }
135 }
136
137 /**
138 * Write the description text for this member represented by the tag.
139 *
140 * @param serialFieldTag the field to document (represented by tag).
141 */
142 public void writeMemberDescription(SerialFieldTag serialFieldTag) {
143 writer.dd();
144 writer.print(serialFieldTag.description());
145 writer.dlEnd();
146 }
147
148 /**
149 * Write the tag information for this member.
150 *
151 * @param field the field to document.
152 */
153 public void writeMemberTags(FieldDoc field) {
154 writer.dl();
155 TagletOutputImpl output = new TagletOutputImpl("");
156 TagletWriter.genTagOuput(configuration().tagletManager, field,
157 configuration().tagletManager.getCustomTags(field),
158 writer.getTagletWriterInstance(false), output);
159 if (output.toString().length() > 0) {
160 print(output.toString());
161 }
162 writer.dlEnd();
163 }
164 public void writeMemberFooter(FieldDoc member) {
165 writer.dlEnd();
166 }
167 }