~ubuntu-branches/ubuntu/trusty/freeguide/trusty

« back to all changes in this revision

Viewing changes to src/freeguide/plugins/grabber/kulichki/HandlerProg.java

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2007-09-11 16:52:59 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070911165259-4r32oke21i1ezbmv
Tags: 0.10.5-1
* New upstream release.
* Update the watch file.
* Change Debian policy to version 3.7.2.2. No changes necessary.
* Add ant-optional to build dependencies. Closes: #441762.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
import freeguide.common.lib.fgspecific.data.TVChannel;
4
4
import freeguide.common.lib.fgspecific.data.TVProgramme;
 
5
import freeguide.common.lib.general.StringHelper;
5
6
import freeguide.common.lib.grabber.HtmlHelper;
6
7
import freeguide.common.lib.grabber.LineProgrammeHelper;
7
8
import freeguide.common.lib.grabber.TimeHelper;
16
17
import java.io.IOException;
17
18
import java.io.StringReader;
18
19
 
 
20
import java.text.MessageFormat;
19
21
import java.text.ParseException;
20
22
 
 
23
import java.util.ResourceBundle;
21
24
import java.util.TimeZone;
22
25
import java.util.regex.Matcher;
23
26
import java.util.regex.Pattern;
26
29
 * DOCUMENT ME!
27
30
 *
28
31
 * @author $author$
29
 
 * @version $Revision: 1342 $
 
32
 * @version $Revision: 1553 $
30
33
 */
31
34
public class HandlerProg extends HtmlHelper.DefaultContentHandler
32
35
{
 
36
    protected static final String TAG_FONT = "font";
 
37
    protected static final String TAG_PRE = "pre";
33
38
    protected static final int MODES_NONE = 0;
34
39
    protected static final int MODES_CHANNEL_NAME = 1;
35
40
    protected static final int MODES_DATA = 2;
36
 
    protected static Pattern RE_CHANNEL =
 
41
    protected static final Pattern RE_CHANNEL =
37
42
        Pattern.compile( 
38
43
            "\\s*(\\S+)\\s*\\.\\s*(\\d{1,2})\\s+(\\S+)\\s*\\.\\s+(.+)" );
39
44
    protected final IStoragePipe storage;
40
 
    protected ILogger logger;
 
45
    protected final ILogger logger;
 
46
    protected final ResourceBundle i18n;
41
47
    protected TimeZone tz;
42
48
    protected long currentDate;
43
49
    protected String currentChannelID;
51
57
     * @param storage DOCUMENT ME!
52
58
     * @param logger DOCUMENT ME!
53
59
     */
54
 
    public HandlerProg( final IStoragePipe storage, ILogger logger )
 
60
    public HandlerProg( 
 
61
        final IStoragePipe storage, final ILogger logger,
 
62
        final ResourceBundle i18n )
55
63
    {
56
64
        this.storage = storage;
57
65
 
58
66
        this.logger = logger;
59
 
 
 
67
        this.i18n = i18n;
60
68
    }
61
69
 
62
70
    /**
107
115
        String uri, String localName, String qName, Attributes atts )
108
116
        throws SAXException
109
117
    {
110
 
        if( "font".equals( qName ) )
 
118
        if( TAG_FONT.equals( qName ) )
111
119
        {
112
120
            mode = MODES_CHANNEL_NAME;
113
121
 
114
122
        }
115
123
 
116
 
        else if( "pre".equals( qName ) )
 
124
        else if( TAG_PRE.equals( qName ) )
117
125
        {
118
126
            mode = MODES_DATA;
119
127
 
132
140
    public void endElement( String uri, String localName, String qName )
133
141
        throws SAXException
134
142
    {
135
 
        if( "font".equals( qName ) )
 
143
        if( TAG_FONT.equals( qName ) )
136
144
        {
137
145
            mode = MODES_NONE;
138
146
 
139
147
        }
140
148
 
141
 
        else if( "pre".equals( qName ) )
 
149
        else if( TAG_PRE.equals( qName ) )
142
150
        {
143
151
            mode = MODES_NONE;
144
152
 
162
170
        switch( mode )
163
171
        {
164
172
        case MODES_CHANNEL_NAME:
 
173
            storage.finishBlock(  );
165
174
 
166
175
            String data =
167
176
                HtmlHelper.strongTrim( new String( ch, start, length ) );
192
201
                {
193
202
                    currentChannelID = null;
194
203
 
195
 
                    logger.warning( "Error on channel name: " + data );
196
 
 
 
204
                    logger.warning( 
 
205
                        MessageFormat.format( 
 
206
                            i18n.getString( "Logging.ErrorChannelName" ), data ) );
197
207
                }
198
208
            }
199
209
 
223
233
                    {
224
234
                        line = line.trim(  );
225
235
 
226
 
                        if( "".equals( line ) )
 
236
                        if( StringHelper.EMPTY_STRING.equals( line ) )
227
237
                        {
228
238
                            continue;
229
239
 
252
262
 
253
263
                            catch( ParseException ex )
254
264
                            {
255
 
                                logger.warning( "Error parse: " + line );
256
 
 
 
265
                                logger.warning( 
 
266
                                    MessageFormat.format( 
 
267
                                        i18n.getString( "Logging.ErrorParse" ),
 
268
                                        line ) );
257
269
                            }
258
270
                        }
259
271