public void processLink(Locator locator, String href) { if ((locator.getDocumentOffset() < offset) || (locator.getDocumentOffset() >= (offset + length))) { return; } if (href.length() > 0 && href.charAt(0) == '#') { if (references == null) { references = new ArrayList<LocalReference>(); } String name = href.substring(1); int length = locator.getLineSegmentEndOffset() - locator.getLineCharacterOffset(); references.add(new LocalReference(name, locator.getDocumentOffset(), length)); } } }
@Override public void beginHeading(int level, Attributes attributes) { this.level = level; this.attributes = attributes; buf = new StringBuilder(); offset = getLocator().getDocumentOffset(); length = getLocator().getLineLength(); }
@Override public void endDocument() { if (currentBlock != outerBlock) { throw new IllegalStateException(); } Locator locator = getLocator(); outerBlock.setLength((locator == null ? 0 : locator.getDocumentOffset()) + offset); partitions = new ArrayList<MarkupPartition>(); // here we flatten our hierarchy of blocks into partitions for (Segment<?> child : outerBlock.getChildren().asList()) { createRegions(null, child); } }
public LocatorImpl(Locator other) { documentOffset = other.getDocumentOffset(); lineCharacterOffset = other.getLineCharacterOffset(); lineDocumentOffset = other.getLineDocumentOffset(); lineLength = other.getLineLength(); lineNumber = other.getLineNumber(); lineSegmentEndOffset = other.getLineSegmentEndOffset(); }
@Override public void beginBlock(BlockType type, Attributes attributes) { final int newBlockOffset = getLocator().getDocumentOffset() + offset; Block newBlock = new Block(type, attributes, newBlockOffset, currentBlock.getLength() - (newBlockOffset - currentBlock.getOffset())); newBlock.setSpansComputed(!blocksOnly); currentBlock.add(newBlock); currentBlock = newBlock; }
@Override public void beginHeading(int level, Attributes attributes) { final int newBlockOffset = getLocator().getDocumentOffset() + offset; Block newBlock = new Block(level, attributes, newBlockOffset, currentBlock.getLength() - (newBlockOffset - currentBlock.getOffset())); newBlock.setSpansComputed(!blocksOnly); currentBlock.add(newBlock); currentBlock = newBlock; }
@Override public void beginSpan(SpanType type, Attributes attributes) { Span span = new Span(type, attributes, getLocator().getDocumentOffset() + offset, getLocator().getLineSegmentEndOffset() - getLocator().getLineCharacterOffset()); if (currentSpan != null) { currentSpan.add(span); currentSpan = span; } else { currentSpan = span; currentBlock.add(span); } }