本文整理汇总了Java中com.sandwich.koan.util.ApplicationUtils类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationUtils类的具体用法?Java ApplicationUtils怎么用?Java ApplicationUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationUtils类属于com.sandwich.koan.util包,在下文中一共展示了ApplicationUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyAssumedStartupBehaviors
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
void applyAssumedStartupBehaviors() {
if(ApplicationUtils.isFirstTimeAppHasBeenRun()){
ArgumentType.BACKUP.run(new String[0]);
ApplicationUtils.getPresenter().clearMessages();
}
if(isEmpty() || !containsKey(ArgumentType.RUN_KOANS) && (
containsKey(ArgumentType.CLASS_ARG) ||
containsKey(ArgumentType.DEBUG))){
if(ApplicationSettings.isDebug()){
SuitePresenter presenter = ApplicationUtils.getPresenter();
presenter.displayMessage("Planting default run target.");
for(Entry<ArgumentType, CommandLineArgument> argEntry : entrySet()){
presenter.displayMessage("Key: '"+argEntry.getKey()+"'");
presenter.displayMessage("Value: '"+argEntry.getValue()+"'");
}
}
put(ArgumentType.RUN_KOANS, new CommandLineArgument(ArgumentType.RUN_KOANS, true, new String[0]));
}
}
示例2: run
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public void run(String... values) throws Exception {
List<File> unableToDelete = new ArrayList<File>();
for(String fileName : files){
File file = new File(fileName);
if(file.exists()){
if(file.delete()){
ApplicationUtils.getPresenter().displayMessage(file.getAbsolutePath() + " deleted successfully.");
}else{
unableToDelete.add(file);
ApplicationUtils.getPresenter().displayError(file.getAbsolutePath() + " was NOT DELETED. Please delete manually.");
}
}else{
ApplicationUtils.getPresenter().displayMessage(file.getAbsolutePath() + " does not exist. Skipping.");
}
}
if(!unableToDelete.isEmpty()){
throw new RuntimeException("Unable to delete: "+unableToDelete+" see output for details.");
}
}
示例3: injectFileSystemSeparators
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
/**
* Will take "home", "wilford", "liberty" and produce: "/home/wilford/liberty"
*
* @param folders
* @return concatenated folders w/ file separators
*/
public static String injectFileSystemSeparators(String...folders){
StringBuilder builder = new StringBuilder();
for(String folder : folders){
if(FILESYSTEM_SEPARATOR.equals(folder)){
continue;
}
builder.append(FILESYSTEM_SEPARATOR);
while(folder.startsWith(FILESYSTEM_SEPARATOR)){
folder = folder.substring(1);
}
while(folder.endsWith(FILESYSTEM_SEPARATOR)){
folder = folder.substring(0, folder.lastIndexOf(FILESYSTEM_SEPARATOR));
}
builder.append(folder);
}
String constructedFolder = builder.toString();
if(ApplicationUtils.isWindows()){
if(constructedFolder.startsWith(FILESYSTEM_SEPARATOR)){
constructedFolder = constructedFolder.substring(1);
}
constructedFolder = constructedFolder.replace("%20", " ");
}
return constructedFolder;
}
示例4: getFileMonitor
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
private static FileMonitor getFileMonitor() {
try{
return FileMonitorFactory.getInstance(new File(DirectoryManager.getMainDir()), new File(DirectoryManager.getDataFile()));
}catch(RuntimeException x){
if(x.getCause() instanceof UTFDataFormatException){
ApplicationUtils.getPresenter().displayError("Issue loading file system hashes, please rerun run.bat or run.sh with the -clear switch to reset.");
System.exit(4);
}
throw x;
}
}
示例5: run
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public void run(String... values) {
ApplicationUtils.getPresenter().clearMessages();
KoanSuiteResult result = runKoans();
ApplicationUtils.getPresenter().displayResult(result);
if (!ApplicationSettings.isInteractive()) {
// could overflow past 255 resulting in 0 (ie all koans succeed)
// or otherwise misleading # of failed koans
AppLauncher.exit(Math.min(255, result.getTotalNumberOfKoans() - result.getNumberPassing()));
}
}
示例6: run
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public void run(String... values) {
SuitePresenter presenter = ApplicationUtils.getPresenter();
try {
copy(DirectoryManager.getProjectDataSourceDir(), DirectoryManager.getSourceDir());
} catch (IOException e) {
e.printStackTrace();
presenter.displayError(getErrorMessage());
System.exit(-1);
}
presenter.displayMessage(getSuccessMessage());
}
示例7: fileSaved
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public void fileSaved(File file) {
String absolutePath = file.getAbsolutePath();
if(CompilerConfig.isSourceFile(absolutePath)){
ApplicationUtils.getPresenter().displayMessage(KoanConstants.EOL+"loading: "+absolutePath);
File[] jars = new File(DirectoryManager.getProjectLibraryDir()).listFiles();
String[] classPath = new String[jars.length];
for (int i = 0; i < jars.length; i++) {
String jarPath = jars[i].getAbsolutePath();
String jarPathLowerCase = jarPath.toLowerCase();
if(jarPathLowerCase.endsWith(".jar") || jarPathLowerCase.endsWith(".war")){
classPath[i] = jarPath;
}
}
try {
FileCompiler.compile(file,
new File(DirectoryManager.getBinDir()),
listener,
ApplicationSettings.getFileCompilationTimeoutInMs(),
classPath);
DynamicClassLoader.remove(FileCompiler.sourceToClass(
DirectoryManager.getSourceDir(), DirectoryManager.getBinDir(), file).toURI().toURL());
if(!listener.isLastCompilationAttemptFailure()){
ApplicationUtils.getPresenter().clearMessages();
new CommandLineArgumentRunner(args).run();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
示例8: stubPresenter
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
protected void stubPresenter(final SuitePresenter presenter)
throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Field f = ApplicationUtils.class.getDeclaredField("suitePresenterFactory");
boolean isAccessible = f.isAccessible();
try {
f.setAccessible(true);
f.set(ApplicationUtils.class, new SuitePresenterFactory(){
@Override public SuitePresenter create(){
return presenter;
}
});
} finally {
f.setAccessible(isAccessible);
}
}
示例9: main
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public static void main(final String... args) throws Throwable {
Map<ArgumentType, CommandLineArgument> argsMap = new CommandLineArgumentBuilder(args);
if(argsMap.containsKey(ArgumentType.RUN_KOANS)){
new Thread(new Runnable(){
public void run() {
do{
try {
char c = (char)System.in.read();
if(Character.toUpperCase(c) ==
Character.toUpperCase(ApplicationSettings.getExitChar())){
FileMonitorFactory.closeAll();
System.exit(0);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}while(true);
}
}).start();
FileMonitor monitor = FileMonitorFactory.getInstance(
new File(DirectoryManager.getProdMainDir()),
new File(DirectoryManager.getDataFile()));
if(ApplicationUtils.isFirstTimeAppHasBeenRun()){
monitor.writeChanges();
}
monitor.addFileSavedListener(new KoanFileCompileAndRunListener(argsMap));
}
new CommandLineArgumentRunner(argsMap).run();
if(ApplicationSettings.isDebug()){
StringBuilder argsBuilder = new StringBuilder();
int argNumber = 0;
for(String arg : args){
argsBuilder.append("Argument number "+String.valueOf(++argNumber)+": '"+arg+"'");
}
ApplicationUtils.getPresenter().displayMessage(argsBuilder.toString());
}
}
示例10: clearMessages
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public void clearMessages(){
for(int i = 0; i < NUMBER_OF_LINES_TO_CLEAR_CONSOLE; i++){
ApplicationUtils.getPresenter().displayMessage(" ");
}
}
示例11: main
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public static void main(final String... args) throws Throwable {
Map<ArgumentType, CommandLineArgument> argsMap = new CommandLineArgumentBuilder(
args);
if (argsMap.containsKey(ArgumentType.RUN_KOANS)) {
if (ApplicationSettings.isInteractive()) {
new Thread(new Runnable() {
public void run() {
do {
try {
char c = (char) System.in.read();
char exitChar = ApplicationSettings.getExitChar();
if (Character.toUpperCase(c) == Character.toUpperCase(exitChar)) {
exit(0);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} while (true);
}
}).start();
FileMonitor monitor = FileMonitorFactory.getInstance(new File(
DirectoryManager.getProdMainDir()), new File(
DirectoryManager.getDataFile()));
if (ApplicationUtils.isFirstTimeAppHasBeenRun()) {
monitor.writeChanges();
}
monitor.addFileSavedListener(new KoanFileCompileAndRunListener(argsMap));
}
}
new CommandLineArgumentRunner(argsMap).run();
if (ApplicationSettings.isDebug()) {
StringBuilder argsBuilder = new StringBuilder();
int argNumber = 0;
for (String arg : args) {
argsBuilder.append("Argument number "
+ String.valueOf(++argNumber) + ": '" + arg + "'");
}
ApplicationUtils.getPresenter().displayMessage(
argsBuilder.toString());
}
}
示例12: run
import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public void run(String... values) {
ApplicationUtils.getPresenter().clearMessages();
ApplicationUtils.getPresenter().displayResult(runKoans());
}