1 /*
2 * Copyright 2009, openv4j.sf.net, and individual contributors as indicated
3 * by the @authors tag. See the copyright.txt in the distribution for a
4 * full listing of individual contributors.
5 *
6 * This is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this software; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20 *
21 * $Id: $
22 *
23 * @author arnep
24 */
25 package net.sf.openv4j;
26
27 /**
28 * DOCUMENT ME!
29 *
30 * @author aploese
31 */
32 public class CycleTimes {
33 private CycleTimeEntry[] entries;
34
35 /**
36 * Creates a new CycleTimes object.
37 *
38 * @param numberOfCycles DOCUMENT ME!
39 */
40 public CycleTimes(int numberOfCycles) {
41 entries = new CycleTimeEntry[numberOfCycles];
42 }
43
44 /**
45 * DOCUMENT ME!
46 *
47 * @param i DOCUMENT ME!
48 *
49 * @return DOCUMENT ME!
50 */
51 public CycleTimeEntry getEntry(int i) {
52 return entries[i];
53 }
54
55 /**
56 * DOCUMENT ME!
57 *
58 * @param i DOCUMENT ME!
59 * @param entry DOCUMENT ME!
60 */
61 public void setEntry(int i, CycleTimeEntry entry) {
62 entries[i] = entry;
63 }
64
65 /**
66 * DOCUMENT ME!
67 *
68 * @return DOCUMENT ME!
69 */
70 @Override
71 public String toString() {
72 StringBuilder sb = new StringBuilder();
73
74 for (CycleTimeEntry ct : entries) {
75 if (ct == null) {
76 sb.append("ON --:-- OFF --:-- | ");
77 } else {
78 sb.append(String.format("ON %02d:%02d OFF %02d:%02d | ", ct.getStartHour(), ct.getStartMin(), ct.getEndHour(), ct.getEndMin()));
79 }
80 }
81
82 sb.delete(sb.lastIndexOf(" | "), sb.length());
83
84 return sb.toString();
85 }
86
87 //TODO parse String....
88 }