001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.lucene.store.jdbc.handler;
018:
019: import java.io.IOException;
020: import java.util.List;
021:
022: import org.apache.lucene.store.IndexInput;
023: import org.apache.lucene.store.IndexOutput;
024: import org.apache.lucene.store.jdbc.JdbcDirectory;
025:
026: /**
027: * A No Operation file entry handler. Performs no actual dirty operations,
028: * and returns empty data for read operations.
029: *
030: * @author kimchy
031: */
032: public class NoOpFileEntryHandler implements FileEntryHandler {
033:
034: private static class NoOpIndexInput extends IndexInput {
035: public byte readByte() throws IOException {
036: return 0;
037: }
038:
039: public void readBytes(byte[] b, int offset, int len)
040: throws IOException {
041:
042: }
043:
044: public void close() throws IOException {
045:
046: }
047:
048: public long getFilePointer() {
049: return 0;
050: }
051:
052: public void seek(long pos) throws IOException {
053: }
054:
055: public long length() {
056: return 0;
057: }
058: }
059:
060: private static class NoOpIndexOutput extends IndexOutput {
061: public void writeByte(byte b) throws IOException {
062:
063: }
064:
065: public void writeBytes(byte[] b, int offset, int length)
066: throws IOException {
067:
068: }
069:
070: public void flush() throws IOException {
071: }
072:
073: public void close() throws IOException {
074: }
075:
076: public long getFilePointer() {
077: return 0;
078: }
079:
080: public void seek(long pos) throws IOException {
081: }
082:
083: public long length() throws IOException {
084: return 0;
085: }
086: }
087:
088: private static IndexInput indexInput = new NoOpIndexInput();
089:
090: private static IndexOutput indexOutput = new NoOpIndexOutput();
091:
092: public void configure(JdbcDirectory jdbcDirectory) {
093: }
094:
095: public boolean fileExists(final String name) throws IOException {
096: return false;
097: }
098:
099: public long fileModified(final String name) throws IOException {
100: return 0;
101: }
102:
103: public void touchFile(final String name) throws IOException {
104: }
105:
106: public void deleteFile(final String name) throws IOException {
107: }
108:
109: public List deleteFiles(List names) throws IOException {
110: return null;
111: }
112:
113: public void renameFile(final String from, final String to)
114: throws IOException {
115: }
116:
117: public long fileLength(final String name) throws IOException {
118: return 0;
119: }
120:
121: public IndexInput openInput(String name) throws IOException {
122: return indexInput;
123: }
124:
125: public IndexOutput createOutput(String name) throws IOException {
126: return indexOutput;
127: }
128:
129: public void close() throws IOException {
130: // do notihng
131: }
132: }
|