BrightSide Workbench Full Report + Source Code
elephant/src/main/java/org/turro/plugin/command/TimelineEvent.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.plugin.command;
20 
21 import java.text.DateFormat;
22 import java.text.SimpleDateFormat;
23 import java.util.Date;
24 import java.util.TimeZone;
25 import org.turro.string.Strings;
26 import org.turro.elephant.context.ElephantContext;
27 import org.turro.html.HTMLGenerator;
28 import org.turro.util.CompareUtil;
29 
34 public class TimelineEvent implements Comparable<TimelineEvent> {
35 
36  private Date start, end;
37  private boolean duration;
38  private String title, image, inside, link;
39 
40  public boolean isDuration() {
41  return duration;
42  }
43 
44  public void setDuration(boolean duration) {
45  this.duration = duration;
46  }
47 
48  public Date getEnd() {
49  return end;
50  }
51 
52  public void setEnd(Date end) {
53  this.end = end;
54  }
55 
56  public String getImage() {
57  return image;
58  }
59 
60  public void setImage(String image) {
61  this.image = image;
62  }
63 
64  public String getInside() {
65  return inside;
66  }
67 
68  public void setInside(String inside) {
69  this.inside = inside;
70  }
71 
72  public String getLink() {
73  return link;
74  }
75 
76  public void setLink(String link) {
77  this.link = link;
78  }
79 
80  public Date getStart() {
81  return start;
82  }
83 
84  public void setStart(Date start) {
85  this.start = start;
86  }
87 
88  public String getTitle() {
89  return title;
90  }
91 
92  public void setTitle(String title) {
93  this.title = title;
94  }
95 
96  public String getEvent() {
97  DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
98  df.setTimeZone(TimeZone.getTimeZone("GMT"));
99  HTMLGenerator hg = new HTMLGenerator();
100  hg.startTag("event", new String[] {
101  (start != null ? "start=\"" + df.format(start) + "\"" : null),
102  (end != null ? "end=\"" + df.format(end) + "\"" : null),
103  (duration ? "isDuration=\"true\"" : null),
104  (!Strings.isBlank(title) ? "title=\"" + Strings.escapeXML(title) + "\"" : null),
105  (!Strings.isBlank(image) ? "image=\"" + ElephantContext.getRootWebPath() + image + "\"" : null),
106  (!Strings.isBlank(link) ? "link=\"" + Strings.escapeXML(link) + "\"" : null)
107  });
108  hg.write("\n");
109  if(!Strings.isBlank(inside)) {
110  hg.write(inside);
111  hg.write("\n");
112  }
113  hg.endAllTags();
114  hg.write("\n");
115  return hg.toString();
116  }
117 
118  @Override
119  public int compareTo(TimelineEvent o) {
120  int result = CompareUtil.compare(start, o.start);
121  if(result == 0) {
122  result = CompareUtil.compare(end, o.end);
123  }
124  if(result == 0) {
125  result = CompareUtil.compare(title, o.title);
126  }
127  return result;
128  }
129 
130 }
HTMLGenerator write(String value)
HTMLGenerator startTag(String tag)