View Javadoc

1   package org.apache.maven.plugin.trac;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.text.ParseException;
23  import java.text.SimpleDateFormat;
24  import java.util.Calendar;
25  import java.util.Date;
26  import java.util.Locale;
27  
28  /**
29   * A Trac Ticket.
30   *
31   * @author Noriko Kinugasa
32   * @version $Id: TracTicket.html 816595 2012-05-08 12:43:00Z hboutemy $
33   */
34  public class TracTicket
35  {
36      private String id;
37  
38      private String link;
39  
40      private Date timeCreated;
41  
42      private Date timeChanged;
43  
44      private String type;
45  
46      private String summary;
47  
48      private String status;
49  
50      private String resolution;
51  
52      private String milestone;
53  
54      private String owner;
55  
56      private String priority;
57  
58      private String reporter;
59  
60      private String component;
61  
62      public String getComponent()
63      {
64          return component;
65      }
66  
67      public void setComponent( String component )
68      {
69          this.component = component;
70      }
71  
72      public String getPriority()
73      {
74          return priority;
75      }
76  
77      public void setPriority( String priority )
78      {
79          this.priority = priority;
80      }
81  
82      public String getReporter()
83      {
84          return reporter;
85      }
86  
87      public void setReporter( String reporter )
88      {
89          this.reporter = reporter;
90      }
91  
92      public TracTicket()
93      {
94      }
95  
96      public String getId()
97      {
98          return id;
99      }
100 
101     public void setId( String id )
102     {
103         this.id = id;
104     }
105 
106     public String getMilestone()
107     {
108         return milestone;
109     }
110 
111     public void setMilestone( String milestone )
112     {
113         this.milestone = milestone;
114     }
115 
116     public String getOwner()
117     {
118         return owner;
119     }
120 
121     public void setOwner( String owner )
122     {
123         this.owner = owner;
124     }
125 
126     public String getResolution()
127     {
128         return resolution;
129     }
130 
131     public void setResolution( String resolution )
132     {
133         this.resolution = resolution;
134     }
135 
136     public String getStatus()
137     {
138         return status;
139     }
140 
141     public void setStatus( String status )
142     {
143         this.status = status;
144     }
145 
146     public String getSummary()
147     {
148         return summary;
149     }
150 
151     public void setSummary( String summary )
152     {
153         this.summary = summary;
154     }
155 
156     public String getType()
157     {
158         return type;
159     }
160 
161     public void setType( String type )
162     {
163         this.type = type;
164     }
165 
166     public Date getTimeChanged()
167     {
168         return timeChanged;
169     }
170 
171     public void setTimeChanged( String timeChanged )
172     {
173         this.timeChanged = parseDate( timeChanged );
174     }
175 
176     public Date getTimeCreated()
177     {
178         return timeCreated;
179     }
180 
181     public void setTimeCreated( String timeCreated )
182     {
183         this.timeCreated = parseDate( timeCreated );
184     }
185 
186     private Date parseDate( String timeCreated )
187         throws RuntimeException
188     {
189         try
190         {
191             long millis = Long.parseLong( timeCreated );
192             Calendar cld = Calendar.getInstance();
193             cld.setTimeInMillis( millis * 1000L );
194             return cld.getTime();
195         }
196         catch ( NumberFormatException e )
197         {
198             SimpleDateFormat format = new SimpleDateFormat( "EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH );
199             try
200             {
201                 return format.parse( timeCreated );
202             }
203             catch ( ParseException e1 )
204             {
205                 throw new RuntimeException( "Failed to parse date '" + timeCreated + "' as a date.", e1 );
206             }
207         }
208     }
209 
210     public String getLink()
211     {
212         return link;
213     }
214 
215     public void setLink( String link )
216     {
217         this.link = link;
218     }
219 
220 }