Mercurial > hg > openmind
diff src/main/java/org/mpi/openmind/repository/utils/OM4XmlEventReader.java @ 32:9c54842f5e86
better names for XML importer sub-classes.
author | casties |
---|---|
date | Thu, 25 Aug 2016 11:29:47 +0200 |
parents | 7d8ebe8ac8a2 |
children | 90f9a1c45b15 |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/utils/OM4XmlEventReader.java Wed Aug 24 19:12:24 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/utils/OM4XmlEventReader.java Thu Aug 25 11:29:47 2016 +0200 @@ -30,8 +30,10 @@ * The read() method reads the contents of the file into the members * .entities and .relations. * - * The contents are Lists of OmEntities and OmRelations also holding - * Lists of omAttributes. + * The contents are Lists of OmXmlEntities and OmXmlRelations holding + * Lists of omXmlAttributes. + * + * This implementation uses XMLEventReader. * * @author casties * @@ -48,11 +50,11 @@ InputStream xmlStream; public int numEntities; - public List<OmEntity> entities; + public List<OmXmlEntity> entities; private int entCnt = 0; public int numRelations; - public List<OmRelation> relations; + public List<OmXmlRelation> relations; private int relCnt = 0; /** @@ -60,7 +62,7 @@ * * @author casties */ - public class OmAttribute { + public class OmXmlAttribute { public Map<String, String> xmlAtts; public String value; @@ -74,10 +76,10 @@ * * @author casties */ - public class OmEntity { + public class OmXmlEntity { public Map<String, String> xmlAtts; public String value; - public List<OmAttribute> attributes; + public List<OmXmlAttribute> attributes; public String getId() { return xmlAtts.get("id"); @@ -89,10 +91,10 @@ * * @author casties */ - public class OmRelation { + public class OmXmlRelation { public Map<String, String> xmlAtts; public String value; - public List<OmAttribute> attributes; + public List<OmXmlAttribute> attributes; public String getId() { return xmlAtts.get("id"); @@ -135,7 +137,7 @@ * @return * @throws XMLStreamException */ - private List<OmEntity> processEntities(StartElement elem, XMLEventReader reader) throws XMLStreamException { + private List<OmXmlEntity> processEntities(StartElement elem, XMLEventReader reader) throws XMLStreamException { logger.debug("loading entities..."); // get number attribute Attribute numa = elem.getAttributeByName(new QName("number")); @@ -143,7 +145,7 @@ numEntities = Integer.parseInt(numa.getValue()); } // start reading sub-elements - List<OmEntity> entities = new ArrayList<OmEntity>(); + List<OmXmlEntity> entities = new ArrayList<OmXmlEntity>(); while (reader.hasNext()) { XMLEvent e = reader.nextEvent(); if (e.isStartElement()) { @@ -175,9 +177,9 @@ * @return * @throws XMLStreamException */ - private OmEntity processEntity(StartElement elem, XMLEventReader reader) throws XMLStreamException { + private OmXmlEntity processEntity(StartElement elem, XMLEventReader reader) throws XMLStreamException { //logger.debug("entity"); - OmEntity ent = new OmEntity(); + OmXmlEntity ent = new OmXmlEntity(); Map<String, String> xmlAtts = new HashMap<String, String>(); @SuppressWarnings("unchecked") Iterator<Attribute> atts = elem.getAttributes(); @@ -187,7 +189,7 @@ } ent.xmlAtts = xmlAtts; // start reading sub-elements - ent.attributes = new ArrayList<OmAttribute>(); + ent.attributes = new ArrayList<OmXmlAttribute>(); while (reader.hasNext()) { XMLEvent e = reader.nextEvent(); if (e.isStartElement()) { @@ -232,7 +234,7 @@ * @return * @throws XMLStreamException */ - private List<OmRelation> processRelations(StartElement elem, XMLEventReader reader) throws XMLStreamException { + private List<OmXmlRelation> processRelations(StartElement elem, XMLEventReader reader) throws XMLStreamException { logger.debug("loading relations..."); // get number attribute Attribute numa = elem.getAttributeByName(new QName("number")); @@ -240,7 +242,7 @@ numRelations = Integer.parseInt(numa.getValue()); } // start reading sub-elements - List<OmRelation> rels = new ArrayList<OmRelation>(); + List<OmXmlRelation> rels = new ArrayList<OmXmlRelation>(); while (reader.hasNext()) { XMLEvent e = reader.nextEvent(); if (e.isStartElement()) { @@ -273,9 +275,9 @@ * @return * @throws XMLStreamException */ - private OmRelation processRelation(StartElement elem, XMLEventReader reader) throws XMLStreamException { + private OmXmlRelation processRelation(StartElement elem, XMLEventReader reader) throws XMLStreamException { //logger.debug("relation"); - OmRelation rel = new OmRelation(); + OmXmlRelation rel = new OmXmlRelation(); Map<String, String> xmlAtts = new HashMap<String, String>(); @SuppressWarnings("unchecked") Iterator<Attribute> atts = elem.getAttributes(); @@ -285,7 +287,7 @@ } rel.xmlAtts = xmlAtts; // start reading sub-elements - rel.attributes = new ArrayList<OmAttribute>(); + rel.attributes = new ArrayList<OmXmlAttribute>(); while (reader.hasNext()) { XMLEvent e = reader.nextEvent(); if (e.isStartElement()) { @@ -330,9 +332,9 @@ * @return * @throws XMLStreamException */ - private OmAttribute processAttribute(StartElement elem, XMLEventReader reader) throws XMLStreamException { + private OmXmlAttribute processAttribute(StartElement elem, XMLEventReader reader) throws XMLStreamException { //logger.debug("attribute"); - OmAttribute oma = new OmAttribute(); + OmXmlAttribute oma = new OmXmlAttribute(); Map<String, String> xmlAtts = new HashMap<String, String>(); @SuppressWarnings("unchecked") Iterator<Attribute> atts = elem.getAttributes();