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 [5/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/AbstractRandomAccessStreamContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessStreamContent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessStreamContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessStreamContent.java Mon Apr 13 04:06:01 2009
@@ -32,95 +32,95 @@
{
protected AbstractRandomAccessStreamContent(final RandomAccessMode mode)
{
- super(mode);
+ super(mode);
}
- protected abstract DataInputStream getDataInputStream() throws IOException;
+ protected abstract DataInputStream getDataInputStream() throws IOException;
- public byte readByte() throws IOException
- {
- byte data = getDataInputStream().readByte();
- return data;
- }
-
- public char readChar() throws IOException
- {
- char data = getDataInputStream().readChar();
- return data;
- }
-
- public double readDouble() throws IOException
- {
- double data = getDataInputStream().readDouble();
- return data;
- }
-
- public float readFloat() throws IOException
- {
- float data = getDataInputStream().readFloat();
- return data;
- }
-
- public int readInt() throws IOException
- {
- int data = getDataInputStream().readInt();
- return data;
- }
-
- public int readUnsignedByte() throws IOException
- {
- int data = getDataInputStream().readUnsignedByte();
- return data;
- }
-
- public int readUnsignedShort() throws IOException
- {
- int data = getDataInputStream().readUnsignedShort();
- return data;
- }
-
- public long readLong() throws IOException
- {
- long data = getDataInputStream().readLong();
- return data;
- }
-
- public short readShort() throws IOException
- {
- short data = getDataInputStream().readShort();
- return data;
- }
-
- public boolean readBoolean() throws IOException
- {
- boolean data = getDataInputStream().readBoolean();
- return data;
- }
-
- public int skipBytes(int n) throws IOException
- {
- int data = getDataInputStream().skipBytes(n);
- return data;
- }
-
- public void readFully(byte b[]) throws IOException
- {
- getDataInputStream().readFully(b);
- }
-
- public void readFully(byte b[], int off, int len) throws IOException
- {
- getDataInputStream().readFully(b, off, len);
- }
-
- public String readUTF() throws IOException
- {
- String data = getDataInputStream().readUTF();
- return data;
- }
-
- public InputStream getInputStream() throws IOException
- {
- return getDataInputStream();
- }
+ public byte readByte() throws IOException
+ {
+ byte data = getDataInputStream().readByte();
+ return data;
+ }
+
+ public char readChar() throws IOException
+ {
+ char data = getDataInputStream().readChar();
+ return data;
+ }
+
+ public double readDouble() throws IOException
+ {
+ double data = getDataInputStream().readDouble();
+ return data;
+ }
+
+ public float readFloat() throws IOException
+ {
+ float data = getDataInputStream().readFloat();
+ return data;
+ }
+
+ public int readInt() throws IOException
+ {
+ int data = getDataInputStream().readInt();
+ return data;
+ }
+
+ public int readUnsignedByte() throws IOException
+ {
+ int data = getDataInputStream().readUnsignedByte();
+ return data;
+ }
+
+ public int readUnsignedShort() throws IOException
+ {
+ int data = getDataInputStream().readUnsignedShort();
+ return data;
+ }
+
+ public long readLong() throws IOException
+ {
+ long data = getDataInputStream().readLong();
+ return data;
+ }
+
+ public short readShort() throws IOException
+ {
+ short data = getDataInputStream().readShort();
+ return data;
+ }
+
+ public boolean readBoolean() throws IOException
+ {
+ boolean data = getDataInputStream().readBoolean();
+ return data;
+ }
+
+ public int skipBytes(int n) throws IOException
+ {
+ int data = getDataInputStream().skipBytes(n);
+ return data;
+ }
+
+ public void readFully(byte b[]) throws IOException
+ {
+ getDataInputStream().readFully(b);
+ }
+
+ public void readFully(byte b[], int off, int len) throws IOException
+ {
+ getDataInputStream().readFully(b, off, len);
+ }
+
+ public String readUTF() throws IOException
+ {
+ String data = getDataInputStream().readUTF();
+ return data;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return getDataInputStream();
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java Mon Apr 13 04:06:01 2009
@@ -188,10 +188,10 @@
try
{
if (!file.doSetLastModTime(modTime))
- {
- throw new FileSystemException("vfs.provider/set-last-modified.error", file);
- }
- }
+ {
+ throw new FileSystemException("vfs.provider/set-last-modified.error", file);
+ }
+ }
catch (final Exception e)
{
throw new FileSystemException("vfs.provider/set-last-modified.error", file, e);
@@ -265,7 +265,7 @@
throws FileSystemException
{
getAttributes();
- return attrs.get(attrName);
+ return attrs.get(attrName);
}
/**
@@ -303,7 +303,7 @@
throw new FileSystemException("vfs.provider/remove-attribute-no-exist.error", file);
}
- try
+ try
{
file.doRemoveAttribute(attrName);
}
@@ -392,8 +392,8 @@
// Get the content
final RandomAccessContent rastr = file.getRandomAccessContent(mode);
- FileRandomAccessContent rac = new FileRandomAccessContent(file, rastr);
- this.getThreadData().addRastr(rac);
+ FileRandomAccessContent rac = new FileRandomAccessContent(file, rastr);
+ this.getThreadData().addRastr(rac);
streamOpened();
// setState(STATE_OPENED);
@@ -447,21 +447,21 @@
instr.close();
}
- // Close the randomAccess stream
- while (getThreadData().getRastrsSize() > 0)
- {
- final RandomAccessContent ra = (RandomAccessContent) getThreadData().removeRastr(0);
- try
- {
- ra.close();
- }
- catch (IOException e)
- {
- throw new FileSystemException(e);
- }
- }
+ // Close the randomAccess stream
+ while (getThreadData().getRastrsSize() > 0)
+ {
+ final RandomAccessContent ra = (RandomAccessContent) getThreadData().removeRastr(0);
+ try
+ {
+ ra.close();
+ }
+ catch (IOException e)
+ {
+ throw new FileSystemException(e);
+ }
+ }
- // Close the output stream
+ // Close the output stream
if (this.getThreadData().getOutstr() != null)
{
this.getThreadData().closeOutstr();
@@ -493,7 +493,7 @@
*/
private void endRandomAccess(RandomAccessContent rac)
{
- getThreadData().removeRastr(rac);
+ getThreadData().removeRastr(rac);
streamClosed();
// setState(STATE_CLOSED);
}
@@ -598,14 +598,14 @@
{
// avoid gc
private final FileObject file;
- private final RandomAccessContent content;
+ private final RandomAccessContent content;
- FileRandomAccessContent(final FileObject file, final RandomAccessContent content)
+ FileRandomAccessContent(final FileObject file, final RandomAccessContent content)
{
super(content);
this.file = file;
- this.content = content;
- }
+ this.content = content;
+ }
/**
* Called after the stream has been closed.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.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.
@@ -60,9 +60,9 @@
return content.getOutputStream();
}
-
+
public long getLastModified()
- {
+ {
try
{
return content.getLastModifiedTime();
@@ -72,9 +72,9 @@
}
return -1;
- }
+ }
- public int getContentLength()
+ public int getContentLength()
{
try
{
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java Mon Apr 13 04:06:01 2009
@@ -36,150 +36,150 @@
* @todo Extract subclass that overlays the children
*/
public class DelegateFileObject
- extends AbstractFileObject
- implements FileListener
+ extends AbstractFileObject
+ implements FileListener
{
- private FileObject file;
- private final Set children = new HashSet();
- private boolean ignoreEvent;
-
- public DelegateFileObject(final FileName name,
- final AbstractFileSystem fileSystem,
- final FileObject file) throws FileSystemException
- {
- super(name, fileSystem);
- this.file = file;
- if (file != null)
- {
- WeakRefFileListener.installListener(file, this);
- }
- }
-
- /**
- * get access to the delegated file
- */
- public FileObject getDelegateFile()
- {
- return file;
- }
-
- /**
- * Adds a child to this file.
- */
- public void attachChild(final FileName baseName, final FileType type) throws Exception
- {
- final FileType oldType = doGetType();
- if (children.add(baseName.getBaseName()))
- {
- childrenChanged(baseName, type);
- }
- maybeTypeChanged(oldType);
- }
-
- /**
- * Attaches or detaches the target file.
- */
- public void setFile(final FileObject file) throws Exception
- {
- final FileType oldType = doGetType();
-
- if (file != null)
- {
- WeakRefFileListener.installListener(file, this);
- }
- this.file = file;
- maybeTypeChanged(oldType);
- }
-
- /**
- * Checks whether the file's type has changed, and fires the appropriate
- * events.
- */
- private void maybeTypeChanged(final FileType oldType) throws Exception
- {
- final FileType newType = doGetType();
- if (oldType == FileType.IMAGINARY && newType != FileType.IMAGINARY)
- {
- handleCreate(newType);
- }
- else if (oldType != FileType.IMAGINARY && newType == FileType.IMAGINARY)
- {
- handleDelete();
- }
- }
-
- /**
- * Determines the type of the file, returns null if the file does not
- * exist.
- */
- protected FileType doGetType() throws FileSystemException
- {
- if (file != null)
- {
- return file.getType();
- }
- else if (children.size() > 0)
- {
- return FileType.FOLDER;
- }
- else
- {
- return FileType.IMAGINARY;
- }
- }
-
- /**
- * Determines if this file can be read.
- */
- protected boolean doIsReadable() throws FileSystemException
- {
- if (file != null)
- {
- return file.isReadable();
- }
- else
- {
- return true;
- }
- }
-
- /**
- * Determines if this file can be written to.
- */
- protected boolean doIsWriteable() throws FileSystemException
- {
- if (file != null)
- {
- return file.isWriteable();
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Determines if this file is hidden.
- */
- protected boolean doIsHidden() throws FileSystemException
- {
- if (file != null)
- {
- return file.isHidden();
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Lists the children of the file.
- */
- protected String[] doListChildren() throws Exception
- {
- if (file != null)
- {
+ private FileObject file;
+ private final Set children = new HashSet();
+ private boolean ignoreEvent;
+
+ public DelegateFileObject(final FileName name,
+ final AbstractFileSystem fileSystem,
+ final FileObject file) throws FileSystemException
+ {
+ super(name, fileSystem);
+ this.file = file;
+ if (file != null)
+ {
+ WeakRefFileListener.installListener(file, this);
+ }
+ }
+
+ /**
+ * get access to the delegated file
+ */
+ public FileObject getDelegateFile()
+ {
+ return file;
+ }
+
+ /**
+ * Adds a child to this file.
+ */
+ public void attachChild(final FileName baseName, final FileType type) throws Exception
+ {
+ final FileType oldType = doGetType();
+ if (children.add(baseName.getBaseName()))
+ {
+ childrenChanged(baseName, type);
+ }
+ maybeTypeChanged(oldType);
+ }
+
+ /**
+ * Attaches or detaches the target file.
+ */
+ public void setFile(final FileObject file) throws Exception
+ {
+ final FileType oldType = doGetType();
+
+ if (file != null)
+ {
+ WeakRefFileListener.installListener(file, this);
+ }
+ this.file = file;
+ maybeTypeChanged(oldType);
+ }
+
+ /**
+ * Checks whether the file's type has changed, and fires the appropriate
+ * events.
+ */
+ private void maybeTypeChanged(final FileType oldType) throws Exception
+ {
+ final FileType newType = doGetType();
+ if (oldType == FileType.IMAGINARY && newType != FileType.IMAGINARY)
+ {
+ handleCreate(newType);
+ }
+ else if (oldType != FileType.IMAGINARY && newType == FileType.IMAGINARY)
+ {
+ handleDelete();
+ }
+ }
+
+ /**
+ * Determines the type of the file, returns null if the file does not
+ * exist.
+ */
+ protected FileType doGetType() throws FileSystemException
+ {
+ if (file != null)
+ {
+ return file.getType();
+ }
+ else if (children.size() > 0)
+ {
+ return FileType.FOLDER;
+ }
+ else
+ {
+ return FileType.IMAGINARY;
+ }
+ }
+
+ /**
+ * Determines if this file can be read.
+ */
+ protected boolean doIsReadable() throws FileSystemException
+ {
+ if (file != null)
+ {
+ return file.isReadable();
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Determines if this file can be written to.
+ */
+ protected boolean doIsWriteable() throws FileSystemException
+ {
+ if (file != null)
+ {
+ return file.isWriteable();
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Determines if this file is hidden.
+ */
+ protected boolean doIsHidden() throws FileSystemException
+ {
+ if (file != null)
+ {
+ return file.isHidden();
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Lists the children of the file.
+ */
+ protected String[] doListChildren() throws Exception
+ {
+ if (file != null)
+ {
final FileObject[] children;
try
@@ -191,222 +191,222 @@
{
throw new FileNotFolderException(getName(), e);
}
-
+
final String[] childNames = new String[children.length];
- for (int i = 0; i < children.length; i++)
- {
- childNames[i] = children[i].getName().getBaseName();
- }
- return childNames;
- }
- else
- {
- return (String[]) children.toArray(new String[children.size()]);
- }
- }
-
- /**
- * Creates this file as a folder.
- */
- protected void doCreateFolder() throws Exception
- {
- ignoreEvent = true;
- try
- {
- file.createFolder();
- }
- finally
- {
- ignoreEvent = false;
- }
- }
-
- /**
- * Deletes the file.
- */
- protected void doDelete() throws Exception
- {
- ignoreEvent = true;
- try
- {
- file.delete();
- }
- finally
- {
- ignoreEvent = false;
- }
- }
-
- /**
- * Returns the size of the file content (in bytes). Is only called if
- * {@link #doGetType} returns {@link FileType#FILE}.
- */
- protected long doGetContentSize() throws Exception
- {
- return file.getContent().getSize();
- }
-
- /**
- * Returns the attributes of this file.
- */
- protected Map doGetAttributes()
- throws Exception
- {
- return file.getContent().getAttributes();
- }
-
- /**
- * Sets an attribute of this file.
- */
- protected void doSetAttribute(final String atttrName,
- final Object value)
- throws Exception
- {
- file.getContent().setAttribute(atttrName, value);
- }
-
- /**
- * Returns the certificates of this file.
- */
- protected Certificate[] doGetCertificates() throws Exception
- {
- return file.getContent().getCertificates();
- }
-
- /**
- * Returns the last-modified time of this file.
- */
- protected long doGetLastModifiedTime() throws Exception
- {
- return file.getContent().getLastModifiedTime();
- }
-
- /**
- * Sets the last-modified time of this file.
- */
- protected boolean doSetLastModTime(final long modtime)
- throws Exception
- {
- file.getContent().setLastModifiedTime(modtime);
- return true;
- }
-
- /**
- * Creates an input stream to read the file content from.
- */
- protected InputStream doGetInputStream() throws Exception
- {
- return file.getContent().getInputStream();
- }
-
- /**
- * Creates an output stream to write the file content to.
- */
- protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
- {
- return file.getContent().getOutputStream(bAppend);
- }
-
- /**
- * Called when a file is created.
- */
- public void fileCreated(final FileChangeEvent event) throws Exception
- {
- if (event.getFile() != file)
- {
- return;
- }
- if (!ignoreEvent)
- {
- handleCreate(file.getType());
- }
- }
-
- /**
- * Called when a file is deleted.
- */
- public void fileDeleted(final FileChangeEvent event) throws Exception
- {
- if (event.getFile() != file)
- {
- return;
- }
- if (!ignoreEvent)
- {
- handleDelete();
- }
- }
-
- /**
- * Called when a file is changed.
- * <p/>
- * This will only happen if you monitor the file using {@link org.apache.commons.vfs.FileMonitor}.
- */
- public void fileChanged(FileChangeEvent event) throws Exception
- {
- if (event.getFile() != file)
- {
- return;
- }
- if (!ignoreEvent)
- {
- handleChanged();
- }
- }
-
- /**
- * Close the delegated file
- */
- public void close() throws FileSystemException
- {
- super.close();
-
- if (file != null)
- {
- file.close();
- }
- }
-
- /**
- * refresh file informations
- */
- public void refresh() throws FileSystemException
- {
- super.refresh();
- if (file != null)
- {
- file.refresh();
- }
- }
-
- protected FileContentInfo doGetContentInfo() throws Exception
- {
- return file.getContent().getContentInfo();
- }
-
- /**
- * Renames the file.
- */
- protected void doRename(FileObject newFile)
- throws Exception
- {
- file.moveTo(((DelegateFileObject) newFile).file);
- }
-
- /**
- * Removes an attribute of this file.
- */
- protected void doRemoveAttribute(final String atttrName)
- throws Exception
- {
- file.getContent().removeAttribute(atttrName);
- }
-
- /**
- * Creates access to the file for random i/o.
- */
- protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
- {
- return file.getContent().getRandomAccessContent(mode);
- }
+ for (int i = 0; i < children.length; i++)
+ {
+ childNames[i] = children[i].getName().getBaseName();
+ }
+ return childNames;
+ }
+ else
+ {
+ return (String[]) children.toArray(new String[children.size()]);
+ }
+ }
+
+ /**
+ * Creates this file as a folder.
+ */
+ protected void doCreateFolder() throws Exception
+ {
+ ignoreEvent = true;
+ try
+ {
+ file.createFolder();
+ }
+ finally
+ {
+ ignoreEvent = false;
+ }
+ }
+
+ /**
+ * Deletes the file.
+ */
+ protected void doDelete() throws Exception
+ {
+ ignoreEvent = true;
+ try
+ {
+ file.delete();
+ }
+ finally
+ {
+ ignoreEvent = false;
+ }
+ }
+
+ /**
+ * Returns the size of the file content (in bytes). Is only called if
+ * {@link #doGetType} returns {@link FileType#FILE}.
+ */
+ protected long doGetContentSize() throws Exception
+ {
+ return file.getContent().getSize();
+ }
+
+ /**
+ * Returns the attributes of this file.
+ */
+ protected Map doGetAttributes()
+ throws Exception
+ {
+ return file.getContent().getAttributes();
+ }
+
+ /**
+ * Sets an attribute of this file.
+ */
+ protected void doSetAttribute(final String atttrName,
+ final Object value)
+ throws Exception
+ {
+ file.getContent().setAttribute(atttrName, value);
+ }
+
+ /**
+ * Returns the certificates of this file.
+ */
+ protected Certificate[] doGetCertificates() throws Exception
+ {
+ return file.getContent().getCertificates();
+ }
+
+ /**
+ * Returns the last-modified time of this file.
+ */
+ protected long doGetLastModifiedTime() throws Exception
+ {
+ return file.getContent().getLastModifiedTime();
+ }
+
+ /**
+ * Sets the last-modified time of this file.
+ */
+ protected boolean doSetLastModTime(final long modtime)
+ throws Exception
+ {
+ file.getContent().setLastModifiedTime(modtime);
+ return true;
+ }
+
+ /**
+ * Creates an input stream to read the file content from.
+ */
+ protected InputStream doGetInputStream() throws Exception
+ {
+ return file.getContent().getInputStream();
+ }
+
+ /**
+ * Creates an output stream to write the file content to.
+ */
+ protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
+ {
+ return file.getContent().getOutputStream(bAppend);
+ }
+
+ /**
+ * Called when a file is created.
+ */
+ public void fileCreated(final FileChangeEvent event) throws Exception
+ {
+ if (event.getFile() != file)
+ {
+ return;
+ }
+ if (!ignoreEvent)
+ {
+ handleCreate(file.getType());
+ }
+ }
+
+ /**
+ * Called when a file is deleted.
+ */
+ public void fileDeleted(final FileChangeEvent event) throws Exception
+ {
+ if (event.getFile() != file)
+ {
+ return;
+ }
+ if (!ignoreEvent)
+ {
+ handleDelete();
+ }
+ }
+
+ /**
+ * Called when a file is changed.
+ * <p/>
+ * This will only happen if you monitor the file using {@link org.apache.commons.vfs.FileMonitor}.
+ */
+ public void fileChanged(FileChangeEvent event) throws Exception
+ {
+ if (event.getFile() != file)
+ {
+ return;
+ }
+ if (!ignoreEvent)
+ {
+ handleChanged();
+ }
+ }
+
+ /**
+ * Close the delegated file
+ */
+ public void close() throws FileSystemException
+ {
+ super.close();
+
+ if (file != null)
+ {
+ file.close();
+ }
+ }
+
+ /**
+ * refresh file informations
+ */
+ public void refresh() throws FileSystemException
+ {
+ super.refresh();
+ if (file != null)
+ {
+ file.refresh();
+ }
+ }
+
+ protected FileContentInfo doGetContentInfo() throws Exception
+ {
+ return file.getContent().getContentInfo();
+ }
+
+ /**
+ * Renames the file.
+ */
+ protected void doRename(FileObject newFile)
+ throws Exception
+ {
+ file.moveTo(((DelegateFileObject) newFile).file);
+ }
+
+ /**
+ * Removes an attribute of this file.
+ */
+ protected void doRemoveAttribute(final String atttrName)
+ throws Exception
+ {
+ file.getContent().removeAttribute(atttrName);
+ }
+
+ /**
+ * Creates access to the file for random i/o.
+ */
+ protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
+ {
+ return file.getContent().getRandomAccessContent(mode);
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java Mon Apr 13 04:06:01 2009
@@ -30,7 +30,7 @@
// private int state = DefaultFileContent.STATE_CLOSED;
private final ArrayList instrs = new ArrayList();
- private final ArrayList rastrs = new ArrayList();
+ private final ArrayList rastrs = new ArrayList();
private DefaultFileContent.FileContentOutputStream outstr;
FileContentThreadData()
@@ -84,17 +84,17 @@
this.rastrs.remove(instr);
}
- public Object removeRastr(int pos)
- {
- return this.rastrs.remove(pos);
- }
-
- public void removeRastr(RandomAccessContent ras)
- {
- this.instrs.remove(ras);
- }
+ public Object removeRastr(int pos)
+ {
+ return this.rastrs.remove(pos);
+ }
- public boolean hasStreams()
+ public void removeRastr(RandomAccessContent ras)
+ {
+ this.instrs.remove(ras);
+ }
+
+ public boolean hasStreams()
{
return instrs.size() > 0 || outstr != null || rastrs.size() > 0;
}
@@ -105,8 +105,8 @@
outstr = null;
}
- int getRastrsSize()
- {
- return rastrs.size();
- }
+ int getRastrsSize()
+ {
+ return rastrs.size();
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/GenericFileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/GenericFileName.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/GenericFileName.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/GenericFileName.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LayeredFileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LayeredFileName.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LayeredFileName.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LayeredFileName.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LocalFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LocalFileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LocalFileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/LocalFileProvider.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/TemporaryFileStore.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/TemporaryFileStore.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/TemporaryFileStore.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/TemporaryFileStore.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/UriParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/UriParser.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/UriParser.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/UriParser.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.
@@ -24,474 +24,474 @@
/**
* Utilities for dealing with URIs. See RFC 2396 for details.
- *
+ *
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @version $Revision$ $Date: 2005-10-13 21:11:33 +0200 (Do, 13 Okt
* 2005) $
*/
public final class UriParser
{
- /**
- * The normalised separator to use.
- */
- private static final char SEPARATOR_CHAR = FileName.SEPARATOR_CHAR;
-
- /**
- * The set of valid separators. These are all converted to the normalised
- * one. Does <i>not</i> contain the normalised separator
- */
- // public static final char[] separators = {'\\'};
- public static final char TRANS_SEPARATOR = '\\';
-
- private UriParser()
- {
- }
-
- /**
- * Extracts the first element of a path.
- */
- public static String extractFirstElement(final StringBuffer name)
- {
- final int len = name.length();
- if (len < 1)
- {
- return null;
- }
- int startPos = 0;
- if (name.charAt(0) == SEPARATOR_CHAR)
- {
- startPos = 1;
- }
- for (int pos = startPos; pos < len; pos++)
- {
- if (name.charAt(pos) == SEPARATOR_CHAR)
- {
- // Found a separator
- final String elem = name.substring(startPos, pos);
- name.delete(startPos, pos + 1);
- return elem;
- }
- }
-
- // No separator
- final String elem = name.substring(startPos);
- name.setLength(0);
- return elem;
- }
-
- /**
- * Normalises a path. Does the following:
- * <ul>
- * <li>Removes empty path elements.
- * <li>Handles '.' and '..' elements.
- * <li>Removes trailing separator.
- * </ul>
- *
- * Its assumed that the separators are already fixed.
- *
- * @see #fixSeparators
- */
- public static FileType normalisePath(final StringBuffer path)
- throws FileSystemException
- {
- FileType fileType = FileType.FOLDER;
- if (path.length() == 0)
- {
- return fileType;
- }
-
- if (path.charAt(path.length() - 1) != '/')
- {
- fileType = FileType.FILE;
- }
-
- // Adjust separators
- // fixSeparators(path);
-
- // Determine the start of the first element
- int startFirstElem = 0;
- if (path.charAt(0) == SEPARATOR_CHAR)
- {
- if (path.length() == 1)
- {
- return fileType;
- }
- startFirstElem = 1;
- }
-
- // Iterate over each element
- int startElem = startFirstElem;
- int maxlen = path.length();
- while (startElem < maxlen)
- {
- // Find the end of the element
- int endElem = startElem;
- for (; endElem < maxlen && path.charAt(endElem) != SEPARATOR_CHAR; endElem++)
- {
- }
-
- final int elemLen = endElem - startElem;
- if (elemLen == 0)
- {
- // An empty element - axe it
- path.delete(endElem, endElem + 1);
- maxlen = path.length();
- continue;
- }
- if (elemLen == 1 && path.charAt(startElem) == '.')
- {
- // A '.' element - axe it
- path.delete(startElem, endElem + 1);
- maxlen = path.length();
- continue;
- }
- if (elemLen == 2 && path.charAt(startElem) == '.'
- && path.charAt(startElem + 1) == '.')
- {
- // A '..' element - remove the previous element
- if (startElem == startFirstElem)
- {
- // Previous element is missing
- throw new FileSystemException(
- "vfs.provider/invalid-relative-path.error");
- }
-
- // Find start of previous element
- int pos = startElem - 2;
- for (; pos >= 0 && path.charAt(pos) != SEPARATOR_CHAR; pos--)
- {
- }
- startElem = pos + 1;
-
- path.delete(startElem, endElem + 1);
- maxlen = path.length();
- continue;
- }
-
- // A regular element
- startElem = endElem + 1;
- }
-
- // Remove trailing separator
- if (!VFS.isUriStyle())
- {
- if (maxlen > 0 && path.charAt(maxlen - 1) == SEPARATOR_CHAR
- && maxlen > 1)
- {
- path.delete(maxlen - 1, maxlen);
- }
- }
-
- return fileType;
- }
-
- /**
- * Normalises the separators in a name.
- */
- public static boolean fixSeparators(final StringBuffer name)
- {
- boolean changed = false;
- final int maxlen = name.length();
- for (int i = 0; i < maxlen; i++)
- {
- final char ch = name.charAt(i);
- if (ch == TRANS_SEPARATOR)
- {
- name.setCharAt(i, SEPARATOR_CHAR);
- changed = true;
- }
- }
- return changed;
- }
-
- /**
- * Extracts the scheme from a URI.
- *
- * @param uri
- * The URI.
- * @return The scheme name. Returns null if there is no scheme.
- */
- public static String extractScheme(final String uri)
- {
- return extractScheme(uri, null);
- }
-
- /**
- * Extracts the scheme from a URI. Removes the scheme and ':' delimiter from
- * the front of the URI.
- *
- * @param uri
- * The URI.
- * @param buffer
- * Returns the remainder of the URI.
- * @return The scheme name. Returns null if there is no scheme.
- */
- public static String extractScheme(final String uri,
- final StringBuffer buffer)
- {
- if (buffer != null)
- {
- buffer.setLength(0);
- buffer.append(uri);
- }
-
- final int maxPos = uri.length();
- for (int pos = 0; pos < maxPos; pos++)
- {
- final char ch = uri.charAt(pos);
-
- if (ch == ':')
- {
- // Found the end of the scheme
- final String scheme = uri.substring(0, pos);
+ /**
+ * The normalised separator to use.
+ */
+ private static final char SEPARATOR_CHAR = FileName.SEPARATOR_CHAR;
+
+ /**
+ * The set of valid separators. These are all converted to the normalised
+ * one. Does <i>not</i> contain the normalised separator
+ */
+ // public static final char[] separators = {'\\'};
+ public static final char TRANS_SEPARATOR = '\\';
+
+ private UriParser()
+ {
+ }
+
+ /**
+ * Extracts the first element of a path.
+ */
+ public static String extractFirstElement(final StringBuffer name)
+ {
+ final int len = name.length();
+ if (len < 1)
+ {
+ return null;
+ }
+ int startPos = 0;
+ if (name.charAt(0) == SEPARATOR_CHAR)
+ {
+ startPos = 1;
+ }
+ for (int pos = startPos; pos < len; pos++)
+ {
+ if (name.charAt(pos) == SEPARATOR_CHAR)
+ {
+ // Found a separator
+ final String elem = name.substring(startPos, pos);
+ name.delete(startPos, pos + 1);
+ return elem;
+ }
+ }
+
+ // No separator
+ final String elem = name.substring(startPos);
+ name.setLength(0);
+ return elem;
+ }
+
+ /**
+ * Normalises a path. Does the following:
+ * <ul>
+ * <li>Removes empty path elements.
+ * <li>Handles '.' and '..' elements.
+ * <li>Removes trailing separator.
+ * </ul>
+ *
+ * Its assumed that the separators are already fixed.
+ *
+ * @see #fixSeparators
+ */
+ public static FileType normalisePath(final StringBuffer path)
+ throws FileSystemException
+ {
+ FileType fileType = FileType.FOLDER;
+ if (path.length() == 0)
+ {
+ return fileType;
+ }
+
+ if (path.charAt(path.length() - 1) != '/')
+ {
+ fileType = FileType.FILE;
+ }
+
+ // Adjust separators
+ // fixSeparators(path);
+
+ // Determine the start of the first element
+ int startFirstElem = 0;
+ if (path.charAt(0) == SEPARATOR_CHAR)
+ {
+ if (path.length() == 1)
+ {
+ return fileType;
+ }
+ startFirstElem = 1;
+ }
+
+ // Iterate over each element
+ int startElem = startFirstElem;
+ int maxlen = path.length();
+ while (startElem < maxlen)
+ {
+ // Find the end of the element
+ int endElem = startElem;
+ for (; endElem < maxlen && path.charAt(endElem) != SEPARATOR_CHAR; endElem++)
+ {
+ }
+
+ final int elemLen = endElem - startElem;
+ if (elemLen == 0)
+ {
+ // An empty element - axe it
+ path.delete(endElem, endElem + 1);
+ maxlen = path.length();
+ continue;
+ }
+ if (elemLen == 1 && path.charAt(startElem) == '.')
+ {
+ // A '.' element - axe it
+ path.delete(startElem, endElem + 1);
+ maxlen = path.length();
+ continue;
+ }
+ if (elemLen == 2 && path.charAt(startElem) == '.'
+ && path.charAt(startElem + 1) == '.')
+ {
+ // A '..' element - remove the previous element
+ if (startElem == startFirstElem)
+ {
+ // Previous element is missing
+ throw new FileSystemException(
+ "vfs.provider/invalid-relative-path.error");
+ }
+
+ // Find start of previous element
+ int pos = startElem - 2;
+ for (; pos >= 0 && path.charAt(pos) != SEPARATOR_CHAR; pos--)
+ {
+ }
+ startElem = pos + 1;
+
+ path.delete(startElem, endElem + 1);
+ maxlen = path.length();
+ continue;
+ }
+
+ // A regular element
+ startElem = endElem + 1;
+ }
+
+ // Remove trailing separator
+ if (!VFS.isUriStyle())
+ {
+ if (maxlen > 0 && path.charAt(maxlen - 1) == SEPARATOR_CHAR
+ && maxlen > 1)
+ {
+ path.delete(maxlen - 1, maxlen);
+ }
+ }
+
+ return fileType;
+ }
+
+ /**
+ * Normalises the separators in a name.
+ */
+ public static boolean fixSeparators(final StringBuffer name)
+ {
+ boolean changed = false;
+ final int maxlen = name.length();
+ for (int i = 0; i < maxlen; i++)
+ {
+ final char ch = name.charAt(i);
+ if (ch == TRANS_SEPARATOR)
+ {
+ name.setCharAt(i, SEPARATOR_CHAR);
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Extracts the scheme from a URI.
+ *
+ * @param uri
+ * The URI.
+ * @return The scheme name. Returns null if there is no scheme.
+ */
+ public static String extractScheme(final String uri)
+ {
+ return extractScheme(uri, null);
+ }
+
+ /**
+ * Extracts the scheme from a URI. Removes the scheme and ':' delimiter from
+ * the front of the URI.
+ *
+ * @param uri
+ * The URI.
+ * @param buffer
+ * Returns the remainder of the URI.
+ * @return The scheme name. Returns null if there is no scheme.
+ */
+ public static String extractScheme(final String uri,
+ final StringBuffer buffer)
+ {
+ if (buffer != null)
+ {
+ buffer.setLength(0);
+ buffer.append(uri);
+ }
+
+ final int maxPos = uri.length();
+ for (int pos = 0; pos < maxPos; pos++)
+ {
+ final char ch = uri.charAt(pos);
+
+ if (ch == ':')
+ {
+ // Found the end of the scheme
+ final String scheme = uri.substring(0, pos);
if (scheme.length() <= 1 && Os.isFamily(Os.OS_FAMILY_WINDOWS))
{
// This is not a scheme, but a Windows drive letter
return null;
}
- if (buffer != null)
- {
- buffer.delete(0, pos + 1);
- }
- return scheme.intern();
- }
-
- if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
- {
- // A scheme character
- continue;
- }
- if (pos > 0
- && ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.'))
- {
- // A scheme character (these are not allowed as the first
- // character of the scheme, but can be used as subsequent
- // characters.
- continue;
- }
-
- // Not a scheme character
- break;
- }
-
- // No scheme in URI
- return null;
- }
-
- /**
- * Removes %nn encodings from a string.
- */
- public static String decode(final String encodedStr)
- throws FileSystemException
- {
- if (encodedStr == null)
- {
- return null;
- }
- if (encodedStr.indexOf('%') < 0)
- {
- return encodedStr;
- }
- final StringBuffer buffer = new StringBuffer(encodedStr);
- decode(buffer, 0, buffer.length());
- return buffer.toString();
- }
-
- /**
- * Removes %nn encodings from a string.
- */
- public static void decode(final StringBuffer buffer, final int offset,
- final int length) throws FileSystemException
- {
- int index = offset;
- int count = length;
- for (; count > 0; count--, index++)
- {
- final char ch = buffer.charAt(index);
- if (ch != '%')
- {
- continue;
- }
- if (count < 3)
- {
- throw new FileSystemException(
- "vfs.provider/invalid-escape-sequence.error", buffer
- .substring(index, index + count));
- }
-
- // Decode
- int dig1 = Character.digit(buffer.charAt(index + 1), 16);
- int dig2 = Character.digit(buffer.charAt(index + 2), 16);
- if (dig1 == -1 || dig2 == -1)
- {
- throw new FileSystemException(
- "vfs.provider/invalid-escape-sequence.error", buffer
- .substring(index, index + 3));
- }
- char value = (char) (dig1 << 4 | dig2);
-
- // Replace
- buffer.setCharAt(index, value);
- buffer.delete(index + 1, index + 3);
- count -= 2;
- }
- }
-
- /**
- * Encodes and appends a string to a StringBuffer.
- */
- public static void appendEncoded(final StringBuffer buffer,
- final String unencodedValue, final char[] reserved)
- {
- final int offset = buffer.length();
- buffer.append(unencodedValue);
- encode(buffer, offset, unencodedValue.length(), reserved);
- }
-
- /**
- * Encodes a set of reserved characters in a StringBuffer, using the URI %nn
- * encoding. Always encodes % characters.
- */
- public static void encode(final StringBuffer buffer, final int offset,
- final int length, final char[] reserved)
- {
- int index = offset;
- int count = length;
- for (; count > 0; index++, count--)
- {
- final char ch = buffer.charAt(index);
- boolean match = (ch == '%');
- if (reserved != null)
- {
- for (int i = 0; !match && i < reserved.length; i++)
- {
- if (ch == reserved[i])
- {
- match = true;
- }
- }
- }
- if (match)
- {
- // Encode
- char[] digits =
- { Character.forDigit(((ch >> 4) & 0xF), 16),
- Character.forDigit((ch & 0xF), 16) };
- buffer.setCharAt(index, '%');
- buffer.insert(index + 1, digits);
- index += 2;
- }
- }
- }
-
- /**
- * Removes %nn encodings from a string.
- */
- public static String encode(final String decodedStr)
- {
- return encode(decodedStr, null);
- }
-
- public static String encode(final String decodedStr, final char[] reserved)
- {
- if (decodedStr == null)
- {
- return null;
- }
- final StringBuffer buffer = new StringBuffer(decodedStr);
- encode(buffer, 0, buffer.length(), reserved);
- return buffer.toString();
- }
-
- public static String[] encode(String[] strings)
- {
- if (strings == null)
- {
- return null;
- }
- for (int i = 0; i < strings.length; i++)
- {
- strings[i] = encode(strings[i]);
- }
- return strings;
- }
-
- public static void checkUriEncoding(String uri) throws FileSystemException
- {
- decode(uri);
- }
-
- public static void canonicalizePath(StringBuffer buffer, int offset,
- int length, FileNameParser fileNameParser)
- throws FileSystemException
- {
- int index = offset;
- int count = length;
- for (; count > 0; count--, index++)
- {
- final char ch = buffer.charAt(index);
- if (ch == '%')
- {
- if (count < 3)
- {
- throw new FileSystemException(
- "vfs.provider/invalid-escape-sequence.error",
- buffer.substring(index, index + count));
- }
-
- // Decode
- int dig1 = Character.digit(buffer.charAt(index + 1), 16);
- int dig2 = Character.digit(buffer.charAt(index + 2), 16);
- if (dig1 == -1 || dig2 == -1)
- {
- throw new FileSystemException(
- "vfs.provider/invalid-escape-sequence.error",
- buffer.substring(index, index + 3));
- }
- char value = (char) (dig1 << 4 | dig2);
-
- boolean match = (value == '%')
- || (fileNameParser != null && fileNameParser
- .encodeCharacter(value));
-
- if (match)
- {
- // this is a reserved character, not allowed to decode
- index += 2;
- count -= 2;
- continue;
- }
-
- // Replace
- buffer.setCharAt(index, value);
- buffer.delete(index + 1, index + 3);
- count -= 2;
- }
- else if (fileNameParser.encodeCharacter(ch))
- {
- // Encode
- char[] digits =
- { Character.forDigit(((ch >> 4) & 0xF), 16),
- Character.forDigit((ch & 0xF), 16) };
- buffer.setCharAt(index, '%');
- buffer.insert(index + 1, digits);
- index += 2;
- }
- }
- }
-
- public static String extractQueryString(StringBuffer name)
- {
- for (int pos = 0; pos < name.length(); pos++)
- {
- if (name.charAt(pos) == '?')
- {
- String queryString = name.substring(pos + 1);
- name.delete(pos, name.length());
- return queryString;
- }
- }
+ if (buffer != null)
+ {
+ buffer.delete(0, pos + 1);
+ }
+ return scheme.intern();
+ }
+
+ if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
+ {
+ // A scheme character
+ continue;
+ }
+ if (pos > 0
+ && ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.'))
+ {
+ // A scheme character (these are not allowed as the first
+ // character of the scheme, but can be used as subsequent
+ // characters.
+ continue;
+ }
+
+ // Not a scheme character
+ break;
+ }
+
+ // No scheme in URI
+ return null;
+ }
+
+ /**
+ * Removes %nn encodings from a string.
+ */
+ public static String decode(final String encodedStr)
+ throws FileSystemException
+ {
+ if (encodedStr == null)
+ {
+ return null;
+ }
+ if (encodedStr.indexOf('%') < 0)
+ {
+ return encodedStr;
+ }
+ final StringBuffer buffer = new StringBuffer(encodedStr);
+ decode(buffer, 0, buffer.length());
+ return buffer.toString();
+ }
+
+ /**
+ * Removes %nn encodings from a string.
+ */
+ public static void decode(final StringBuffer buffer, final int offset,
+ final int length) throws FileSystemException
+ {
+ int index = offset;
+ int count = length;
+ for (; count > 0; count--, index++)
+ {
+ final char ch = buffer.charAt(index);
+ if (ch != '%')
+ {
+ continue;
+ }
+ if (count < 3)
+ {
+ throw new FileSystemException(
+ "vfs.provider/invalid-escape-sequence.error", buffer
+ .substring(index, index + count));
+ }
+
+ // Decode
+ int dig1 = Character.digit(buffer.charAt(index + 1), 16);
+ int dig2 = Character.digit(buffer.charAt(index + 2), 16);
+ if (dig1 == -1 || dig2 == -1)
+ {
+ throw new FileSystemException(
+ "vfs.provider/invalid-escape-sequence.error", buffer
+ .substring(index, index + 3));
+ }
+ char value = (char) (dig1 << 4 | dig2);
+
+ // Replace
+ buffer.setCharAt(index, value);
+ buffer.delete(index + 1, index + 3);
+ count -= 2;
+ }
+ }
+
+ /**
+ * Encodes and appends a string to a StringBuffer.
+ */
+ public static void appendEncoded(final StringBuffer buffer,
+ final String unencodedValue, final char[] reserved)
+ {
+ final int offset = buffer.length();
+ buffer.append(unencodedValue);
+ encode(buffer, offset, unencodedValue.length(), reserved);
+ }
+
+ /**
+ * Encodes a set of reserved characters in a StringBuffer, using the URI %nn
+ * encoding. Always encodes % characters.
+ */
+ public static void encode(final StringBuffer buffer, final int offset,
+ final int length, final char[] reserved)
+ {
+ int index = offset;
+ int count = length;
+ for (; count > 0; index++, count--)
+ {
+ final char ch = buffer.charAt(index);
+ boolean match = (ch == '%');
+ if (reserved != null)
+ {
+ for (int i = 0; !match && i < reserved.length; i++)
+ {
+ if (ch == reserved[i])
+ {
+ match = true;
+ }
+ }
+ }
+ if (match)
+ {
+ // Encode
+ char[] digits =
+ { Character.forDigit(((ch >> 4) & 0xF), 16),
+ Character.forDigit((ch & 0xF), 16) };
+ buffer.setCharAt(index, '%');
+ buffer.insert(index + 1, digits);
+ index += 2;
+ }
+ }
+ }
+
+ /**
+ * Removes %nn encodings from a string.
+ */
+ public static String encode(final String decodedStr)
+ {
+ return encode(decodedStr, null);
+ }
+
+ public static String encode(final String decodedStr, final char[] reserved)
+ {
+ if (decodedStr == null)
+ {
+ return null;
+ }
+ final StringBuffer buffer = new StringBuffer(decodedStr);
+ encode(buffer, 0, buffer.length(), reserved);
+ return buffer.toString();
+ }
+
+ public static String[] encode(String[] strings)
+ {
+ if (strings == null)
+ {
+ return null;
+ }
+ for (int i = 0; i < strings.length; i++)
+ {
+ strings[i] = encode(strings[i]);
+ }
+ return strings;
+ }
+
+ public static void checkUriEncoding(String uri) throws FileSystemException
+ {
+ decode(uri);
+ }
+
+ public static void canonicalizePath(StringBuffer buffer, int offset,
+ int length, FileNameParser fileNameParser)
+ throws FileSystemException
+ {
+ int index = offset;
+ int count = length;
+ for (; count > 0; count--, index++)
+ {
+ final char ch = buffer.charAt(index);
+ if (ch == '%')
+ {
+ if (count < 3)
+ {
+ throw new FileSystemException(
+ "vfs.provider/invalid-escape-sequence.error",
+ buffer.substring(index, index + count));
+ }
+
+ // Decode
+ int dig1 = Character.digit(buffer.charAt(index + 1), 16);
+ int dig2 = Character.digit(buffer.charAt(index + 2), 16);
+ if (dig1 == -1 || dig2 == -1)
+ {
+ throw new FileSystemException(
+ "vfs.provider/invalid-escape-sequence.error",
+ buffer.substring(index, index + 3));
+ }
+ char value = (char) (dig1 << 4 | dig2);
+
+ boolean match = (value == '%')
+ || (fileNameParser != null && fileNameParser
+ .encodeCharacter(value));
+
+ if (match)
+ {
+ // this is a reserved character, not allowed to decode
+ index += 2;
+ count -= 2;
+ continue;
+ }
+
+ // Replace
+ buffer.setCharAt(index, value);
+ buffer.delete(index + 1, index + 3);
+ count -= 2;
+ }
+ else if (fileNameParser.encodeCharacter(ch))
+ {
+ // Encode
+ char[] digits =
+ { Character.forDigit(((ch >> 4) & 0xF), 16),
+ Character.forDigit((ch & 0xF), 16) };
+ buffer.setCharAt(index, '%');
+ buffer.insert(index + 1, digits);
+ index += 2;
+ }
+ }
+ }
+
+ public static String extractQueryString(StringBuffer name)
+ {
+ for (int pos = 0; pos < name.length(); pos++)
+ {
+ if (name.charAt(pos) == '?')
+ {
+ String queryString = name.substring(pos + 1);
+ name.delete(pos, name.length());
+ return queryString;
+ }
+ }
- return null;
- }
+ return null;
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponent.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponentContext.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponentContext.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponentContext.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/VfsComponentContext.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/BZip2Constants.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/BZip2Constants.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/BZip2Constants.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/BZip2Constants.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.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileProvider.java Mon Apr 13 04:06:01 2009
@@ -36,23 +36,26 @@
*/
public class Bzip2FileProvider extends CompressedFileFileProvider
{
- protected final static Collection capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[]
- {
- Capability.GET_LAST_MODIFIED,
- Capability.GET_TYPE,
- Capability.LIST_CHILDREN,
- Capability.READ_CONTENT,
- Capability.WRITE_CONTENT,
- Capability.URI,
- Capability.COMPRESS
- }));
+ protected final static Collection capabilities =
+ Collections.unmodifiableCollection(Arrays.asList(new Capability[]
+ {
+ Capability.GET_LAST_MODIFIED,
+ Capability.GET_TYPE,
+ Capability.LIST_CHILDREN,
+ Capability.READ_CONTENT,
+ Capability.WRITE_CONTENT,
+ Capability.URI,
+ Capability.COMPRESS
+ }));
public Bzip2FileProvider()
{
super();
}
- protected FileSystem createFileSystem(FileName name, FileObject file, FileSystemOptions fileSystemOptions) throws FileSystemException
+ protected FileSystem createFileSystem(FileName name, FileObject file,
+ FileSystemOptions fileSystemOptions)
+ throws FileSystemException
{
return new Bzip2FileSystem(name, file, fileSystemOptions);
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileSystem.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/Bzip2FileSystem.java Mon Apr 13 04:06:01 2009
@@ -32,7 +32,8 @@
*/
public class Bzip2FileSystem extends CompressedFileFileSystem
{
- protected Bzip2FileSystem(FileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions) throws FileSystemException
+ protected Bzip2FileSystem(FileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions)
+ throws FileSystemException
{
super(rootName, parentLayer, fileSystemOptions);
}