edu.rice.cs.drjava.model
Class DrJavaFileUtils

java.lang.Object
  extended by edu.rice.cs.drjava.model.DrJavaFileUtils

public class DrJavaFileUtils
extends java.lang.Object

Some common methods for determining Java source files, language level files, etc.

Version:
$Id: DrJavaFileUtils.java 5395 2010-09-21 15:26:15Z mgricken $

Constructor Summary
DrJavaFileUtils()
           
 
Method Summary
static java.io.File getDJ0ForJavaFile(java.io.File f)
          A.java --> A.dj0 otherwise unchanged
static java.lang.String getDJ0ForJavaFile(java.lang.String f)
          A.java --> A.dj0 otherwise unchanged
static java.io.File getDJ1ForJavaFile(java.io.File f)
          A.java --> A.dj1 otherwise unchanged
static java.lang.String getDJ1ForJavaFile(java.lang.String f)
          A.java --> A.dj1 otherwise unchanged
static java.io.File getDJ2ForJavaFile(java.io.File f)
          A.java --> A.dj2 otherwise unchanged
static java.lang.String getDJ2ForJavaFile(java.lang.String f)
          A.java --> A.dj2 otherwise unchanged
static java.io.File getDJForJavaFile(java.io.File f)
          A.java --> A.dj otherwise unchanged
static java.lang.String getDJForJavaFile(java.lang.String f)
          A.java --> A.dj otherwise unchanged
static java.lang.String getExtension(java.lang.String fileName)
           
static java.io.File getFileWithDifferentExt(java.io.File f, java.lang.String source, java.lang.String dest)
          getFileWithDifferentExt(new File("A.java"), ".java", ".dj") ~= new File("A.dj")
static java.lang.String getFileWithDifferentExt(java.lang.String fileName, java.lang.String source, java.lang.String dest)
          getFileWithDifferentExt("A.java", ".java", ".dj") --> "A.dj"
static java.io.File getJavaForLLFile(java.io.File f)
           
static java.lang.String getJavaForLLFile(java.lang.String fileName)
          A.dj --> A.java A.dj0 --> A.java A.dj1 --> A.java A.dj2 --> A.java otherwise unchanged
static java.io.File getNewLLForOldLLFile(java.io.File f)
           
static java.lang.String getNewLLForOldLLFile(java.lang.String fileName)
          A.dj0 -> A.dj A.dj1 -> A.dj A.dj2 -> A.java otherwise unchanged
static java.lang.String getPackageDir(java.lang.String className)
          Returns the relative directory (from the source root) that the source file with this qualifed name will be in, given its package.
static java.util.Set<java.lang.String> getSourceFileExtensions()
          Return the set of source file extensions that this compiler supports.
static java.lang.String getSuggestedFileExtension()
          Return the suggested file extension that will be appended to a file without extension.
static boolean isLLFile(java.io.File f)
           
static boolean isLLFile(java.lang.String fileName)
          .dj --> true .dj0 --> true .dj1 --> true .dj2 --> true otherwise false
static boolean isOldLLFile(java.io.File f)
           
static boolean isOldLLFile(java.lang.String fileName)
          .dj0 --> true .dj1 --> true .dj2 --> true otherwise false
static boolean isOldProjectFile(java.io.File f)
           
static boolean isOldProjectFile(java.lang.String fileName)
          .pjt --> true otherwise false
static boolean isProjectFile(java.io.File f)
           
static boolean isProjectFile(java.lang.String fileName)
          .pjt --> true .drjava --> true .xml --> true otherwise false
static boolean isSourceFile(java.io.File f)
           
static boolean isSourceFile(java.lang.String fileName)
          .java --> true .dj --> true .dj0 --> true .dj1 --> true .dj2 --> true otherwise false
static java.lang.String removeExtension(java.lang.String fileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrJavaFileUtils

public DrJavaFileUtils()
Method Detail

getSourceFileExtensions

public static java.util.Set<java.lang.String> getSourceFileExtensions()
Return the set of source file extensions that this compiler supports.

Returns:
the set of source file extensions that this compiler supports.

getSuggestedFileExtension

public static java.lang.String getSuggestedFileExtension()
Return the suggested file extension that will be appended to a file without extension.

Returns:
the suggested file extension

isSourceFile

public static boolean isSourceFile(java.lang.String fileName)
.java --> true .dj --> true .dj0 --> true .dj1 --> true .dj2 --> true otherwise false

Returns:
true if the file is a Java or language level file.

isSourceFile

public static boolean isSourceFile(java.io.File f)
Returns:
true if the file is a Java or language level file.

isLLFile

public static boolean isLLFile(java.lang.String fileName)
.dj --> true .dj0 --> true .dj1 --> true .dj2 --> true otherwise false

Returns:
true if the file is a language level file.

isLLFile

public static boolean isLLFile(java.io.File f)
Returns:
true if the file is a language level file.

isOldLLFile

public static boolean isOldLLFile(java.lang.String fileName)
.dj0 --> true .dj1 --> true .dj2 --> true otherwise false

Returns:
true if the file is an old language level file.

isOldLLFile

public static boolean isOldLLFile(java.io.File f)
Returns:
true if the file is an old language level file.

isOldProjectFile

public static boolean isOldProjectFile(java.lang.String fileName)
.pjt --> true otherwise false

Returns:
true if the file is an old project file.

isOldProjectFile

public static boolean isOldProjectFile(java.io.File f)
Returns:
true if the file is an old project file.

isProjectFile

public static boolean isProjectFile(java.lang.String fileName)
.pjt --> true .drjava --> true .xml --> true otherwise false

Returns:
true if the file is a project file.

isProjectFile

public static boolean isProjectFile(java.io.File f)
Returns:
true if the file is a project file.

getJavaForLLFile

public static java.lang.String getJavaForLLFile(java.lang.String fileName)
A.dj --> A.java A.dj0 --> A.java A.dj1 --> A.java A.dj2 --> A.java otherwise unchanged

Returns:
matching Java file for a language level file.

getJavaForLLFile

public static java.io.File getJavaForLLFile(java.io.File f)
Returns:
matching Java file for a language level file.

getDJForJavaFile

public static java.io.File getDJForJavaFile(java.io.File f)
A.java --> A.dj otherwise unchanged

Returns:
matching .dj file for a .java file.

getDJ0ForJavaFile

public static java.io.File getDJ0ForJavaFile(java.io.File f)
A.java --> A.dj0 otherwise unchanged

Returns:
matching .dj0 file for a .java file.

getDJ1ForJavaFile

public static java.io.File getDJ1ForJavaFile(java.io.File f)
A.java --> A.dj1 otherwise unchanged

Returns:
matching .dj1 file for a .java file.

getDJ2ForJavaFile

public static java.io.File getDJ2ForJavaFile(java.io.File f)
A.java --> A.dj2 otherwise unchanged

Returns:
matching .dj2 file for a .java file.

getDJForJavaFile

public static java.lang.String getDJForJavaFile(java.lang.String f)
A.java --> A.dj otherwise unchanged

Returns:
matching .dj file for a .java file.

getDJ0ForJavaFile

public static java.lang.String getDJ0ForJavaFile(java.lang.String f)
A.java --> A.dj0 otherwise unchanged

Returns:
matching .dj0 file for a .java file.

getDJ1ForJavaFile

public static java.lang.String getDJ1ForJavaFile(java.lang.String f)
A.java --> A.dj1 otherwise unchanged

Returns:
matching .dj1 file for a .java file.

getDJ2ForJavaFile

public static java.lang.String getDJ2ForJavaFile(java.lang.String f)
A.java --> A.dj2 otherwise unchanged

Returns:
matching .dj2 file for a .java file.

getNewLLForOldLLFile

public static java.lang.String getNewLLForOldLLFile(java.lang.String fileName)
A.dj0 -> A.dj A.dj1 -> A.dj A.dj2 -> A.java otherwise unchanged

Returns:
new language level file matching an old language level file.

getNewLLForOldLLFile

public static java.io.File getNewLLForOldLLFile(java.io.File f)
Returns:
new language level file matching an old language level file.

getFileWithDifferentExt

public static java.lang.String getFileWithDifferentExt(java.lang.String fileName,
                                                       java.lang.String source,
                                                       java.lang.String dest)
getFileWithDifferentExt("A.java", ".java", ".dj") --> "A.dj"

Returns:
matching file with extension dest for a file with extension source.

getFileWithDifferentExt

public static java.io.File getFileWithDifferentExt(java.io.File f,
                                                   java.lang.String source,
                                                   java.lang.String dest)
getFileWithDifferentExt(new File("A.java"), ".java", ".dj") ~= new File("A.dj")

Returns:
matching file with extension dest for a file with extension source.

getPackageDir

public static java.lang.String getPackageDir(java.lang.String className)
Returns the relative directory (from the source root) that the source file with this qualifed name will be in, given its package. Returns the empty string for classes without packages.

Parameters:
className - The fully qualified class name

removeExtension

public static java.lang.String removeExtension(java.lang.String fileName)
Returns:
the file without the extension; the dot is removed too.

getExtension

public static java.lang.String getExtension(java.lang.String fileName)
Returns:
the extension, including the dot.