Wiki
Clone wikiXLIFF Toolkit / Unit
Working with Unit
The Unit class hold all objects stored in the <unit>
element. It is composed of a list of Part
and Segment
objects corresponding to the <ignorable>
and <segment>
elements. Note that the Segment
class is derived from Part
, so when needed you can process all components of the unit as parts.
The following code shows how to loop through all the parts (segments and ignorables) of a unit:
#!java for ( Part part : unit ) { if ( part.isSegment() { // It's a segment Segment segment = (Segment)part; String state = segment.getState(); Fragment fragment = segment.getSource(); // Do something... } else { // It's not a segment: do something else... Fragment source = part.getSource(); } }
To loop through only the the segments use the getSegments()
method:
#!java for ( segment segment : unit.getSegments() ) { Fragment source = segment.getSource(); // Do something... }
Updated