Code Search for Developers
 
 
  

FSPathCriteria.java from Kneobase at Krugle


Show FSPathCriteria.java syntax highlighted

/*
 * Created on May 14, 2004
 *
 */
package com.kneobase.driver.fs;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;

import com.kneobase.KneobaseException;
import com.kneobase.driver.content.A_SourceCriteria;
import com.kneobase.driver.content.I_ContentSource;

/**
 * This class implements a SourceCriteria where the criteria 
 * is collection of path prefix. 
 * 
 * 
 * A ContentUnits (wrapped file) matches with this criteria if
 * its file path starts with any of the configured path prefix.
 */
public class FSPathCriteria extends A_SourceCriteria {

    private Collection paths = new ArrayList();

    public Collection getCompositeContents(I_ContentSource contentSource)
        throws KneobaseException {
        Collection contents = new Vector();
        Iterator itPaths = getPaths().iterator();
        while (itPaths.hasNext()) {
            String path = (String) itPaths.next();
            File rootFolder = (File) contentSource.getSourceObject();
            File folder = new File(rootFolder.getAbsolutePath() + path);
            if (folder.isDirectory()) {
                FolderAdapter folderAdapter = new FolderAdapter(folder);
                contents.add(folderAdapter);
            } else {
                throw new KneobaseException(
                    "path criteria need are defined over folders, can not locate or isn't folder: "
                        + folder.getAbsolutePath());
            }
        }

        return contents;
    }

    /**
     * Add a path prefix.
     * @param path
     */
    public void addPath(String path) {
        paths.add(path);
    }
    /**
     * Rescue the path prefix collection. 
     * @return
     */
    public Collection getPaths() {
        return paths;
    }

    /**
     * Sets the path prefix collection.  
     * @param collection
     */
    public void setPaths(Collection collection) {
        paths = collection;
    }

}




See more files for this project here

Kneobase

Kneobase is an enterprise search engine, based upon the Lucene search engine and the Spring framework. It allows to perform full-text search across many different content sources. It is highly adaptable out-of-the-box and has a pluggable architecture.

Project homepage: http://sourceforge.net/projects/kneobase
Programming language(s): Java,XML
License: other

  condition/
    FSCategoryCondition.java
    FSRegularExpressionCondition.java
  documentbuilder/
    A_FSFieldBuilder.java
  FSContentSource.java
  FSPathCriteria.java
  FileAdapter.java
  FolderAdapter.java