edu.rice.cs.drjava.model
Class DrJavaFileUtils

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

public class DrJavaFileUtils
extends 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 File getDJ0ForJavaFile(File f)
          A.java --> A.dj0 otherwise unchanged
static String getDJ0ForJavaFile(String f)
          A.java --> A.dj0 otherwise unchanged
static File getDJ1ForJavaFile(File f)
          A.java --> A.dj1 otherwise unchanged
static String getDJ1ForJavaFile(String f)
          A.java --> A.dj1 otherwise unchanged
static File getDJ2ForJavaFile(File f)
          A.java --> A.dj2 otherwise unchanged
static String getDJ2ForJavaFile(String f)
          A.java --> A.dj2 otherwise unchanged
static File getDJForJavaFile(File f)
          A.java --> A.dj otherwise unchanged
static String getDJForJavaFile(String f)
          A.java --> A.dj otherwise unchanged
static String getExtension(String fileName)
           
static File getFileWithDifferentExt(File f, String source, String dest)
          getFileWithDifferentExt(new File("A.java"), ".java", ".dj") ~= new File("A.dj")
static String getFileWithDifferentExt(String fileName, String source, String dest)
          getFileWithDifferentExt("A.java", ".java", ".dj") --> "A.dj"
static File getJavaForLLFile(File f)
           
static String getJavaForLLFile(String fileName)
          A.dj --> A.java A.dj0 --> A.java A.dj1 --> A.java A.dj2 --> A.java otherwise unchanged
static File getNewLLForOldLLFile(File f)
           
static String getNewLLForOldLLFile(String fileName)
          A.dj0 -> A.dj A.dj1 -> A.dj A.dj2 -> A.java otherwise unchanged
static String getPackageDir(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 Set<String> getSourceFileExtensions()
          Return the set of source file extensions that this compiler supports.
static String getSuggestedFileExtension()
          Return the suggested file extension that will be appended to a file without extension.
static boolean isLLFile(File f)
           
static boolean isLLFile(String fileName)
          .dj --> true .dj0 --> true .dj1 --> true .dj2 --> true otherwise false
static boolean isOldLLFile(File f)
           
static boolean isOldLLFile(String fileName)
          .dj0 --> true .dj1 --> true .dj2 --> true otherwise false
static boolean isOldProjectFile(File f)
           
static boolean isOldProjectFile(String fileName)
          .pjt --> true otherwise false
static boolean isProjectFile(File f)
           
static boolean isProjectFile(String fileName)
          .pjt --> true .drjava --> true .xml --> true otherwise false
static boolean isSourceFile(File f)
           
static boolean isSourceFile(String fileName)
          .java --> true .dj --> true .dj0 --> true .dj1 --> true .dj2 --> true otherwise false
static String removeExtension(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 Set<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 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(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(File f)
Returns:
true if the file is a Java or language level file.

isLLFile

public static boolean isLLFile(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(File f)
Returns:
true if the file is a language level file.

isOldLLFile

public static boolean isOldLLFile(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(File f)
Returns:
true if the file is an old language level file.

isOldProjectFile

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

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

isOldProjectFile

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

isProjectFile

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

Returns:
true if the file is a project file.

isProjectFile

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

getJavaForLLFile

public static String getJavaForLLFile(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 File getJavaForLLFile(File f)
Returns:
matching Java file for a language level file.

getDJForJavaFile

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

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

getDJ0ForJavaFile

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

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

getDJ1ForJavaFile

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

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

getDJ2ForJavaFile

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

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

getDJForJavaFile

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

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

getDJ0ForJavaFile

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

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

getDJ1ForJavaFile

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

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

getDJ2ForJavaFile

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

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

getNewLLForOldLLFile

public static String getNewLLForOldLLFile(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 File getNewLLForOldLLFile(File f)
Returns:
new language level file matching an old language level file.

getFileWithDifferentExt

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

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

getFileWithDifferentExt

public static File getFileWithDifferentExt(File f,
                                           String source,
                                           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 String getPackageDir(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 String removeExtension(String fileName)
Returns:
the file without the extension; the dot is removed too.

getExtension

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