do not use VFS to read .class file content,
[fedora-idea.git] / java / compiler / impl / src / com / intellij / compiler / impl / javaCompiler / api / FileVirtualObject.java
blob0537997cc91183ccc661105eca76dfee416f2c68
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.compiler.impl.javaCompiler.api;
18 import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
19 import com.intellij.openapi.vfs.VirtualFile;
21 import javax.tools.*;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.io.OutputStream;
25 import java.net.URI;
27 /**
28 * @author cdr
30 @SuppressWarnings({"Since15"})
31 public abstract class FileVirtualObject extends SimpleJavaFileObject {
32 public FileVirtualObject(URI uri, Kind kind) {
33 super(uri, kind);
36 protected abstract VirtualFile getVirtualFile();
37 @Override
38 public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
39 VirtualFile virtualFile = getVirtualFile();
40 if (virtualFile == null) return null;
41 return LoadTextUtil.loadText(virtualFile);
44 @Override
45 public InputStream openInputStream() throws IOException {
46 return getVirtualFile().getInputStream();
49 @Override
50 public OutputStream openOutputStream() throws IOException {
51 return getVirtualFile().getOutputStream(this);
54 @Override
55 public String toString() {
56 return toUri().toString();
58 @Override
59 public int hashCode() {
60 return toUri().hashCode();
63 @Override
64 public boolean equals(Object obj) {
65 return obj instanceof JavaFileObject && toUri().equals(((JavaFileObject)obj).toUri());