From 4b2c5405cba6ba4a2e288817be21ea832fa07fcd Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Sun, 18 Nov 2012 21:42:42 +0000 Subject: [PATCH] Reestructuración para tener en cuenta las listas que son listas de listas (valga la redundáncia) y las listas de segmentos --- src/com/upc/pbe/upcnews/InfoException.java | 10 ++++++++++ src/com/upc/pbe/upcnews/Parser.java | 37 ++++++++++++++++++------------------- src/com/upc/pbe/upcnews/Playlist.java | 49 ++++--------------------------------------------- src/com/upc/pbe/upcnews/SegmentList.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 64 deletions(-) create mode 100644 src/com/upc/pbe/upcnews/InfoException.java create mode 100644 src/com/upc/pbe/upcnews/SegmentList.java diff --git a/src/com/upc/pbe/upcnews/InfoException.java b/src/com/upc/pbe/upcnews/InfoException.java new file mode 100644 index 0000000..1700463 --- /dev/null +++ b/src/com/upc/pbe/upcnews/InfoException.java @@ -0,0 +1,10 @@ +package com.upc.pbe.upcnews; + +public class InfoException extends Exception +{ + private static final long serialVersionUID = 1L; + public InfoException(String message) + { + super(message); + } +} diff --git a/src/com/upc/pbe/upcnews/Parser.java b/src/com/upc/pbe/upcnews/Parser.java index 7c4075e..0e10a0d 100644 --- a/src/com/upc/pbe/upcnews/Parser.java +++ b/src/com/upc/pbe/upcnews/Parser.java @@ -2,7 +2,7 @@ package com.upc.pbe.upcnews; public class Parser { - private Playlist playlist; + private SegmentList playlist; private static final String STARTWORD = "#EXTM3U"; @@ -11,22 +11,23 @@ public class Parser } - public void setPlaylist(Playlist pls) + public void setPlaylist(SegmentList pls) { playlist = pls; } - public Playlist getPlaylist() + public SegmentList getPlaylist() { return playlist; } - public void parseLine(String line) throws ErrorException, WarningException + public void parseLine(String line) throws ErrorException, WarningException, InfoException { - Playlist pls = getPlaylist(); + SegmentList pls = getPlaylist(); int currentLine = 0; int currentSegment = 0; boolean expectSegment = false; + boolean expectList = false; if(pls == null) { @@ -86,8 +87,7 @@ public class Parser else if(extTag[0].equals("#EXT-X-STREAM-INF")) { - /*"#EXT-X-STREAM-INF") - EXTXSTREAM=1 + /*EXTXSTREAM=1 PROGRAMID="" CODECS="" RESOLUTION="" @@ -116,16 +116,16 @@ public class Parser else { + currentLine++; throw new WarningException("Tag not implemented"); } } - - /*else - echo "INFO: Comment found on line $CURRENT_LINE: \"`echo $line | cut -d'#' -f 2`\"" - fi;*/ - - - } //es tag + else + { + String comment = line.substring(1); + throw new InfoException("Comment on line " + currentLine++ + " " + comment); + } + } else { @@ -145,10 +145,9 @@ public class Parser echo "ERROR: Unexpected string \"$line\"" exit 1 */ - } //no es tag - } //ya validado - } - currentLine++; + } + } + currentLine++; + } } - } diff --git a/src/com/upc/pbe/upcnews/Playlist.java b/src/com/upc/pbe/upcnews/Playlist.java index 98ca928..1812c49 100644 --- a/src/com/upc/pbe/upcnews/Playlist.java +++ b/src/com/upc/pbe/upcnews/Playlist.java @@ -1,53 +1,12 @@ package com.upc.pbe.upcnews; -import java.util.ArrayList; - public class Playlist { - private boolean validated; - private int sequenceFirst; - private int maxDuration; - private ArrayList segments; - + private SegmentList segmentList; + public Playlist() { - validated = false; - segments = new ArrayList(); - } - - public void setValidated(boolean val) - { - validated = val; - } - - public boolean getValidated() - { - return validated; - } - - public void setSequence(int seq) - { - sequenceFirst = seq; - } - - public int getSequence() - { - return sequenceFirst; - } - - public void setMaxDuration(int dur) - { - maxDuration = dur; - } - - public int getMaxDuration() - { - return maxDuration; + segmentList = new SegmentList(); } - - public ArrayList getSegments() - { - return segments; - } -} +} diff --git a/src/com/upc/pbe/upcnews/SegmentList.java b/src/com/upc/pbe/upcnews/SegmentList.java new file mode 100644 index 0000000..ca2bf0e --- /dev/null +++ b/src/com/upc/pbe/upcnews/SegmentList.java @@ -0,0 +1,53 @@ +package com.upc.pbe.upcnews; + +import java.util.ArrayList; + +public class SegmentList +{ + private boolean validated; + private int sequenceFirst; + private int maxDuration; + private ArrayList segments; + + public SegmentList() + { + validated = false; + segments = new ArrayList(); + } + + public void setValidated(boolean val) + { + validated = val; + } + + public boolean getValidated() + { + return validated; + } + + public void setSequence(int seq) + { + sequenceFirst = seq; + } + + public int getSequence() + { + return sequenceFirst; + } + + public void setMaxDuration(int dur) + { + maxDuration = dur; + } + + public int getMaxDuration() + { + return maxDuration; + } + + public ArrayList getSegments() + { + return segments; + } +} + -- libgit2 0.22.2