001/* 002 * Copyright 2011-2012 Stephen Connolly. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.jszip.pseudo.io; 018 019import java.io.IOException; 020import java.io.InputStream; 021import java.io.OutputStream; 022 023public class NotExistingPseudoFile extends PseudoFile { 024 private final String name; 025 026 public NotExistingPseudoFile(PseudoFile parent, String name) { 027 super(parent); 028 this.name = name; 029 } 030 031 /** 032 * {@inheritDoc} 033 */ 034 public boolean canRead() { 035 return false; 036 } 037 038 /** 039 * {@inheritDoc} 040 */ 041 public boolean canWrite() { 042 return false; 043 } 044 045 /** 046 * {@inheritDoc} 047 */ 048 public boolean createNewFile() throws IOException { 049 throw new IOException(getPath() + " is a non-existing file"); 050 } 051 052 /** 053 * {@inheritDoc} 054 */ 055 public boolean delete() { 056 return false; 057 } 058 059 /** 060 * {@inheritDoc} 061 */ 062 public void deleteOnExit() { 063 } 064 065 /** 066 * {@inheritDoc} 067 */ 068 public boolean exists() { 069 return false; 070 } 071 072 /** 073 * {@inheritDoc} 074 */ 075 public String getName() { 076 return name; 077 } 078 079 /** 080 * {@inheritDoc} 081 */ 082 public boolean isDirectory() { 083 return true; 084 } 085 086 /** 087 * {@inheritDoc} 088 */ 089 public boolean isFile() { 090 return false; 091 } 092 093 /** 094 * {@inheritDoc} 095 */ 096 public boolean isHidden() { 097 return false; 098 } 099 100 /** 101 * {@inheritDoc} 102 */ 103 public long lastModified() { 104 return 0; 105 } 106 107 /** 108 * {@inheritDoc} 109 */ 110 public long length() { 111 return 0; 112 } 113 114 /** 115 * {@inheritDoc} 116 */ 117 public boolean mkdir() { 118 return false; 119 } 120 121 /** 122 * {@inheritDoc} 123 */ 124 public boolean mkdirs() { 125 return false; 126 } 127 128 /** 129 * {@inheritDoc} 130 */ 131 public boolean renameTo(PseudoFile dest) { 132 return false; 133 } 134 135 /** 136 * {@inheritDoc} 137 */ 138 public boolean setLastModified(long time) { 139 return false; 140 } 141 142 /** 143 * {@inheritDoc} 144 */ 145 InputStream $newInputStream() throws IOException { 146 throw new IOException(getPath() + " is a non-existing file"); 147 } 148 149 /** 150 * {@inheritDoc} 151 */ 152 OutputStream $newOutputStream() throws IOException { 153 throw new IOException(getPath() + " is a non-existing file"); 154 } 155 156 /** 157 * {@inheritDoc} 158 */ 159 OutputStream $newOutputStream(boolean append) throws IOException { 160 throw new IOException(getPath() + " is a non-existing file"); 161 } 162}