Package net.sf.okapi.common.skeleton
Class SkeletonUtil
- java.lang.Object
-
- net.sf.okapi.common.skeleton.SkeletonUtil
-
public class SkeletonUtil extends Object
Helper methods to manipulate skeleton objects.
-
-
Constructor Summary
Constructors Constructor Description SkeletonUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidchangeParent(ISkeleton skel, IResource curParent, IResource newParent)static intfindTuRefInSkeleton(GenericSkeleton skel)Finds source reference in the skeleton.static intfindTuRefInSkeleton(GenericSkeleton skel, LocaleId locId)Finds either source or target reference in the skeleton.static intgetNumParts(GenericSkeleton skel)static GenericSkeletonPartgetPart(GenericSkeleton skel, int index)static StringgetRefId(GenericSkeletonPart part)static booleanhasTuRef(GenericSkeleton skel)Determines if a given skeleton contains a source reference in it.static booleanhasTuRef(GenericSkeleton skel, LocaleId locId)Determines if a given skeleton contains a target reference in a given locale.static booleanisExtPropValuePlaceholder(GenericSkeletonPart part, IResource resource)static booleanisExtSegmentPlaceholder(GenericSkeletonPart part, IResource resource)static booleanisExtSourcePlaceholder(GenericSkeletonPart part, IResource resource)static booleanisExtTargetPlaceholder(GenericSkeletonPart part, IResource resource)static booleanisPropRef(GenericSkeletonPart part)static booleanisPropValuePlaceholder(GenericSkeletonPart part, IResource resource)static booleanisRef(GenericSkeletonPart part)static booleanisReference(GenericSkeletonPart part)static booleanisSegmentPlaceholder(GenericSkeletonPart part, IResource resource)static booleanisSegRef(GenericSkeletonPart part)static booleanisSourcePlaceholder(GenericSkeletonPart part, IResource resource)static booleanisTargetPlaceholder(GenericSkeletonPart part, IResource resource)static booleanisText(GenericSkeletonPart part)static booleanisTuRef(GenericSkeletonPart part)static booleanreplaceSkeletonPart(GenericSkeleton skel, int index, GenericSkeleton replacement)Replaces a part of a given skeleton with another given skeleton part.static GenericSkeleton[]splitSkeleton(GenericSkeleton skel)Splits a givenGenericSkeletoninto 2 parts: before and after the content placeholder (self-marker).
-
-
-
Method Detail
-
findTuRefInSkeleton
public static int findTuRefInSkeleton(GenericSkeleton skel)
Finds source reference in the skeleton.- Parameters:
skel- the skeleton being sought for the reference- Returns:
- index in the list of skeleton parts for the skeleton part containing the reference
-
findTuRefInSkeleton
public static int findTuRefInSkeleton(GenericSkeleton skel, LocaleId locId)
Finds either source or target reference in the skeleton. If locId is specified, then its target reference is sought for.- Parameters:
skel- the skeleton being sought for the reference.locId- the locale to search the reference for.- Returns:
- index in the list of skeleton parts for the skeleton part containing the reference.
-
hasTuRef
public static boolean hasTuRef(GenericSkeleton skel)
Determines if a given skeleton contains a source reference in it.- Parameters:
skel- the skeleton being sought for the reference.- Returns:
- true if the given skeleton contains such a reference.
-
hasTuRef
public static boolean hasTuRef(GenericSkeleton skel, LocaleId locId)
Determines if a given skeleton contains a target reference in a given locale.- Parameters:
skel- the skeleton being sought for the reference.locId- the locale of the target part being sought.- Returns:
- true if the given skeleton contains such a reference.
-
splitSkeleton
public static GenericSkeleton[] splitSkeleton(GenericSkeleton skel)
Splits a givenGenericSkeletoninto 2 parts: before and after the content placeholder (self-marker).- Parameters:
skel- the givenGenericSkeleton.- Returns:
- array of 2
GenericSkeletons before and after self-marker.
-
replaceSkeletonPart
public static boolean replaceSkeletonPart(GenericSkeleton skel, int index, GenericSkeleton replacement)
Replaces a part of a given skeleton with another given skeleton part.- Parameters:
skel- the skeleton which part is being replaced.index- the index of the skeleton part to be replaced.replacement- the given new skeleton part to replace the existing one.- Returns:
- true if replacement succeeded.
-
getNumParts
public static int getNumParts(GenericSkeleton skel)
-
getPart
public static GenericSkeletonPart getPart(GenericSkeleton skel, int index)
-
isTuRef
public static boolean isTuRef(GenericSkeletonPart part)
-
isRef
public static boolean isRef(GenericSkeletonPart part)
-
isPropRef
public static boolean isPropRef(GenericSkeletonPart part)
-
isSegRef
public static boolean isSegRef(GenericSkeletonPart part)
-
isSourcePlaceholder
public static boolean isSourcePlaceholder(GenericSkeletonPart part, IResource resource)
-
isTargetPlaceholder
public static boolean isTargetPlaceholder(GenericSkeletonPart part, IResource resource)
-
isPropValuePlaceholder
public static boolean isPropValuePlaceholder(GenericSkeletonPart part, IResource resource)
-
isSegmentPlaceholder
public static boolean isSegmentPlaceholder(GenericSkeletonPart part, IResource resource)
-
isExtSourcePlaceholder
public static boolean isExtSourcePlaceholder(GenericSkeletonPart part, IResource resource)
-
isExtTargetPlaceholder
public static boolean isExtTargetPlaceholder(GenericSkeletonPart part, IResource resource)
-
isExtPropValuePlaceholder
public static boolean isExtPropValuePlaceholder(GenericSkeletonPart part, IResource resource)
-
isExtSegmentPlaceholder
public static boolean isExtSegmentPlaceholder(GenericSkeletonPart part, IResource resource)
-
isReference
public static boolean isReference(GenericSkeletonPart part)
-
isText
public static boolean isText(GenericSkeletonPart part)
-
getRefId
public static String getRefId(GenericSkeletonPart part)
-
-