/** * Create an instance of {@link LinearSegment } * */ public LinearSegment createLinearSegment() { return new LinearSegment(); }
/** * @param theSegment * Segment to test "be include" by <code>inThisSegment</code> * @param inThisSegment * Segment to test "includes" <code>theSegment</code> * @return <code>false</code> if one <code>Segment</code> is null, or if * the Segments aren't of the same <code>Segment</code> type, or * if according to their type <code>theSegment</code> isn't * included in <code>inThisSegment</code>. <code>true</code> if * they are included. */ private static boolean isIncludedLinear(final LinearSegment theSegment, final LinearSegment inThisSegment) { return (theSegment.getStart() >= inThisSegment.getStart()) && (theSegment.getEnd() <= inThisSegment.getEnd()); }
final String temp = text.getContent(); if (temp != null) { if (temp.length() >= segment.getEnd()) { return temp.substring(segment.getStart(), segment.getEnd()); throw new WebLabCheckedException("Segment (" + segment.getUri() + ") ends after of content of Text: " + text.getUri() + "."); throw new WebLabCheckedException("Text (" + text.getUri() + ") is not the parent of Segment: " + segment.getUri() + ".");
/** * @param track * The TrackSegment in which to add a Linear * @param start * The starting offset of the linear * @param end * The ending offset of the linear * @return The created linear */ public final static LinearSegment createAndLinkLinearSegment(final TrackSegment track, final int start, final int end) { SegmentFactory.checkArgsForLinearAndTemporal(track, start, end); final LinearSegment lSeg = SegmentFactory.createAndLinkSegment(track, LinearSegment.class); lSeg.setStart(start); lSeg.setEnd(end); return lSeg; }
private static <T extends Segment> T getExistingSegment(final List<Segment> segments, final int start, final int end, final Class<T> linearOrTemporalSegment) { final boolean isLinear; if (linearOrTemporalSegment.equals(LinearSegment.class)) { isLinear = true; } else { isLinear = false; } T theSeg = null; for (final Segment seg : segments) { if ((seg instanceof LinearSegment) && isLinear) { final LinearSegment linSeg = (LinearSegment) seg; if ((linSeg.getStart() == start) && (linSeg.getEnd() == end)) { theSeg = linearOrTemporalSegment.cast(linSeg); break; } } else if ((seg instanceof TemporalSegment) && !isLinear) { final TemporalSegment tempSeg = (TemporalSegment) seg; if ((tempSeg.getStart() == start) && (tempSeg.getEnd() == end)) { theSeg = linearOrTemporalSegment.cast(tempSeg); break; } } } return theSeg; }