Package edu.uci.ics.jung.io.graphml

Examples of edu.uci.ics.jung.io.graphml.DataMetadata


    public DataMetadata parse(XMLEventReader xmlEventReader, StartElement start)
            throws GraphIOException {

        try {
            // Create the new port.
            DataMetadata data = new DataMetadata();

            // Parse the attributes.
            Iterator iterator = start.getAttributes();
            while (iterator.hasNext()) {
                Attribute attribute = (Attribute) iterator.next();
                String name = attribute.getName().getLocalPart();
                String value = attribute.getValue();
                if (data.getKey() == null && GraphMLConstants.KEY_NAME.equals(name)) {
                    data.setKey(value);
                }
            }

            // Make sure the key has been set.
            if (data.getKey() == null) {
                throw new GraphIOException(
                        "Element 'data' is missing attribute 'key'");
            }

            while (xmlEventReader.hasNext()) {

                XMLEvent event = xmlEventReader.nextEvent();
                if (event.isStartElement()) {
                    StartElement element = (StartElement) event;
                       
                    // Treat any child elements as unknown
                    getUnknownParser().parse(xmlEventReader, element);
                }
                if (event.isCharacters()) {
                    Characters characters = (Characters) event;
                    data.setValue(characters.getData());
                }
                if (event.isEndElement()) {
                    EndElement end = (EndElement) event;
                    verifyMatch(start, end);
                    break;
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.io.graphml.DataMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.