3 namespace Lucene
.Net
.Store
5 /* ====================================================================
6 * The Apache Software License, Version 1.1
8 * Copyright (c) 2001 The Apache Software Foundation. All rights
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in
20 * the documentation and/or other materials provided with the
23 * 3. The end-user documentation included with the redistribution,
24 * if any, must include the following acknowledgment:
25 * "This product includes software developed by the
26 * Apache Software Foundation (http://www.apache.org/)."
27 * Alternately, this acknowledgment may appear in the software itself,
28 * if and wherever such third-party acknowledgments normally appear.
30 * 4. The names "Apache" and "Apache Software Foundation" and
31 * "Apache Lucene" must not be used to endorse or promote products
32 * derived from this software without prior written permission. For
33 * written permission, please contact apache@apache.org.
35 * 5. Products derived from this software may not be called "Apache",
36 * "Apache Lucene", nor may "Apache" appear in their name, without
37 * prior written permission of the Apache Software Foundation.
39 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
40 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
46 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * ====================================================================
53 * This software consists of voluntary contributions made by many
54 * individuals on behalf of the Apache Software Foundation. For more
55 * information on the Apache Software Foundation, please see
56 * <http://www.apache.org/>.
60 /// A Directory is a flat list of files. Files may be written once, when they
61 /// are created. Once a file is created it may only be opened for read, or
62 /// deleted. Random access is permitted both when reading and writing.
64 /// <p> Java's i/o APIs not used directly, but rather all i/o is
65 /// through this API. This permits things such as: </p>
67 /// <li> implementation of RAM-based indices;</li>
68 /// <li> implementation indices stored in a database, via JDBC;</li>
69 /// <li> implementation of an index as a single file;</li>
72 /// <author>Doug Cutting</author>
73 public abstract class Directory
76 /// Returns an array of strings, one for each file in the directory.
78 /// <returns></returns>
79 public abstract String
[] List();
82 /// Returns true iff a file with the given name exists.
84 /// <param name="name"></param>
85 /// <returns></returns>
86 public abstract bool FileExists(String name
);
89 /// Returns the time the named file was last modified.
91 /// <param name="name"></param>
92 /// <returns></returns>
93 public abstract long FileModified(String name
) ;
96 /// Set the modified time of an existing file to now.
98 /// <param name="name"></param>
99 public abstract void TouchFile(String name
);
102 /// Removes an existing file in the directory.
104 /// <param name="name"></param>
105 public abstract void DeleteFile(String name
);
108 /// Renames an existing file in the directory.
109 /// If a file already exists with the new name, then it is replaced.
110 /// This replacement should be atomic.
112 /// <param name="from"></param>
113 /// <param name="to"></param>
114 public abstract void RenameFile(String
from, String to
);
117 /// Returns the length of a file in the directory.
119 /// <param name="name"></param>
120 /// <returns></returns>
121 public abstract long FileLength(String name
);
124 /// Creates a new, empty file in the directory with the given name.
125 /// Returns a stream writing this file.
127 /// <param name="name"></param>
128 /// <returns></returns>
129 public abstract OutputStream
CreateFile(String name
);
132 /// Returns a stream reading an existing file.
134 /// <param name="name"></param>
135 /// <returns></returns>
136 public abstract InputStream
OpenFile(String name
);
139 /// Construct a Lock.
141 /// <param name="name">the name of the lock file</param>
142 /// <returns></returns>
143 public abstract Lock
MakeLock(String name
);
146 /// Closes the store.
148 public abstract void Close();