Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 55204 invoked from network); 15 Jun 2004 19:26:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 15 Jun 2004 19:26:30 -0000 Received: (qmail 14917 invoked by uid 500); 15 Jun 2004 19:26:44 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 14795 invoked by uid 500); 15 Jun 2004 19:26:43 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 14782 invoked by uid 500); 15 Jun 2004 19:26:43 -0000 Received: (qmail 14777 invoked by uid 99); 15 Jun 2004 19:26:43 -0000 Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Tue, 15 Jun 2004 12:26:43 -0700 Received: (qmail 55109 invoked by uid 1850); 15 Jun 2004 19:26:21 -0000 Date: 15 Jun 2004 19:26:21 -0000 Message-ID: <20040615192621.55108.qmail@minotaur.apache.org> From: imario@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/compressedFile CompressedFileFileObject.java CompressedFileFileProvider.java CompressedFileFileSystem.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N imario 2004/06/15 12:26:21 Added: vfs/src/java/org/apache/commons/vfs/provider/compressedFile CompressedFileFileObject.java CompressedFileFileProvider.java CompressedFileFileSystem.java Log: base for compressed files e.g. gzip, bzip2 Revision Changes Path 1.1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/compressedFile/CompressedFileFileObject.java Index: CompressedFileFileObject.java =================================================================== /* * Copyright 2002, 2003,2004 The Apache Software Foundation. * * Licensed 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. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.vfs.provider.compressedFile; import org.apache.commons.vfs.Capability; import org.apache.commons.vfs.FileName; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileType; import org.apache.commons.vfs.provider.AbstractFileObject; /** * A compressedFile compressed file * * @author Mario Ivankovits * @version $Revision: 1.1 $ $Date: 2004/06/15 19:26:21 $ */ public abstract class CompressedFileFileObject extends AbstractFileObject implements FileObject { private final FileObject container; private String[] children; public CompressedFileFileObject(FileName name, FileObject container, CompressedFileFileSystem fs) { super(name, fs); this.container = container; // todo, add getBaseName(String) to FileName String basename = container.getName().getBaseName(); int pos = basename.lastIndexOf('.'); basename = basename.substring(0, pos); children = new String[] { basename }; } /** * Returns true if this file is read-only. */ public boolean isWriteable() { return getFileSystem().hasCapability(Capability.WRITE_CONTENT); } /** * Returns the file's type. */ protected FileType doGetType() throws FileSystemException { return this.container.getType(); } /** * Lists the children of the file. */ protected String[] doListChildren() { return children; } /** * Returns the size of the file content (in bytes). Is only called if * {@link #doGetType} returns {@link FileType#FILE}. */ protected long doGetContentSize() { return -1; } /** * Returns the last modified time of this file. */ protected long doGetLastModifiedTime() throws Exception { return container.getContent().getLastModifiedTime(); } protected FileObject getContainer() { return container; } public void createFile() throws FileSystemException { container.createFile(); injectType(FileType.FILE); } } 1.1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/compressedFile/CompressedFileFileProvider.java Index: CompressedFileFileProvider.java =================================================================== /* * Copyright 2002, 2003,2004 The Apache Software Foundation. * * Licensed 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. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.vfs.provider.compressedFile; import org.apache.commons.vfs.FileName; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSystem; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileSystemOptions; import org.apache.commons.vfs.provider.AbstractLayeredFileProvider; import org.apache.commons.vfs.provider.FileProvider; import org.apache.commons.vfs.provider.zip.ZipFileName; import java.util.Collection; /** * A file system provider for compressedFile compressed files. Provides read-only file * systems. * * @author Mario Ivankovits * @version $Revision: 1.1 $ $Date: 2004/06/15 19:26:21 $ */ public abstract class CompressedFileFileProvider extends AbstractLayeredFileProvider implements FileProvider { public CompressedFileFileProvider() { super(); } /** * Parses an absolute URI. * * @param uri The URI to parse. */ protected FileName parseUri(final String uri) throws FileSystemException { return ZipFileName.parseUri(uri); } /** * Creates a layered file system. This method is called if the file system * is not cached. * * @param scheme The URI scheme. * @param file The file to create the file system on top of. * @return The file system. */ protected FileSystem doCreateFileSystem(final String scheme, final FileObject file, final FileSystemOptions fileSystemOptions) throws FileSystemException { final FileName name = new ZipFileName(scheme, file.getName().getURI(), FileName.ROOT_PATH); return createFileSystem(name, file, fileSystemOptions); } protected abstract FileSystem createFileSystem(final FileName name, final FileObject file, final FileSystemOptions fileSystemOptions) throws FileSystemException; public abstract Collection getCapabilities(); } 1.1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/compressedFile/CompressedFileFileSystem.java Index: CompressedFileFileSystem.java =================================================================== /* * Copyright 2002, 2003,2004 The Apache Software Foundation. * * Licensed 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. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.vfs.provider.compressedFile; import org.apache.commons.vfs.FileName; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSystem; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileSystemOptions; import org.apache.commons.vfs.provider.AbstractFileSystem; import java.util.Collection; /** * A read-only file system for compressedFile files. * * @author Mario Ivankovits * @version $Revision: 1.1 $ $Date: 2004/06/15 19:26:21 $ */ public abstract class CompressedFileFileSystem extends AbstractFileSystem implements FileSystem { public CompressedFileFileSystem(final FileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) throws FileSystemException { super(rootName, parentLayer, fileSystemOptions); } public void init() throws FileSystemException { super.init(); } /** * Returns the capabilities of this file system. */ protected abstract void addCapabilities(final Collection caps); /** * Creates a file object. */ protected abstract FileObject createFile(final FileName name) throws FileSystemException; } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org