You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rg...@apache.org on 2009/04/13 06:06:06 UTC

svn commit: r764356 [9/11] - in /commons/proper/vfs/trunk: ./ core/src/main/java/org/apache/commons/vfs/ core/src/main/java/org/apache/commons/vfs/auth/ core/src/main/java/org/apache/commons/vfs/cache/ core/src/main/java/org/apache/commons/vfs/events/ ...

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileRandomAccessContent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileRandomAccessContent.java Mon Apr 13 04:06:01 2009
@@ -31,582 +31,582 @@
  */
 public class RamFileRandomAccessContent implements RandomAccessContent
 {
-	/**
-	 * Buffer
-	 */
-	byte[] buf;
-
-	/**
-	 * File Pointer
-	 */
-	protected int filePointer = 0;
-
-	/**
-	 * buffer
-	 */
-	private byte buffer8[] = new byte[8];
-
-	/**
-	 * buffer
-	 */
-	private byte buffer4[] = new byte[4];
-
-	/**
-	 * buffer
-	 */
-	private byte buffer2[] = new byte[2];
-
-	/**
-	 * buffer
-	 */
-	private byte buffer1[] = new byte[1];
-
-	/**
-	 * Mode
-	 */
-	private RandomAccessMode mode;
-
-	/**
-	 * File
-	 */
-	private RamFileObject file;
-
-	private InputStream rafis;
-
-	/**
-	 * @param mode
-	 */
-	public RamFileRandomAccessContent(RamFileObject file, RandomAccessMode mode)
-	{
-		super();
-		this.buf = file.getData().getBuffer();
-		this.file = file;
-		this.mode = mode;
-
-		rafis = new InputStream()
-		{
-			public int read() throws IOException
-			{
-				try
-				{
-					return readByte();
-				}
-				catch (EOFException e)
-				{
-					return -1;
-				}
-			}
-
-			public long skip(long n) throws IOException
-			{
-				seek(getFilePointer() + n);
-				return n;
-			}
-
-			public void close() throws IOException
-			{
-			}
-
-			public int read(byte b[]) throws IOException
-			{
-				return read(b, 0, b.length);
-			}
-
-			public int read(byte b[], int off, int len) throws IOException
-			{
-				int retLen = Math.min(len, getLeftBytes());
-				RamFileRandomAccessContent.this.readFully(b, off, retLen);
-				return retLen;
-			}
-
-			public int available() throws IOException
-			{
-				return getLeftBytes();
-			}
-		};
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.commons.vfs.RandomAccessContent#getFilePointer()
-	 */
-	public long getFilePointer() throws IOException
-	{
-		return this.filePointer;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.commons.vfs.RandomAccessContent#seek(long)
-	 */
-	public void seek(long pos) throws IOException
-	{
-		this.filePointer = (int) pos;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.commons.vfs.RandomAccessContent#length()
-	 */
-	public long length() throws IOException
-	{
-		return buf.length;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.commons.vfs.RandomAccessContent#close()
-	 */
-	public void close() throws IOException
-	{
-
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readByte()
-	 */
-	public byte readByte() throws IOException
-	{
-		return (byte) this.readUnsignedByte();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readChar()
-	 */
-	public char readChar() throws IOException
-	{
-		int ch1 = this.readUnsignedByte();
-		int ch2 = this.readUnsignedByte();
-		return (char) ((ch1 << 8) + (ch2 << 0));
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readDouble()
-	 */
-	public double readDouble() throws IOException
-	{
-		return Double.longBitsToDouble(this.readLong());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readFloat()
-	 */
-	public float readFloat() throws IOException
-	{
-		return Float.intBitsToFloat(this.readInt());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readInt()
-	 */
-	public int readInt() throws IOException
-	{
-		return (readUnsignedByte() << 24) | (readUnsignedByte() << 16)
-				| (readUnsignedByte() << 8) | readUnsignedByte();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readUnsignedByte()
-	 */
-	public int readUnsignedByte() throws IOException
-	{
-		if (filePointer < buf.length)
-		{
-			return buf[filePointer++] & 0xFF;
-		}
-		else
-		{
-			throw new EOFException();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readUnsignedShort()
-	 */
-	public int readUnsignedShort() throws IOException
-	{
-		this.readFully(buffer2);
-		return toUnsignedShort(buffer2);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readLong()
-	 */
-	public long readLong() throws IOException
-	{
-		this.readFully(buffer8);
-		return toLong(buffer8);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readShort()
-	 */
-	public short readShort() throws IOException
-	{
-		this.readFully(buffer2);
-		return toShort(buffer2);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readBoolean()
-	 */
-	public boolean readBoolean() throws IOException
-	{
-		return (this.readUnsignedByte() != 0);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#skipBytes(int)
-	 */
-	public int skipBytes(int n) throws IOException
-	{
-		if (n < 0)
-		{
-			throw new IndexOutOfBoundsException(
-					"The skip number can't be negative");
-		}
-
-		long newPos = filePointer + n;
-
-		if (newPos > buf.length)
-		{
-			throw new IndexOutOfBoundsException("Tyring to skip too much bytes");
-		}
-
-		seek(newPos);
-
-		return n;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readFully(byte[])
-	 */
-	public void readFully(byte[] b) throws IOException
-	{
-		this.readFully(b, 0, b.length);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readFully(byte[], int, int)
-	 */
-	public void readFully(byte[] b, int off, int len) throws IOException
-	{
-		if (len < 0)
-		{
-			throw new IndexOutOfBoundsException("Length is lower than 0");
-		}
-
-		if (len > this.getLeftBytes())
-		{
-			throw new IndexOutOfBoundsException("Read length (" + len
-					+ ") is higher than buffer left bytes ("
-					+ this.getLeftBytes() + ") ");
-		}
-
-		System.arraycopy(buf, filePointer, b, off, len);
-
-		filePointer += len;
-	}
-
-	private int getLeftBytes()
-	{
-		return buf.length - filePointer;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readUTF()
-	 */
-	public String readUTF() throws IOException
-	{
-		return DataInputStream.readUTF(this);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#write(byte[], int, int)
-	 */
-	public void write(byte[] b, int off, int len) throws IOException
-	{
-		if (this.getLeftBytes() < len)
-		{
-			int newSize = this.buf.length + len - this.getLeftBytes();
-			this.file.resize(newSize);
-			this.buf = this.file.getData().getBuffer();
-		}
-		System.arraycopy(b, off, this.buf, filePointer, len);
-		this.filePointer += len;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#write(byte[])
-	 */
-	public void write(byte[] b) throws IOException
-	{
-		this.write(b, 0, b.length);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeByte(int)
-	 */
-	public void writeByte(int i) throws IOException
-	{
-		this.write(i);
-	}
-
-	/**
-	 * Build a long from first 8 bytes of the array.
-	 * 
-	 * @author Apache-Commons-Id Team
-	 * @param b
-	 *            The byte[] to convert.
-	 * @return A long.
-	 */
-	public static long toLong(byte[] b)
-	{
-		return ((((long) b[7]) & 0xFF) + ((((long) b[6]) & 0xFF) << 8)
-				+ ((((long) b[5]) & 0xFF) << 16)
-				+ ((((long) b[4]) & 0xFF) << 24)
-				+ ((((long) b[3]) & 0xFF) << 32)
-				+ ((((long) b[2]) & 0xFF) << 40)
-				+ ((((long) b[1]) & 0xFF) << 48) + ((((long) b[0]) & 0xFF) << 56));
-	}
-
-	/**
-	 * Build a 8-byte array from a long. No check is performed on the array
-	 * length.
-	 * 
-	 * @author Commons-Id Team
-	 * 
-	 * @param n
-	 *            The number to convert.
-	 * @param b
-	 *            The array to fill.
-	 * @return A byte[].
-	 */
-	public static byte[] toBytes(long n, byte[] b)
-	{
-		b[7] = (byte) (n);
-		n >>>= 8;
-		b[6] = (byte) (n);
-		n >>>= 8;
-		b[5] = (byte) (n);
-		n >>>= 8;
-		b[4] = (byte) (n);
-		n >>>= 8;
-		b[3] = (byte) (n);
-		n >>>= 8;
-		b[2] = (byte) (n);
-		n >>>= 8;
-		b[1] = (byte) (n);
-		n >>>= 8;
-		b[0] = (byte) (n);
-		return b;
-	}
-
-	/**
-	 * Build a short from first 2 bytes of the array.
-	 * 
-	 * @author Apache-Commons-Id Team
-	 * @param b
-	 *            The byte[] to convert.
-	 * @return A short.
-	 */
-	public static short toShort(byte[] b)
-	{
-		return (short) toUnsignedShort(b);
-	}
-
-	/**
-	 * Build a short from first 2 bytes of the array.
-	 * 
-	 * @author Apache-Commons-Id Team
-	 * @param b
-	 *            The byte[] to convert.
-	 * @return A short.
-	 */
-	public static int toUnsignedShort(byte[] b)
-	{
-		return ((b[1] & 0xFF) + ((b[0] & 0xFF) << 8));
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#write(int)
-	 */
-	public void write(int b) throws IOException
-	{
-		buffer1[0] = (byte) b;
-		this.write(buffer1);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeBoolean(boolean)
-	 */
-	public void writeBoolean(boolean v) throws IOException
-	{
-		this.write(v ? 1 : 0);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeBytes(java.lang.String)
-	 */
-	public void writeBytes(String s) throws IOException
-	{
-		write(s.getBytes());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeChar(int)
-	 */
-	public void writeChar(int v) throws IOException
-	{
-		buffer2[0] = (byte) ((v >>> 8) & 0xFF);
-		buffer2[1] = (byte) ((v >>> 0) & 0xFF);
-		write(buffer2);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeChars(java.lang.String)
-	 */
-	public void writeChars(String s) throws IOException
-	{
-		int len = s.length();
-		for (int i = 0; i < len; i++)
-		{
-			writeChar(s.charAt(i));
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeDouble(double)
-	 */
-	public void writeDouble(double v) throws IOException
-	{
-		writeLong(Double.doubleToLongBits(v));
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeFloat(float)
-	 */
-	public void writeFloat(float v) throws IOException
-	{
-		writeInt(Float.floatToIntBits(v));
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeInt(int)
-	 */
-	public void writeInt(int v) throws IOException
-	{
-		buffer4[0] = (byte) ((v >>> 24) & 0xFF);
-		buffer4[1] = (byte) ((v >>> 16) & 0xFF);
-		buffer4[2] = (byte) ((v >>> 8) & 0xFF);
-		buffer4[3] = (byte) (v & 0xFF);
-		write(buffer4);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeLong(long)
-	 */
-	public void writeLong(long v) throws IOException
-	{
-		write(toBytes(v, buffer8));
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeShort(int)
-	 */
-	public void writeShort(int v) throws IOException
-	{
-		buffer2[0] = (byte) ((v >>> 8) & 0xFF);
-		buffer2[1] = (byte) (v & 0xFF);
-		write(buffer2);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataOutput#writeUTF(java.lang.String)
-	 */
-	public void writeUTF(String str) throws IOException
-	{
-		ByteArrayOutputStream out = new ByteArrayOutputStream(str.length());
-		DataOutputStream dataOut = new DataOutputStream(out);
-		dataOut.writeUTF(str);
-		dataOut.flush();
-		dataOut.close();
-		byte[] b = out.toByteArray();
-		write(b);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.DataInput#readLine()
-	 */
-	public String readLine() throws IOException
-	{
-		throw new UnsupportedOperationException("deprecated");
-	}
-
-	public InputStream getInputStream() throws IOException
-	{
-		return rafis;
-	}
+    /**
+     * Buffer
+     */
+    byte[] buf;
+
+    /**
+     * File Pointer
+     */
+    protected int filePointer = 0;
+
+    /**
+     * buffer
+     */
+    private byte buffer8[] = new byte[8];
+
+    /**
+     * buffer
+     */
+    private byte buffer4[] = new byte[4];
+
+    /**
+     * buffer
+     */
+    private byte buffer2[] = new byte[2];
+
+    /**
+     * buffer
+     */
+    private byte buffer1[] = new byte[1];
+
+    /**
+     * Mode
+     */
+    private RandomAccessMode mode;
+
+    /**
+     * File
+     */
+    private RamFileObject file;
+
+    private InputStream rafis;
+
+    /**
+     * @param mode
+     */
+    public RamFileRandomAccessContent(RamFileObject file, RandomAccessMode mode)
+    {
+        super();
+        this.buf = file.getData().getBuffer();
+        this.file = file;
+        this.mode = mode;
+
+        rafis = new InputStream()
+        {
+            public int read() throws IOException
+            {
+                try
+                {
+                    return readByte();
+                }
+                catch (EOFException e)
+                {
+                    return -1;
+                }
+            }
+
+            public long skip(long n) throws IOException
+            {
+                seek(getFilePointer() + n);
+                return n;
+            }
+
+            public void close() throws IOException
+            {
+            }
+
+            public int read(byte b[]) throws IOException
+            {
+                return read(b, 0, b.length);
+            }
+
+            public int read(byte b[], int off, int len) throws IOException
+            {
+                int retLen = Math.min(len, getLeftBytes());
+                RamFileRandomAccessContent.this.readFully(b, off, retLen);
+                return retLen;
+            }
+
+            public int available() throws IOException
+            {
+                return getLeftBytes();
+            }
+        };
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.vfs.RandomAccessContent#getFilePointer()
+     */
+    public long getFilePointer() throws IOException
+    {
+        return this.filePointer;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.vfs.RandomAccessContent#seek(long)
+     */
+    public void seek(long pos) throws IOException
+    {
+        this.filePointer = (int) pos;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.vfs.RandomAccessContent#length()
+     */
+    public long length() throws IOException
+    {
+        return buf.length;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.vfs.RandomAccessContent#close()
+     */
+    public void close() throws IOException
+    {
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readByte()
+     */
+    public byte readByte() throws IOException
+    {
+        return (byte) this.readUnsignedByte();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readChar()
+     */
+    public char readChar() throws IOException
+    {
+        int ch1 = this.readUnsignedByte();
+        int ch2 = this.readUnsignedByte();
+        return (char) ((ch1 << 8) + (ch2 << 0));
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readDouble()
+     */
+    public double readDouble() throws IOException
+    {
+        return Double.longBitsToDouble(this.readLong());
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readFloat()
+     */
+    public float readFloat() throws IOException
+    {
+        return Float.intBitsToFloat(this.readInt());
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readInt()
+     */
+    public int readInt() throws IOException
+    {
+        return (readUnsignedByte() << 24) | (readUnsignedByte() << 16)
+                | (readUnsignedByte() << 8) | readUnsignedByte();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readUnsignedByte()
+     */
+    public int readUnsignedByte() throws IOException
+    {
+        if (filePointer < buf.length)
+        {
+            return buf[filePointer++] & 0xFF;
+        }
+        else
+        {
+            throw new EOFException();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readUnsignedShort()
+     */
+    public int readUnsignedShort() throws IOException
+    {
+        this.readFully(buffer2);
+        return toUnsignedShort(buffer2);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readLong()
+     */
+    public long readLong() throws IOException
+    {
+        this.readFully(buffer8);
+        return toLong(buffer8);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readShort()
+     */
+    public short readShort() throws IOException
+    {
+        this.readFully(buffer2);
+        return toShort(buffer2);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readBoolean()
+     */
+    public boolean readBoolean() throws IOException
+    {
+        return (this.readUnsignedByte() != 0);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#skipBytes(int)
+     */
+    public int skipBytes(int n) throws IOException
+    {
+        if (n < 0)
+        {
+            throw new IndexOutOfBoundsException(
+                    "The skip number can't be negative");
+        }
+
+        long newPos = filePointer + n;
+
+        if (newPos > buf.length)
+        {
+            throw new IndexOutOfBoundsException("Tyring to skip too much bytes");
+        }
+
+        seek(newPos);
+
+        return n;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readFully(byte[])
+     */
+    public void readFully(byte[] b) throws IOException
+    {
+        this.readFully(b, 0, b.length);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readFully(byte[], int, int)
+     */
+    public void readFully(byte[] b, int off, int len) throws IOException
+    {
+        if (len < 0)
+        {
+            throw new IndexOutOfBoundsException("Length is lower than 0");
+        }
+
+        if (len > this.getLeftBytes())
+        {
+            throw new IndexOutOfBoundsException("Read length (" + len
+                    + ") is higher than buffer left bytes ("
+                    + this.getLeftBytes() + ") ");
+        }
+
+        System.arraycopy(buf, filePointer, b, off, len);
+
+        filePointer += len;
+    }
+
+    private int getLeftBytes()
+    {
+        return buf.length - filePointer;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readUTF()
+     */
+    public String readUTF() throws IOException
+    {
+        return DataInputStream.readUTF(this);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#write(byte[], int, int)
+     */
+    public void write(byte[] b, int off, int len) throws IOException
+    {
+        if (this.getLeftBytes() < len)
+        {
+            int newSize = this.buf.length + len - this.getLeftBytes();
+            this.file.resize(newSize);
+            this.buf = this.file.getData().getBuffer();
+        }
+        System.arraycopy(b, off, this.buf, filePointer, len);
+        this.filePointer += len;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#write(byte[])
+     */
+    public void write(byte[] b) throws IOException
+    {
+        this.write(b, 0, b.length);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeByte(int)
+     */
+    public void writeByte(int i) throws IOException
+    {
+        this.write(i);
+    }
+
+    /**
+     * Build a long from first 8 bytes of the array.
+     *
+     * @author Apache-Commons-Id Team
+     * @param b
+     *            The byte[] to convert.
+     * @return A long.
+     */
+    public static long toLong(byte[] b)
+    {
+        return ((((long) b[7]) & 0xFF) + ((((long) b[6]) & 0xFF) << 8)
+                + ((((long) b[5]) & 0xFF) << 16)
+                + ((((long) b[4]) & 0xFF) << 24)
+                + ((((long) b[3]) & 0xFF) << 32)
+                + ((((long) b[2]) & 0xFF) << 40)
+                + ((((long) b[1]) & 0xFF) << 48) + ((((long) b[0]) & 0xFF) << 56));
+    }
+
+    /**
+     * Build a 8-byte array from a long. No check is performed on the array
+     * length.
+     *
+     * @author Commons-Id Team
+     *
+     * @param n
+     *            The number to convert.
+     * @param b
+     *            The array to fill.
+     * @return A byte[].
+     */
+    public static byte[] toBytes(long n, byte[] b)
+    {
+        b[7] = (byte) (n);
+        n >>>= 8;
+        b[6] = (byte) (n);
+        n >>>= 8;
+        b[5] = (byte) (n);
+        n >>>= 8;
+        b[4] = (byte) (n);
+        n >>>= 8;
+        b[3] = (byte) (n);
+        n >>>= 8;
+        b[2] = (byte) (n);
+        n >>>= 8;
+        b[1] = (byte) (n);
+        n >>>= 8;
+        b[0] = (byte) (n);
+        return b;
+    }
+
+    /**
+     * Build a short from first 2 bytes of the array.
+     *
+     * @author Apache-Commons-Id Team
+     * @param b
+     *            The byte[] to convert.
+     * @return A short.
+     */
+    public static short toShort(byte[] b)
+    {
+        return (short) toUnsignedShort(b);
+    }
+
+    /**
+     * Build a short from first 2 bytes of the array.
+     *
+     * @author Apache-Commons-Id Team
+     * @param b
+     *            The byte[] to convert.
+     * @return A short.
+     */
+    public static int toUnsignedShort(byte[] b)
+    {
+        return ((b[1] & 0xFF) + ((b[0] & 0xFF) << 8));
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#write(int)
+     */
+    public void write(int b) throws IOException
+    {
+        buffer1[0] = (byte) b;
+        this.write(buffer1);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeBoolean(boolean)
+     */
+    public void writeBoolean(boolean v) throws IOException
+    {
+        this.write(v ? 1 : 0);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeBytes(java.lang.String)
+     */
+    public void writeBytes(String s) throws IOException
+    {
+        write(s.getBytes());
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeChar(int)
+     */
+    public void writeChar(int v) throws IOException
+    {
+        buffer2[0] = (byte) ((v >>> 8) & 0xFF);
+        buffer2[1] = (byte) ((v >>> 0) & 0xFF);
+        write(buffer2);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeChars(java.lang.String)
+     */
+    public void writeChars(String s) throws IOException
+    {
+        int len = s.length();
+        for (int i = 0; i < len; i++)
+        {
+            writeChar(s.charAt(i));
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeDouble(double)
+     */
+    public void writeDouble(double v) throws IOException
+    {
+        writeLong(Double.doubleToLongBits(v));
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeFloat(float)
+     */
+    public void writeFloat(float v) throws IOException
+    {
+        writeInt(Float.floatToIntBits(v));
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeInt(int)
+     */
+    public void writeInt(int v) throws IOException
+    {
+        buffer4[0] = (byte) ((v >>> 24) & 0xFF);
+        buffer4[1] = (byte) ((v >>> 16) & 0xFF);
+        buffer4[2] = (byte) ((v >>> 8) & 0xFF);
+        buffer4[3] = (byte) (v & 0xFF);
+        write(buffer4);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeLong(long)
+     */
+    public void writeLong(long v) throws IOException
+    {
+        write(toBytes(v, buffer8));
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeShort(int)
+     */
+    public void writeShort(int v) throws IOException
+    {
+        buffer2[0] = (byte) ((v >>> 8) & 0xFF);
+        buffer2[1] = (byte) (v & 0xFF);
+        write(buffer2);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataOutput#writeUTF(java.lang.String)
+     */
+    public void writeUTF(String str) throws IOException
+    {
+        ByteArrayOutputStream out = new ByteArrayOutputStream(str.length());
+        DataOutputStream dataOut = new DataOutputStream(out);
+        dataOut.writeUTF(str);
+        dataOut.flush();
+        dataOut.close();
+        byte[] b = out.toByteArray();
+        write(b);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.io.DataInput#readLine()
+     */
+    public String readLine() throws IOException
+    {
+        throw new UnsupportedOperationException("deprecated");
+    }
+
+    public InputStream getInputStream() throws IOException
+    {
+        return rafis;
+    }
 }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java Mon Apr 13 04:06:01 2009
@@ -40,272 +40,272 @@
  */
 public class RamFileSystem extends AbstractFileSystem implements Serializable
 {
-	/**
-	 * Cache of RAM File Data
-	 */
-	private Map cache;
-
-	/**
-	 * @param rootName
-	 * @param fileSystemOptions
-	 */
-	protected RamFileSystem(FileName rootName,
-			FileSystemOptions fileSystemOptions)
-	{
-		super(rootName, null, fileSystemOptions);
-		this.cache = Collections.synchronizedMap(new HashMap());
+    /**
+     * Cache of RAM File Data
+     */
+    private Map cache;
+
+    /**
+     * @param rootName
+     * @param fileSystemOptions
+     */
+    protected RamFileSystem(FileName rootName,
+            FileSystemOptions fileSystemOptions)
+    {
+        super(rootName, null, fileSystemOptions);
+        this.cache = Collections.synchronizedMap(new HashMap());
         // create root
         RamFileData rootData = new RamFileData(rootName) ;
         rootData.setType(FileType.FOLDER);
         rootData.setLastModified(System.currentTimeMillis());
         this.cache.put(rootName, rootData);
-	}
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.commons.vfs.provider.AbstractFileSystem#createFile(org.apache.commons.vfs.FileName)
-	 */
-	protected FileObject createFile(FileName name) throws Exception
-	{
-		RamFileObject file = new RamFileObject(name, this);
-		return file;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.commons.vfs.provider.AbstractFileSystem#addCapabilities(java.util.Collection)
-	 */
-	protected void addCapabilities(Collection caps)
-	{
-		caps.addAll(RamFileProvider.capabilities);
-	}
-
-	/**
-	 * @param name
-	 * @return children
-	 */
-	String[] listChildren(FileName name)
-	{
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.vfs.provider.AbstractFileSystem#createFile(org.apache.commons.vfs.FileName)
+     */
+    protected FileObject createFile(FileName name) throws Exception
+    {
+        RamFileObject file = new RamFileObject(name, this);
+        return file;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.vfs.provider.AbstractFileSystem#addCapabilities(java.util.Collection)
+     */
+    protected void addCapabilities(Collection caps)
+    {
+        caps.addAll(RamFileProvider.capabilities);
+    }
+
+    /**
+     * @param name
+     * @return children
+     */
+    String[] listChildren(FileName name)
+    {
         RamFileData data = (RamFileData) this.cache.get(name);
         if (data == null || !data.getType().hasChildren())
         {
             return null;
         }
         Collection children = data.getChildren();
-        
+
         String[] names = new String[children.size()];
-        
+
         int pos = 0 ;
         Iterator iter = children.iterator() ;
-        while (iter.hasNext()) 
+        while (iter.hasNext())
         {
             RamFileData childData = (RamFileData) iter.next();
             names[pos] = childData.getName().getBaseName();
             pos++;
         }
-        
-		return names;
-	}
-
-	/**
-	 * Delete a file
-	 * 
-	 * @param file
-	 * @throws FileSystemException
-	 */
-	void delete(RamFileObject file) throws FileSystemException
-	{
-	    // root is read only check
+
+        return names;
+    }
+
+    /**
+     * Delete a file
+     *
+     * @param file
+     * @throws FileSystemException
+     */
+    void delete(RamFileObject file) throws FileSystemException
+    {
+        // root is read only check
         if (file.getParent()==null) {
             throw new FileSystemException("unable to delete root");
         }
-        
-		// Remove reference from cache
-		this.cache.remove(file.getName());
-		// Notify the parent
+
+        // Remove reference from cache
+        this.cache.remove(file.getName());
+        // Notify the parent
         RamFileObject parent = (RamFileObject) this.resolveFile(file
                 .getParent().getName());
         parent.getData().removeChild(file.getData());
-		parent.close();
-		// Close the file
-		file.getData().clear();
-		file.close();
-	}
-
-	/**
-	 * Saves a file
-	 * 
-	 * @param file
-	 * @throws FileSystemException
-	 */
-	void save(final RamFileObject file) throws FileSystemException
-	{
-
-		// Validate name
-		if (file.getData().getName() == null)
-		{
-			throw new FileSystemException(new IllegalStateException(
-					"The data has no name. " + file));
-		}
-
-		// Add to the parent
-		if (file.getName().getDepth() > 0)
-		{
-			RamFileData parentData = (RamFileData) this.cache.get(file
-					.getParent().getName());
-			// Only if not already added
-			if (!parentData.hasChildren(file.getData()))
-			{
-				RamFileObject parent = (RamFileObject) file.getParent();
-				parent.getData().addChild(file.getData());
-				parent.close();
-			}
-		}
-		// Store in cache
-		cache.put(file.getName(), file.getData());
-		file.getData().updateLastModified();
-		file.close();
-	}
-
-	/**
-	 * @param from
-	 * @param to
-	 * @throws FileSystemException
-	 */
-	void rename(RamFileObject from, RamFileObject to)
-			throws FileSystemException
-	{
-		if (!this.cache.containsKey(from.getName()))
-		{
-			throw new FileSystemException("File does not exist: "
-					+ from.getName());
-		}
-		// Copy data
-
-		to.getData().setBuffer(from.getData().getBuffer());
-		to.getData().setLastModified(from.getData().getLastModified());
-		to.getData().setType(from.getData().getType());
-
-		this.save(to);
-		this.delete(from);
-	}
-
-	public void attach(RamFileObject fo)
-	{
-		if (fo.getName() == null)
-		{
-			throw new IllegalArgumentException("Null argument");
-		}
-		RamFileData data = (RamFileData) this.cache.get(fo.getName());
-		if (data == null)
-		{
-			data = new RamFileData(fo.getName());
-		}
-		fo.setData(data);
-	}
-
-	/**
-	 * Import a Tree
-	 * 
-	 * @param file
-	 * @throws FileSystemException
-	 */
-	public void importTree(File file) throws FileSystemException
-	{
-		FileObject fileFo = getFileSystemManager().toFileObject(file);
-		this.toRamFileObject(fileFo, fileFo);
-	}
-
-	/**
-	 * Import the given file with the name relative to the given root
-	 * 
-	 * @param fo
-	 * @param root
-	 * @throws FileSystemException
-	 */
-	void toRamFileObject(FileObject fo, FileObject root)
-			throws FileSystemException
-	{
-		RamFileObject memFo = (RamFileObject) this.resolveFile(fo.getName()
-				.getPath().substring(root.getName().getPath().length()));
-		if (fo.getType().hasChildren())
-		{
-			// Create Folder
-			memFo.createFolder();
-			// Import recursively
-			FileObject[] fos = fo.getChildren();
-			for (int i = 0; i < fos.length; i++)
-			{
-				FileObject child = fos[i];
-				this.toRamFileObject(child, root);
-			}
-		}
-		else if (fo.getType().equals(FileType.FILE))
-		{
-			// Read bytes
-			try
-			{
-				InputStream is = fo.getContent().getInputStream();
-				try
-				{
-					OutputStream os = new BufferedOutputStream(memFo
-							.getOutputStream(), 512);
-					int i;
-					while ((i = is.read()) != -1)
-					{
-						os.write(i);
-					}
-					os.flush();
-					os.close();
-				}
-				finally
-				{
-					try
-					{
-						is.close();
-					}
-					catch (IOException e)
-					{
-						// ignore on close exception
-					}
-				}
-			}
-			catch (IOException e)
-			{
-				throw new FileSystemException(e.getClass().getName() + " "
-						+ e.getMessage());
-			}
-		}
-		else
-		{
-			throw new FileSystemException("File is not a folder nor a file "
-					+ memFo);
-		}
-	}
-
-	/**
-	 * @return Returns the size of the FileSystem
-	 */
-	int size()
-	{
-		int size = 0;
-		Iterator iter = cache.values().iterator();
-		while (iter.hasNext())
-		{
-			RamFileData data = (RamFileData) iter.next();
-			size += data.size();
-		}
-		return size;
-	}
-
-	/**
-	 * Close the RAMFileSystem
-	 */
-	public void close()
-	{
-		this.cache = null;
-		super.close();
-	}
+        parent.close();
+        // Close the file
+        file.getData().clear();
+        file.close();
+    }
+
+    /**
+     * Saves a file
+     *
+     * @param file
+     * @throws FileSystemException
+     */
+    void save(final RamFileObject file) throws FileSystemException
+    {
+
+        // Validate name
+        if (file.getData().getName() == null)
+        {
+            throw new FileSystemException(new IllegalStateException(
+                    "The data has no name. " + file));
+        }
+
+        // Add to the parent
+        if (file.getName().getDepth() > 0)
+        {
+            RamFileData parentData = (RamFileData) this.cache.get(file
+                    .getParent().getName());
+            // Only if not already added
+            if (!parentData.hasChildren(file.getData()))
+            {
+                RamFileObject parent = (RamFileObject) file.getParent();
+                parent.getData().addChild(file.getData());
+                parent.close();
+            }
+        }
+        // Store in cache
+        cache.put(file.getName(), file.getData());
+        file.getData().updateLastModified();
+        file.close();
+    }
+
+    /**
+     * @param from
+     * @param to
+     * @throws FileSystemException
+     */
+    void rename(RamFileObject from, RamFileObject to)
+            throws FileSystemException
+    {
+        if (!this.cache.containsKey(from.getName()))
+        {
+            throw new FileSystemException("File does not exist: "
+                    + from.getName());
+        }
+        // Copy data
+
+        to.getData().setBuffer(from.getData().getBuffer());
+        to.getData().setLastModified(from.getData().getLastModified());
+        to.getData().setType(from.getData().getType());
+
+        this.save(to);
+        this.delete(from);
+    }
+
+    public void attach(RamFileObject fo)
+    {
+        if (fo.getName() == null)
+        {
+            throw new IllegalArgumentException("Null argument");
+        }
+        RamFileData data = (RamFileData) this.cache.get(fo.getName());
+        if (data == null)
+        {
+            data = new RamFileData(fo.getName());
+        }
+        fo.setData(data);
+    }
+
+    /**
+     * Import a Tree
+     *
+     * @param file
+     * @throws FileSystemException
+     */
+    public void importTree(File file) throws FileSystemException
+    {
+        FileObject fileFo = getFileSystemManager().toFileObject(file);
+        this.toRamFileObject(fileFo, fileFo);
+    }
+
+    /**
+     * Import the given file with the name relative to the given root
+     *
+     * @param fo
+     * @param root
+     * @throws FileSystemException
+     */
+    void toRamFileObject(FileObject fo, FileObject root)
+            throws FileSystemException
+    {
+        RamFileObject memFo = (RamFileObject) this.resolveFile(fo.getName()
+                .getPath().substring(root.getName().getPath().length()));
+        if (fo.getType().hasChildren())
+        {
+            // Create Folder
+            memFo.createFolder();
+            // Import recursively
+            FileObject[] fos = fo.getChildren();
+            for (int i = 0; i < fos.length; i++)
+            {
+                FileObject child = fos[i];
+                this.toRamFileObject(child, root);
+            }
+        }
+        else if (fo.getType().equals(FileType.FILE))
+        {
+            // Read bytes
+            try
+            {
+                InputStream is = fo.getContent().getInputStream();
+                try
+                {
+                    OutputStream os = new BufferedOutputStream(memFo
+                            .getOutputStream(), 512);
+                    int i;
+                    while ((i = is.read()) != -1)
+                    {
+                        os.write(i);
+                    }
+                    os.flush();
+                    os.close();
+                }
+                finally
+                {
+                    try
+                    {
+                        is.close();
+                    }
+                    catch (IOException e)
+                    {
+                        // ignore on close exception
+                    }
+                }
+            }
+            catch (IOException e)
+            {
+                throw new FileSystemException(e.getClass().getName() + " "
+                        + e.getMessage());
+            }
+        }
+        else
+        {
+            throw new FileSystemException("File is not a folder nor a file "
+                    + memFo);
+        }
+    }
+
+    /**
+     * @return Returns the size of the FileSystem
+     */
+    int size()
+    {
+        int size = 0;
+        Iterator iter = cache.values().iterator();
+        while (iter.hasNext())
+        {
+            RamFileData data = (RamFileData) iter.next();
+            size += data.size();
+        }
+        return size;
+    }
+
+    /**
+     * Close the RAMFileSystem
+     */
+    public void close()
+    {
+        this.cache = null;
+        super.close();
+    }
 }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java Mon Apr 13 04:06:01 2009
@@ -25,55 +25,55 @@
 public class RamFileSystemConfigBuilder extends FileSystemConfigBuilder
 {
 
-	/** max size key */
-	private static final String MAX_SIZE_KEY = "maxsize";
+    /** max size key */
+    private static final String MAX_SIZE_KEY = "maxsize";
 
-	/** config builder singleton */
-	private static RamFileSystemConfigBuilder singleton = new RamFileSystemConfigBuilder();
+    /** config builder singleton */
+    private static RamFileSystemConfigBuilder singleton = new RamFileSystemConfigBuilder();
 
-	/**
-	 * Constructor
-	 */
-	private RamFileSystemConfigBuilder()
-	{
-		super("ram.");
-	}
-
-	/**
-	 * @return the config builder singleton
-	 */
-	public static RamFileSystemConfigBuilder getInstance()
-	{
-		return singleton;
-	}
-
-	/**
-	 * @inheritDoc
-	 */
-	protected Class getConfigClass()
-	{
-		return RamFileSystem.class;
-	}
-
-	/**
-	 * @param opts
-	 * @return
-	 * @see #setMaxSize
-	 */
-	public int getMaxSize(FileSystemOptions opts)
-	{
-		return getInteger(opts, MAX_SIZE_KEY, Integer.MAX_VALUE);
-	}
-
-	/**
-	 * sets the maximum size of the file system
-	 * 
-	 * @param opts
-	 * @param sizeInBytes
-	 */
-	public void setMaxSize(FileSystemOptions opts, int sizeInBytes)
-	{
-		setParam(opts, MAX_SIZE_KEY, new Integer(sizeInBytes));
-	}
+    /**
+     * Constructor
+     */
+    private RamFileSystemConfigBuilder()
+    {
+        super("ram.");
+    }
+
+    /**
+     * @return the config builder singleton
+     */
+    public static RamFileSystemConfigBuilder getInstance()
+    {
+        return singleton;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected Class getConfigClass()
+    {
+        return RamFileSystem.class;
+    }
+
+    /**
+     * @param opts
+     * @return
+     * @see #setMaxSize
+     */
+    public int getMaxSize(FileSystemOptions opts)
+    {
+        return getInteger(opts, MAX_SIZE_KEY, Integer.MAX_VALUE);
+    }
+
+    /**
+     * sets the maximum size of the file system
+     *
+     * @param opts
+     * @param sizeInBytes
+     */
+    public void setMaxSize(FileSystemOptions opts, int sizeInBytes)
+    {
+        setParam(opts, MAX_SIZE_KEY, new Integer(sizeInBytes));
+    }
 
 }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java Mon Apr 13 04:06:01 2009
@@ -140,7 +140,7 @@
             Integer timeout = SftpFileSystemConfigBuilder.getInstance().getTimeout(fileSystemOptions);
             if (timeout != null)
             {
-            	session.setTimeout(timeout.intValue());
+                session.setTimeout(timeout.intValue());
             }
 
             UserInfo userInfo = SftpFileSystemConfigBuilder.getInstance().getUserInfo(fileSystemOptions);

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java Mon Apr 13 04:06:01 2009
@@ -31,7 +31,7 @@
     {
         super(22);
     }
-    
+
     public static FileNameParser getInstance()
     {
         return INSTANCE;

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java Mon Apr 13 04:06:01 2009
@@ -46,247 +46,247 @@
  */
 public class SftpFileObject extends AbstractFileObject implements FileObject
 {
-	private final SftpFileSystem fileSystem;
-	private SftpATTRS attrs;
-	private final String relPath;
-
-	private boolean inRefresh;
-
-	protected SftpFileObject(final FileName name,
-			final SftpFileSystem fileSystem) throws FileSystemException
-	{
-		super(name, fileSystem);
-		this.fileSystem = fileSystem;
-		relPath = UriParser.decode(fileSystem.getRootName().getRelativeName(
-				name));
-	}
-
-	protected void doDetach() throws Exception
-	{
-		attrs = null;
-	}
-
-	public void refresh() throws FileSystemException
-	{
-		if (!inRefresh)
-		{
-			try
-			{
-				inRefresh = true;
-				super.refresh();
-				try
-				{
-					attrs = null;
-					getType();
-				}
-				catch (IOException e)
-				{
-					throw new FileSystemException(e);
-				}
-			}
-			finally
-			{
-				inRefresh = false;
-			}
-		}
-	}
-
-	/**
-	 * Determines the type of this file, returns null if the file does not
-	 * exist.
-	 */
-	protected FileType doGetType() throws Exception
-	{
-		if (attrs == null)
-		{
-			statSelf();
-		}
-
-		if (attrs == null)
-		{
-			return FileType.IMAGINARY;
-		}
-
-		if ((attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS) == 0)
-		{
-			throw new FileSystemException(
-					"vfs.provider.sftp/unknown-permissions.error");
-		}
-		if (attrs.isDir())
-		{
-			return FileType.FOLDER;
-		}
-		else
-		{
-			return FileType.FILE;
-		}
-	}
-
-	/**
-	 * Called when the type or content of this file changes.
-	 */
-	protected void onChange() throws Exception
-	{
-		statSelf();
-	}
-
-	/**
-	 * Fetches file attrs from server.
-	 */
-	private void statSelf() throws Exception
-	{
-		ChannelSftp channel = fileSystem.getChannel();
-		try
-		{
-			setStat(channel.stat(relPath));
-		}
-		catch (final SftpException e)
-		{
-			try
-			{
-				// maybe the channel has some problems, so recreate the channel and retry
-				if (e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE)
-				{
-					channel.disconnect();
-					channel = fileSystem.getChannel();
-					setStat(channel.stat(relPath));
-				}
-				else
-				{
-					// Really does not exist
-					attrs = null;
-				}
-			}
-			catch (final SftpException e2)
-			{
-				// TODO - not strictly true, but jsch 0.1.2 does not give us
-				// enough info in the exception. Should be using:
-				// if ( e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE )
-				// However, sometimes the exception has the correct id, and
-				// sometimes
-				// it does not. Need to look into why.
-	
-				// Does not exist
-				attrs = null;
-			}
-		}
-		finally
-		{
-			fileSystem.putChannel(channel);
-		}
-	}
-
-	/**
-	 * Set attrs from listChildrenResolved
-	 */
-	private void setStat(SftpATTRS attrs)
-	{
-		this.attrs = attrs;
-	}
-
-	/**
-	 * Creates this file as a folder.
-	 */
-	protected void doCreateFolder() throws Exception
-	{
-		final ChannelSftp channel = fileSystem.getChannel();
-		try
-		{
-			channel.mkdir(relPath);
-		}
-		finally
-		{
-			fileSystem.putChannel(channel);
-		}
-	}
-
-	protected long doGetLastModifiedTime() throws Exception
-	{
-		if (attrs == null
-				|| (attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_ACMODTIME) == 0)
-		{
-			throw new FileSystemException(
-					"vfs.provider.sftp/unknown-modtime.error");
-		}
-		return attrs.getMTime() * 1000L;
-	}
-
-	/**
-	 * Sets the last modified time of this file. Is only called if
-	 * {@link #doGetType} does not return {@link FileType#IMAGINARY}. <p/>
-	 *
-	 * @param modtime
-	 *            is modification time in milliseconds. SFTP protocol can send
-	 *            times with nanosecond precision but at the moment jsch send
-	 *            them with second precision.
-	 */
-	protected void doSetLastModifiedTime(final long modtime) throws Exception
-	{
-		final ChannelSftp channel = fileSystem.getChannel();
-		try
-		{
-			int newMTime = (int) (modtime / 1000L);
-
-			attrs.setACMODTIME(attrs.getATime(), newMTime);
-			channel.setStat(relPath, attrs);
-		}
-		finally
-		{
-			fileSystem.putChannel(channel);
-		}
-	}
-
-	/**
-	 * Deletes the file.
-	 */
-	protected void doDelete() throws Exception
-	{
-		final ChannelSftp channel = fileSystem.getChannel();
-		try
-		{
-			if (getType() == FileType.FILE)
-			{
-				channel.rm(relPath);
-			}
-			else
-			{
-				channel.rmdir(relPath);
-			}
-		}
-		finally
-		{
-			fileSystem.putChannel(channel);
-		}
-	}
-
-	/**
-	 * Rename the file.
-	 */
-	protected void doRename(FileObject newfile) throws Exception
-	{
-		final ChannelSftp channel = fileSystem.getChannel();
-		try
-		{
-			channel.rename(relPath, ((SftpFileObject) newfile).relPath);
-		}
-		finally
-		{
-			fileSystem.putChannel(channel);
-		}
-	}
-
-	/**
-	 * Lists the children of this file.
-	 */
-	protected FileObject[] doListChildrenResolved() throws Exception
-	{
-		// List the contents of the folder
-		final Vector vector;
-		final ChannelSftp channel = fileSystem.getChannel();
+    private final SftpFileSystem fileSystem;
+    private SftpATTRS attrs;
+    private final String relPath;
+
+    private boolean inRefresh;
+
+    protected SftpFileObject(final FileName name,
+            final SftpFileSystem fileSystem) throws FileSystemException
+    {
+        super(name, fileSystem);
+        this.fileSystem = fileSystem;
+        relPath = UriParser.decode(fileSystem.getRootName().getRelativeName(
+                name));
+    }
+
+    protected void doDetach() throws Exception
+    {
+        attrs = null;
+    }
+
+    public void refresh() throws FileSystemException
+    {
+        if (!inRefresh)
+        {
+            try
+            {
+                inRefresh = true;
+                super.refresh();
+                try
+                {
+                    attrs = null;
+                    getType();
+                }
+                catch (IOException e)
+                {
+                    throw new FileSystemException(e);
+                }
+            }
+            finally
+            {
+                inRefresh = false;
+            }
+        }
+    }
+
+    /**
+     * Determines the type of this file, returns null if the file does not
+     * exist.
+     */
+    protected FileType doGetType() throws Exception
+    {
+        if (attrs == null)
+        {
+            statSelf();
+        }
+
+        if (attrs == null)
+        {
+            return FileType.IMAGINARY;
+        }
+
+        if ((attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS) == 0)
+        {
+            throw new FileSystemException(
+                    "vfs.provider.sftp/unknown-permissions.error");
+        }
+        if (attrs.isDir())
+        {
+            return FileType.FOLDER;
+        }
+        else
+        {
+            return FileType.FILE;
+        }
+    }
+
+    /**
+     * Called when the type or content of this file changes.
+     */
+    protected void onChange() throws Exception
+    {
+        statSelf();
+    }
+
+    /**
+     * Fetches file attrs from server.
+     */
+    private void statSelf() throws Exception
+    {
+        ChannelSftp channel = fileSystem.getChannel();
+        try
+        {
+            setStat(channel.stat(relPath));
+        }
+        catch (final SftpException e)
+        {
+            try
+            {
+                // maybe the channel has some problems, so recreate the channel and retry
+                if (e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE)
+                {
+                    channel.disconnect();
+                    channel = fileSystem.getChannel();
+                    setStat(channel.stat(relPath));
+                }
+                else
+                {
+                    // Really does not exist
+                    attrs = null;
+                }
+            }
+            catch (final SftpException e2)
+            {
+                // TODO - not strictly true, but jsch 0.1.2 does not give us
+                // enough info in the exception. Should be using:
+                // if ( e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE )
+                // However, sometimes the exception has the correct id, and
+                // sometimes
+                // it does not. Need to look into why.
+
+                // Does not exist
+                attrs = null;
+            }
+        }
+        finally
+        {
+            fileSystem.putChannel(channel);
+        }
+    }
+
+    /**
+     * Set attrs from listChildrenResolved
+     */
+    private void setStat(SftpATTRS attrs)
+    {
+        this.attrs = attrs;
+    }
+
+    /**
+     * Creates this file as a folder.
+     */
+    protected void doCreateFolder() throws Exception
+    {
+        final ChannelSftp channel = fileSystem.getChannel();
+        try
+        {
+            channel.mkdir(relPath);
+        }
+        finally
+        {
+            fileSystem.putChannel(channel);
+        }
+    }
+
+    protected long doGetLastModifiedTime() throws Exception
+    {
+        if (attrs == null
+                || (attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_ACMODTIME) == 0)
+        {
+            throw new FileSystemException(
+                    "vfs.provider.sftp/unknown-modtime.error");
+        }
+        return attrs.getMTime() * 1000L;
+    }
+
+    /**
+     * Sets the last modified time of this file. Is only called if
+     * {@link #doGetType} does not return {@link FileType#IMAGINARY}. <p/>
+     *
+     * @param modtime
+     *            is modification time in milliseconds. SFTP protocol can send
+     *            times with nanosecond precision but at the moment jsch send
+     *            them with second precision.
+     */
+    protected void doSetLastModifiedTime(final long modtime) throws Exception
+    {
+        final ChannelSftp channel = fileSystem.getChannel();
+        try
+        {
+            int newMTime = (int) (modtime / 1000L);
+
+            attrs.setACMODTIME(attrs.getATime(), newMTime);
+            channel.setStat(relPath, attrs);
+        }
+        finally
+        {
+            fileSystem.putChannel(channel);
+        }
+    }
+
+    /**
+     * Deletes the file.
+     */
+    protected void doDelete() throws Exception
+    {
+        final ChannelSftp channel = fileSystem.getChannel();
+        try
+        {
+            if (getType() == FileType.FILE)
+            {
+                channel.rm(relPath);
+            }
+            else
+            {
+                channel.rmdir(relPath);
+            }
+        }
+        finally
+        {
+            fileSystem.putChannel(channel);
+        }
+    }
+
+    /**
+     * Rename the file.
+     */
+    protected void doRename(FileObject newfile) throws Exception
+    {
+        final ChannelSftp channel = fileSystem.getChannel();
+        try
+        {
+            channel.rename(relPath, ((SftpFileObject) newfile).relPath);
+        }
+        finally
+        {
+            fileSystem.putChannel(channel);
+        }
+    }
+
+    /**
+     * Lists the children of this file.
+     */
+    protected FileObject[] doListChildrenResolved() throws Exception
+    {
+        // List the contents of the folder
+        final Vector vector;
+        final ChannelSftp channel = fileSystem.getChannel();
 
         String workingDirectory = null;
-		try
-		{
+        try
+        {
             try
             {
                 if (relPath != null)
@@ -315,137 +315,137 @@
                 throw new FileSystemException("vfs.provider.sftp/change-work-directory-back.error", workingDirectory);
             }
         }
-		finally
-		{
-			fileSystem.putChannel(channel);
-		}
-		if (vector == null)
-		{
-			throw new FileSystemException(
-					"vfs.provider.sftp/list-children.error");
-		}
-
-		// Extract the child names
-		final ArrayList children = new ArrayList();
-		for (Iterator iterator = vector.iterator(); iterator.hasNext();)
-		{
-			final LsEntry stat = (LsEntry) iterator.next();
-
-			String name = stat.getFilename();
-			if (VFS.isUriStyle())
-			{
-				if (stat.getAttrs().isDir()
-						&& name.charAt(name.length() - 1) != '/')
-				{
-					name = name + "/";
-				}
-			}
-
-			if (name.equals(".") || name.equals("..") || name.equals("./")
-					|| name.equals("../"))
-			{
-				continue;
-			}
-
-			FileObject fo =
-				getFileSystem()
-					.resolveFile(
-							getFileSystem().getFileSystemManager().resolveName(
-									getName(), UriParser.encode(name),
-									NameScope.CHILD));
-
-			((SftpFileObject) FileObjectUtils.getAbstractFileObject(fo)).setStat(stat.getAttrs());
-
-			children.add(fo);
-		}
-
-		return (FileObject[]) children.toArray(new FileObject[children
-				.size()]);
-	}
-
-	/**
-	 * Lists the children of this file.
-	 */
-	protected String[] doListChildren() throws Exception
-	{
-		// use doListChildrenResolved for performance
-		return null;
-	}
-
-	/**
-	 * Returns the size of the file content (in bytes).
-	 */
-	protected long doGetContentSize() throws Exception
-	{
-		if (attrs == null
-				|| (attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_SIZE) == 0)
-		{
-			throw new FileSystemException(
-					"vfs.provider.sftp/unknown-size.error");
-		}
-		return attrs.getSize();
-	}
-
-	protected RandomAccessContent doGetRandomAccessContent(
-			final RandomAccessMode mode) throws Exception
-	{
-		return new SftpRandomAccessContent(this, mode);
-	}
-
-	/**
-	 * Creates an input stream to read the file content from.
-	 */
-	InputStream getInputStream(long filePointer) throws IOException
-	{
-		final ChannelSftp channel = fileSystem.getChannel();
-		try
-		{
-			// hmmm - using the in memory method is soooo much faster ...
-			// TODO - Don't read the entire file into memory. Use the
-			// stream-based methods on ChannelSftp once they work properly final
-			// .... no stream based method with resume???
-			ByteArrayOutputStream outstr = new ByteArrayOutputStream();
-			try
-			{
-				channel.get(getName().getPathDecoded(), outstr, null,
-						ChannelSftp.RESUME, filePointer);
-			}
-			catch (SftpException e)
-			{
-				throw new FileSystemException(e);
-			}
-			outstr.close();
-			return new ByteArrayInputStream(outstr.toByteArray());
-		}
-		finally
-		{
-			fileSystem.putChannel(channel);
-		}
-	}
-
-	/**
-	 * Creates an input stream to read the file content from.
-	 */
-	protected InputStream doGetInputStream() throws Exception
-	{
-		// VFS-113: avoid npe
-		synchronized(fileSystem)
-		{
-			final ChannelSftp channel = fileSystem.getChannel();
-			try
-			{
-				// return channel.get(getName().getPath());
-				// hmmm - using the in memory method is soooo much faster ...
-
-				// TODO - Don't read the entire file into memory. Use the
-				// stream-based methods on ChannelSftp once they work properly
-
-				/*
-				final ByteArrayOutputStream outstr = new ByteArrayOutputStream();
-				channel.get(relPath, outstr);
-				outstr.close();
-				return new ByteArrayInputStream(outstr.toByteArray());
-				*/
+        finally
+        {
+            fileSystem.putChannel(channel);
+        }
+        if (vector == null)
+        {
+            throw new FileSystemException(
+                    "vfs.provider.sftp/list-children.error");
+        }
+
+        // Extract the child names
+        final ArrayList children = new ArrayList();
+        for (Iterator iterator = vector.iterator(); iterator.hasNext();)
+        {
+            final LsEntry stat = (LsEntry) iterator.next();
+
+            String name = stat.getFilename();
+            if (VFS.isUriStyle())
+            {
+                if (stat.getAttrs().isDir()
+                        && name.charAt(name.length() - 1) != '/')
+                {
+                    name = name + "/";
+                }
+            }
+
+            if (name.equals(".") || name.equals("..") || name.equals("./")
+                    || name.equals("../"))
+            {
+                continue;
+            }
+
+            FileObject fo =
+                getFileSystem()
+                    .resolveFile(
+                            getFileSystem().getFileSystemManager().resolveName(
+                                    getName(), UriParser.encode(name),
+                                    NameScope.CHILD));
+
+            ((SftpFileObject) FileObjectUtils.getAbstractFileObject(fo)).setStat(stat.getAttrs());
+
+            children.add(fo);
+        }
+
+        return (FileObject[]) children.toArray(new FileObject[children
+                .size()]);
+    }
+
+    /**
+     * Lists the children of this file.
+     */
+    protected String[] doListChildren() throws Exception
+    {
+        // use doListChildrenResolved for performance
+        return null;
+    }
+
+    /**
+     * Returns the size of the file content (in bytes).
+     */
+    protected long doGetContentSize() throws Exception
+    {
+        if (attrs == null
+                || (attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_SIZE) == 0)
+        {
+            throw new FileSystemException(
+                    "vfs.provider.sftp/unknown-size.error");
+        }
+        return attrs.getSize();
+    }
+
+    protected RandomAccessContent doGetRandomAccessContent(
+            final RandomAccessMode mode) throws Exception
+    {
+        return new SftpRandomAccessContent(this, mode);
+    }
+
+    /**
+     * Creates an input stream to read the file content from.
+     */
+    InputStream getInputStream(long filePointer) throws IOException
+    {
+        final ChannelSftp channel = fileSystem.getChannel();
+        try
+        {
+            // hmmm - using the in memory method is soooo much faster ...
+            // TODO - Don't read the entire file into memory. Use the
+            // stream-based methods on ChannelSftp once they work properly final
+            // .... no stream based method with resume???
+            ByteArrayOutputStream outstr = new ByteArrayOutputStream();
+            try
+            {
+                channel.get(getName().getPathDecoded(), outstr, null,
+                        ChannelSftp.RESUME, filePointer);
+            }
+            catch (SftpException e)
+            {
+                throw new FileSystemException(e);
+            }
+            outstr.close();
+            return new ByteArrayInputStream(outstr.toByteArray());
+        }
+        finally
+        {
+            fileSystem.putChannel(channel);
+        }
+    }
+
+    /**
+     * Creates an input stream to read the file content from.
+     */
+    protected InputStream doGetInputStream() throws Exception
+    {
+        // VFS-113: avoid npe
+        synchronized(fileSystem)
+        {
+            final ChannelSftp channel = fileSystem.getChannel();
+            try
+            {
+                // return channel.get(getName().getPath());
+                // hmmm - using the in memory method is soooo much faster ...
+
+                // TODO - Don't read the entire file into memory. Use the
+                // stream-based methods on ChannelSftp once they work properly
+
+                /*
+                final ByteArrayOutputStream outstr = new ByteArrayOutputStream();
+                channel.get(relPath, outstr);
+                outstr.close();
+                return new ByteArrayInputStream(outstr.toByteArray());
+                */
 
                 InputStream is;
                 try
@@ -471,88 +471,88 @@
 
                 return new SftpInputStream(channel, is);
 
-			}
-			finally
-			{
-//				fileSystem.putChannel(channel);
-			}
-		}
-	}
-
-	/**
-	 * Creates an output stream to write the file content to.
-	 */
-	protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
-	{
-		// TODO - Don't write the entire file into memory. Use the stream-based
-		// methods on ChannelSftp once the work properly
-		/*
-		final ChannelSftp channel = fileSystem.getChannel();
-		return new SftpOutputStream(channel);
-		*/
-
-		final ChannelSftp channel = fileSystem.getChannel();
-		return new SftpOutputStream(channel, channel.put(relPath));
-	}
-
-	/**
-	 * An InputStream that monitors for end-of-file.
-	 */
-	private class SftpInputStream extends MonitorInputStream
-	{
-		private final ChannelSftp channel;
-
-		public SftpInputStream(final ChannelSftp channel, final InputStream in)
-		{
-			super(in);
-			this.channel = channel;
-		}
-
-		/**
-		 * Called after the stream has been closed.
-		 */
-		protected void onClose() throws IOException
-		{
-			fileSystem.putChannel(channel);
-		}
-	}
-
-	/**
-	 * An OutputStream that wraps an sftp OutputStream, and closes the channel
-	 * when the stream is closed.
-	 */
-	private class SftpOutputStream extends MonitorOutputStream
-	{
-		private final ChannelSftp channel;
-
-		public SftpOutputStream(final ChannelSftp channel, OutputStream out)
-		{
-			super(out);
-			this.channel = channel;
-		}
-
-		/**
-		 * Called after this stream is closed.
-		 */
-		protected void onClose() throws IOException
-		{
-			/*
-			try
-			{
-				final ByteArrayOutputStream outstr = (ByteArrayOutputStream) out;
-				channel.put(new ByteArrayInputStream(outstr.toByteArray()),
-						relPath);
-			}
-			catch (final SftpException e)
-			{
-				throw new FileSystemException(e);
-			}
-			finally
-			*/
-			{
-				fileSystem.putChannel(channel);
-			}
-		}
-	}
+            }
+            finally
+            {
+//              fileSystem.putChannel(channel);
+            }
+        }
+    }
+
+    /**
+     * Creates an output stream to write the file content to.
+     */
+    protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
+    {
+        // TODO - Don't write the entire file into memory. Use the stream-based
+        // methods on ChannelSftp once the work properly
+        /*
+        final ChannelSftp channel = fileSystem.getChannel();
+        return new SftpOutputStream(channel);
+        */
+
+        final ChannelSftp channel = fileSystem.getChannel();
+        return new SftpOutputStream(channel, channel.put(relPath));
+    }
+
+    /**
+     * An InputStream that monitors for end-of-file.
+     */
+    private class SftpInputStream extends MonitorInputStream
+    {
+        private final ChannelSftp channel;
+
+        public SftpInputStream(final ChannelSftp channel, final InputStream in)
+        {
+            super(in);
+            this.channel = channel;
+        }
+
+        /**
+         * Called after the stream has been closed.
+         */
+        protected void onClose() throws IOException
+        {
+            fileSystem.putChannel(channel);
+        }
+    }
+
+    /**
+     * An OutputStream that wraps an sftp OutputStream, and closes the channel
+     * when the stream is closed.
+     */
+    private class SftpOutputStream extends MonitorOutputStream
+    {
+        private final ChannelSftp channel;
+
+        public SftpOutputStream(final ChannelSftp channel, OutputStream out)
+        {
+            super(out);
+            this.channel = channel;
+        }
+
+        /**
+         * Called after this stream is closed.
+         */
+        protected void onClose() throws IOException
+        {
+            /*
+            try
+            {
+                final ByteArrayOutputStream outstr = (ByteArrayOutputStream) out;
+                channel.put(new ByteArrayInputStream(outstr.toByteArray()),
+                        relPath);
+            }
+            catch (final SftpException e)
+            {
+                throw new FileSystemException(e);
+            }
+            finally
+            */
+            {
+                fileSystem.putChannel(channel);
+            }
+        }
+    }
 
 }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java Mon Apr 13 04:06:01 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -57,13 +57,13 @@
     }));
 
     public final static String ATTR_USER_INFO = "UI";
-	
-	public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
-		{
-			UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
-		};
 
-	// private JSch jSch = new JSch();
+    public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
+        {
+            UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
+        };
+
+    // private JSch jSch = new JSch();
 
     public SftpFileProvider()
     {
@@ -82,17 +82,17 @@
         final GenericFileName rootName = (GenericFileName) name;
 
         Session session;
-		UserAuthenticationData authData = null;
+        UserAuthenticationData authData = null;
         try
         {
-			authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
+            authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
 
-			session = SftpClientFactory.createConnection(
-				rootName.getHostName(),
-				rootName.getPort(),
-				UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName())),
-				UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword())),
-				fileSystemOptions);
+            session = SftpClientFactory.createConnection(
+                rootName.getHostName(),
+                rootName.getPort(),
+                UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName())),
+                UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword())),
+                fileSystemOptions);
         }
         catch (final Exception e)
         {
@@ -100,12 +100,12 @@
                 name,
                 e);
         }
-		finally
-		{
-			UserAuthenticatorUtils.cleanup(authData);
-		}
+        finally
+        {
+            UserAuthenticatorUtils.cleanup(authData);
+        }
 
-		return new SftpFileSystem(rootName, session, fileSystemOptions);
+        return new SftpFileSystem(rootName, session, fileSystemOptions);
     }
 
 

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java Mon Apr 13 04:06:01 2009
@@ -44,7 +44,7 @@
     implements FileSystem
 {
 
-	private Session session;
+    private Session session;
     // private final JSch jSch;
     private ChannelSftp idleChannel;
 
@@ -78,23 +78,23 @@
     {
         if (this.session == null || !this.session.isConnected())
         {
-			doCloseCommunicationLink();
-			
-			// channel closed. e.g. by freeUnusedResources, but now we need it again
+            doCloseCommunicationLink();
+
+            // channel closed. e.g. by freeUnusedResources, but now we need it again
             Session session;
-			UserAuthenticationData authData = null;
-			try
+            UserAuthenticationData authData = null;
+            try
             {
                 final GenericFileName rootName = (GenericFileName) getRootName();
 
-				authData = UserAuthenticatorUtils.authenticate(getFileSystemOptions(), SftpFileProvider.AUTHENTICATOR_TYPES);
+                authData = UserAuthenticatorUtils.authenticate(getFileSystemOptions(), SftpFileProvider.AUTHENTICATOR_TYPES);
 
-				session = SftpClientFactory.createConnection(
-					rootName.getHostName(),
-					rootName.getPort(),
-					UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName())),
-					UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword())),
-					getFileSystemOptions());
+                session = SftpClientFactory.createConnection(
+                    rootName.getHostName(),
+                    rootName.getPort(),
+                    UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName())),
+                    UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword())),
+                    getFileSystemOptions());
             }
             catch (final Exception e)
             {
@@ -102,12 +102,12 @@
                     getRootName(),
                     e);
             }
-			finally
-			{
-				UserAuthenticatorUtils.cleanup(authData);
-			}
+            finally
+            {
+                UserAuthenticatorUtils.cleanup(authData);
+            }
 
-			this.session = session;
+            this.session = session;
         }
 
         try
@@ -121,7 +121,7 @@
             }
             else
             {
-				channel = (ChannelSftp) session.openChannel("sftp");
+                channel = (ChannelSftp) session.openChannel("sftp");
                 channel.connect();
 
                 Boolean userDirIsRoot = SftpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(getFileSystemOptions());
@@ -156,11 +156,11 @@
     {
         if (idleChannel == null)
         {
-        	// put back the channel only if it is still connected
-        	if (channel.isConnected() && !channel.isClosed())
-        	{
-        		idleChannel = channel;
-        	}
+            // put back the channel only if it is still connected
+            if (channel.isConnected() && !channel.isClosed())
+            {
+                idleChannel = channel;
+            }
         }
         else
         {

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java Mon Apr 13 04:06:01 2009
@@ -241,7 +241,7 @@
     {
         return getInteger(opts, TIMEOUT);
     }
-    
+
     protected Class getConfigClass()
     {
         return SftpFileSystem.class;

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java Mon Apr 13 04:06:01 2009
@@ -70,7 +70,7 @@
         filePointer = pos;
     }
 
-	protected DataInputStream getDataInputStream() throws IOException
+    protected DataInputStream getDataInputStream() throws IOException
     {
         if (dis != null)
         {
@@ -117,8 +117,8 @@
             }
         });
 
-		return dis;
-	}
+        return dis;
+    }
 
 
     public void close() throws IOException