当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationUtils类代码示例

本文整理汇总了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]));
	}
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:20,代码来源:CommandLineArgumentBuilder.java

示例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.");
	}
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:20,代码来源:Clear.java

示例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;
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:31,代码来源:DirectoryManager.java

示例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;
	}
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:12,代码来源:KoanClassLoader.java

示例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()));
    }
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:11,代码来源:RunKoans.java

示例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());
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:12,代码来源:KoanFileCopying.java

示例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);
		}
	}
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:31,代码来源:KoanFileCompileAndRunListener.java

示例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);
	}
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:16,代码来源:CommandLineTestCase.java

示例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());
	}
}
 
开发者ID:MarinaMurashev,项目名称:JavaKoans,代码行数:38,代码来源:AppLauncher.java

示例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(" ");
	}
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:6,代码来源:ConsolePresenter.java

示例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());
    }
}
 
开发者ID:nkalupahana,项目名称:completed-koans,代码行数:43,代码来源:AppLauncher.java

示例12: run

import com.sandwich.koan.util.ApplicationUtils; //导入依赖的package包/类
public void run(String... values) {
	ApplicationUtils.getPresenter().clearMessages();
	ApplicationUtils.getPresenter().displayResult(runKoans());
}
 
开发者ID:MarinaMurashev,项目名称:JavaKoans,代码行数:5,代码来源:RunKoans.java


注:本文中的com.sandwich.koan.util.ApplicationUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。