/** * Appends the constant value of the field (if the field is a constant). * * @param buffer the buffer to append to. * @param fieldDoc the access to the constant value. */ private static void appendConstantValue( final StringBuilder buffer, final FieldDoc fieldDoc) { final Object value = fieldDoc.constantValue(); if (value != null) { buffer.append(value); } }
... private Content getValue(FieldDoc member) { Content valueContent; if ("char".equals(member.type().toString())) { valueContent = new StringContent("'" + (char) ((Integer) member.constantValue()).intValue() + "'" ); } else { valueContent = new StringContent(member.constantValueExpression()); } Content code = HtmlTree.CODE(valueContent); return HtmlTree.TD(HtmlStyle.colLast, code); } ...
/** * Return the list of visible constant fields for the given classdoc. * @param cd the classdoc to examine. * @return the list of visible constant fields for the given classdoc. */ protected List<FieldDoc> members() { List<ProgramElementDoc> l = visibleMemberMapFields.getLeafClassMembers(configuration); l.addAll(visibleMemberMapEnumConst.getLeafClassMembers(configuration)); Iterator<ProgramElementDoc> iter; if(l != null){ iter = l.iterator(); } else { return null; } List<FieldDoc> inclList = new LinkedList<FieldDoc>(); FieldDoc member; while(iter.hasNext()){ member = (FieldDoc)iter.next(); if(member.constantValue() != null){ inclList.add(member); } } return inclList; } }
/** * {@inheritDoc} */ public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) { FieldDoc field = getFieldDoc( writer.configuration(), tag, tag.text()); if (field == null) { //Reference is unknown. writer.getMsgRetriever().warning(tag.holder().position(), "doclet.value_tag_invalid_reference", tag.text()); } else if (field.constantValue() != null) { return writer.valueTagOutput(field, Util.escapeHtmlChars(field.constantValueExpression()), ! field.equals(tag.holder())); } else { //Referenced field is not a constant. writer.getMsgRetriever().warning(tag.holder().position(), "doclet.value_tag_invalid_constant", field.name()); } return writer.getOutputInstance(); } }
/** * Return the list of visible constant fields for the given classdoc. * @return the list of visible constant fields for the given classdoc. */ protected List<FieldDoc> members() { List<ProgramElementDoc> l = visibleMemberMapFields.getLeafClassMembers(configuration); l.addAll(visibleMemberMapEnumConst.getLeafClassMembers(configuration)); Iterator<ProgramElementDoc> iter; if(l != null){ iter = l.iterator(); } else { return null; } List<FieldDoc> inclList = new LinkedList<FieldDoc>(); FieldDoc member; while(iter.hasNext()){ member = (FieldDoc)iter.next(); if(member.constantValue() != null){ inclList.add(member); } } return inclList; } }
/** * {@inheritDoc} */ public Content getTagletOutput(Tag tag, TagletWriter writer) { FieldDoc field = getFieldDoc( writer.configuration(), tag, tag.text()); if (field == null) { if (tag.text().isEmpty()) { //Invalid use of @value writer.getMsgRetriever().warning(tag.holder().position(), "doclet.value_tag_invalid_use"); } else { //Reference is unknown. writer.getMsgRetriever().warning(tag.holder().position(), "doclet.value_tag_invalid_reference", tag.text()); } } else if (field.constantValue() != null) { return writer.valueTagOutput(field, field.constantValueExpression(), ! field.equals(tag.holder())); } else { //Referenced field is not a constant. writer.getMsgRetriever().warning(tag.holder().position(), "doclet.value_tag_invalid_constant", field.name()); } return writer.getOutputInstance(); } }
private static Entry<String, String> createParameterRow(FieldDoc field) { Tag[] tags = field.tags("@" + ConfigurationParameters.NAME); if (tags.length == 0) { return null; } String name = wrapWithTag("td", field.constantValue(), "padding-right: 20px"); String desc = wrapWithTag("td", field.commentText(), "padding-right: 20px"); StringBuilder defaultValues = new StringBuilder(""); for (Tag tag : tags) { defaultValues.append(tag.text()); defaultValues.append("<br />"); } String values = wrapWithTag("td", defaultValues.toString(), null); String row = wrapWithTag("tr", name + desc + values, null); return new AbstractMap.SimpleEntry<>(field.constantValue().toString(), row); }
private static List<String> createResourceItem(FieldDoc field) { Tag[] tags = field.tags("@" + ExternalResources.NAME); if (tags.length == 0) { return Collections.emptyList(); } List<String> ret = new ArrayList<>(); String pkg = field.containingPackage().name(); int levels = pkg.length() - pkg.replaceAll("\\.", "").length() + 1; StringBuilder linkLevels = new StringBuilder(""); for (int i = 0; i < levels; i++) { linkLevels.append("../"); } for (Tag tag : tags) { ret.add( "<a href=\"" + linkLevels.toString() + tag.text().replaceAll("\\.", "/") + ".html\">" + tag.text() + "</a> (key = " + field.constantValue() + ")"); } return ret; }
Object cv = ((FieldDoc) doc).constantValue(); if (cv == null) { rootDoc.printError(
if (fd.isEnumConstant()) return fd.name(); Object cv = fd.constantValue(); if (cv == null) { rootDoc.printError(
if( holder.isField() && ((FieldDoc) holder).constantValue() != null && htmlWriter instanceof ClassWriterImpl )
if (holder.isField() && ((FieldDoc)holder).constantValue() != null && htmlWriter instanceof ClassWriterImpl) {