void emitOffsetMapping() { if (textOffsetRange.length() == 0 && sourceOffsetRange.length() == 0) { return; } if (LOG.isLoggable(Level.FINER)) { LOG.finer( "New offset mapping: text = " + textOffsetRange + "==> source += " + sourceOffsetRange); } for (XMLTransformerModule<T> m : modules) { m.offsetMapping(this, textOffsetRange, sourceOffsetRange); } }
void mapOffsetDelta(long addToText, long addToSource) { if (addToText == 0 && addToSource == 0) { return; } if (LOG.isLoggable(Level.FINER)) { LOG.finer("Moving offsets: text += " + addToText + "; source += " + addToSource); } final long textOffsetRangeLength = textOffsetRange.length(); final long sourceOffsetRangeLength = sourceOffsetRange.length(); if (addToText == 0 && textOffsetRangeLength == 0) { sourceOffsetRange = new TextRange(sourceOffsetRange.getStart(), sourceOffsetRange.getEnd() + addToSource); } else if (addToSource == 0 && sourceOffsetRangeLength == 0) { textOffsetRange = new TextRange(textOffsetRange.getStart(), textOffsetRange.getEnd() + addToText); } else if (textOffsetRangeLength == sourceOffsetRangeLength && addToText == addToSource) { sourceOffsetRange = new TextRange(sourceOffsetRange.getStart(), sourceOffsetRange.getEnd() + addToSource); textOffsetRange = new TextRange(textOffsetRange.getStart(), textOffsetRange.getEnd() + addToText); } else { emitOffsetMapping(); sourceOffsetRange = new TextRange(sourceOffsetRange.getEnd(), sourceOffsetRange.getEnd() + addToSource); textOffsetRange = new TextRange(textOffsetRange.getEnd(), textOffsetRange.getEnd() + addToText); } this.textOffset += addToText; this.sourceOffset += addToSource; }