public class AlignedSegments extends Object implements IAlignedSegments
Currently tightly coupled to ITextUnit.
| Constructor and Description |
|---|
AlignedSegments(ITextUnit parent) |
| Modifier and Type | Method and Description |
|---|---|
void |
align(List<AlignedPair> alignedSegmentPairs,
LocaleId trgLoc)
Aligns all the segments listed in the aligned pairs for given locale.
|
void |
align(LocaleId trgLoc)
Force one to one alignment.
|
void |
alignCollapseAll(LocaleId trgLoc)
Aligns all the segments for the specified sources and targets by
collapsing all segments into one.
|
void |
append(Segment srcSeg,
Segment trgSeg,
LocaleId trgLoc)
Adds given source and target segments to the end of the content.
|
AlignmentStatus |
getAlignmentStatus()
Gets the status of the alignment for this entire text unit.
|
AlignmentStatus |
getAlignmentStatus(LocaleId trgLoc)
Gets the status of the alignment the given target locale in this text
unit.
|
Segment |
getCorrespondingSource(Segment trgSeg,
LocaleId trgLoc)
Gets the source segment corresponding to a given target segment
|
Segment |
getCorrespondingTarget(Segment srcSeg,
LocaleId trgLoc)
Gets the target segment corresponding to a given source segment
|
ITextUnit |
getParent() |
Segment |
getSource(int index,
LocaleId trgLoc)
Gets the source segment for the given target locale at a given position.
|
void |
insert(int index,
Segment srcSeg,
Segment trgSeg,
LocaleId trgLoc)
Inserts given source and target segments at the specified position in the
list of segments.
|
Iterator<Segment> |
iterator()
Gets an iterator for the default source segments of this text unit.
|
Iterator<Segment> |
iterator(LocaleId trgLoc)
Gets an iterator for the source of the specified target locale.
|
void |
joinAll(LocaleId trgLoc)
Joins all segments for the specified sources and targets.
|
void |
joinWithNext(Segment seg,
LocaleId trgLoc)
Joins the segment for a given segment's id to the next segment, including
all the parts between the two segments.
|
boolean |
remove(Segment seg,
LocaleId trgLoc)
Removes the given segment and any segments with the same id from the
specified sources and targets.
|
void |
segmentSource(ISegmenter segmenter,
LocaleId targetLocale)
Segments the source content used for the given target locale based on the
rules provided by a given
ISegmenter. |
void |
segmentTarget(ISegmenter segmenter,
LocaleId targetLocale)
Segments the specified target content based on the rules provided by a
given
ISegmenter. |
void |
setSegment(int index,
Segment seg,
LocaleId trgLoc)
Replaces a segment at a given position with a clone of the given segment.
|
Segment |
splitSource(LocaleId trgLoc,
Segment srcSeg,
int splitPos)
Splits a given source segment into two.
|
Segment |
splitTarget(LocaleId trgLoc,
Segment trgSeg,
int splitPos)
Splits a given target segment into two.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic AlignedSegments(ITextUnit parent)
public void append(Segment srcSeg, Segment trgSeg, LocaleId trgLoc)
IAlignedSegmentsIf srcSeg is non-null, the content of srcSeg will be used for any new segments that are not empty, otherwise the content of trgSeg will be used. srcSeg and trgSeg cannot both be null.
append in interface IAlignedSegmentssrcSeg - the source segment to add.trgSeg - the target segment to add. Null to use a clone of srcSeg
instead.trgLoc - the target locale for which to append segmentspublic void insert(int index,
Segment srcSeg,
Segment trgSeg,
LocaleId trgLoc)
IAlignedSegmentsThe validated id (after insertion) of srcSeg will be applied to all other inserted segments, including trgSeg.
insert in interface IAlignedSegmentsindex - the segment index position.srcSeg - the source segment to insert.trgSeg - the target segment to insert. Null to use srcSeg instead.trgLoc - the target locale for which to insert the segmentpublic void setSegment(int index,
Segment seg,
LocaleId trgLoc)
IAlignedSegmentsThe segment id is determined by the segment at the position of index in the source for trgLoc, the segment id is then used to locate the segments in other sources and targets to replace.
setSegment in interface IAlignedSegmentsindex - the segment index positionseg - the new segment to place at the positiontrgLoc - the target localepublic boolean remove(Segment seg, LocaleId trgLoc)
IAlignedSegmentsremove in interface IAlignedSegmentsseg - the segment to remove.trgLoc - the locale used in specifying which sources and targets to
use.public Segment getSource(int index, LocaleId trgLoc)
IAlignedSegmentsThe first segment has the index 0, the second has the index 1, etc.
getSource in interface IAlignedSegmentsindex - the segment index of the segment to retrieve.trgLoc - the target locale for the source from which to retrieve the
indicated segment.public Segment getCorrespondingTarget(Segment srcSeg, LocaleId trgLoc)
IAlignedSegmentsgetCorrespondingTarget in interface IAlignedSegmentssrcSeg - the source (or other target) segment for which a corresponding
target segment is requested.trgLoc - the target to look up.Segment (may be empty).public Segment getCorrespondingSource(Segment trgSeg, LocaleId trgLoc)
IAlignedSegmentsgetCorrespondingSource in interface IAlignedSegmentstrgSeg - the target segment for which the corresponding source segment
is requested.trgLoc - the target locale of the source to look up.public void align(List<AlignedPair> alignedSegmentPairs, LocaleId trgLoc)
IAlignedSegmentsThis will replace any content in the target and variant source for the given target locale (if either are not present they will be created).
The target for the given locale will be considered aligned with its source when this operation is complete.
align in interface IAlignedSegmentsalignedSegmentPairs - the list of pairs to aligntrgLoc - the target locale to work with.public void align(LocaleId trgLoc)
align in interface IAlignedSegmentstrgLoc - target locale used to align with the sourcepublic void alignCollapseAll(LocaleId trgLoc)
IAlignedSegmentsalignCollapseAll in interface IAlignedSegmentstrgLoc - the target locale of the target (and its corresponding source)
to collapse.public Segment splitSource(LocaleId trgLoc, Segment srcSeg, int splitPos)
IAlignedSegmentsAlignment statuses are updated for the locales that have been modified. May cause a misalignment.
splitSource in interface IAlignedSegmentstrgLoc - the target locale that uses the source in which the segment is
to be splitsrcSeg - the source segment to split.splitPos - the position where to split.public Segment splitTarget(LocaleId trgLoc, Segment trgSeg, int splitPos)
IAlignedSegmentsAlignment statuses are updated for the locales that have been modified. May cause a misalignment.
splitTarget in interface IAlignedSegmentstrgLoc - the target locale to work on.trgSeg - the targets segment.splitPos - the position where to split.public void joinWithNext(Segment seg, LocaleId trgLoc)
IAlignedSegmentsjoinWithNext in interface IAlignedSegmentsseg - a segment holding the id to use for the join.trgLoc - the target localepublic void joinAll(LocaleId trgLoc)
IAlignedSegmentsjoinAll in interface IAlignedSegmentstrgLoc - the target localepublic AlignmentStatus getAlignmentStatus()
IAlignedSegmentsgetAlignmentStatus in interface IAlignedSegmentspublic AlignmentStatus getAlignmentStatus(LocaleId trgLoc)
IAlignedSegmentsgetAlignmentStatus in interface IAlignedSegmentstrgLoc - the target locale for which to get the alignment status.public void segmentSource(ISegmenter segmenter, LocaleId targetLocale)
IAlignedSegmentsISegmenter.
No associated targets are modified.
segmentSource in interface IAlignedSegmentssegmenter - the segmenter to use to create the segments.targetLocale - the target locale that uses the source to segment.public void segmentTarget(ISegmenter segmenter, LocaleId targetLocale)
IAlignedSegmentsISegmenter.
If the given target does not exist one is created.
segmentTarget in interface IAlignedSegmentssegmenter - the segmenter to use to create the segments.targetLocale - LocaleId of the target we want to segment.public Iterator<Segment> iterator()
IAlignedSegmentsiterator in interface Iterable<Segment>iterator in interface IAlignedSegmentspublic Iterator<Segment> iterator(LocaleId trgLoc)
IAlignedSegmentsiterator in interface IAlignedSegmentstrgLoc - the target locale for the source to iterate over.public final ITextUnit getParent()
Copyright © 2022. All rights reserved.