View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package goldengate.common.file.passthrough;
22  
23  import java.nio.channels.FileChannel;
24  import java.util.List;
25  
26  import org.jboss.netty.buffer.ChannelBuffer;
27  
28  /**
29   * This interface is for Object used in Passthrough mode.
30   *
31   * @author Frederic Bregier
32   *
33   */
34  public interface PassthroughFile {
35  
36      public boolean isDirectory();
37      public boolean isFile();
38      public ChannelBuffer read(int sizeblock) throws PassthroughException;
39      public int write(ChannelBuffer buffer) throws PassthroughException;
40      public long length();
41      public boolean canRead();
42      public boolean canWrite();
43      public boolean isInReading();
44      public boolean isInWriting();
45      public boolean exists();
46      public boolean delete() throws PassthroughException;
47      public boolean renameTo(String path) throws PassthroughException;
48      public void position(long position) throws PassthroughException;
49      public void flush() throws PassthroughException;
50      /**
51       * Note: be aware to not directly use transferTo or transferFrom at once but
52       * to use them by chunk to prevent memory usage (mmap used under the wood by the JVM)
53       * 
54       * @param out
55       * @return the size in bytes transfered
56       * @throws PassthroughException
57       */
58      public long transferTo(FileChannel out) throws PassthroughException;
59      public void close() throws PassthroughException;
60  
61      // Some extra functions that could be not implemented but just throwing the exception
62      public List<String> wildcard(String subPath) throws PassthroughException;
63      public boolean mkdir() throws PassthroughException;
64      public boolean rmdir() throws PassthroughException;
65      public boolean changeDirectory(String path) throws PassthroughException;
66      /**
67       * Return the Modification time
68       *
69       * @return the Modification time as a String YYYYMMDDHHMMSS.sss
70       */
71      public String getModificationTime() throws PassthroughException;
72      public List<String> list() throws PassthroughException;
73      public List<String> listFull(boolean lsFormat) throws PassthroughException;
74      public String fileFull(boolean lsFormat) throws PassthroughException;
75      public long getFreeSpace() throws PassthroughException;
76      public long getCRC() throws PassthroughException;
77      public byte[] getMD5() throws PassthroughException;
78      public byte[] getSHA1() throws PassthroughException;
79  
80  }