/** * Returns a list of all {@linkplain StartTag start tags} in this source document. * <p> * Calling this method on the <code>Source</code> object performs a {@linkplain #fullSequentialParse() full sequential parse} automatically. * <p> * See the {@link Tag} class documentation for more details about the behaviour of this method. * * @return a list of all {@linkplain StartTag start tags} in this source document. */ public List<StartTag> getAllStartTags() { if (allStartTags==null) { final List<Tag> allTags=getAllTags(); allStartTags=new ArrayList<StartTag>(allTags.size()); for (Tag tag : allTags) if (tag instanceof StartTag) allStartTags.add((StartTag)tag); } return allStartTags; }
sourceHtml.setLogger(null); sourceHtml.fullSequentialParse(); List<Tag> tags = sourceHtml.getAllTags();
List<Tag> tags1 = source1.getAllTags(); List<Tag> tags2 = source2.getAllTags();
@Override public String filter(String source, Map<String, Object> properties) { Source sourceHtml = new Source(source); sourceHtml.setLogger(null); sourceHtml.fullSequentialParse(); OutputDocument outputDocument = new OutputDocument(sourceHtml); List<Tag> tags = sourceHtml.getAllTags(); int pos = 0; for (Tag tag : tags) { boolean correctAndAllowedTag = processTag(tag, outputDocument); if (!correctAndAllowedTag) { String elementName = tag.getName().toLowerCase(); if (removedTags.contains(elementName) || allowedTags.contains(elementName)) { outputDocument.remove(tag); } else { outputDocument.replace(tag, StringEscapeUtils.escapeHtml(tag.toString())); } } reencodeTextSegment(sourceHtml, outputDocument, pos, tag.getBegin()); pos = tag.getEnd(); } reencodeTextSegment(sourceHtml, outputDocument, pos, sourceHtml.getEnd()); return correctNewLineSigns(outputDocument.toString(), properties); }