All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.xolite.graph.PersonObjectFactory Maven / Gradle / Ivy

package net.sf.xolite.graph;


import java.util.HashMap;
import java.util.Map;

import net.sf.xolite.Attributes;
import net.sf.xolite.XMLEventParser;
import net.sf.xolite.XMLObjectFactory;
import net.sf.xolite.XMLParseException;
import net.sf.xolite.XMLSerializable;


public class PersonObjectFactory implements XMLObjectFactory {


    private Map allPersons = new HashMap();


    public XMLSerializable createObject(String namespaceUri, String localName, XMLEventParser parser) throws XMLParseException {
        String firstName = Attributes.getMandatoryString(Person.FIRST_NAME_ATTRIBUTE, parser);
        String lastName = Attributes.getMandatoryString(Person.LAST_NAME_ATTRIBUTE, parser);
        String dateString = Attributes.getMandatoryString(Person.BIRTH_DATE_ATTRIBUTE, parser);
        String key = firstName + "|" + lastName + "|" + dateString;
        Person p = allPersons.get(key);
        if (p == null) {
            p = new Person();
            allPersons.put(key, p);
        }
        parser.delegateParsingTo(p);
        return p;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy