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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2190 - (show annotations) (download)
Fri Jun 24 20:18:03 2011 UTC (12 years, 10 months ago) by iliev
File size: 2896 byte(s)
* Added support for send effects

1 /*
2 * jlscp - a java LinuxSampler control protocol API
3 *
4 * Copyright (C) 2005-2011 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 /** Creates a new instance of <code>ScanJobInfo</code>. */
36 public
37 ScanJobInfo() { }
38
39 /**
40 * Creates a new instance of <code>ScanJobInfo</code>.
41 * @param resultSet An array with information categories about a scan job.
42 */
43 public
44 ScanJobInfo(String[] resultSet) throws LscpException {
45 for(String s : resultSet)
46 if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s));
47 }
48
49 /**
50 * Determines whether the job is finished.
51 * Note that a negative value of <code>status</code> indicates error.
52 */
53 public boolean
54 isFinished() {
55 if(status < 0) return true;
56 if(filesScanned == filesTotal && status == 100) return true;
57 return false;
58 }
59
60 /**
61 * Parses a line of text.
62 * @param s The string to be parsed.
63 * @return <code>true</code> if the line has been processed, <code>false</code> otherwise.
64 * @throws LscpException If some error occurs.
65 */
66 public boolean
67 parse(String s) throws LscpException {
68 if(s.startsWith("FILES_TOTAL: ")) {
69 s= s.substring("FILES_TOTAL: ".length());
70 try { filesTotal = Integer.parseInt(s); }
71 catch(NumberFormatException x) {
72 throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"), x);
73 }
74 } else if(s.startsWith("FILES_SCANNED: ")) {
75 s = s.substring("FILES_SCANNED: ".length());
76 try { filesScanned = Integer.parseInt(s); }
77 catch(NumberFormatException x) {
78 throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"), x);
79 }
80 } else if(s.startsWith("SCANNING: ")) {
81 scanning = s.substring("SCANNING: ".length());
82 } else if(s.startsWith("STATUS: ")) {
83 s = s.substring("STATUS: ".length());
84 try { status = Integer.parseInt(s); }
85 catch(NumberFormatException x) {
86 throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"), x);
87 }
88 } else return false;
89
90 return true;
91 }
92 }

  ViewVC Help
Powered by ViewVC