use of com.sun.javadoc.FieldDoc in project checkstyle by checkstyle.
the class TokenTypesDoclet method start.
/**
* The doclet's starter method.
* @param root {@code RootDoc} given to the doclet
* @return true if the given {@code RootDoc} is processed.
* @exception FileNotFoundException will be thrown if the doclet
* will be unable to write to the specified file.
*/
public static boolean start(RootDoc root) throws FileNotFoundException {
final String fileName = getDestFileName(root.options());
final FileOutputStream fos = new FileOutputStream(fileName);
final Writer osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
final PrintWriter writer = new PrintWriter(osw, false);
try {
final ClassDoc[] classes = root.classes();
final FieldDoc[] fields = classes[0].fields();
for (final FieldDoc field : fields) {
if (field.isStatic() && field.isPublic() && field.isFinal() && "int".equals(field.type().qualifiedTypeName())) {
if (field.firstSentenceTags().length != 1) {
final String message = "Should be only one tag.";
throw new IllegalArgumentException(message);
}
writer.println(field.name() + "=" + field.firstSentenceTags()[0].text());
}
}
} finally {
writer.close();
}
return true;
}
use of com.sun.javadoc.FieldDoc in project zm-mailbox by Zimbra.
the class DocletApiListener method processClass.
private void processClass(ClassDoc classDoc) {
ApiClassDocumentation doc = new ApiClassDocumentation();
processClassTags(doc, classDoc.tags());
for (FieldDoc fieldDoc : classDoc.fields()) {
processFieldTags(doc, fieldDoc);
}
for (MethodDoc methodDoc : classDoc.methods()) {
processMethodTags(doc, methodDoc);
}
if (doc.hasDocumentation()) {
docMap.put(classDoc.toString(), doc);
}
}
use of com.sun.javadoc.FieldDoc in project RESTdoclet by IG-Group.
the class DocTypeUtils method getEnumDoc.
/**
* Return the documentation for an enum type
*
* @param type
* @return
*/
private static String getEnumDoc(final Type type) {
String typeInfo = "";
if (type.asClassDoc() != null) {
FieldDoc[] enumConstants = type.asClassDoc().enumConstants();
for (FieldDoc constant : enumConstants) {
typeInfo += "<TR>";
typeInfo += "<TD>" + constant.name() + "</TD>";
typeInfo += "<TD>" + constant.commentText() + "</TD>";
typeInfo += "</TR>";
}
}
return typeInfo;
}
use of com.sun.javadoc.FieldDoc in project RESTdoclet by IG-Group.
the class DocTypeUtils method getPublicConstantDoc.
/**
* Return the documentation for a public constant
*
* @param type
* @return
*/
private static String getPublicConstantDoc(final Type type) {
String typeInfo = "";
FieldDoc[] fields = type.asClassDoc().fields(false);
for (FieldDoc field : fields) {
if (field.isPublic() && field.isFinal() && StringUtils.equals(field.name(), field.name().toUpperCase())) {
typeInfo += "<tr><td>" + field.type().simpleTypeName() + " " + field.name() + "</td><td>" + field.commentText() + "</td></tr>";
}
}
return typeInfo;
}
use of com.sun.javadoc.FieldDoc in project RESTdoclet by IG-Group.
the class DocletUtils method getPublicFields.
/**
* Return a list of all fields that have a public getter
*
* @param classDoc class documentation
* @return list of all fields that have a public getter
*/
public static Collection<FieldParameter> getPublicFields(final ClassDoc classDoc) {
ArrayList<FieldParameter> fields = new ArrayList<FieldParameter>();
MethodDoc[] methods = classDoc.methods();
for (FieldDoc fieldDoc : classDoc.fields(false)) {
boolean found = false;
for (MethodDoc md : methods) {
if (md.name().equalsIgnoreCase(GETTER_PREFIX + fieldDoc.name())) {
found = true;
}
}
if (found) {
fields.add(new FieldParameterBuilder().build(new FieldParameter(), fieldDoc));
}
}
return fields;
}
Aggregations