Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
ExtensionJobHistorySerializer | 37 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software 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 GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.extension.job.history; | |
21 | ||
22 | import java.io.File; | |
23 | import java.io.IOException; | |
24 | import java.io.Reader; | |
25 | import java.io.Writer; | |
26 | import java.util.List; | |
27 | ||
28 | import org.xwiki.component.annotation.Role; | |
29 | ||
30 | /** | |
31 | * The interface used to serialize and deserialize the {@link ExtensionJobHistory}. | |
32 | * | |
33 | * @version $Id: 9666c0523a60e1d938c3c36b21e0776f42cacafd $ | |
34 | * @since 7.1RC1 | |
35 | */ | |
36 | @Role | |
37 | public interface ExtensionJobHistorySerializer | |
38 | { | |
39 | /** | |
40 | * Serializes a given history record. | |
41 | * | |
42 | * @param record the history record to serialize | |
43 | * @return the string serialization of the given history record | |
44 | */ | |
45 | String serialize(ExtensionJobHistoryRecord record); | |
46 | ||
47 | /** | |
48 | * Serializes a given history record and passes the result to the given writer. | |
49 | * | |
50 | * @param record the history record to serialize | |
51 | * @param writer where to write the serialized history record | |
52 | */ | |
53 | void write(ExtensionJobHistoryRecord record, Writer writer); | |
54 | ||
55 | /** | |
56 | * Appends the serialization of a given history record to a specified partial history file. | |
57 | * | |
58 | * @param record the history record to serialize | |
59 | * @param historyFile the history file where to append the result | |
60 | * @throws IOException if it fails to append the serialized history record to the specified file | |
61 | */ | |
62 | void append(ExtensionJobHistoryRecord record, File historyFile) throws IOException; | |
63 | ||
64 | /** | |
65 | * Deserializes a list of history records. | |
66 | * | |
67 | * @param serializedRecords the string containing the serialized history records | |
68 | * @return the list of history records that have been deserialized | |
69 | */ | |
70 | List<ExtensionJobHistoryRecord> deserialize(String serializedRecords); | |
71 | ||
72 | /** | |
73 | * Deserializes a list of history records from a given reader. | |
74 | * | |
75 | * @param reader from where to read the history records | |
76 | * @return the list of history records that have been deserialized | |
77 | */ | |
78 | List<ExtensionJobHistoryRecord> read(Reader reader); | |
79 | ||
80 | /** | |
81 | * Deserializes all the history records that have been serialized in the given file. | |
82 | * | |
83 | * @param historyFile the history file containing the serialized history records | |
84 | * @return the list of history records that have been deserialized | |
85 | * @throws IOException if it fails to read from the specified file | |
86 | */ | |
87 | List<ExtensionJobHistoryRecord> read(File historyFile) throws IOException; | |
88 | ||
89 | /** | |
90 | * Clones a list of history records by serializing and deserializing it. | |
91 | * | |
92 | * @param records the list of history records to clone | |
93 | * @return the cloned list | |
94 | */ | |
95 | List<ExtensionJobHistoryRecord> clone(List<ExtensionJobHistoryRecord> records); | |
96 | } |