Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ToDoItemXMLHelper |
|
| 2.0;2 |
1 | /* $Id: ToDoItemXMLHelper.java 17832 2010-01-12 19:02:29Z linus $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * tfmorris | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 1996-2006 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.persistence; | |
40 | ||
41 | import org.argouml.cognitive.ToDoItem; | |
42 | ||
43 | /** | |
44 | * Helper class to help save todo items properly in the .todo XML file. | |
45 | * It provides a view of A ToDoItem particularly suited for saving in an | |
46 | * XML file by encoding strings to preserve graphic characters and allow | |
47 | * lines to be broken and still be able to regain the original contents. | |
48 | * Used by todo.tee | |
49 | * This is not to be considered as part of the peristence interface. | |
50 | * | |
51 | * @see ToDoItem | |
52 | * @author Michael Stockman | |
53 | */ | |
54 | public class ToDoItemXMLHelper | |
55 | { | |
56 | private final ToDoItem item; | |
57 | ||
58 | /** | |
59 | * Creates a new ToDoItemXMLHelper for item. | |
60 | * | |
61 | * @param todoItem A ToDoItem. | |
62 | */ | |
63 | public ToDoItemXMLHelper(ToDoItem todoItem) | |
64 | 0 | { |
65 | 0 | if (todoItem == null) |
66 | 0 | throw new NullPointerException(); |
67 | 0 | item = todoItem; |
68 | 0 | } |
69 | ||
70 | /** | |
71 | * Encodes the headline of this ToDoItem in an XML safe way and | |
72 | * returns the new String. The String can be regained by running the | |
73 | * returned String through | |
74 | * {@link TodoParser#decode(String)}. | |
75 | * | |
76 | * @return The encoded headline. | |
77 | */ | |
78 | public String getHeadline() | |
79 | { | |
80 | 0 | return TodoParser.encode(item.getHeadline()); |
81 | } | |
82 | ||
83 | /** | |
84 | * Encodes the priority of this ToDoItem in an XML safe way and | |
85 | * returns the new String. The String can be regained by running the | |
86 | * returned String through | |
87 | * {@link TodoParser#decode(String)} and comparing to the | |
88 | * STRING_prio_* values in TodoTokenTable. | |
89 | * | |
90 | * @return The encoded priority. | |
91 | */ | |
92 | public String getPriority() | |
93 | { | |
94 | 0 | String s = TodoTokenTable.STRING_PRIO_HIGH; |
95 | 0 | switch (item.getPriority()) |
96 | { | |
97 | case ToDoItem.HIGH_PRIORITY: | |
98 | 0 | s = TodoTokenTable.STRING_PRIO_HIGH; |
99 | 0 | break; |
100 | ||
101 | case ToDoItem.MED_PRIORITY: | |
102 | 0 | s = TodoTokenTable.STRING_PRIO_MED; |
103 | 0 | break; |
104 | ||
105 | case ToDoItem.LOW_PRIORITY: | |
106 | 0 | s = TodoTokenTable.STRING_PRIO_LOW; |
107 | break; | |
108 | } | |
109 | ||
110 | 0 | return TodoParser.encode(s); |
111 | } | |
112 | ||
113 | /** | |
114 | * Encodes the moreInfoURL of this ToDoItem in an XML safe way and | |
115 | * returns the new String. The String can be regained by running the | |
116 | * returned String through | |
117 | * {@link TodoParser#decode(String)}. | |
118 | * | |
119 | * @return The encoded moreInfoURL. | |
120 | */ | |
121 | public String getMoreInfoURL() | |
122 | { | |
123 | 0 | return TodoParser.encode(item.getMoreInfoURL()); |
124 | } | |
125 | ||
126 | /** | |
127 | * Encodes the description of this ToDoItem in an XML safe way and | |
128 | * returns the new String. The String can be regained by running the | |
129 | * returned String through | |
130 | * {@link TodoParser#decode(String)}. | |
131 | * | |
132 | * @return The encoded description. | |
133 | */ | |
134 | public String getDescription() | |
135 | { | |
136 | 0 | return TodoParser.encode(item.getDescription()); |
137 | } | |
138 | } | |
139 |