pathwrapper.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 728 行 · 第 1/2 页

JAVA
728
字号
/* * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty * of NON-INFRINGEMENT.  See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * *   Free Software Foundation, Inc. *   59 Temple Place, Suite 330 *   Boston, MA 02111-1307  USA * * @author Scott Ferguson */package com.caucho.vfs;import com.caucho.util.L10N;import java.io.IOException;import java.io.OutputStream;import java.util.ArrayList;import java.util.Iterator;import java.util.Map;/** * Wraps a path object. */public abstract class PathWrapper extends Path {  protected final static L10N L = new L10N(PathWrapper.class);  private final Path _path;  /**   * Creates a new Path object.   *   * @param path the new Path root.   */  protected PathWrapper(Path path)  {    super(path);    _path = path;  }  /**   * Returns the wrapped path.   */  public Path getWrappedPath()  {    return _path;  }  /**   * Returns a new path relative to the current one.   *   * <p>Path only handles scheme:xxx.  Subclasses of Path will specialize   * the xxx.   *   * @param userPath relative or absolute path, essentially any url.   * @param newAttributes attributes for the new path.   *   * @return the new path or null if the scheme doesn't exist   */   public Path lookup(String userPath, Map<String,Object> newAttributes)   {     return getWrappedPath().lookup(userPath, newAttributes);   }  /**   * Returns a new path relative to the current one.   *   * <p>Path only handles scheme:xxx.  Subclasses of Path will specialize   * the xxx.   *   * @param userPath relative or absolute path, essentially any url.   * @param newAttributes attributes for the new path.   *   * @return the new path or null if the scheme doesn't exist   */  public Path lookupImpl(String userPath, Map<String,Object> newAttributes)  {    return getWrappedPath().lookupImpl(userPath, newAttributes);  }  /**   * Looks up a native path, adding attributes.   */  public Path lookupNative(String name, Map<String,Object> attributes)  {    return getWrappedPath().lookupNative(name, attributes);  }  /**   * Looks up all the resources matching a name.  (Generally only useful   * with MergePath.   */  public ArrayList<Path> getResources(String name)  {    return getWrappedPath().getResources(name);  }  /**   * Looks up all the existing resources.  (Generally only useful   * with MergePath.   */  public ArrayList<Path> getResources()  {    return getWrappedPath().getResources();  }  /**   * Returns the parent path.   */  public Path getParent()  {    return getWrappedPath().getParent();  }  /**   * Path-specific lookup.  Path implementations will override this.   *   * @param userPath the user's lookup() path.   * @param newAttributes the attributes for the new path.   * @param newPath the lookup() path   * @param offset offset into newPath to start lookup.   *   * @return the found path   */  protected Path schemeWalk(String userPath,			    Map<String,Object> newAttributes,			    String newPath, int offset)  {    return getWrappedPath().schemeWalk(userPath, newAttributes,				       newPath, offset);  }  /**   * Returns the full url for the given path.   */  public String getURL()  {    return getWrappedPath().getURL();  }  /**   * Returns the url scheme   */  public String getScheme()  {    return getWrappedPath().getScheme();  }  /**   * Returns the hostname   */  public String getHost()  {    return getWrappedPath().getHost();  }  /**   * Returns the port.   */  public int getPort()  {    return getWrappedPath().getPort();  }  /**   * Returns the path.  e.g. for HTTP, returns the part after the   * host and port.   */  public String getPath()  {    return getWrappedPath().getPath();  }  /**   * Returns the last segment of the path.   *   * <p>e.g. for http://www.caucho.com/products/index.html, getTail()   * returns 'index.html'   */  public String getTail()  {    return getWrappedPath().getTail();  }  /**   * Returns the query string of the path.   */  public String getQuery()  {    return getWrappedPath().getQuery();  }  /**   * Returns the native representation of the path.   *   * On Windows, getNativePath() returns 'd:\\foo\bar.html',   * getPath() returns '/d:/foo/bar.html'   */  public String getNativePath()  {    return getWrappedPath().getNativePath();  }  /**   * Returns the last string used as a lookup, if available.  This allows   * parsers to give intelligent error messages, with the user's path   * instead of the whole path.   *   * The following will print '../test.html':   * <code><pre>   * Path path = Pwd.lookup("/some/dir").lookup("../test.html");   * System.out.println(path.getUserPath());   * </pre></code>   *   */  public String getUserPath()  {    return getWrappedPath().getUserPath();  }  /**   * Sets the user path.  Useful for temporary files caching another   * URL.   */  public void setUserPath(String userPath)  {    getWrappedPath().setUserPath(userPath);  }  /**   * Returns the full path, including the restricted root.   *   * <p>For the following, path.getPath() returns '/file.html', while   * path.getFullPath() returns '/chroot/file.html'.   * <code><pre>   * Path chroot = Pwd.lookup("/chroot").createRoot();   * Path path = chroot.lookup("/file.html");   * </pre></code>   */  public String getFullPath()  {    return getWrappedPath().getFullPath();  }  /**   * For union paths like MergePath, return the relative path into   * that path.   */  public String getRelativePath()  {    return getWrappedPath().getRelativePath();  }  /**   * Tests if the file exists.   */  public boolean exists()  {    return getWrappedPath().exists();  }  /**   * Returns the mime-type of the file.   * <p>Mime-type ignorant filesystems return 'application/octet-stream'   */  public String getContentType()  {    return getWrappedPath().getContentType();  }  /**   * Tests if the path refers to a directory.   */  public boolean isDirectory()  {    return getWrappedPath().isDirectory();  }  /**   * Tests if the path refers to a file.   */  public boolean isFile()  {    return getWrappedPath().isFile();  }  /**   * Tests if the path refers to an object.   */  public boolean isObject()  {    return getWrappedPath().isObject();  }  /**   * Returns the length of the file in bytes.   * @return 0 for non-files   */  public long getLength()  {    return getWrappedPath().getLength();  }  /**   * Returns the last modified time of the file.  According to the jdk,   * this may not correspond to the system time.   * @return 0 for non-files.   */  public long getLastModified()  {    return getWrappedPath().getLastModified();  }  public void setLastModified(long time)  {    getWrappedPath().setLastModified(time);  }  /**   * Returns the last access time of the file.   *   * @return 0 for non-files.   */  public long getLastAccessTime()  {    return getWrappedPath().getLastAccessTime();  }  /**   * Returns the create time of the file.   *   * @return 0 for non-files.   */  public long getCreateTime()  {    return getWrappedPath().getCreateTime();  }  /**   * Tests if the file can be read.   */  public boolean canRead()  {    return getWrappedPath().canRead();  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?