commit | author | age
|
ca8e1e
|
1 |
/* |
U |
2 |
Transit - Remote procedure calls made simple |
|
3 |
Copyright (c) 2012 Ulrich Hilger |
|
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 de.uhilger.transit; |
|
20 |
|
|
21 |
|
|
22 |
import com.thoughtworks.xstream.XStream; |
|
23 |
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; |
|
24 |
|
|
25 |
/** |
|
26 |
* Java-Objekte in die JavaScript Object Notation (JSON) |
|
27 |
* verwandeln und umgekehrt |
|
28 |
* |
053e6a
|
29 |
* Dieser Wandler erzeugt ein unformatiertes und nicht so gut |
U |
30 |
* lesbares , aber voll gueltiges JSON-Format |
|
31 |
* |
ca8e1e
|
32 |
* <p>Diese Klasse benoetigt die Java-Klassenbibliotheken |
42c48e
|
33 |
* <a href="http://xstream.codehaus.org/" target="_blank">XStream</a> |
U |
34 |
* und <a href="http://jettison.codehaus.org/" target="_blank">Jettison</a> |
ca8e1e
|
35 |
* im Classpath.</p> |
U |
36 |
* |
|
37 |
* @author Copyright (c) Ulrich Hilger, http://uhilger.de |
|
38 |
* @author Published under the terms and conditions of |
|
39 |
* the <a href="http://www.gnu.org/licenses/agpl-3.0" target="_blank">GNU Affero General Public License</a> |
|
40 |
* |
|
41 |
* @version 1, September 16, 2012 |
|
42 |
*/ |
|
43 |
public class JsonWandler extends AbstractWandler { |
|
44 |
|
|
45 |
/** Bezeichnerdes Formats, das dieser Wandler unterstuetzt */ |
|
46 |
public static final String FORMAT_JSON = "JSON"; |
|
47 |
|
053e6a
|
48 |
@Override |
ca8e1e
|
49 |
protected XStream getXStream() { |
U |
50 |
return new XStream(new JettisonMappedXmlDriver()); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Das Format ermitteln, das dieser Wandler verarbeitet |
|
55 |
* @return das Format, das dieser Wandler verarbeitet |
|
56 |
*/ |
|
57 |
@Override |
|
58 |
public String getFormat() { |
|
59 |
return FORMAT_JSON; |
|
60 |
} |
|
61 |
|
|
62 |
} |