001package com.hfg.util.io;
002
003import java.util.Calendar;
004import java.io.InputStream;
005import java.io.IOException;
006import java.io.File;
007import java.io.OutputStream;
008
009//------------------------------------------------------------------------------
010/**
011 * Interface for remote files
012 *
013 * @author J. Alex Taylor, hairyfatguy.com
014 */
015//------------------------------------------------------------------------------
016// com.hfg XML/HTML Coding Library
017//
018// This library is free software; you can redistribute it and/or
019// modify it under the terms of the GNU Lesser General Public
020// License as published by the Free Software Foundation; either
021// version 2.1 of the License, or (at your option) any later version.
022//
023// This library is distributed in the hope that it will be useful,
024// but WITHOUT ANY WARRANTY; without even the implied warranty of
025// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
026// Lesser General Public License for more details.
027//
028// You should have received a copy of the GNU Lesser General Public
029// License along with this library; if not, write to the Free Software
030// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
031//
032// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
033// jataylor@hairyfatguy.com
034//------------------------------------------------------------------------------
035
036public interface RemoteFile
037{
038   public String getName();
039
040   public String getPath();
041
042   /**
043    The requested path may differ from getPath() if the requested path was a symbolic link.
044    @return The (unwildcarded) path as it was originally requested.
045    */
046   public String getRequestedPath();
047
048   public String getURL();
049
050   public long getSize();
051
052   public Calendar getTimestamp();
053
054   public InputStream getInputStream() throws IOException;
055
056   public long writeToStream(OutputStream stream) throws IOException;
057
058   /**
059    Copies the remote file to the specified local directory. If a local file exists and
060    is up-to-date (same size and an equivalent or newer last modified time),
061    no transfer is done.
062    @return Whether or not the file was actually transferred.
063    */
064   public boolean writeToLocalDir(File inLocalDir) throws IOException;
065
066   /**
067    Copies the remote file to the specified local file. If the local file exists and
068    is up-to-date (same size and an equivalent or newer last modified time),
069    no transfer is done.
070    @return Whether or not the file was actually transferred.
071    */
072   public boolean writeToLocalFile(File inLocalFile) throws IOException;
073
074   /**
075    Copies the remote file to the specified local root dir plus the file's remote path.
076    If the local file exists and is up-to-date (same size and an equivalent or newer last modified time),
077    no transfer is done.
078    @return Whether or not the file was actually transferred.
079    */
080   public boolean copyLocallyPreservingPath(File inLocalRootDir) throws IOException;
081}