public class Unit extends InheritedData implements java.lang.Iterable<Part>, IWithStore, IWithITSAttributes, IWithITSGroups
Constructor and Description |
---|
Unit(java.lang.String id)
Creates a new
Unit object. |
Unit(java.lang.String id,
StartFileData startFileData)
Creates a new
Unit object with a given id and file context. |
Unit(Unit original)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
DataCategoryGroup<?> |
addITSGroup(DataCategoryGroup<?> group)
Adds an ITS group to this object.
|
void |
addNote(Note note)
Adds a note to the list of notes.
|
Part |
appendIgnorable()
Appends an empty ignorable part to this unit.
|
Segment |
appendSegment()
Appends a new empty segment to this unit.
|
boolean |
doNonEmptySourcesHaveNonEmptyTargets()
Indicates if all parts (segments and ignorables) of this unit that have a non-empty source
have also a non-empty target.
|
java.util.List<Match> |
getAllExactMatches()
Retrieves all exact matches from this unit, i.e.
|
java.util.List<AnnotatedSpan> |
getAnnotatedSpans(boolean target)
Creates a list of the annotated spans in this unit.
|
ChangeTrack |
getChangeTrack()
Gets the
ChangeTrack object for this element, creates an empty of if there is none. |
ExtAttributes |
getExtAttributes()
Gets the
ExtAttributes object for the parent object. |
java.lang.String |
getExtAttributeValue(java.lang.String namespaceURI,
java.lang.String localName)
Gets the value for a given extension attribute.
|
ExtElements |
getExtElements()
Gets the
ExtElements object associated with this object. |
Glossary |
getGlossary()
Gets the
Glossary object for this unit, creates an empty of if there is none. |
java.lang.String |
getId()
Gets the id for this object.
|
java.util.List<DataCategoryGroup<?>> |
getITSGroups()
Gets the ITS groups associated with this object.
|
ITSItems |
getITSItems()
Gets the ITS items associated with this object.
|
Matches |
getMatches()
Gets the
Matches object for this unit, creates an empty of if there is none. |
java.util.List<Match> |
getMatchesByMinimumSimilarity(double minSim)
Retrieves all matches from this unit with the given minimum similarity.
|
java.util.List<Match> |
getMatchesByRef(java.lang.String ref)
Retrieves all matches from this unit for the given ref attribute value.
|
java.util.List<Match> |
getMatchesBySimilarityRange(double minSim,
double maxSim)
Retrieves all matches from this unit in the given similarity range.
|
java.util.List<Match> |
getMatchesForSegment(int segIdx)
Retrieves all matches from this unit for the given segment (zero-based index)
|
Metadata |
getMetadata()
Gets the
Metadata object for the parent, creates an empty of if there is none. |
java.lang.String |
getName()
Gets the name for this group.
|
int |
getNoteCount()
Gets the number of notes for this object.
|
Notes |
getNotes()
Gets the
Notes object for this object. |
java.lang.Object |
getObjectFromId(java.lang.String id)
Gets the object associated with a given span-class id in this unit.
|
java.util.List<CTag> |
getOrderedCTags(boolean target)
Creates the list of
CTag in the source or target content, in their
respective order. |
Part |
getPart(int partIndex)
Gets the part at a given index.
|
int |
getPartCount()
Gets the number of parts in this unit.
|
java.lang.String |
getPlainText(boolean target,
boolean useSourceForMissingTargetIgnorables)
Gets the plain text version of the full content of this unit,
for either the source or the target.
|
Segment |
getSegment(int segIndex)
Gets the segment at a given index.
|
int |
getSegmentCount()
Gets the number of segments in this unit.
|
java.lang.Iterable<Segment> |
getSegments()
Creates an
Iterable object for the segments in this unit. |
java.lang.Object |
getSourceOrTargetReference(java.lang.String ref)
Gets the span-like object associated with a given id in this unit.
|
Store |
getStore()
Gets the store for this unit.
|
java.util.List<Part> |
getTargetOrderedParts()
Gets the list of the parts for this unit in the order specified for the target content.
|
java.util.List<java.lang.Boolean> |
getTranslateStateEndings(boolean doSource)
Creates a list of booleans corresponding to the translate state at the end of each part in this unit.
|
java.lang.String |
getType()
Gets the type for this group.
|
Validation |
getValidation()
Gets the
Validation object for the parent, creates an empty of if there is none. |
boolean |
hasChangeTrack()
Check if there is at least a revision for this element.
|
boolean |
hasExtAttribute()
Indicates if at least one extension attribute is present.
|
boolean |
hasExtElements()
Indicates if there is a
ExtElements object associated with this object. |
boolean |
hasGlossEntry()
Indicates if this unit has at least one glossary entry.
|
boolean |
hasITSGroup()
Indicates if the object has at least one ITS group.
|
boolean |
hasITSItem()
Indicates if the object has at least one ITS item.
|
boolean |
hasMatch()
Indicates if this unit has at least one match.
|
boolean |
hasMetadata()
Indicates if the object has metadata.
|
boolean |
hasTargetOrder()
Indicates if this unit has at least one target part not in the same order as the source.
|
boolean |
hasValidation()
Indicates if the object has validation data.
|
void |
hideProtectedContent()
Hides all protected spans of this unit into
PCont objects. |
boolean |
isIdUsed(java.lang.String id)
|
java.util.Iterator<Part> |
iterator()
Creates a new iterator to loop through the segments and ignorables of this unit.
|
void |
join(int startPartIndex,
int endPartIndex,
boolean restrictedJoin,
boolean adjustTargetIgnorable)
Joins two or more parts together into the first one.
|
void |
joinAll(boolean adjustTargetIgnorable) |
void |
removeMarkers()
Removes all the annotation markers from the source and target
(if a target is available) in this unit.
|
void |
setChangeTrack(ChangeTrack changeTrack)
Sets the
ChangeTrack object for this element. |
void |
setExtAttributes(ExtAttributes attributes)
Sets the
ExtAttributes object associated with this object. |
ExtElements |
setExtElements(ExtElements elements)
Sets the
ExtElements object associated with this object. |
void |
setGlossary(Glossary glossary)
sets the
Glossary object for this unit. |
void |
setId(java.lang.String id)
Sets the id for this object.
|
void |
setITSItems(ITSItems itsItems)
Sets the list of the ITS items associated with this object.
|
void |
setMatches(Matches matches)
sets the
Matches object for this unit. |
void |
setMetadata(Metadata metadata)
sets the
Metadata object for the parent. |
void |
setName(java.lang.String name)
Sets the name for this group.
|
void |
setType(java.lang.String type)
Sets the type for this group.
|
void |
setValidation(Validation validation)
sets the
Validation object for the parent. |
void |
showProtectedContent()
Show all
PCont references in this unit into content. |
void |
split(int partIndex,
int srcStart,
int srcEnd,
int trgStart,
int trgEnd,
boolean changeState)
Splits a segment.
|
void |
verifyOpeningsBeforeClosings(boolean target)
Verifies that all opening tags in the source or targt content of this unit
are located before their closing counterparts.
|
void |
verifyReadOnlyTags()
Verifies if the non-removable tags in the source content of this unit are present in the target.
|
getAnnotatorsRef, getCanResegment, getSourceDir, getTargetDir, getTranslate, setAnnotatorsRef, setCanResegment, setInheritableData, setSourceDir, setTargetDir, setTranslate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSourceDir, getTargetDir, setSourceDir, setTargetDir
getId
public Unit(Unit original)
Important: Most of the time you MUST change the id of the resulting unit as a unit id must be unique within its parent file element.
original
- the original unit to duplicate.public Unit(java.lang.String id)
Unit
object.id
- the id of the unit.public Unit(java.lang.String id, StartFileData startFileData)
Unit
object with a given id and file context.id
- the id of the unit.startFileData
- the file context (can be null).public java.util.Iterator<Part> iterator()
iterator
in interface java.lang.Iterable<Part>
public int getPartCount()
public int getSegmentCount()
public Segment appendSegment()
public Part appendIgnorable()
public Part getPart(int partIndex)
partIndex
- the index of the part to retrieve (between 0 and getPartCount()
-1).Part
object at the given index position, the part may or may not be a Segment
.java.lang.IndexOutOfBoundsException
- if the index is invalid.public Segment getSegment(int segIndex)
segIndex
- the index of the segment to retrieve (between 0 and getSegmentCount()
-1).Segment
object at the given index position.java.lang.IndexOutOfBoundsException
- if the index is invalid.public Store getStore()
getStore
in interface IWithStore
Store
object for this unit.public boolean isIdUsed(java.lang.String id)
IWithStore
isIdUsed
in interface IWithStore
id
- the id value to lookup.public java.lang.Object getObjectFromId(java.lang.String id)
The objects checked are: the parts (including segments) and all the
tags except the PCont
objects.
id
- the id to look for.public void split(int partIndex, int srcStart, int srcEnd, int trgStart, int trgEnd, boolean changeState)
partIndex
- the part index of the segment to split.srcStart
- the start position of the middle new segment for the source (inclusive, in coded text).srcEnd
- the end position of the middle new segment for the source (exclusive, in coded text),
use -1 for the end of the current segment.trgStart
- the start position of the middle new segment for the target (inclusive, in coded text).trgEnd
- the end position of the middle new segment for the target (exclusive, in coded text),
use -1 for the end of the current segment.changeState
- true to change the state and possibly the subState attributes for the modified or added
segments if the initial segment as a target and its state is other than "initial" and "translated".
Use false to keep the same state and subState.public boolean hasTargetOrder()
public void join(int startPartIndex, int endPartIndex, boolean restrictedJoin, boolean adjustTargetIgnorable)
startPartIndex
- the index of the first part to join (in the target order)endPartIndex
- the index of the last part to join (in the target order)restrictedJoin
- true to throw an exception if one of the segment cannot be merged,
false to allow to merge regardless of the canResegment values (merger mode)adjustTargetIgnorable
- TODOpublic void joinAll(boolean adjustTargetIgnorable)
public java.lang.Iterable<Segment> getSegments()
Iterable
object for the segments in this unit.
Use getTargetOrderedParts()
to get a list of the parts in target order.
Iterable
object for the segments in this unit.public java.util.List<Part> getTargetOrderedParts()
public java.lang.String getPlainText(boolean target, boolean useSourceForMissingTargetIgnorables)
target
- true to generate the text for the target, false for the source.useSourceForMissingTargetIgnorables
- true to use the source content when generating the target
text and a target ignorable is missing. this parameter is ignored when generating the source text.public void hideProtectedContent()
PCont
objects.
No target parts are created.showProtectedContent()
public java.util.List<java.lang.Boolean> getTranslateStateEndings(boolean doSource)
doSource
- true to generates the list from the source viewpoint, false to do it for the target.public void showProtectedContent()
PCont
references in this unit into content.hideProtectedContent()
public void verifyOpeningsBeforeClosings(boolean target)
target
- true to verify the target, false to verify the source.public void verifyReadOnlyTags()
public java.lang.Object getSourceOrTargetReference(java.lang.String ref)
ref
- the reference of the object.public java.util.List<CTag> getOrderedCTags(boolean target)
CTag
in the source or target content, in their
respective order.
This method does not check content inside protected text.target
- true to create the target list (in target order).public boolean doNonEmptySourcesHaveNonEmptyTargets()
public void removeMarkers()
public DataCategoryGroup<?> addITSGroup(DataCategoryGroup<?> group)
IWithITSGroups
addITSGroup
in interface IWithITSGroups
group
- the group to add.public boolean hasITSGroup()
IWithITSGroups
hasITSGroup
in interface IWithITSGroups
public java.util.List<DataCategoryGroup<?>> getITSGroups()
IWithITSGroups
getITSGroups
in interface IWithITSGroups
public boolean hasITSItem()
IWithITSAttributes
hasITSItem
in interface IWithITSAttributes
public ITSItems getITSItems()
IWithITSAttributes
getITSItems
in interface IWithITSAttributes
public void setITSItems(ITSItems itsItems)
IWithITSAttributes
setITSItems
in interface IWithITSAttributes
itsItems
- the new items to set.public boolean hasMatch()
public Matches getMatches()
Matches
object for this unit, creates an empty of if there is none.Matches
object for this unit (can be empty, but never null).public void setMatches(Matches matches)
Matches
object for this unit.matches
- the new Matches
object for this unit.public boolean hasGlossEntry()
public Glossary getGlossary()
Glossary
object for this unit, creates an empty of if there is none.Glossary
object for this unit (can be empty, but never null).public void setGlossary(Glossary glossary)
Glossary
object for this unit.glossary
- the new Glossary
object for this unit.public java.util.List<AnnotatedSpan> getAnnotatedSpans(boolean target)
The Part
and MTag
objects in the list are live references,
but any static data (e.g. the start and end position of the span) are a snapshot of the
information at the moment of the call, any change to the content may make that information
out-of-date and invalid.
The spans are listed in the order their opening markers appears in the coded text.
The call is expected to be made on a unit with no hidden protected content.
target
- true to lookup the target, false to lookup the source.AnnotatedSpan
objects for this unit.public java.util.List<Match> getAllExactMatches()
public java.util.List<Match> getMatchesByMinimumSimilarity(double minSim)
minSim
- The minimum similarity as a percentage, e.g. 75.0 for all matches with 75% or higherpublic java.util.List<Match> getMatchesBySimilarityRange(double minSim, double maxSim)
minSim
- The minimum similarity as a percentage, e.g. 75.0 for all matches with 75% or highermaxSim
- The maximum similaritypublic java.util.List<Match> getMatchesForSegment(int segIdx)
segIdx
- The index of the segment (zero-based)public java.util.List<Match> getMatchesByRef(java.lang.String ref)
ref
- The value of the ref attribute, with or without the "#" prefixpublic ExtElements getExtElements()
IWithExtElements
ExtElements
object associated with this object.
If none exists one is created.getExtElements
in interface IWithExtElements
ExtElements
object associated with this object. If none exists one is created.public boolean hasExtElements()
IWithExtElements
ExtElements
object associated with this object.hasExtElements
in interface IWithExtElements
ExtElements
object associated with this object,
false otherwise.public ExtElements setExtElements(ExtElements elements)
IWithExtElements
ExtElements
object associated with this object.setExtElements
in interface IWithExtElements
elements
- the ExtElements
object associated with this object.
If null, a new ExtElements
object is created.ExtElements
object associated with this object, never null.public void addNote(Note note)
IWithNotes
addNote
in interface IWithNotes
note
- the note to add.public Notes getNotes()
IWithNotes
Notes
object for this object.getNotes
in interface IWithNotes
public int getNoteCount()
IWithNotes
getNoteCount
in interface IWithNotes
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the new name to set (can be null).public java.lang.String getType()
public void setType(java.lang.String type)
type
- the new type to set (can be null).public boolean hasMetadata()
IWithMetadata
hasMetadata
in interface IWithMetadata
public Metadata getMetadata()
IWithMetadata
Metadata
object for the parent, creates an empty of if there is none.getMetadata
in interface IWithMetadata
Metadata
object for the parent (can be empty, but never null).public void setMetadata(Metadata metadata)
IWithMetadata
Metadata
object for the parent.setMetadata
in interface IWithMetadata
metadata
- the new Metadata
object for the parent.public boolean hasValidation()
IWithValidation
hasValidation
in interface IWithValidation
public Validation getValidation()
IWithValidation
Validation
object for the parent, creates an empty of if there is none.getValidation
in interface IWithValidation
Validation
object for the parent (can be empty, but never null).public void setValidation(Validation validation)
IWithValidation
Validation
object for the parent.setValidation
in interface IWithValidation
validation
- the new Validation
object for the parent.public ChangeTrack getChangeTrack()
IWithChangeTrack
ChangeTrack
object for this element, creates an empty of if there is none.getChangeTrack
in interface IWithChangeTrack
ChangeTrack
object for this element (can be empty, never null).public void setChangeTrack(ChangeTrack changeTrack)
IWithChangeTrack
ChangeTrack
object for this element.setChangeTrack
in interface IWithChangeTrack
changeTrack
- the ChangeTrack
object for this element.public boolean hasChangeTrack()
IWithChangeTrack
hasChangeTrack
in interface IWithChangeTrack
true
if there is at least a revision for this element; false
otherwise.public void setId(java.lang.String id)
id
- the id for this object.public java.lang.String getId()
public void setExtAttributes(ExtAttributes attributes)
IWithExtAttributes
ExtAttributes
object associated with this object.setExtAttributes
in interface IWithExtAttributes
attributes
- the ExtAttributes
object associated with this object.
If null, a new ExtAttributes
object is created.public ExtAttributes getExtAttributes()
IWithExtAttributes
ExtAttributes
object for the parent object.
If none exists, one is created.getExtAttributes
in interface IWithExtAttributes
ExtAttributes
object for the parent object, never null.public boolean hasExtAttribute()
IWithExtAttributes
hasExtAttribute
in interface IWithExtAttributes
public java.lang.String getExtAttributeValue(java.lang.String namespaceURI, java.lang.String localName)
IWithExtAttributes
getExtAttributeValue
in interface IWithExtAttributes
namespaceURI
- the URI of the namespace for the attribute.localName
- the name of the attribute.