protected void process(ClassDoc clss) { writer.println(""); writer.println("## *" + clss.simpleTypeName() + "*"); writer.println(clss.commentText()); writer.println(""); if (clss.isEnum()) { for (FieldDoc field : clss.enumConstants()) { printEnumConstant(field); } writer.println(""); for (MethodDoc method : clss.methods(false)) { printMethod(method); } } else if (clss.isInterface()) { /* for (ClassDoc subClass : getDerivedClassessubclasses( clss )) { printSubClass(subClass); } */ } else { for (FieldDoc field : clss.fields(false)) { printField(field); } for (MethodDoc method : clss.methods(false)) { printMethod(method); } } }
protected void write(OutputStream o, ClassDoc clazz) throws ClassNotFoundException { String cname = mangleClassName(clazz.qualifiedName()); PrintWriter pw = wrapWriter(o); fields = clazz.fields(); methods = clazz.methods(); generateDeclsForClass(pw, clazz, cname); }
/** * Build the serial UID information for the given class. * * @param node the XML element that specifies which components to document * @param classTree content tree to which the serial UID information will be added */ public void buildSerialUIDInfo(XMLNode node, Content classTree) { Content serialUidTree = writer.getSerialUIDInfoHeader(); FieldDoc[] fields = currentClass.fields(false); for (int i = 0; i < fields.length; i++) { if (fields[i].name().equals("serialVersionUID") && fields[i].constantValueExpression() != null) { writer.addSerialUIDInfo( SERIAL_VERSION_UID_HEADER, fields[i].constantValueExpression(), serialUidTree); break; } } classTree.addContent(serialUidTree); }
private int doTwoWordFields( FieldDefsRes res, ClassDoc clazz, int offset, String cname, boolean padWord) throws ClassNotFoundException { boolean first = true; FieldDoc[] fields = clazz.fields(); for (int i = 0; i < fields.length; i++) { FieldDoc field = fields[i]; String tc = field.type().typeName(); boolean twoWords = (tc.equals("long") || tc.equals("double")); if (twoWords && doField(res, field, cname, first && padWord)) { offset += 8; first = false; } } return offset; }
protected FieldDefsRes fieldDefs(ClassDoc clazz, String cname, boolean bottomMost) throws ClassNotFoundException { FieldDefsRes res; int offset; boolean didTwoWordFields = false; ClassDoc superclazz = clazz.superclass(); if (superclazz != null) { String supername = superclazz.qualifiedName(); res = new FieldDefsRes(clazz, fieldDefs(superclazz, cname, false), bottomMost); offset = res.parent.byteSize; } else { res = new FieldDefsRes(clazz, null, bottomMost); offset = 0; } FieldDoc[] fields = clazz.fields(); for (int i = 0; i < fields.length; i++) { FieldDoc field = fields[i]; if (doubleAlign && !didTwoWordFields && (offset % 8) == 0) { offset = doTwoWordFields(res, clazz, offset, cname, false); didTwoWordFields = true; } String tc = field.type().typeName(); boolean twoWords = (tc.equals("long") || tc.equals("double")); if (!doubleAlign || !twoWords) { if (doField(res, field, cname, false)) offset += 4; } } if (doubleAlign && !didTwoWordFields) { if ((offset % 8) != 0) offset += 4; offset = doTwoWordFields(res, clazz, offset, cname, true); } res.byteSize = offset; return res; }
/** * Build the sorted list of all the deprecated APIs in this run. Build separate lists for * deprecated packages, classes, constructors, methods and fields. * * @param configuration the current configuration of the doclet. */ private void buildDeprecatedAPIInfo(Configuration configuration) { PackageDoc[] packages = configuration.packages; PackageDoc pkg; for (int c = 0; c < packages.length; c++) { pkg = packages[c]; if (Util.isDeprecated(pkg)) { getList(PACKAGE).add(pkg); } } ClassDoc[] classes = configuration.root.classes(); for (int i = 0; i < classes.length; i++) { ClassDoc cd = classes[i]; if (Util.isDeprecated(cd)) { if (cd.isOrdinaryClass()) { getList(CLASS).add(cd); } else if (cd.isInterface()) { getList(INTERFACE).add(cd); } else if (cd.isException()) { getList(EXCEPTION).add(cd); } else if (cd.isEnum()) { getList(ENUM).add(cd); } else if (cd.isError()) { getList(ERROR).add(cd); } else if (cd.isAnnotationType()) { getList(ANNOTATION_TYPE).add(cd); } } composeDeprecatedList(getList(FIELD), cd.fields()); composeDeprecatedList(getList(METHOD), cd.methods()); composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors()); if (cd.isEnum()) { composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants()); } if (cd.isAnnotationType()) { composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER), ((AnnotationTypeDoc) cd).elements()); } } sortDeprecatedLists(); }
/** * Parses the data for a class type definition * * @param docClass * @return */ protected static Class ParseClass(ClassDoc docClass) { assert (docClass != null); Class xmlClass = new Class(); // illegal use of this class. assert (xmlClass != null); xmlClass.name = docClass.name(); xmlClass.qualifiedName = docClass.qualifiedName(); xmlClass.isSerializable = docClass.isSerializable(); xmlClass.isExternalizable = docClass.isExternalizable(); xmlClass.isAbstract = docClass.isAbstract(); xmlClass.isException = docClass.isException(); xmlClass.isError = docClass.isError(); xmlClass.comment = docClass.commentText(); xmlClass.scope = DetermineScope(docClass); xmlClass.isIncluded = docClass.isIncluded(); xmlClass.typeVariables = ParseTypeVariables(docClass.typeParameters(), docClass.typeParamTags()); Type superClassType = docClass.superclassType(); if (superClassType != null) { xmlClass.superClass = ParseType(superClassType); } Type[] interfaces = docClass.interfaceTypes(); ArrayList<TypeInfo> interfaceTypeNames = new ArrayList<TypeInfo>(); if (interfaces != null && interfaces.length > 0) { for (Type interfaceType : interfaces) { interfaceTypeNames.add(ParseType(interfaceType)); } xmlClass.interfaces = interfaceTypeNames.toArray(new TypeInfo[] {}); } ConstructorDoc[] constructors = docClass.constructors(); if (constructors != null && constructors.length > 0) { ArrayList<Constructor> constructorList = new ArrayList<Constructor>(); for (ConstructorDoc constructor : constructors) { constructorList.add(ParseConstructor(constructor)); } xmlClass.constructors = constructorList.toArray(new Constructor[] {}); } else { log.debug("No constructors in class: " + docClass.name()); } MethodDoc[] methods = docClass.methods(); if (methods != null && methods.length > 0) { ArrayList<Method> methodList = new ArrayList<Method>(); for (MethodDoc method : methods) { methodList.add(ParseMethod(method)); } xmlClass.methods = methodList.toArray(new Method[] {}); } else { log.debug("No methods in class: " + docClass.name()); } FieldDoc[] fields = docClass.fields(); if (fields != null && fields.length > 0) { ArrayList<Field> fieldList = new ArrayList<Field>(); for (FieldDoc field : fields) { fieldList.add(ParseField(field)); } xmlClass.fields = fieldList.toArray(new Field[] {}); } xmlClass.annotationInstances = ParseAnnotationInstances(docClass.annotations(), docClass.qualifiedName()); return xmlClass; }
public static boolean start(RootDoc root) { ClassDoc cd = root.classes()[0]; FieldDoc fd = cd.fields()[0]; fd.firstSentenceTags(); return true; }