Commit 4b2c5405cba6ba4a2e288817be21ea832fa07fcd

Authored by Imanol-Mikel Barba Sabariego
1 parent 44688419

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 0 → 100644
  1 +package com.upc.pbe.upcnews;
  2 +
  3 +public class InfoException extends Exception
  4 +{
  5 + private static final long serialVersionUID = 1L;
  6 + public InfoException(String message)
  7 + {
  8 + super(message);
  9 + }
  10 +}
... ...
src/com/upc/pbe/upcnews/Parser.java
... ... @@ -2,7 +2,7 @@ package com.upc.pbe.upcnews;
2 2  
3 3 public class Parser
4 4 {
5   - private Playlist playlist;
  5 + private SegmentList playlist;
6 6  
7 7 private static final String STARTWORD = "#EXTM3U";
8 8  
... ... @@ -11,22 +11,23 @@ public class Parser
11 11  
12 12 }
13 13  
14   - public void setPlaylist(Playlist pls)
  14 + public void setPlaylist(SegmentList pls)
15 15 {
16 16 playlist = pls;
17 17 }
18 18  
19   - public Playlist getPlaylist()
  19 + public SegmentList getPlaylist()
20 20 {
21 21 return playlist;
22 22 }
23 23  
24   - public void parseLine(String line) throws ErrorException, WarningException
  24 + public void parseLine(String line) throws ErrorException, WarningException, InfoException
25 25 {
26   - Playlist pls = getPlaylist();
  26 + SegmentList pls = getPlaylist();
27 27 int currentLine = 0;
28 28 int currentSegment = 0;
29 29 boolean expectSegment = false;
  30 + boolean expectList = false;
30 31  
31 32 if(pls == null)
32 33 {
... ... @@ -86,8 +87,7 @@ public class Parser
86 87  
87 88 else if(extTag[0].equals("#EXT-X-STREAM-INF"))
88 89 {
89   - /*"#EXT-X-STREAM-INF")
90   - EXTXSTREAM=1
  90 + /*EXTXSTREAM=1
91 91 PROGRAMID=""
92 92 CODECS=""
93 93 RESOLUTION=""
... ... @@ -116,16 +116,16 @@ public class Parser
116 116  
117 117 else
118 118 {
  119 + currentLine++;
119 120 throw new WarningException("Tag not implemented");
120 121 }
121 122 }
122   -
123   - /*else
124   - echo "INFO: Comment found on line $CURRENT_LINE: \"`echo $line | cut -d'#' -f 2`\""
125   - fi;*/
126   -
127   -
128   - } //es tag
  123 + else
  124 + {
  125 + String comment = line.substring(1);
  126 + throw new InfoException("Comment on line " + currentLine++ + " " + comment);
  127 + }
  128 + }
129 129 else
130 130 {
131 131  
... ... @@ -145,10 +145,9 @@ public class Parser
145 145 echo "ERROR: Unexpected string \"$line\""
146 146 exit 1
147 147 */
148   - } //no es tag
149   - } //ya validado
150   - }
151   - currentLine++;
  148 + }
  149 + }
  150 + currentLine++;
  151 + }
152 152 }
153   -
154 153 }
... ...
src/com/upc/pbe/upcnews/Playlist.java
1 1 package com.upc.pbe.upcnews;
2 2  
3   -import java.util.ArrayList;
4   -
5 3 public class Playlist
6 4 {
7   - private boolean validated;
8   - private int sequenceFirst;
9   - private int maxDuration;
10   - private ArrayList<Segment> segments;
11   -
  5 + private SegmentList segmentList;
  6 +
12 7 public Playlist()
13 8 {
14   - validated = false;
15   - segments = new ArrayList<Segment>();
16   - }
17   -
18   - public void setValidated(boolean val)
19   - {
20   - validated = val;
21   - }
22   -
23   - public boolean getValidated()
24   - {
25   - return validated;
26   - }
27   -
28   - public void setSequence(int seq)
29   - {
30   - sequenceFirst = seq;
31   - }
32   -
33   - public int getSequence()
34   - {
35   - return sequenceFirst;
36   - }
37   -
38   - public void setMaxDuration(int dur)
39   - {
40   - maxDuration = dur;
41   - }
42   -
43   - public int getMaxDuration()
44   - {
45   - return maxDuration;
  9 + segmentList = new SegmentList();
46 10 }
47   -
48   - public ArrayList<Segment> getSegments()
49   - {
50   - return segments;
51   - }
52   -}
53 11  
  12 +}
... ...
src/com/upc/pbe/upcnews/SegmentList.java 0 → 100644
  1 +package com.upc.pbe.upcnews;
  2 +
  3 +import java.util.ArrayList;
  4 +
  5 +public class SegmentList
  6 +{
  7 + private boolean validated;
  8 + private int sequenceFirst;
  9 + private int maxDuration;
  10 + private ArrayList<Segment> segments;
  11 +
  12 + public SegmentList()
  13 + {
  14 + validated = false;
  15 + segments = new ArrayList<Segment>();
  16 + }
  17 +
  18 + public void setValidated(boolean val)
  19 + {
  20 + validated = val;
  21 + }
  22 +
  23 + public boolean getValidated()
  24 + {
  25 + return validated;
  26 + }
  27 +
  28 + public void setSequence(int seq)
  29 + {
  30 + sequenceFirst = seq;
  31 + }
  32 +
  33 + public int getSequence()
  34 + {
  35 + return sequenceFirst;
  36 + }
  37 +
  38 + public void setMaxDuration(int dur)
  39 + {
  40 + maxDuration = dur;
  41 + }
  42 +
  43 + public int getMaxDuration()
  44 + {
  45 + return maxDuration;
  46 + }
  47 +
  48 + public ArrayList<Segment> getSegments()
  49 + {
  50 + return segments;
  51 + }
  52 +}
  53 +
... ...