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