alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file 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.

Other links

The source code

package org.apache.lucene.store;
import java.io.RandomAccessFile;
import java.io.IOException;

/** 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 FSInputStream.
     */
    public static boolean isFSInputStream(InputStream is) {
        return is instanceof FSInputStream;
    }

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

    /** Given an instance of FSDirectory.FSInputStream, 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
     *  FSInputStream that owns this descriptor is closed. However, the
     *  descriptor may possibly become invalid in other ways as well.
     */
    public static boolean isFSInputStreamOpen(InputStream is)
    throws IOException
    {
        if (isFSInputStream(is)) {
            FSInputStream fis = (FSInputStream) is;
            return fis.isFDValid();
        } else {
            return false;
        }
    }

}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 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.