简体   繁体   中英

Generate Java class from custom model

Generate java file from XML file without any API

Hi, I would like to know if it's possible to generate a java class from existing model as illustrate in this picture below. enter image description here

Informations about the generated class will be found in a XML file like this:

<?xml version="1.0" encoding="UTF-8"?>
    <entity name="Balise1">
    <attribut name="a" type="List" basetypeid="1"/>
    <typedef type="List" basetypeid="2" id="1"/>
    <typedef type="String" id="2"/> 
</entity>

For exemple when I find the tagname "entity" I create a instance of MjEntity and so on. After iterating the XML file, I have just to generate my Java class.

I believe a costum XML format reader requires you to write your own generator.

There are formats that can generate Java classes from XML. Take a look at .XSD -> .java here.. Generate Java classes from .XSD files...?

Also, if you dont want entity relations in the class object, you can create an orm.xml (Object Relation Mapping) to define this. Take a look at https://dzone.com/articles/persisting-entity-classes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM