|
| 1 | +/* |
| 2 | + * Copyright (C) 2022 Matthieu Gautier <mgautier@kymeria.fr> |
| 3 | + * |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 3 of the License, or |
| 7 | + * any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program; if not, write to the Free Software |
| 16 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 17 | + * MA 02110-1301, USA. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.kiwix.libzim; |
| 21 | + |
| 22 | +import org.kiwix.libzim.ZimFileFormatException; |
| 23 | +import org.kiwix.libzim.Archive; |
| 24 | +import org.kiwix.libzim.Search; |
| 25 | +import org.kiwix.libzim.Query; |
| 26 | +import java.io.FileDescriptor; |
| 27 | + |
| 28 | +public class Searcher |
| 29 | +{ |
| 30 | + |
| 31 | + public Searcĥer(Archive archive) throws ZimFileFormatException |
| 32 | + { |
| 33 | + nativeHandle = getNativeSearcher(archive); |
| 34 | + if (nativeHandle == 0) { |
| 35 | + throw new ZimFileFormatException("Cannot open zimfile "+filename); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + public Searcher(List<Archive> archives) throws ZimFileFormatException |
| 40 | + { |
| 41 | + nativeHandle = getNativeSearcher(archives); |
| 42 | + if (nativeHandle == 0) { |
| 43 | + throw new ZimFileFormatException("Cannot open zimfile by fd "+fd.toString()); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + public native Searcher addArchive(Archive archive); |
| 48 | + public native Search search(Query query); |
| 49 | + public native void setVerbose(boolean verbose); |
| 50 | + |
| 51 | + private native long getNativeSearcher(Archive archive); |
| 52 | + private native long getNativeSearcherMulti(List<Archive> archives); |
| 53 | + |
| 54 | +///--------- The wrapper thing |
| 55 | + // To delete our native wrapper |
| 56 | + public native void dispose(); |
| 57 | + |
| 58 | + // A pointer (as a long) to a native Handle |
| 59 | + private long nativeHandle; |
| 60 | +} |
0 commit comments