/** * This file is part of Archiv-Editor. * * The software Archiv-Editor serves as a client user interface for working with * the Person Data Repository. See: pdr.bbaw.de * * The software Archiv-Editor was developed at the Berlin-Brandenburg Academy * of Sciences and Humanities, Jägerstr. 22/23, D-10117 Berlin. * www.bbaw.de * * Copyright (C) 2010-2013 Berlin-Brandenburg Academy * of Sciences and Humanities * * The software Archiv-Editor was developed by @author: Christoph Plutte. * * Archiv-Editor is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Archiv-Editor is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Archiv-Editor. * If not, see <http://www.gnu.org/licenses/lgpl-3.0.html>. */ package org.bbaw.pdr.ae.control.saxHandler; import java.util.Vector; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; /** * The Class IDSaxHandler. * @author Christoph Plutte */ public class IDSaxHandler implements ContentHandler { /** The ids. */ private Vector<String> _ids = new Vector<String>(); /** The id. */ private String _id; /** The _result object. */ private Object _resultObject; @Override public void characters(final char[] ch, final int start, final int length) throws SAXException { } @Override public void endDocument() throws SAXException { } @Override public final void endElement(final String uri, final String localName, final String qName) throws SAXException { if (localName.equals("id")) { _ids.add(_id); } else if (localName.equals("result")) { // mainSearcher.setTempIds(ids); setResultObject(_ids); } } @Override public void endPrefixMapping(final String prefix) throws SAXException { } /** * Gets the result object. * @return the result object */ public final Object getResultObject() { return _resultObject; } @Override public void ignorableWhitespace(final char[] ch, final int start, final int length) throws SAXException { } @Override public void processingInstruction(final String target, final String data) throws SAXException { } @Override public void setDocumentLocator(final Locator locator) { } /** * Sets the result object. * @param resultObject the new result object */ private void setResultObject(final Object resultObject) { this._resultObject = resultObject; } @Override public void skippedEntity(final String name) throws SAXException { } @Override public void startDocument() throws SAXException { } @Override public final void startElement(final String uri, final String localName, final String qName, final Attributes atts) throws SAXException { if (localName.equals("id")) { for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("id")) { _id = new String(atts.getValue(i)); } } } } @Override public void startPrefixMapping(final String prefix, final String uri) throws SAXException { } }