duke@1: /* duke@1: * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. Sun designates this duke@1: * particular file as subject to the "Classpath" exception as provided duke@1: * by Sun in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * duke@1: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: * CA 95054 USA or visit www.sun.com if you need additional information or duke@1: * have any questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: duke@1: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.taglets.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: import com.sun.javadoc.*; duke@1: import java.util.*; duke@1: duke@1: /** duke@1: * Generate serialized form for serializable fields. duke@1: * Documentation denoted by the tags serial and duke@1: * serialField is processed. duke@1: * duke@1: * @author Joe Fialli duke@1: */ duke@1: public class HtmlSerialFieldWriter extends FieldWriterImpl duke@1: implements SerializedFormWriter.SerialFieldWriter { duke@1: ProgramElementDoc[] members = null; duke@1: duke@1: private boolean printedOverallAnchor = false; duke@1: duke@1: private boolean printedFirstMember = false; duke@1: duke@1: public HtmlSerialFieldWriter(SubWriterHolderWriter writer, duke@1: ClassDoc classdoc) { duke@1: super(writer, classdoc); duke@1: } duke@1: duke@1: public List members(ClassDoc cd) { duke@1: return Util.asList(cd.serializableFields()); duke@1: } duke@1: duke@1: protected void printTypeLinkNoDimension(Type type) { duke@1: ClassDoc cd = type.asClassDoc(); duke@1: //Linking to package private classes in serialized for causes duke@1: //broken links. Don't link to them. duke@1: if (type.isPrimitive() || cd.isPackagePrivate()) { duke@1: print(type.typeName()); duke@1: } else { duke@1: writer.printLink(new LinkInfoImpl( duke@1: LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type)); duke@1: } duke@1: } duke@1: duke@1: public void writeHeader(String heading) { duke@1: if (! printedOverallAnchor) { duke@1: writer.anchor("serializedForm"); duke@1: printedOverallAnchor = true; duke@1: writer.printTableHeadingBackground(heading); duke@1: writer.println(); duke@1: if (heading.equals( duke@1: configuration().getText("doclet.Serialized_Form_class"))) { duke@1: writer.dl(); duke@1: } duke@1: } else { duke@1: writer.printTableHeadingBackground(heading); duke@1: writer.println(); duke@1: } duke@1: } duke@1: duke@1: public void writeMemberHeader(ClassDoc fieldType, String fieldTypeStr, duke@1: String fieldDimensions, String fieldName) { duke@1: if (printedFirstMember) { duke@1: writer.printMemberHeader(); duke@1: } duke@1: printedFirstMember = true; duke@1: writer.h3(); duke@1: writer.print(fieldName); duke@1: writer.h3End(); duke@1: writer.pre(); duke@1: if (fieldType == null) { duke@1: writer.print(fieldTypeStr); duke@1: } else { duke@1: writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIAL_MEMBER, duke@1: fieldType)); duke@1: } duke@1: print(fieldDimensions + ' '); bpatel@182: strong(fieldName); duke@1: writer.preEnd(); duke@1: writer.dl(); duke@1: } duke@1: duke@1: /** duke@1: * Write the deprecated information for this member. duke@1: * duke@1: * @param field the field to document. duke@1: */ duke@1: public void writeMemberDeprecatedInfo(FieldDoc field) { duke@1: print(((TagletOutputImpl) duke@1: (new DeprecatedTaglet()).getTagletOutput(field, duke@1: writer.getTagletWriterInstance(false))).toString()); duke@1: } duke@1: duke@1: /** duke@1: * Write the description text for this member. duke@1: * duke@1: * @param field the field to document. duke@1: */ duke@1: public void writeMemberDescription(FieldDoc field) { duke@1: if (field.inlineTags().length > 0) { duke@1: writer.dd(); duke@1: writer.printInlineComment(field); duke@1: } duke@1: Tag[] tags = field.tags("serial"); duke@1: if (tags.length > 0) { duke@1: writer.dt(); duke@1: writer.dd(); duke@1: writer.printInlineComment(field, tags[0]); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Write the description text for this member represented by the tag. duke@1: * duke@1: * @param serialFieldTag the field to document (represented by tag). duke@1: */ duke@1: public void writeMemberDescription(SerialFieldTag serialFieldTag) { duke@1: writer.dd(); duke@1: writer.print(serialFieldTag.description()); duke@1: writer.dlEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Write the tag information for this member. duke@1: * duke@1: * @param field the field to document. duke@1: */ duke@1: public void writeMemberTags(FieldDoc field) { duke@1: writer.dl(); duke@1: TagletOutputImpl output = new TagletOutputImpl(""); duke@1: TagletWriter.genTagOuput(configuration().tagletManager, field, duke@1: configuration().tagletManager.getCustomTags(field), duke@1: writer.getTagletWriterInstance(false), output); duke@1: if (output.toString().length() > 0) { duke@1: print(output.toString()); duke@1: } duke@1: writer.dlEnd(); duke@1: } duke@1: public void writeMemberFooter(FieldDoc member) { duke@1: writer.dlEnd(); duke@1: } duke@1: }