-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #979 from johnbrvc/i232_submit_judges_solutions_wi…
…th_tracking I232 submit judges' solutions with tracking
- Loading branch information
Showing
37 changed files
with
5,668 additions
and
1,013 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
// Copyright (C) 1989-2023 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
package edu.csus.ecs.pc2.core; | ||
|
||
import edu.csus.ecs.pc2.core.model.IInternalContest; | ||
import edu.csus.ecs.pc2.core.model.Language; | ||
|
||
/** | ||
* Utility methods for languages | ||
* | ||
* | ||
* @author Douglas A. Lane <[email protected]> | ||
*/ | ||
public class LanguageUtilities { | ||
|
||
/** | ||
* List of language extensions and their full or partial language display name | ||
* Legacy list of language extensions and their full or partial language display name | ||
* This should be deprecated and languages defined in system.pc2.yaml should be required to | ||
* include the CLICS ID (as shown above) and optionally a list of extensions supported by the | ||
* language. The list below is inadequate and out of date. For the moment, it is included for | ||
* backward compatibility. JB | ||
*/ | ||
public static final String[][] LANGUAGE_LIST = { // | ||
{ "java", "Java" }, // | ||
|
@@ -28,10 +32,9 @@ public class LanguageUtilities { | |
{ "c", "C" }, // | ||
}; | ||
|
||
|
||
/** | ||
/** | ||
* get file extension. | ||
* | ||
* | ||
* @param filename | ||
* @return file extension if no period found returns null | ||
*/ | ||
|
@@ -45,7 +48,7 @@ public static String getExtension(String filename) { | |
|
||
/** | ||
* Match a contest Language for the input extension. | ||
* | ||
* | ||
* @param myContest contest model | ||
* @param filename base name file or full path name. | ||
* @return | ||
|
@@ -57,14 +60,22 @@ public static Language guessLanguage(IInternalContest myContest, String filename | |
|
||
/** | ||
* Match a contest Language for the input extension. | ||
* | ||
* | ||
* @param inContest contest model | ||
* @param extension the extension without period, ex cpp | ||
* @return null if does not match any language title | ||
*/ | ||
public static Language matchFirstLanguage(IInternalContest inContest, String extension) { | ||
Language[] lang = inContest.getLanguages(); | ||
Language[] allLangs = inContest.getLanguages(); | ||
|
||
// first try the new way | ||
for(Language lang : allLangs) { | ||
if(lang.getExtensions().contains(extension)) { | ||
return(lang); | ||
} | ||
} | ||
|
||
// if all else fails, try the old way. This should be deprecated. JB | ||
/** | ||
* Partial or complete display name | ||
*/ | ||
|
@@ -73,7 +84,7 @@ public static Language matchFirstLanguage(IInternalContest inContest, String ext | |
for (String[] row : LANGUAGE_LIST) { | ||
String fileExtension = row[0]; | ||
String dispName = row[1]; | ||
|
||
if (fileExtension.equals(extension)) { | ||
displayName = dispName; | ||
break; | ||
|
@@ -82,7 +93,7 @@ public static Language matchFirstLanguage(IInternalContest inContest, String ext | |
|
||
displayName = displayName.toLowerCase(); | ||
|
||
for (Language language : lang) { | ||
for (Language language : allLangs) { | ||
if (language.getDisplayName().toLowerCase().indexOf(displayName) != -1) { | ||
return language; | ||
} | ||
|
Oops, something went wrong.