/[svn]/jlscp/trunk/src/org/linuxsampler/lscp/ScanJobInfo.java
ViewVC logotype

Annotation of /jlscp/trunk/src/org/linuxsampler/lscp/ScanJobInfo.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1202 - (hide annotations) (download)
Thu May 24 20:17:25 2007 UTC (16 years, 11 months ago) by iliev
File size: 2808 byte(s)
* updated to version 0.5a

1 iliev 1202 /*
2     * jlscp - a java LinuxSampler control protocol API
3     *
4     * Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>
5     *
6     * This file is part of jlscp.
7     *
8     * jlscp is free software; you can redistribute it and/or modify
9     * it under the terms of the GNU General Public License version 2
10     * as published by the Free Software Foundation.
11     *
12     * jlscp is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with jlscp; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20     * MA 02111-1307 USA
21     */
22    
23     package org.linuxsampler.lscp;
24    
25     /**
26     * Provides information about a running scan job.
27     * @author Grigor Iliev
28     */
29     public class ScanJobInfo implements Parseable {
30     public int filesTotal;
31     public int filesScanned;
32     public String scanning;
33     public int status;
34    
35     /**
36     * Creates a new instance of <code>ScanJobInfo</code>.
37     * @param resultSet An array with information categories about a scan job.
38     */
39     public
40     ScanJobInfo(String[] resultSet) throws LscpException {
41     for(String s : resultSet)
42     if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s));
43     }
44    
45     /**
46     * Determines whether the job is finished.
47     * Note that a negative value of <code>status</code> indicates error.
48     */
49     public boolean
50     isFinished() {
51     if(status < 0) return true;
52     if(filesScanned == filesTotal && status == 100) return true;
53     return false;
54     }
55    
56     /**
57     * Parses a line of text.
58     * @param s The string to be parsed.
59     * @return <code>true</code> if the line has been processed, <code>false</code> otherwise.
60     * @throws LscpException If some error occurs.
61     */
62     public boolean
63     parse(String s) throws LscpException {
64     if(s.startsWith("FILES_TOTAL: ")) {
65     s= s.substring("FILES_TOTAL: ".length());
66     try { filesTotal = Integer.parseInt(s); }
67     catch(NumberFormatException x) {
68     throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"), x);
69     }
70     } else if(s.startsWith("FILES_SCANNED: ")) {
71     s = s.substring("FILES_SCANNED: ".length());
72     try { filesScanned = Integer.parseInt(s); }
73     catch(NumberFormatException x) {
74     throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"), x);
75     }
76     } else if(s.startsWith("SCANNING: ")) {
77     scanning = s.substring("SCANNING: ".length());
78     } else if(s.startsWith("STATUS: ")) {
79     s = s.substring("STATUS: ".length());
80     try { status = Integer.parseInt(s); }
81     catch(NumberFormatException x) {
82     throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"), x);
83     }
84     } else return false;
85    
86     return true;
87     }
88     }

  ViewVC Help
Powered by ViewVC