01 /*
02 * Java Genetic Algorithm Library (jenetics-2.0.2).
03 * Copyright (c) 2007-2014 Franz Wilhelmstötter
04 *
05 * Licensed under the Apache License, Version 2.0 (the "License");
06 * you may not use this file except in compliance with the License.
07 * You may obtain a copy of the License at
08 *
09 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Author:
18 * Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
19 */
20 package org.jenetics.internal.util;
21
22 import javax.xml.bind.annotation.XmlAccessType;
23 import javax.xml.bind.annotation.XmlAccessorType;
24 import javax.xml.bind.annotation.XmlAttribute;
25 import javax.xml.bind.annotation.XmlElement;
26 import javax.xml.bind.annotation.XmlRootElement;
27 import javax.xml.bind.annotation.XmlType;
28 import javax.xml.bind.annotation.XmlValue;
29 import javax.xml.bind.annotation.adapters.XmlAdapter;
30
31 import org.jenetics.util.StaticObject;
32
33 /**
34 * This object contains models not defined as native XML type.
35 *
36 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
37 * @version 1.6 — <em>$Date: 2014-03-27 $</em>
38 * @since 2.0
39 */
40 public final class model extends StaticObject {
41 private model() {}
42
43 @XmlRootElement(name = "char")
44 @XmlType(name = "char")
45 @XmlAccessorType(XmlAccessType.FIELD)
46 public static final class CharacterModel {
47
48 @XmlValue
49 public String value;
50
51 public static final class Adapter
52 extends XmlAdapter<CharacterModel, Character>
53 {
54 @Override
55 public CharacterModel marshal(final Character value) {
56 final CharacterModel model = new CharacterModel();
57 model.value = value.toString();
58 return model;
59 }
60
61 @Override
62 public Character unmarshal(final CharacterModel model) {
63 return model.value.charAt(0);
64 }
65 }
66
67 public static final Adapter ADAPTER = new Adapter();
68
69 }
70
71 @XmlRootElement(name = "indexed-object")
72 @XmlType(name = "org.jenetics.IndexedObject")
73 @XmlAccessorType(XmlAccessType.FIELD)
74 public static final class IndexedObject {
75
76 @XmlAttribute(required = true)
77 public int index;
78
79 @XmlElement(name = "value", required = true, nillable = false)
80 public Object value;
81
82 }
83
84 }
|