# Class: com.pnfsoftware.jeb.core.output.text.TextPartUtil

Class containing utility methods to operate on parts of text documents.

## Constructor: TextPartUtil


## Static Method: buildRawTextFromPart
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `java.lang.String`

Description: Build the textual representation of a part.
parameter: part: the part
return: a string

## Static Method: buildRawTextFromPartInterruptibly
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `java.lang.String`

Description: Build the textual representation of a part. This routine throws [InterruptedException](InterruptedException) if the executing thread is interrupted.
parameter: part: the part
return: a string
throws: if the executing thread is interrupted.

## Static Method: coordinatesToLineIndex
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `coord`, type: `com.pnfsoftware.jeb.core.output.text.ICoordinates`
- return type: `int`

Description: Compute the part\-relative index of a line given its coordinates.
parameter: part: the part
parameter: coord: some coordinates
return: the line index, or \-1 if the provided coordinates are outside the part or cannot be         mapped to text located in the part

## Static Method: getAnchorAtLine
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `lineIndex`, type: `int`
- return type: `com.pnfsoftware.jeb.core.output.text.IAnchor`

Description: Retrieve the document anchor at the provided line.
parameter: lineIndex: a line index within the part
return: the closest anchor or null

## Static Method: getAnchorById
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `anchorId`, type: `long`
- return type: `com.pnfsoftware.jeb.core.output.text.IAnchor`

Description: Get the anchor that has the **exact** provided id.
parameter: part: the part
parameter: anchorId: the anchor identifier
return: the anchor whose id is the provided `"anchor id"`, or null

## Static Method: getApproximateAnchorById
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `anchorId`, type: `long`
- parameter: `mode`, type: `int`
- return type: `com.pnfsoftware.jeb.core.output.text.IAnchor`

Description: Get the anchor that has the provided id, or if none is found, one if its neighbor \(not necessarily the closest neighbor\). The neighbor is determined by the \`mode\` parameter.
parameter: part: the part
parameter: anchorId: the requested anchor identifier
parameter: mode: in effect only if no exact anchor was found \- 0= nearest neighbor; 1= the right            nearest neighbor; \-1: the left nearest neighbor
return: the proximity anchor, null if no suitable anchor was found \(eg, going out of bound\)

## Static Method: getFirstAnchor
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `com.pnfsoftware.jeb.core.output.text.IAnchor`

Description: Determine the first anchor of the provided part.
parameter: part: a part
return: the first anchor, null on error

## Static Method: getFirstAnchorId
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `long`

Description: Determine the id of the first anchor of the provided part.
parameter: part: a part
return: the id, \-1 on error

## Static Method: getItemAt
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `lineIndex`, type: `int`
- parameter: `offset`, type: `int`
- return type: `com.pnfsoftware.jeb.core.output.text.ITextItem`

Description: Get the item at the given offset of the given line.
parameter: part: the part
parameter: lineIndex: a line index within the part
parameter: offset: an offset that belongs to the item
return: the item, null on error

## Static Method: getItemAt
- parameter: `line`, type: `com.pnfsoftware.jeb.core.output.text.ILine`
- parameter: `offset`, type: `int`
- return type: `com.pnfsoftware.jeb.core.output.text.ITextItem`

Description: Get the item at the given offset of the given line.
parameter: line: part line object
parameter: offset: an offset that belongs to the item
return: the item, null on error

## Static Method: getItems
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `java.util.List<com.pnfsoftware.jeb.core.output.text.ITextItem>`

Description: Retrieve all items of a part.
parameter: part: 
return: 

## Static Method: getLastAnchor
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `com.pnfsoftware.jeb.core.output.text.IAnchor`

Description: Determine the last **inclusive** anchor of the provided part. The returned anchor is guaranteed to reference lines that are in the document part.
parameter: part: a part
return: the last anchor, null on error

## Static Method: getLastAnchorId
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `long`

Description: Determine the id of the last anchor of the provided part.
parameter: part: a part
return: the id, \-1 on error

## Static Method: getLineAt
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `coord`, type: `com.pnfsoftware.jeb.core.output.text.ICoordinates`
- return type: `com.pnfsoftware.jeb.core.output.text.ILine`


## Static Method: getLinesOfAnchor
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `anchorId`, type: `long`
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.output.text.ILine>`

Description: Get the lines that belong to a specific anchor of a text part.
parameter: part: the part
parameter: anchorId: the anchor
return: a list of part lines, null on error

## Static Method: getNearestAnchorById
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `anchorId`, type: `long`
- return type: `com.pnfsoftware.jeb.core.output.text.IAnchor`

Description: Get the anchor that has the **closest** id to the requested id. 

 Note: usual integer distance calculation takes place.
parameter: part: the part
parameter: anchorId: the requested anchor identifier
return: the closest anchor \(may be exact, before, or after the requested one\)

## Static Method: getNextAnchorId
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `long`

Description: Determine the id of the first anchor of the next \(contiguous, possibly virtual\) part.
parameter: part: the current part
return: the *next* anchor id, \-1 on error

## Static Method: getObjectsAt
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `lineIndex`, type: `int`
- parameter: `columnOffset`, type: `int`
- return type: `java.util.List<java.lang.Object>`

Description: Retrieve the list of objects whose representations fall onto the provided coordinates, within a part.  Note that objects and their locations are provided by the optional method [ITextDocumentPart#getObjectLocations()](ITextDocumentPart#getObjectLocations()). This method will return an empty list if nothing was provided in the first place.
parameter: part: 
parameter: lineIndex: 
parameter: columnOffset: 
return: 

## Static Method: isAnchorDisplayed
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `anchorId`, type: `long`
- return type: `boolean`


## Static Method: isInsidePart
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- parameter: `coord`, type: `com.pnfsoftware.jeb.core.output.text.ICoordinates`
- return type: `boolean`

Description: Determine if the provided coordinates are inside a document part.
parameter: part: a part
parameter: coord: some text coordinates
return: true if the coordinates are included within the part

## Static Method: iterateLines
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`
- return type: `java.lang.Iterable<com.pnfsoftware.jeb.core.output.text.TextPartUtil.LineInfo>`

Description: Generate an `iterable` object for easy iteration over the lines \(and their associated anchor id, and line numbers\) of a part. Easy to use in a for\-loop.
parameter: part: a part
return: an iterable providing [LineInfo](LineInfo) objects

## Static Method: verifyPart
- parameter: `part`, type: `com.pnfsoftware.jeb.core.output.text.ITextDocumentPart`

Description: Verify the partial correctness of a part. A correct part will pass this test; however, passing this test does not mean the part is correct.
parameter: part: the part to be tested

