throw new IllegalStateException("Text pieces table is empty"); if (_textPiecesFCOrder.get(0).getPieceDescriptor().getFilePosition() > startBytePos) return _textPiecesFCOrder.get(0).getPieceDescriptor().getFilePosition(); .getPieceDescriptor().getFilePosition() <= startBytePos) return startBytePos; int mid = (low + high) >>> 1; final TextPiece textPiece = _textPiecesFCOrder.get(mid); int midVal = textPiece.getPieceDescriptor().getFilePosition(); else return textPiece.getPieceDescriptor().getFilePosition(); .getFilePosition() < startBytePos; .getFilePosition() > startBytePos; return _textPiecesFCOrder.get(low + 1).getPieceDescriptor().getFilePosition();
@Override public String toString() { return "PieceDescriptor (pos: " + getFilePosition() + "; " + ( isUnicode() ? "unicode" : "non-unicode" ) + "; prm: " + getPrm() + ")"; } }
throw new IllegalStateException( "Text pieces table is empty" ); if ( _textPiecesFCOrder.get( 0 ).getPieceDescriptor().getFilePosition() > startBytePos ) return _textPiecesFCOrder.get( 0 ).getPieceDescriptor().getFilePosition(); .getPieceDescriptor().getFilePosition() <= startBytePos ) return startBytePos; int midVal = textPiece.getPieceDescriptor().getFilePosition(); else return textPiece.getPieceDescriptor().getFilePosition(); .getFilePosition() < startBytePos; .getFilePosition() > startBytePos; return _textPiecesFCOrder.get( low + 1 ).getPieceDescriptor().getFilePosition();
@Override public String toString() { return "PieceDescriptor (pos: " + getFilePosition() + "; " + (isUnicode() ? "unicode" : "non-unicode") + "; prm: " + getPrm() + ")"; } }
public boolean isIndexInTable(int bytePos) { for (TextPiece tp : _textPiecesFCOrder) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); if (bytePos > pieceStart + tp.bytesLength()) { continue; } if (pieceStart > bytePos) { return false; } return true; } return false; }
boolean isIndexInTable(int startBytePos, int endBytePos) { for (TextPiece tp : _textPiecesFCOrder) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); if (startBytePos >= pieceStart + tp.bytesLength()) { continue; } int left = Math.max(startBytePos, pieceStart); int right = Math.min(endBytePos, pieceStart + tp.bytesLength()); if (left >= right) return false; return true; } return false; }
boolean isIndexInTable( int startBytePos, int endBytePos ) { for ( TextPiece tp : _textPiecesFCOrder ) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); if ( startBytePos >= pieceStart + tp.bytesLength() ) { continue; } int left = Math.max( startBytePos, pieceStart ); int right = Math.min( endBytePos, pieceStart + tp.bytesLength() ); if ( left >= right ) return false; return true; } return false; }
public boolean isIndexInTable( int bytePos ) { for ( TextPiece tp : _textPiecesFCOrder ) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); if ( bytePos > pieceStart + tp.bytesLength() ) { continue; } if ( pieceStart > bytePos ) { return false; } return true; } return false; }
public int[][] getCharIndexRanges( int startBytePosInclusive, int endBytePosExclusive ) { List<int[]> result = new LinkedList<int[]>(); for ( TextPiece textPiece : _textPiecesFCOrder ) { final int tpStart = textPiece.getPieceDescriptor() .getFilePosition(); final int tpEnd = textPiece.getPieceDescriptor().getFilePosition() + textPiece.bytesLength(); if ( startBytePosInclusive > tpEnd ) continue; if ( endBytePosExclusive < tpStart ) break; final int rangeStartBytes = Math.max( tpStart, startBytePosInclusive ); final int rangeEndBytes = Math.min( tpEnd, endBytePosExclusive ); final int rangeLengthBytes = rangeEndBytes - rangeStartBytes; if ( rangeStartBytes > rangeEndBytes ) continue; final int encodingMultiplier = textPiece.isUnicode() ? 2 : 1; final int rangeStartCp = textPiece.getStart() + ( rangeStartBytes - tpStart ) / encodingMultiplier; final int rangeEndCp = rangeStartCp + rangeLengthBytes / encodingMultiplier; result.add( new int[] { rangeStartCp, rangeEndCp } ); } return result.toArray( new int[result.size()][] ); }
@Override public int[][] getCharIndexRanges(int startBytePosInclusive, int endBytePosExclusive) { List<int[]> result = new LinkedList<>(); for (TextPiece textPiece : _textPiecesFCOrder) { final int tpStart = textPiece.getPieceDescriptor() .getFilePosition(); final int tpEnd = textPiece.getPieceDescriptor().getFilePosition() + textPiece.bytesLength(); if (startBytePosInclusive > tpEnd) continue; if (endBytePosExclusive <= tpStart) break; final int rangeStartBytes = Math.max(tpStart, startBytePosInclusive); final int rangeEndBytes = Math.min(tpEnd, endBytePosExclusive); final int rangeLengthBytes = rangeEndBytes - rangeStartBytes; if (rangeStartBytes > rangeEndBytes) continue; final int encodingMultiplier = getEncodingMultiplier(textPiece); final int rangeStartCp = textPiece.getStart() + (rangeStartBytes - tpStart) / encodingMultiplier; final int rangeEndCp = rangeStartCp + rangeLengthBytes / encodingMultiplier; result.add(new int[]{rangeStartCp, rangeEndCp}); } return result.toArray(new int[result.size()][]); }
public int lookIndexBackward(final int startBytePos) { int bytePos = startBytePos; int lastEnd = 0; for (TextPiece tp : _textPiecesFCOrder) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); if (bytePos > pieceStart + tp.bytesLength()) { lastEnd = pieceStart + tp.bytesLength(); continue; } if (pieceStart > bytePos) { bytePos = lastEnd; } break; } return bytePos; }
public int lookIndexBackward( final int startBytePos ) { int bytePos = startBytePos; int lastEnd = 0; for ( TextPiece tp : _textPiecesFCOrder ) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); if ( bytePos > pieceStart + tp.bytesLength() ) { lastEnd = pieceStart + tp.bytesLength(); continue; } if ( pieceStart > bytePos ) { bytePos = lastEnd; } break; } return bytePos; }
@Deprecated public int getCharIndex(int startBytePos, int startCP) { int charCount = 0; int bytePos = lookIndexForward(startBytePos); for (TextPiece tp : _textPieces) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); int bytesLength = tp.bytesLength(); int pieceEnd = pieceStart + bytesLength; int toAdd; if (bytePos < pieceStart || bytePos > pieceEnd) { toAdd = bytesLength; } else if (bytePos > pieceStart && bytePos < pieceEnd) { toAdd = (bytePos - pieceStart); } else { toAdd = bytesLength - (pieceEnd - bytePos); } if (tp.isUnicode()) { charCount += toAdd / 2; } else { charCount += toAdd; } if (bytePos >= pieceStart && bytePos <= pieceEnd && charCount >= startCP) { break; } } return charCount; }
_cpMin = pieces[0].getFilePosition() - fcMin; for (PieceDescriptor piece : pieces) { int start = piece.getFilePosition() - fcMin; if (start < _cpMin) { _cpMin = start; int start = pieces[x].getFilePosition(); GenericPropertyNode node = pieceTable.getProperty(x);
_cpMin = pieces[0].getFilePosition() - fcMin; for (PieceDescriptor piece : pieces) { int start = piece.getFilePosition() - fcMin; if (start < _cpMin) { _cpMin = start; int start = pieces[x].getFilePosition(); GenericPropertyNode node = pieceTable.getProperty(x);
int pieceStart = tp.getPieceDescriptor().getFilePosition();
_cpMin = pieces[0].getFilePosition() - fcMin; for ( int x = 0; x < pieces.length; x++ ) int start = pieces[x].getFilePosition() - fcMin; if ( start < _cpMin ) int start = pieces[x].getFilePosition(); GenericPropertyNode node = pieceTable.getProperty( x );
public int getByteIndex(int charPos) { int byteCount = 0; for (TextPiece tp : _textPieces) { if (charPos >= tp.getEnd()) { byteCount = tp.getPieceDescriptor().getFilePosition() + (tp.getEnd() - tp.getStart()) * (tp.isUnicode() ? 2 : 1); if (charPos == tp.getEnd()) break; continue; } if (charPos < tp.getEnd()) { int left = charPos - tp.getStart(); byteCount = tp.getPieceDescriptor().getFilePosition() + left * (tp.isUnicode() ? 2 : 1); break; } } return byteCount; }
public int getByteIndex( int charPos ) { int byteCount = 0; for ( TextPiece tp : _textPieces ) { if ( charPos >= tp.getEnd() ) { byteCount = tp.getPieceDescriptor().getFilePosition() + ( tp.getEnd() - tp.getStart() ) * ( tp.isUnicode() ? 2 : 1 ); if ( charPos == tp.getEnd() ) break; continue; } if ( charPos < tp.getEnd() ) { int left = charPos - tp.getStart(); byteCount = tp.getPieceDescriptor().getFilePosition() + left * ( tp.isUnicode() ? 2 : 1 ); break; } } return byteCount; }