vcs: rewritten getCharset() method to make a better use of available information...
[fedora-idea.git] / vcs-api / src / com / intellij / openapi / vcs / FilePath.java
blobf57924cc49dbf243d29500331358191d5733304a
1 /*
2 * Copyright 2000-2007 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.openapi.vcs;
18 import com.intellij.openapi.editor.Document;
19 import com.intellij.openapi.fileTypes.FileType;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.openapi.vfs.VirtualFile;
22 import org.jetbrains.annotations.NotNull;
23 import org.jetbrains.annotations.Nullable;
25 import java.io.File;
26 import java.nio.charset.Charset;
28 /**
29 * Represents a path to a (possibly non-existing) file on disk or in a VCS repository.
31 public interface FilePath {
32 /**
33 * @return a virtual file that corresponds to this path, or null if the virtual file is no more valid.
35 VirtualFile getVirtualFile();
37 /**
38 * @return the virtual file that corresponds to the parent file path, or null if the virtual file is no more valid.
40 VirtualFile getVirtualFileParent();
42 /**
43 * @return the {@link java.io.File} that corresponds to the path. The path might be non-existent or not local.
44 * @see #isNonLocal()
46 @NotNull
47 File getIOFile();
49 /**
50 * @return the file name (without directory component)
52 String getName();
54 String getPresentableUrl();
56 @Nullable
57 Document getDocument();
59 Charset getCharset();
61 /**
62 * Get character set, considering the project defaults and a virtual file
64 * @param project the project which settings will be consulted
65 * @return the character set of the file
67 Charset getCharset(Project project);
69 /**
70 * @return the type of the file
72 FileType getFileType();
74 void refresh();
76 String getPath();
78 /**
79 * @return true if the path represents the directory
81 boolean isDirectory();
83 /**
84 * Check if the provided file is an ancestor of the current file.
86 * @param parent a possible parent
87 * @param strict if false, the method also returns true if files are equal
88 * @return true if {@code this} file is ancestor of the {@code parent}.
90 boolean isUnder(FilePath parent, boolean strict);
92 /**
93 * @return the parent path or null if there are no parent
95 @Nullable
96 FilePath getParentPath();
98 /**
99 * @return true if the path does not represents a file in the local file system
101 boolean isNonLocal();