Package net.sf.okapi.lib.xliff2.core
Class Part
- java.lang.Object
-
- net.sf.okapi.lib.xliff2.core.Part
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPart.GetTargetOptions when getting a target which does not exists yet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetId()Gets the id for this part.StringgetId(boolean createIfNeeded)Gets the id for this part.booleangetPreserveWS()Indicates if the whitespace of this part's content must be preserved.FragmentgetSource()Gets the source fragment for this part.TagsgetSourceTags()Gets all the source tags for the unit where this part is.StoregetStore()Gets the store for this part.FragmentgetTarget()Gets the target fragment for this part.FragmentgetTarget(Part.GetTarget creationOption)Gets the target fragment for this part, and possibly create it if it does not exists yet.intgetTargetOrder()Gets the target order for this part.TagsgetTargetTags()Gets all the target tags for the unit where this part is.booleanhasTarget()Indicates if this part has a target.booleanisSegment()Indicates if this part is a segment or an ignorable.voidremoveMarkers(boolean target, String type)Removes the markers in the source or target content of this part.voidsetId(String id)Sets the id for this part.voidsetPreserveWS(boolean preserveWS)Sets the flag indicating if the whitespace of this part's content must be preserved.FragmentsetSource(String plainText)Sets the source for this part as a new fragment made of a plain text string.FragmentsetSource(Fragment fragment)Sets the fragment of the source for this part.FragmentsetTarget(String plainText)Sets the target for this part as a new fragment made of a plain text string.FragmentsetTarget(Fragment fragment)Sets the fragment of the target for this part.voidsetTargetOrder(int targetOrder)Sets the target order value for this part.voidshowProtectedContent()Expands allPContreferences in this part into normal content.
-
-
-
Method Detail
-
getId
public String getId()
Gets the id for this part.- Returns:
- the id for this part if one exists, return null otherwise.
-
getId
public String getId(boolean createIfNeeded)
Gets the id for this part.- Parameters:
createIfNeeded- true to assign automatically an id if none is already set, false to get null if there is no id set.- Returns:
- the id for this part (can be null if createIfNeeded is false).
-
setId
public void setId(String id)
Sets the id for this part.- Parameters:
id- the new id for this part (can be null). No check is done for uniqueness.
-
getPreserveWS
public boolean getPreserveWS()
Indicates if the whitespace of this part's content must be preserved.- Returns:
- true if the whitespace must be preserved, false if the whitespace can be modified.
-
setPreserveWS
public void setPreserveWS(boolean preserveWS)
Sets the flag indicating if the whitespace of this part's content must be preserved.- Parameters:
preserveWS- true to preserve the whitespace, false otherwise.
-
getSource
public Fragment getSource()
Gets the source fragment for this part.- Returns:
- the source fragment for this part (never null).
-
setSource
public Fragment setSource(Fragment fragment)
Sets the fragment of the source for this part. The fragment must have the same store as the part.- Parameters:
fragment- the fragment to set.- Returns:
- the new source fragment.
-
setSource
public Fragment setSource(String plainText)
Sets the source for this part as a new fragment made of a plain text string.- Parameters:
plainText- the plain text source content to set.- Returns:
- the new source fragment.
-
hasTarget
public boolean hasTarget()
Indicates if this part has a target.- Returns:
- true if this part has a target, false otherwise.
-
getTarget
public Fragment getTarget(Part.GetTarget creationOption)
Gets the target fragment for this part, and possibly create it if it does not exists yet.- Parameters:
creationOption- action to take if no target exists yet for this part.- Returns:
- the target fragment or null.
- See Also:
getTarget()
-
getTarget
public Fragment getTarget()
Gets the target fragment for this part.- Use this when you know the target exists.
- Use
getTarget(GetTarget)to create the fragment if needed.
- Returns:
- the target fragment or null
- See Also:
getTarget(GetTarget)
-
setTarget
public Fragment setTarget(Fragment fragment)
Sets the fragment of the target for this part. The fragment must have the same store as the part.- Parameters:
fragment- the fragment to set.- Returns:
- the new target fragment.
-
setTarget
public Fragment setTarget(String plainText)
Sets the target for this part as a new fragment made of a plain text string.- Parameters:
plainText- the plain text target content to set.- Returns:
- the new target fragment.
-
getSourceTags
public Tags getSourceTags()
Gets all the source tags for the unit where this part is.- Returns:
- all the source tags for the unit where this part is.
-
getTargetTags
public Tags getTargetTags()
Gets all the target tags for the unit where this part is.- Returns:
- all the target tags for the unit where this part is.
-
setTargetOrder
public void setTargetOrder(int targetOrder)
Sets the target order value for this part. Zero means the default source order.- Parameters:
targetOrder- the new target order for this part.
-
getTargetOrder
public int getTargetOrder()
Gets the target order for this part. Zero means the default source order.- Returns:
- the target order for this part.
-
getStore
public Store getStore()
Gets the store for this part.- Returns:
- the store for this part (never null).
-
isSegment
public boolean isSegment()
Indicates if this part is a segment or an ignorable.- Returns:
- true if this part is a segment, false otherwise.
-
removeMarkers
public void removeMarkers(boolean target, String type)Removes the markers in the source or target content of this part.- Parameters:
target- true to remove from the target, false to remove from the source.type- the type of markers to remove (or null to remove all markers).
-
showProtectedContent
public void showProtectedContent()
Expands allPContreferences in this part into normal content. This is done on both source and target.
-
-