本文整理匯總了Java中com.sun.javadoc.FieldDoc.isStatic方法的典型用法代碼示例。如果您正苦於以下問題:Java FieldDoc.isStatic方法的具體用法?Java FieldDoc.isStatic怎麽用?Java FieldDoc.isStatic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.javadoc.FieldDoc
的用法示例。
在下文中一共展示了FieldDoc.isStatic方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GroupDefDoc
import com.sun.javadoc.FieldDoc; //導入方法依賴的package包/類
public GroupDefDoc(ClassDoc doc) {
this.classDoc = doc;
this.name = DocAnnotationDoclet.getNameAnnotation(classDoc.annotations(), classDoc.simpleTypeName());
this.className = classDoc.qualifiedName();
// fields
fields = new ArrayList<>();
for (FieldDoc field : getFields(classDoc)) {
if (field.isStatic()) {
continue;
}
String fieldName = DocAnnotationDoclet.getNameAnnotation(field.annotations(), field.name());
fields.add(new FieldDefDoc(fieldName, field));
}
}
示例2: start
import com.sun.javadoc.FieldDoc; //導入方法依賴的package包/類
/**
* 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())) {
final String firstSentence;
if (field.firstSentenceTags().length == 1) {
firstSentence = field.firstSentenceTags()[0].text();
}
else if (Arrays.stream(field.firstSentenceTags())
.filter(tag -> !"Text".equals(tag.name())).count() == 1) {
// We have to filter "Text" tags because of jdk parsing bug
// till JDK-8186270
firstSentence = field.firstSentenceTags()[0].text()
+ "<code>"
+ field.firstSentenceTags()[1].text()
+ "</code>"
+ field.firstSentenceTags()[2].text();
}
else {
final List<Tag> tags = Arrays.asList(field.firstSentenceTags());
final String joinedTags = tags
.stream()
.map(Tag::toString)
.collect(Collectors.joining("\", \"", "[\"", "\"]"));
final String message = String.format(Locale.ROOT,
"Should be only one tag for %s. Tags %s.",
field.toString(), joinedTags);
throw new IllegalArgumentException(message);
}
writer.println(field.name() + "=" + firstSentence);
}
}
}
finally {
writer.close();
}
return true;
}
示例3: makeMemberInfo
import com.sun.javadoc.FieldDoc; //導入方法依賴的package包/類
/**
* Convert a javadoc object of a class field into an object of my MemberInfo class.
* If the field is a constant, its value is read and serialized into JSON format.
* The JSON object is attached to the returned MemberInfo.
* @param errInfo
* @param field
* @param errorContext
* @return MemberInfo object
* @throws GeneratorException
*/
private MemberInfo makeMemberInfo(ErrorInfo errInfo, FieldDoc field, String errorContext) throws GeneratorException {
errInfo = errInfo.copy();
String name = field.name();
if (FORBIDDEN_FIELD_AND_METHOD_NAMES.contains(name)) {
errInfo.fieldName = name;
errInfo.msg = "Forbidden field name";
throw new GeneratorException(errInfo);
}
ArrayList<CommentInfo> cinfos = new ArrayList<CommentInfo>();
addSummaryAndRemarksCommentInfo(field, cinfos);
errInfo.fieldName = name;
TypeInfo type = makeElementTypeInfo(errInfo, field.type(), errorContext + "." + name);
long since = getSince(errInfo, field.tags());
// Constant or Enum?
String value = null;
if (((field.isFinal() && field.isStatic()) || field.isEnumConstant())) {
ClassDoc cls = field.containingClass();
TypeInfo ctype = new TypeInfo(cls.name(), cls.qualifiedName(), "", null, field.isEnumConstant(), false, false);
Object valueObj = classDB.fieldReader.getValue(ctype, name);
if (valueObj != null) {
if (field.isEnumConstant()) {
Enum<?> en = (Enum<?>)valueObj;
value = Integer.toString(en.ordinal());
}
else {
value = serializeObjectToJson(errInfo, valueObj);
}
}
else if (type.isStringType() && type.dims.length() == 0) {
value = "";
}
}
MemberInfo minfo = new MemberInfo(name, cinfos, type,
field.isPublic(), field.isProtected(), field.isPackagePrivate(), field.isPrivate(),
field.isFinal(), field.isStatic(), field.isTransient(),
since, value);
return minfo;
}