View Javadoc
1   package info.mikethomas.fahview.v6project.model;
2   
3   /*
4    * #%L
5    * This file is part of FAHView-v6project.
6    * %%
7    * Copyright (C) 2011 - 2017 Mike Thomas <mikepthomas@outlook.com>
8    * %%
9    * FAHView is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * %
14   * FAHView is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * %
19   * You should have received a copy of the GNU General Public License
20   * along with FAHView.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  /**
25   * Class to represent data stored about a Folding@home client.
26   *
27   * @author <a href="mailto:mikepthomas@outlook.com">Michael Thomas</a>
28   * @version $Id: $Id
29   */
30  public class Client {
31      private QueueImpl queue;
32  
33      private String location, type;
34  
35      private String edition, version, launchDirectory, executable, arguments;
36      private String userName, userID;
37      private int machineID, teamNo;
38  
39      /**
40       * <p>Constructor for Client.</p>
41       *
42       * @param location a {@link java.lang.String} object.
43       */
44      public Client(String location) {
45          this.location = location;
46          //queue = new QueueImpl(location + "queue.dat");
47      }
48  
49      /**
50       * <p>Setter for the field <code>arguments</code>.</p>
51       *
52       * @param line a {@link java.lang.String} object.
53       */
54      protected void setArguments(String line) {
55          arguments = trimFilePath(line);
56      }
57  
58      /**
59       * <p>Setter for the field <code>edition</code>.</p>
60       *
61       * @param line a {@link java.lang.String} object.
62       */
63      protected void setEdition(String line) {
64          edition = (line.replace("#", "")).trim();
65      }
66  
67      /**
68       * <p>Setter for the field <code>executable</code>.</p>
69       *
70       * @param line a {@link java.lang.String} object.
71       */
72      protected void setExecutable(String line) {
73          executable = trimFilePath(line);
74      }
75  
76      /**
77       * <p>Setter for the field <code>launchDirectory</code>.</p>
78       *
79       * @param line a {@link java.lang.String} object.
80       */
81      protected void setLaunchDirectory(String line) {
82          launchDirectory = trimFilePath(line);
83      }
84  
85      /**
86       * <p>Setter for the field <code>machineID</code>.</p>
87       *
88       * @param line a {@link java.lang.String} object.
89       */
90      protected void setMachineID(String line) {
91          machineID = Integer.valueOf(trimAttribute(line));
92      }
93  
94      /**
95       * <p>Setter for the field <code>userID</code>.</p>
96       *
97       * @param line a {@link java.lang.String} object.
98       */
99      protected void setUserID(String line) {
100         userID = trimAttribute(line);
101     }
102 
103     /**
104      * <p>Setter for the field <code>userName</code>.</p>
105      *
106      * @param line a {@link java.lang.String} object.
107      */
108     protected void setUserName(String line) {
109         String user = line.substring(line.lastIndexOf(":") + 2, line.indexOf("(") - 1);
110         userName = user;
111         String team = line.substring(line.lastIndexOf(" ") + 1, line.indexOf(")"));
112         teamNo = Integer.parseInt(team);
113     }
114 
115     /**
116      * <p>Setter for the field <code>version</code>.</p>
117      *
118      * @param line a {@link java.lang.String} object.
119      */
120     protected void setVersion(String line) {
121         version = line.trim();
122     }
123 
124     /**
125      * <p>Getter for the field <code>arguments</code>.</p>
126      *
127      * @return a {@link java.lang.String} object.
128      */
129     public String getArguments() {
130         return arguments;
131     }
132 
133     /**
134      * <p>Getter for the field <code>edition</code>.</p>
135      *
136      * @return a {@link java.lang.String} object.
137      */
138     public String getEdition() {
139         return edition;
140     }
141 
142     /**
143      * <p>Getter for the field <code>executable</code>.</p>
144      *
145      * @return a {@link java.lang.String} object.
146      */
147     public String getExecutable() {
148         return executable;
149     }
150 
151     /**
152      * <p>Getter for the field <code>launchDirectory</code>.</p>
153      *
154      * @return a {@link java.lang.String} object.
155      */
156     public String getLaunchDirectory() {
157         return launchDirectory;
158     }
159 
160     /**
161      * <p>Getter for the field <code>teamNo</code>.</p>
162      *
163      * @return a int.
164      */
165     public int getTeamNo() {
166         return teamNo;
167     }
168 
169     /**
170      * <p>Getter for the field <code>machineID</code>.</p>
171      *
172      * @return a int.
173      */
174     public int getMachineID() {
175         return machineID;
176     }
177 
178     /**
179      * <p>Getter for the field <code>userID</code>.</p>
180      *
181      * @return a {@link java.lang.String} object.
182      */
183     public String getUserID() {
184         return userID;
185     }
186 
187     /**
188      * <p>Getter for the field <code>userName</code>.</p>
189      *
190      * @return a {@link java.lang.String} object.
191      */
192     public String getUserName() {
193         return userName;
194     }
195 
196     /**
197      * <p>Getter for the field <code>version</code>.</p>
198      *
199      * @return a {@link java.lang.String} object.
200      */
201     public String getVersion() {
202         return version;
203     }
204 
205     /**
206      * <p>trimAttribute.</p>
207      *
208      * @param line a {@link java.lang.String} object.
209      * @return a {@link java.lang.String} object.
210      */
211     private String trimAttribute(String line) {
212         return line = line.substring(line.lastIndexOf(":") + 2);
213     }
214 
215     /**
216      * <p>trimFilePath.</p>
217      *
218      * @param line a {@link java.lang.String} object.
219      * @return a {@link java.lang.String} object.
220      */
221     private String trimFilePath(String line) {
222         return line = line.substring(line.indexOf(":") + 2);
223     }
224 
225     /**
226      * <p>Getter for the field <code>location</code>.</p>
227      *
228      * @return a {@link java.lang.String} object.
229      */
230     public String getLocation() {
231         return location;
232     }
233 }