home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lucene example source code file (_TestHelper.java)

This example Lucene source code file (_TestHelper.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lucene tags/keywords

io, ioexception, ioexception, simplefsindexinput, simplefsindexinput

The Lucene _TestHelper.java source code

package org.apache.lucene.store;

 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

import java.io.IOException;

import org.apache.lucene.store.SimpleFSDirectory.SimpleFSIndexInput;

/** This class provides access to package-level features defined in the
 *  store package. It is used for testing only.
public class _TestHelper {

    /** Returns true if the instance of the provided input stream is actually
     *  an SimpleFSIndexInput.
    public static boolean isSimpleFSIndexInput(IndexInput is) {
        return is instanceof SimpleFSIndexInput;

    /** Returns true if the provided input stream is an SimpleFSIndexInput and
     *  is a clone, that is it does not own its underlying file descriptor.
    public static boolean isSimpleFSIndexInputClone(IndexInput is) {
        if (isSimpleFSIndexInput(is)) {
            return ((SimpleFSIndexInput) is).isClone;
        } else {
            return false;

    /** Given an instance of SimpleFSDirectory.SimpleFSIndexInput, this method returns
     *  true if the underlying file descriptor is valid, and false otherwise.
     *  This can be used to determine if the OS file has been closed.
     *  The descriptor becomes invalid when the non-clone instance of the
     *  SimpleFSIndexInput that owns this descriptor is closed. However, the
     *  descriptor may possibly become invalid in other ways as well.
    public static boolean isSimpleFSIndexInputOpen(IndexInput is)
    throws IOException
        if (isSimpleFSIndexInput(is)) {
            SimpleFSIndexInput fis = (SimpleFSIndexInput) is;
            return fis.isFDValid();
        } else {
            return false;


Other Lucene examples (source code examples)

Here is a short list of links related to this Lucene _TestHelper.java source code file:

my book on functional programming


new blog posts


Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.