Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
markusweigelt committed Jan 2, 2024
1 parent 0ca03d8 commit f42a188
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,27 @@ public class MediaPartialView extends View {

private String extent;

/**
* Constructs a media partial view object.
*
* @param begin
* The begin as formatted time in form of
* {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN}
*/
public MediaPartialView(String begin) {
this.begin = begin;
}

/**
* Constructs a media partial view object.
*
* @param begin
* The begin as formatted time in form of
* {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN}
* @param extent
* The extent as formatted time in form of
* {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN}
*/
public MediaPartialView(String begin, String extent) {
this(begin);
this.extent = extent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MediaPartialHelper {

public static final Pattern FORMATTED_TIME_PATTERN = Pattern.compile("([0-1]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}");

private static final MediaPartialLogicalDivisionComparator mediaPartialLogicalDivisionComparator = new MediaPartialLogicalDivisionComparator();
private static final MediaPartialLogicalDivisionComparator logicalDivisionComparator = new MediaPartialLogicalDivisionComparator();

/**
* Convert formatted time to milliseconds.
Expand Down Expand Up @@ -65,7 +65,7 @@ public static String convertMillisecondsToFormattedTime(Long milliseconds) {
*/
public static void calculateExtentAndSortMediaPartials(List<LogicalDivision> logicalDivisions, Long mediaDuration) {
calculateExtentForMediaPartials(logicalDivisions, mediaDuration);
logicalDivisions.sort(mediaPartialLogicalDivisionComparator);
logicalDivisions.sort(logicalDivisionComparator);
}

/**
Expand All @@ -81,7 +81,7 @@ public static void calculateExtentAndSortMediaPartials(List<LogicalDivision> log
*/
private static void calculateExtentForMediaPartials(List<LogicalDivision> logicalDivisions, Long mediaDuration) {
// sorting reverse by begin
logicalDivisions.sort(mediaPartialLogicalDivisionComparator.reversed());
logicalDivisions.sort(logicalDivisionComparator.reversed());

ListIterator<LogicalDivision> iterator = logicalDivisions.listIterator();
LogicalDivision previousLogicalDivision = null;
Expand All @@ -97,7 +97,8 @@ private static void calculateExtentForMediaPartials(List<LogicalDivision> logica
long previousBegin = convertFormattedTimeToMilliseconds(
previousPhysicalDivision.getMediaPartialView().getBegin());
long currentBegin = convertFormattedTimeToMilliseconds(mediaPartialView.getBegin());
mediaPartialView.setExtent(convertMillisecondsToFormattedTime(previousBegin - currentBegin));
String extent = convertMillisecondsToFormattedTime(previousBegin - currentBegin);
mediaPartialView.setExtent(extent);
}
} else {
// calculate the duration of media partial to the end of media
Expand Down

0 comments on commit f42a188

Please sign in to comment.