📄 nulldocumentfactory.java
字号:
package test.it.unimi.dsi.mg4j.document;/* * MG4J: Managing Gigabytes for Java * * Copyright (C) 2006-2007 Sebastiano Vigna * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;import it.unimi.dsi.io.FastBufferedReader;import it.unimi.dsi.io.NullReader;import it.unimi.dsi.io.WordReader;import it.unimi.dsi.mg4j.document.AbstractDocument;import it.unimi.dsi.mg4j.document.Document;import it.unimi.dsi.mg4j.document.PropertyBasedDocumentFactory;import it.unimi.dsi.util.Properties;import java.io.InputStream;/** A factory (with a single text field named <samp>text</samp>) that does not read at all from input streams and always * return an empty reader. */@SuppressWarnings("unused")public class NullDocumentFactory extends PropertyBasedDocumentFactory { private static final long serialVersionUID = 1L; public NullDocumentFactory() {} public NullDocumentFactory( final Reference2ObjectMap<Enum<?>,Object> defaultMetadata ) {} public NullDocumentFactory( final Properties properties ) {} public NullDocumentFactory( final String[] property ) {} public NullDocumentFactory copy() { return this; } public int numberOfFields() { return 1; } public String fieldName( final int field ) { if ( field != 0 ) throw new IndexOutOfBoundsException(); return "text"; } public int fieldIndex( final String fieldName ) { return fieldName.equals( "text" ) ? 0: -1; } public FieldType fieldType( final int field ) { return FieldType.TEXT; } public Document getDocument( final InputStream rawContent, final Reference2ObjectMap<Enum<?>,Object> metadata ) { return new AbstractDocument() { public CharSequence title() { return "dummy title"; } public String toString() { return title().toString(); } public CharSequence uri() { return "dummy://"; } public Object content( final int field ) { if ( field != 0 ) throw new IndexOutOfBoundsException(); return NullReader.getInstance(); } public WordReader wordReader( final int field ) { return new FastBufferedReader(); } }; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -