1
我想马歇尔对象“主”与JAXB,这是根类的属性:编组站ObservableList与JAXB
private StringProperty mensaje;
private bd database;
private ObservableList<MarcoOntologicoColectivo> Inteligencia_colectiva=FXCollections.observableArrayList();
private ObservableList<agent> agentData = FXCollections.observableArrayList();
private ObservableList<MarcoOntologicoColectivo> Colectivo=FXCollections.observableArrayList();
private ObservableList<MarcoOntologicoColectivo> Belongs=FXCollections.observableArrayList();
但由于某些原因(我不知道为什么)JAXB只需要属性数据库和mensaje,我需要保存observableList这也是输出:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<main>
<database>
<a_mecanismo>Hebbiano</a_mecanismo>
<a_tecnicas>Redes Neuronales</a_tecnicas>
<a_tecnicas>Arboles de Decision</a_tecnicas>
<a_tecnicas>Reglas</a_tecnicas> <a_tipo>Supervisado</a_tipo>
<a_tipo>No supervisado</a_tipo>
<a_tipo>Reforzamiento</a_tipo>
<actos_habla>Requerimiento de Procesamiento</actos_habla>
<caracterizacion>Concepto</caracterizacion>
<caracterizacion>Propiedad</caracterizacion>
<r_estrategia>Deductivo</r_estrategia>
<r_estrategia>Inductivo</r_estrategia>
<r_estrategia>Abductivo</r_estrategia>
<r_lenguaje>OWL</r_lenguaje>
<r_lenguaje>RDF</r_lenguaje>
<servicio>Interno</servicio>
<servicio>Externo</servicio>
<servicio>Dual</servicio>
<tipo_datos>byte</tipo_datos>
<tipo_datos>short</tipo_datos>
<tipo_datos>int</tipo_datos>
</database>
<mensaje/>
</main>
那么,我错了?我该怎么办?
我编辑的项目,并增加了可观察名单适配器将:
public class ObservableListAdapter<T> extends XmlAdapter<LinkedList<T>, ObservableList<T>> {
@Override
public ObservableList<T> unmarshal(LinkedList<T> v) throws Exception {
return FXCollections.observableList(v);
}
@Override
public LinkedList<T> marshal(ObservableList<T> v) throws Exception {
LinkedList<T> list = new LinkedList<T>();
list.addAll(v);
return list; // Or whatever the correct method is
}
}
现在在XML文件中出现:
<belongs/>
<colectivo/>
<inteligencia_colectiva/>
但犯规元帅他们的内容,我该怎么办?
我宣布JAXB背景是这样的:
File file = new File("file.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(MyClass.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
是否JAXB编组标MarcoOntologicoColectivo和标代理?另外,你是否尝试将列表声明为'List <...>'? – laune
嗨,不,我不想要列表我需要observableList那是我不想改变的东西。我用适配器ObservableList,他们JAXB马歇尔'ObservableList'正确,但没有'ObservableList '为examplo –
是的,我知道你需要一个ObservableList,他们却看它是否有一个列表的作品,我们会把它从那里。 – laune