private PropertyComment parse(final String systemId, final InputStream input) throws CommentException { try { final SAXBuilder parser = new SAXBuilder(); final Document document = parser.build(input, systemId); final PropertyComment.Builder builder = new PropertyComment.Builder(); final Element rootNode = document.getRootElement(); final String comment = rootNode.getChildTextNormalize("specification", PROPERTY_NS); final PropertyValueComment valueComment = parseValueComment(rootNode); builder.withText(comment).with(valueComment); return builder.build(); } catch (final JDOMException e) { throw new CommentException(systemId, e); } catch (final IOException e) { throw new CommentException(systemId, e); } }
private void handleItem(final PropertyReport report, final Class<?> type, final JavaMethod javaMethod) { if (!isPropertyMethod(javaMethod)) { return; } final PropertyMetaDataParser metaDataParser = PropertyMetaDataParser.createWithoutContextAccess(); final PropertyReportItem.Builder builder = new PropertyReportItem.Builder(); final PropertyDescriptor descriptor = readDescriptor(report, type, javaMethod, metaDataParser); builder.with(descriptor); final SourceInfo sourceInfo = new SourceInfo(type.getName(), javaMethod.getName(), javaMethod.getLineNumber()); builder.with(sourceInfo); final String commentText = javaMethod.getComment(); final PropertyValueComment valueComment = loadValueComment(report, descriptor); final PropertyComment comment = new PropertyComment.Builder().withText(commentText) .with(valueComment).build(); builder.with(comment); final PropertyReportItem item = builder.build(); report.handle(item); }
/** * Creates the report item. * * @return the report item. */ public PropertyReportItem build() { Arg.checkNotNull("descriptor", descriptor); if (comment == null) { comment = new PropertyComment.Builder().build(); } if (sourceInfo == null) { sourceInfo = SourceInfo.EMPTY; } return new PropertyReportItem(this); }
private void addPropertyValueComment(final PropertyProjectdoc projectdoc, final ParserContext context) { final PropertyComment.Builder builder = new PropertyComment.Builder(); final Document document = context.getDocument(); final Element rootNode = document.getRootElement(); final String specification = rootNode.getChildTextNormalize("specification", NS); final PropertyValueComment valueComment = parseValueComment(rootNode); builder.withText(specification).with(valueComment); final PropertyComment propertyComment = builder.build(); projectdoc.setComment(propertyComment); }