Method from com.sun.tools.javac.file.RegularFileObject Detail: |
public boolean delete() {
return file.delete();
}
|
public boolean equals(Object other) {
if (this == other)
return true;
if (!(other instanceof RegularFileObject))
return false;
RegularFileObject o = (RegularFileObject) other;
return getAbsoluteFile().equals(o.getAbsoluteFile());
}
Check if two file objects are equal.
Two RegularFileObjects are equal if the absolute paths of the underlying
files are equal. |
public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
CharBuffer cb = fileManager.getCachedContent(this);
if (cb == null) {
InputStream in = new FileInputStream(file);
try {
ByteBuffer bb = fileManager.makeByteBuffer(in);
JavaFileObject prev = fileManager.log.useSource(this);
try {
cb = fileManager.decode(bb, ignoreEncodingErrors);
} finally {
fileManager.log.useSource(prev);
}
fileManager.recycleByteBuffer(bb);
if (!ignoreEncodingErrors) {
fileManager.cache(this, cb);
}
} finally {
in.close();
}
}
return cb;
}
|
protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
}
|
public Kind getKind() {
return getKind(name);
}
|
public long getLastModified() {
return file.lastModified();
}
|
public String getName() {
return file.getPath();
}
|
public String getShortName() {
return name;
}
|
public int hashCode() {
return getAbsoluteFile().hashCode();
}
|
protected String inferBinaryName(Iterable<File> path) {
String fPath = file.getPath();
//System.err.println("RegularFileObject " + file + " " +r.getPath());
for (File dir: path) {
//System.err.println("dir: " + dir);
String dPath = dir.getPath();
if (dPath.length() == 0)
dPath = System.getProperty("user.dir");
if (!dPath.endsWith(File.separator))
dPath += File.separator;
if (fPath.regionMatches(true, 0, dPath, 0, dPath.length())
&& new File(fPath.substring(0, dPath.length())).equals(new File(dPath))) {
String relativeName = fPath.substring(dPath.length());
return removeExtension(relativeName).replace(File.separatorChar, '.');
}
}
return null;
}
|
public boolean isNameCompatible(String cn,
Kind kind) {
cn.getClass();
// null check
if (kind == Kind.OTHER && getKind() != kind) {
return false;
}
String n = cn + kind.extension;
if (name.equals(n)) {
return true;
}
if (name.equalsIgnoreCase(n)) {
try {
// allow for Windows
return file.getCanonicalFile().getName().equals(n);
} catch (IOException e) {
}
}
return false;
}
|
public InputStream openInputStream() throws IOException {
return new FileInputStream(file);
}
|
public OutputStream openOutputStream() throws IOException {
ensureParentDirectoriesExist();
return new FileOutputStream(file);
}
|
public Writer openWriter() throws IOException {
ensureParentDirectoriesExist();
return new OutputStreamWriter(new FileOutputStream(file), fileManager.getEncodingName());
}
|
public URI toUri() {
return file.toURI().normalize();
}
|