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 implements
042: 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 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(configuration().getText(
077: "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,
087: String fieldTypeStr, String fieldDimensions,
088: String fieldName) {
089: if (printedFirstMember) {
090: writer.printMemberHeader();
091: }
092: printedFirstMember = true;
093: writer.h3();
094: writer.print(fieldName);
095: writer.h3End();
096: writer.pre();
097: if (fieldType == null) {
098: writer.print(fieldTypeStr);
099: } else {
100: writer.printLink(new LinkInfoImpl(
101: LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType));
102: }
103: print(fieldDimensions + ' ');
104: bold(fieldName);
105: writer.preEnd();
106: writer.dl();
107: }
108:
109: /**
110: * Write the deprecated information for this member.
111: *
112: * @param field the field to document.
113: */
114: public void writeMemberDeprecatedInfo(FieldDoc field) {
115: print(((TagletOutputImpl) (new DeprecatedTaglet())
116: .getTagletOutput(field, writer
117: .getTagletWriterInstance(false))).toString());
118: }
119:
120: /**
121: * Write the description text for this member.
122: *
123: * @param field the field to document.
124: */
125: public void writeMemberDescription(FieldDoc field) {
126: if (field.inlineTags().length > 0) {
127: writer.dd();
128: writer.printInlineComment(field);
129: }
130: Tag[] tags = field.tags("serial");
131: if (tags.length > 0) {
132: writer.dt();
133: writer.dd();
134: writer.printInlineComment(field, tags[0]);
135: }
136: }
137:
138: /**
139: * Write the description text for this member represented by the tag.
140: *
141: * @param serialFieldTag the field to document (represented by tag).
142: */
143: public void writeMemberDescription(SerialFieldTag serialFieldTag) {
144: writer.dd();
145: writer.print(serialFieldTag.description());
146: writer.dlEnd();
147: }
148:
149: /**
150: * Write the tag information for this member.
151: *
152: * @param field the field to document.
153: */
154: public void writeMemberTags(FieldDoc field) {
155: writer.dl();
156: TagletOutputImpl output = new TagletOutputImpl("");
157: TagletWriter.genTagOuput(configuration().tagletManager, field,
158: configuration().tagletManager.getCustomTags(field),
159: writer.getTagletWriterInstance(false), output);
160: if (output.toString().length() > 0) {
161: print(output.toString());
162: }
163: writer.dlEnd();
164: }
165:
166: public void writeMemberFooter(FieldDoc member) {
167: writer.dlEnd();
168: }
169: }
|