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
;
22 import java
.io
.IOException
;
23 import java
.io
.InputStream
;
24 import java
.io
.OutputStream
;
30 @SuppressWarnings({"Since15"})
31 public abstract class FileVirtualObject
extends SimpleJavaFileObject
{
32 public FileVirtualObject(URI uri
, Kind kind
) {
36 protected abstract VirtualFile
getVirtualFile();
38 public CharSequence
getCharContent(boolean ignoreEncodingErrors
) throws IOException
{
39 VirtualFile virtualFile
= getVirtualFile();
40 if (virtualFile
== null) return null;
41 return LoadTextUtil
.loadText(virtualFile
);
45 public InputStream
openInputStream() throws IOException
{
46 return getVirtualFile().getInputStream();
50 public OutputStream
openOutputStream() throws IOException
{
51 return getVirtualFile().getOutputStream(this);
55 public String
toString() {
56 return toUri().toString();
59 public int hashCode() {
60 return toUri().hashCode();
64 public boolean equals(Object obj
) {
65 return obj
instanceof JavaFileObject
&& toUri().equals(((JavaFileObject
)obj
).toUri());