001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2.provider; 018 019import org.apache.commons.vfs2.FileName; 020import org.apache.commons.vfs2.FileType; 021 022/** 023 * A file name for layered files. 024 */ 025public class LayeredFileName extends AbstractFileName { 026 private final FileName outerUri; 027 028 public LayeredFileName(final String scheme, final FileName outerUri, final String path, final FileType type) { 029 super(scheme, path, type); 030 this.outerUri = outerUri; 031 } 032 033 /** 034 * Returns the URI of the outer file. 035 * 036 * @return The FileName. 037 */ 038 public FileName getOuterName() { 039 return outerUri; 040 } 041 042 /** 043 * Create a FileName. 044 * 045 * @param path The file URI. 046 * @param type The FileType. 047 * @return The FileName. 048 */ 049 @Override 050 public FileName createName(final String path, final FileType type) { 051 return new LayeredFileName(getScheme(), getOuterName(), path, type); 052 } 053 054 @Override 055 protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) { 056 buffer.append(getScheme()); 057 buffer.append(":"); 058 buffer.append(getOuterName().getURI()); 059 buffer.append("!"); 060 } 061}