From: <eg...@us...> - 2009-03-06 19:48:13
|
Revision: 14368 http://cdk.svn.sourceforge.net/cdk/?rev=14368&view=rev Author: egonw Date: 2009-03-06 19:47:55 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Fixed the use of the iterating readers for Jython, by reverting an patch r10907. Problem was reported on http://chem-bla-ics.blogspot.com/2009/02/cdk-12-release-candidate.html Modified Paths: -------------- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IIteratingChemObjectReader.java cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IteratingPCSubstancesXMLReader.java cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/IRandomAccessChemObjectReader.java cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessReader.java cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessSDFReader.java Added Paths: ----------- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/DefaultRandomAccessChemObjectReader.java Modified: cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IIteratingChemObjectReader.java =================================================================== --- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IIteratingChemObjectReader.java 2009-03-06 16:27:45 UTC (rev 14367) +++ cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IIteratingChemObjectReader.java 2009-03-06 19:47:55 UTC (rev 14368) @@ -27,8 +27,8 @@ */ package org.openscience.cdk.io.iterator; -import org.openscience.cdk.exception.CDKException; -import org.openscience.cdk.interfaces.IChemObject; +import java.util.Iterator; + import org.openscience.cdk.io.IChemObjectReader; /** @@ -44,11 +44,8 @@ * @author Egon Willighagen <eg...@sc...> * @cdk.created 2003-10-19 */ -public interface IIteratingChemObjectReader extends IChemObjectReader { +public interface IIteratingChemObjectReader + extends IChemObjectReader, Iterator { - public boolean hasNext() throws CDKException; - - public IChemObject next() throws CDKException; - } Modified: cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IteratingPCSubstancesXMLReader.java =================================================================== --- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IteratingPCSubstancesXMLReader.java 2009-03-06 16:27:45 UTC (rev 14367) +++ cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/iterator/IteratingPCSubstancesXMLReader.java 2009-03-06 19:47:55 UTC (rev 14368) @@ -107,7 +107,7 @@ return PubChemSubstancesXMLFormat.getInstance(); } - public boolean hasNext() throws CDKException { + public boolean hasNext() { if (!nextAvailableIsKnown) { hasNext = false; @@ -128,7 +128,7 @@ } catch (Exception e) { if (mode == Mode.STRICT) { - throw new CDKException("Error while parsing the XML: " + e.getMessage(), e); + throw new RuntimeException("Error while parsing the XML: " + e.getMessage(), e); } hasNext = false; } @@ -139,7 +139,7 @@ return hasNext; } - public IChemObject next() throws CDKException { + public IChemObject next() { if (!nextAvailableIsKnown) { hasNext(); } Added: cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/DefaultRandomAccessChemObjectReader.java =================================================================== --- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/DefaultRandomAccessChemObjectReader.java (rev 0) +++ cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/DefaultRandomAccessChemObjectReader.java 2009-03-06 19:47:55 UTC (rev 14368) @@ -0,0 +1,75 @@ +/* $Revision$ $Author$ $Date$ + * + * Copyright (C) 2003-2007 The Jmol Development Team + * 2009 Egon Willighagen <eg...@us...> + * + * Contact: cdk...@li... + * + * This library 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 2.1 of the License, or (at your option) any later version. + * + * This library 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.openscience.cdk.io.random; + +import java.util.ArrayList; +import java.util.List; + +import org.openscience.cdk.interfaces.IChemObject; +import org.openscience.cdk.io.IChemObjectReader; +import org.openscience.cdk.io.ISimpleChemObjectReader; +import org.openscience.cdk.io.listener.IChemObjectIOListener; +import org.openscience.cdk.io.setting.IOSetting; + +/** + * Abstract class that {@link IRandomAccessChemObjectReader}'s can implement to + * have it take care of basic stuff, like managing the ReaderListeners. + * + * @cdk.module io + * @cdk.svnrev $Revision$ + */ +public abstract class DefaultRandomAccessChemObjectReader + implements IRandomAccessChemObjectReader<IChemObject> { + + protected IChemObjectReader.Mode mode = IChemObjectReader.Mode.RELAXED; + + /** + * Holder of reader event listeners. + */ + private List<IChemObjectIOListener> listenerList = new ArrayList<IChemObjectIOListener>(); + + public void addChemObjectIOListener(IChemObjectIOListener listener) { + listenerList.add(listener); + } + + public void removeChemObjectIOListener(IChemObjectIOListener listener) { + listenerList.remove(listener); + } + + /* Extra convenience methods */ + + protected void fireIOSettingQuestion(IOSetting setting) { + for (int i = 0; i < listenerList.size(); ++i) { + IChemObjectIOListener listener = listenerList.get(i); + listener.processIOSettingQuestion(setting); + } + } + + public IOSetting[] getIOSettings() { + return new IOSetting[0]; + } + + public void setReaderMode(ISimpleChemObjectReader.Mode mode) { + this.mode = mode; + } + +} Modified: cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/IRandomAccessChemObjectReader.java =================================================================== --- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/IRandomAccessChemObjectReader.java 2009-03-06 16:27:45 UTC (rev 14367) +++ cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/IRandomAccessChemObjectReader.java 2009-03-06 19:47:55 UTC (rev 14368) @@ -22,16 +22,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * */ - - package org.openscience.cdk.io.random; import java.util.ListIterator; /** - * Extension of {@link java.util.ListIterator} - * @author Nina Jeliazkova ni...@ac... - * <b>Modified</b> May 25, 2008 + * Extension of {@link java.util.ListIterator}. + * + * @author Nina Jeliazkova <ni...@ac...> + * @cdk.module io */ public interface IRandomAccessChemObjectReader<T> extends ListIterator<T> { Modified: cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessReader.java =================================================================== --- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessReader.java 2009-03-06 16:27:45 UTC (rev 14367) +++ cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessReader.java 2009-03-06 19:47:55 UTC (rev 14368) @@ -1,6 +1,7 @@ /* $Revision:$ * * Copyright (C) 2005-2008 Nina Jeliazkova <ni...@ac...> + * 2009 Egon Willighagen <eg...@us...> * * Contact: cdk...@li... * @@ -39,7 +40,6 @@ import org.openscience.cdk.io.IChemObjectReader; import org.openscience.cdk.io.ISimpleChemObjectReader; import org.openscience.cdk.io.ReaderEvent; -import org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader; import org.openscience.cdk.io.listener.IChemObjectIOListener; import org.openscience.cdk.io.listener.IReaderListener; import org.openscience.cdk.io.setting.IOSetting; @@ -52,9 +52,13 @@ * Subsequent access for a record N uses this index to seek the record and return the molecule. * Useful for very big files. * - * @author Nina Jeliazkova ni...@ac... + * @author Nina Jeliazkova <ni...@ac...> + * @cdk.module io */ -public abstract class RandomAccessReader extends DefaultIteratingChemObjectReader implements IRandomAccessChemObjectReader<IChemObject> { +public abstract class RandomAccessReader + extends DefaultRandomAccessChemObjectReader + implements IRandomAccessChemObjectReader<IChemObject> { + protected static LoggingTool logger = new LoggingTool(RandomAccessReader.class); protected RandomAccessFile raFile; protected IOSetting[] headerOptions = null; Modified: cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessSDFReader.java =================================================================== --- cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessSDFReader.java 2009-03-06 16:27:45 UTC (rev 14367) +++ cdk/branches/cdk-1.2.x/src/main/org/openscience/cdk/io/random/RandomAccessSDFReader.java 2009-03-06 19:47:55 UTC (rev 14368) @@ -44,9 +44,11 @@ import org.openscience.cdk.io.listener.IReaderListener; /** - * Random access of SDF file. Doesn't load molecules in memory, uses prebuilt index and seeks to find the correct record offset. + * Random access of SDF file. Doesn't load molecules in memory, uses prebuilt + * index and seeks to find the correct record offset. * - * @author Nina Jeliazkova ni...@ac... + * @author Nina Jeliazkova <ni...@ac...> + * @cdk.module io */ public class RandomAccessSDFReader extends RandomAccessReader { @@ -120,4 +122,9 @@ return chemObjectReader.accepts(classObject); } + public void remove() { + throw new UnsupportedOperationException("Cannot remove entries with " + + "the RandomAccessSDFReader"); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |