Java Code Examples for com.martiansoftware.jsap.JSAPException

The following examples show how to use com.martiansoftware.jsap.JSAPException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: BUbiNG   Source File: GZIPIndexer.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] arg) throws IOException, JSAPException {
	final SimpleJSAP jsap = new SimpleJSAP(GZIPIndexer.class.getName(), "Computes and stores a quasi-succinct index for a compressed archive.",
			new Parameter[] {
				new UnflaggedOption("archive", JSAP.STRING_PARSER, JSAP.REQUIRED, "The name a GZIP's archive."),
				new UnflaggedOption("index", JSAP.STRING_PARSER, JSAP.REQUIRED, "The output (a serialized LongBigList of pointers to the records in the archive) filename."),
			}
	);

	final JSAPResult jsapResult = jsap.parse(arg);
	if (jsap.messagePrinted()) return;

	final FastBufferedInputStream input = new FastBufferedInputStream(new FileInputStream(jsapResult.getString("archive")));
	ProgressLogger pl = new ProgressLogger(LOGGER, 1, TimeUnit.MINUTES, "records");
	pl.start("Scanning...");
	final EliasFanoMonotoneLongBigList list = new EliasFanoMonotoneLongBigList(index(input, pl));
	pl.done();
	BinIO.storeObject(list, jsapResult.getString("index"));
}
 
Example 2
Source Project: astor   Source File: GramProcessor.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Deprecated
public Map<String, NGrams> calculateByPackage(List<CtType<?>> all) throws JSAPException {

	Map<String, NGrams> result = new HashedMap();
	CodeParserLauncher ingp = new CodeParserLauncher<>(ingredientProcessor);
	int allElements = 0;

	for (CtType<?> ctType : all) {
		NGrams ns = new NGrams();
		CtPackage parent = (CtPackage) ctType.getParent(CtPackage.class);
		if (!result.containsKey(parent.getQualifiedName())) {
			allElements += getNGramsFromCodeElements(parent, ns, ingp);
			result.put(parent.getQualifiedName(), ns);
		}
	}
	logger.debug("allElements " + allElements);
	return result;
}
 
Example 3
Source Project: BUbiNG   Source File: GZIPArchiveWriterTest.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException, JSAPException {

	SimpleJSAP jsap = new SimpleJSAP(GZIPArchiveReader.class.getName(), "Writes some random records on disk.",
		new Parameter[] {
			new Switch("fully", 'f', "fully",
				"Whether to read fully the record (and do a minimal cosnsistency check)."),
			new UnflaggedOption("path", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
				"The path to read from."), });

	JSAPResult jsapResult = jsap.parse(args);
	if (jsap.messagePrinted())
	    System.exit(1);

	final boolean fully = jsapResult.getBoolean("fully");
	GZIPArchiveReader gzar = new GZIPArchiveReader(new FileInputStream(jsapResult.getString("path")));
	for (;;) {
	    ReadEntry e = gzar.getEntry();
	    if (e == null)
		break;
	    InputStream inflater = e.lazyInflater.get();
	    if (fully)
		ByteStreams.toByteArray(inflater);
	    e.lazyInflater.consume();
	    System.out.println(e);
	}
    }
 
Example 4
Source Project: astor   Source File: DeepRepairEngine.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void loadIngredientPool() throws JSAPException, Exception {

	List<TargetElementProcessor<?>> ingredientProcessors = this.getTargetElementProcessors();

	// The ingredients for build the patches
	String scope = ConfigurationProperties.properties.getProperty("scope");
	CtLocationIngredientSpace ingredientspace = null;
	if ("global".equals(scope)) {
		ingredientspace = (new CtGlobalIngredientScope(ingredientProcessors));
	} else if ("package".equals(scope)) {
		ingredientspace = (new CtPackageIngredientScope(ingredientProcessors));
	} else if ("local".equals(scope)) {
		ingredientspace = (new CtClassIngredientSpace(ingredientProcessors));
	} else {
		ingredientspace = (CtLocationIngredientSpace) PlugInLoader.loadPlugin(
				ExtensionPoints.INGREDIENT_STRATEGY_SCOPE, new Class[] { List.class },
				new Object[] { ingredientProcessors });

	}
	this.setIngredientPool(ingredientspace);
}
 
Example 5
Source Project: astor   Source File: CardumenApproach.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CardumenApproach(MutationSupporter mutatorExecutor, ProjectRepairFacade projFacade) throws JSAPException {
	super(mutatorExecutor, projFacade);
	// Default configuration of Cardumen:
	ConfigurationProperties.setProperty("cleantemplates", "true");

	if (!ConfigurationProperties.hasProperty(ExtensionPoints.INGREDIENT_TRANSFORM_STRATEGY.identifier)) {

		if (ConfigurationProperties.getPropertyBool("probabilistictransformation")) {
			ConfigurationProperties.setProperty(ExtensionPoints.INGREDIENT_TRANSFORM_STRATEGY.identifier,
					"name-probability-based");
		} else
			ConfigurationProperties.setProperty(ExtensionPoints.INGREDIENT_TRANSFORM_STRATEGY.identifier,
					"random-variable-replacement");
	}

	ConfigurationProperties.setProperty(ExtensionPoints.TARGET_CODE_PROCESSOR.identifier, "expression");
	ConfigurationProperties.setProperty(ExtensionPoints.OPERATORS_SPACE.identifier, "r-expression");
	setPropertyIfNotDefined(ExtensionPoints.INGREDIENT_SEARCH_STRATEGY.identifier, "name-probability-based");

}
 
Example 6
Source Project: astor   Source File: PatchGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public LiteralsSpace getSpace(ProgramVariant pv) {

		String scope = ConfigurationProperties.properties.getProperty("scope");
		IngredientPoolScope ingScope = IngredientPoolScope.valueOf(scope.toUpperCase());
		if (literalspace == null) {
			try {
				logger.debug("Initializing literal space: scope " + ingScope);
				literalspace = new LiteralsSpace(ingScope);
				literalspace.defineSpace(pv);

			} catch (JSAPException e) {
				e.printStackTrace();
				logger.error(e);
			}
		}
		return literalspace;
	}
 
Example 7
public DeepRepairExhausitiveCloneEngine(MutationSupporter mutatorExecutor, ProjectRepairFacade projFacade)
		throws JSAPException {
	super(mutatorExecutor, projFacade);

	List<TargetElementProcessor<?>> ingredientProcessors = new ArrayList<TargetElementProcessor<?>>();
	// Fix Space
	ingredientProcessors.add(new SingleStatementFixSpaceProcessor());

	try {
		this.ingredientSpace = (IngredientPool) PlugInLoader.loadPlugin(ExtensionPoints.INGREDIENT_STRATEGY_SCOPE,
				new Class[] { List.class }, new Object[] { ingredientProcessors });

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 8
Source Project: BUbiNG   Source File: CatEFGraphsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected=IllegalArgumentException.class)
public void testWrongBound() throws IOException, JSAPException {
	// (0,1) (0,2) (0,3) (1,7)
	ImmutableGraph graph1 = new XImmutableGraph(ImmutableGraph.wrap(new ArrayListMutableGraph(8, new int[][] { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 7 } }).immutableView()), 4);
	// (4,2) (4,3) (7,4) (7,6)
	ImmutableGraph graph2 = new XImmutableGraph(ImmutableGraph.wrap(new ArrayListMutableGraph(8, new int[][] { { 0, 2 }, { 0, 3 }, { 3, 4 }, { 3, 6 } }).immutableView()), 4);
	File ef1 = new File(dir, "graph1.ef");
	EFGraph.store(graph1, 10, ef1.getAbsolutePath(), null);
	File ef2 = new File(dir, "graph2.ef");
	EFGraph.store(graph2, 8, ef2.getAbsolutePath(), null);
	File result = new File(dir, "result-ef"); result.delete();
	CatEFGraphs.main(new String[] { "-m", result.getAbsolutePath(), ef1.getAbsolutePath(), ef2.getAbsolutePath() });
}
 
Example 9
Source Project: BUbiNG   Source File: HttpResponseWarcRecordTest.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] arg) throws JSAPException, URISyntaxException, NoSuchAlgorithmException, ClientProtocolException, IOException, InterruptedException, ConfigurationException, IllegalArgumentException, ClassNotFoundException {

		SimpleJSAP jsap = new SimpleJSAP(HttpResponseWarcRecordTest.class.getName(), "Outputs an URL (given as argument) as the UncompressedWarcWriter would do",
			new Parameter[] {
				new UnflaggedOption("url", JSAP.STRING_PARSER, JSAP.REQUIRED, "The url of the page."),
			});

		JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) System.exit(1);

		final String url = jsapResult.getString("url");

		final URI uri = new URI(url);
		final WarcWriter writer = new UncompressedWarcWriter(System.out);

		// Setup FetchData
		final RuntimeConfiguration testConfiguration = Helpers.getTestConfiguration(null);
		final HttpClient httpClient = FetchDataTest.getHttpClient(null, false);
		final FetchData fetchData = new FetchData(testConfiguration);

		fetchData.fetch(uri, httpClient, null, null, false);
		final HttpResponseWarcRecord record = new HttpResponseWarcRecord(uri, fetchData.response());
		writer.write(record);
		fetchData.close();
		System.out.println(record);

		writer.close();
	}
 
Example 10
Source Project: astor   Source File: CodeParserLauncher.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 * @param processors
 * @throws JSAPException
 */
public CodeParserLauncher(List<TargetElementProcessor<?>> processors) throws JSAPException {
	this();
	for (TargetElementProcessor<?> abstractFixSpaceProcessor : processors) {
		processing.addProcessor(abstractFixSpaceProcessor.getClass().getName() );
	}
}
 
Example 11
Source Project: repairnator   Source File: Launcher.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) throws JSAPException{
    JSAP jsap = defineBasicArgs();
    JSAPResult jsapResult = jsap.parse(args); 
    String choice = jsapResult.getString("launcherChoice");

    if (choice.equals("OLD") ) {
        launcher = new LegacyLauncher(args);
    } else {
        launcher = new BranchLauncher(args);
    }
    RepairnatorConfig.getInstance().setSonarRules(removeDuplicatesInArray(jsapResult.getString("sonarRules").split(",")));
    launcher.launch();
}
 
Example 12
Source Project: repairnator   Source File: LegacyLauncher.java    License: MIT License 5 votes vote down vote up
public LegacyLauncher(String[] args) throws JSAPException {
    InputStream propertyStream = getClass().getResourceAsStream("/version.properties");
    Properties properties = new Properties();
    if (propertyStream != null) {
        try {
            properties.load(propertyStream);
        } catch (IOException e) {
            LOGGER.error("Error while loading property file.", e);
        }
        LOGGER.info("PIPELINE VERSION: "+properties.getProperty("PIPELINE_VERSION"));
    } else {
        LOGGER.info("No information about PIPELINE VERSION has been found.");
    }

    JSAP jsap = this.defineArgs();
    JSAPResult arguments = jsap.parse(args);
    LauncherUtils.checkArguments(jsap, arguments, LauncherType.PIPELINE);
    this.initConfig(arguments);

    if (this.getConfig().getLauncherMode() == LauncherMode.REPAIR) {
        this.checkToolsLoaded(jsap);
        this.checkNopolSolverPath(jsap);
        LOGGER.info("The pipeline will try to repair the following build id: "+this.getConfig().getBuildId());
    } else {
        this.checkNextBuildId(jsap);
        LOGGER.info("The pipeline will try to reproduce a bug from build "+this.getConfig().getBuildId()+" and its corresponding patch from build "+this.getConfig().getNextBuildId());
    }

    if (this.getConfig().isDebug()) {
        Utils.setLoggersLevel(Level.DEBUG);
    } else {
        Utils.setLoggersLevel(Level.INFO);
    }

    this.initSerializerEngines();
    this.initNotifiers();
}
 
Example 13
Source Project: repairnator   Source File: MainProcessFactory.java    License: MIT License 5 votes vote down vote up
public static MainProcess getDefaultMainProcess(String[] inputArgs) {

		DefaultDefineJSAPArgs defaultDefineJSAPArgs = new DefaultDefineJSAPArgs();
		DefaultInitConfig defaultInitConfig = new DefaultInitConfig();
		DefaultInitNotifiers defaultInitNotifiers = new DefaultInitNotifiers();
		DefaultInitSerializerEngines defaultInitSerializerEngines = new DefaultInitSerializerEngines();
		
		JSAP jsap;
		try {
			jsap = defaultDefineJSAPArgs.defineArgs();
		} catch (JSAPException e) {
			throw new RuntimeException("Failed to parse JSAP");
		}
		defaultInitConfig.initConfigWithJSAP(jsap,inputArgs);
		defaultInitSerializerEngines.initSerializerEngines();
		defaultInitNotifiers.initNotifiers();

		DefaultMainProcess defaultMainProcess = new DefaultMainProcess(defaultDefineJSAPArgs,
																		defaultInitConfig,
																		defaultInitSerializerEngines,
																			defaultInitNotifiers);

		serializeHardwareInfoSerializer(defaultInitSerializerEngines.getEngines());

		ProjectInspector inspector = constructInspector4Default(defaultMainProcess.getBuildToBeInspected(),defaultInitSerializerEngines.getEngines(),defaultInitNotifiers.getNotifiers());

		defaultMainProcess = defaultMainProcess.setInspector(inspector)
												.setEngines(defaultInitSerializerEngines.getEngines())
												.setNotifiers(defaultInitNotifiers.getNotifiers());

		return defaultMainProcess;
	}
 
Example 14
Source Project: repairnator   Source File: MainProcessFactory.java    License: MIT License 5 votes vote down vote up
public static MainProcess getGithubMainProcess(String[] inputArgs) {

		GithubDefineJSAPArgs githubDefineJSAPArgs = new GithubDefineJSAPArgs();
		GithubInitConfig githubInitConfig = new GithubInitConfig();
		GithubInitNotifiers githubInitNotifiers = new GithubInitNotifiers();
		GithubInitSerializerEngines githubInitSerializerEngines = new GithubInitSerializerEngines();

		JSAP jsap;
		try {
			jsap = githubDefineJSAPArgs.defineArgs();
		} catch (JSAPException e) {
			throw new RuntimeException("Failed to parse JSAP");
		}
		githubInitConfig.initConfigWithJSAP(jsap,inputArgs);
		githubInitSerializerEngines.initSerializerEngines();
		githubInitNotifiers.initNotifiers();

		GithubMainProcess githubMainProcess = new GithubMainProcess(githubDefineJSAPArgs,
																	githubInitConfig,
																	githubInitSerializerEngines,
																	githubInitNotifiers);

		serializeHardwareInfoSerializer(githubInitSerializerEngines.getEngines());

		ProjectInspector inspector =  constructInspector4Github(githubInitSerializerEngines.getEngines(),githubInitNotifiers.getNotifiers());

		githubMainProcess = githubMainProcess.setInspector(inspector)
												.setNotifiers(githubInitNotifiers.getNotifiers())
												.setEngines(githubInitSerializerEngines.getEngines());

		return githubMainProcess;
	}
 
Example 15
Source Project: repairnator   Source File: BranchLauncher.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) throws JSAPException {
	JSAP jsap = defineBasicArgs();
	JSAPResult jsapResult = jsap.parse(args);
	
	MainProcess mainProcess = getMainProcess(jsap,args);
	mainProcess.run();
}
 
Example 16
Source Project: repairnator   Source File: CheckBranchLauncher.java    License: MIT License 5 votes vote down vote up
private CheckBranchLauncher(String[] args) throws JSAPException {
    JSAP jsap = this.defineArgs();
    JSAPResult arguments = jsap.parse(args);
    LauncherUtils.checkArguments(jsap, arguments, LauncherType.CHECKBRANCHES);

    this.initConfig(arguments);
    this.initNotifiers();
}
 
Example 17
Source Project: repairnator   Source File: BuildAnalyzerLauncher.java    License: MIT License 5 votes vote down vote up
private BuildAnalyzerLauncher(String[] args) throws JSAPException {
    JSAP jsap = this.defineArgs();
    JSAPResult arguments = jsap.parse(args);
    LauncherUtils.checkArguments(jsap, arguments, LauncherType.DOCKERPOOL);

    this.initConfig(arguments);
    this.initSerializerEngines();
    this.initNotifiers();
}
 
Example 18
Source Project: repairnator   Source File: RTLauncher.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) throws JSAPException {
    RTLauncher rtLauncher = new RTLauncher(args);
    /* If scanner mode is RTSCanner */
    rtLauncher.initAndRunRTScanner();
    /* If scanner mode is BuildRainer */
    /* Create and connect BuildRainer */
}
 
Example 19
public static void main( final String[] arg ) throws IOException, ClassNotFoundException, JSAPException {

		SimpleJSAP jsap = new SimpleJSAP( PermutedFrontCodedStringList.class.getName(), "Builds a permuted front-coded list of strings using a given front-coded string list and permutation",  
				new Parameter[] {
					new Switch( "invert", 'i', "invert", "Invert permutation before creating the permuted list." ),
					new UnflaggedOption( "list", JSAP.STRING_PARSER, JSAP.REQUIRED, "A front-coded string list." ),
					new UnflaggedOption( "permutation", JSAP.STRING_PARSER, JSAP.REQUIRED, "A permutation for the indices of the list." ),
					new UnflaggedOption( "permutedList", JSAP.STRING_PARSER, JSAP.REQUIRED, "A the filename for the resulting permuted list." ),
			} );

		JSAPResult jsapResult = jsap.parse( arg ); 
		if ( jsap.messagePrinted() ) return;
		
		int[] basePermutation =  BinIO.loadInts( jsapResult.getString( "permutation" ) ), permutation;
		if ( jsapResult.getBoolean( "invert" ) ) {
			int i = basePermutation.length;
			permutation = new int[ i ];
			while( i-- != 0 ) permutation[ basePermutation[ i ] ] = i;
		}
		else permutation = basePermutation;
		
		basePermutation = null;
		
		BinIO.storeObject( 
				new PermutedFrontCodedStringList( (FrontCodedStringList)BinIO.loadObject( jsapResult.getString( "list" ) ), permutation ), 
				jsapResult.getString( "permutedList" ) 
		);
	}
 
Example 20
@SuppressWarnings("unchecked")
public static void main( final String[] arg ) throws NoSuchMethodException, IOException, JSAPException, ClassNotFoundException {

	final SimpleJSAP jsap = new SimpleJSAP( ShiftAddXorSignedStringMap.class.getName(), "Builds a shift-add-xor signed string map by reading a newline-separated list of strings and a function built on the same list of strings.",
			new Parameter[] {
		new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read strings." ),
		new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The string file encoding." ),
		new Switch( "zipped", 'z', "zipped", "The string list is compressed in gzip format." ),
		new FlaggedOption( "width", JSAP.INTEGER_PARSER, Integer.toString( Integer.SIZE ), JSAP.NOT_REQUIRED, 'w', "width", "The signature width in bits." ),
		new UnflaggedOption( "function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the function to be signed." ),
		new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the resulting serialised signed string map." ),
		new UnflaggedOption( "stringFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "Read strings from this file instead of standard input." ),
	});

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;

	final int bufferSize = jsapResult.getInt( "bufferSize" );
	final String functionName = jsapResult.getString( "function" );
	final String mapName = jsapResult.getString( "map" );
	final String stringFile = jsapResult.getString( "stringFile" );
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );
	final int width = jsapResult.getInt( "width" );
	final boolean zipped = jsapResult.getBoolean( "zipped" );

	final InputStream inputStream = stringFile != null ? new FileInputStream( stringFile ) : System.in;
	final Iterator<MutableString> iterator = new LineIterator( new FastBufferedReader( new InputStreamReader( zipped ? new GZIPInputStream( inputStream ) : inputStream, encoding ), bufferSize ) );
	final Object2LongFunction<CharSequence> function = (Object2LongFunction<CharSequence>)BinIO.loadObject( functionName );
	LOGGER.info( "Signing..." );
	BinIO.storeObject( new ShiftAddXorSignedStringMap( iterator, function, width ), mapName );
	LOGGER.info( "Completed." );
}
 
Example 21
public static void main( final String[] arg ) throws IOException, JSAPException, NoSuchMethodException {
	
	final SimpleJSAP jsap = new SimpleJSAP( FrontCodedStringList.class.getName(), "Builds a front-coded string list reading from standard input a newline-separated ordered list of terms.",
			new Parameter[] {
				new FlaggedOption( "bufferSize", IntSizeStringParser.getParser(), "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read terms." ),
				new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding." ),
				new FlaggedOption( "ratio", IntSizeStringParser.getParser(), "4", JSAP.NOT_REQUIRED, 'r',  "ratio", "The compression ratio." ),
				new Switch( "utf8", 'u', "utf8", "Store the strings as UTF-8 byte arrays." ),
				new Switch( "zipped", 'z', "zipped", "The term list is compressed in gzip format." ),
				new UnflaggedOption( "frontCodedList", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised front-coded list." )
	});
	
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;
	
	final int bufferSize = jsapResult.getInt( "bufferSize" );
	final int ratio = jsapResult.getInt( "ratio" );
	final boolean utf8 = jsapResult.getBoolean( "utf8" );
	final boolean zipped = jsapResult.getBoolean( "zipped" );
	final String listName = jsapResult.getString( "frontCodedList" );
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );
	
	final ProgressLogger pl = new ProgressLogger();
	pl.itemsName = "words";
	pl.start( "Reading words..." );
	final FrontCodedStringList frontCodedStringList = new FrontCodedStringList( new LineIterator( new FastBufferedReader( 
			new InputStreamReader( zipped ? new GZIPInputStream( System.in ) : System.in, encoding ), bufferSize ), pl ), ratio, utf8 );
	pl.done();

	System.err.print( "Writing to file..." );
	BinIO.storeObject( frontCodedStringList, listName );
	System.err.println( " done." );
}
 
Example 22
public static void main( final String[] arg ) throws IOException, JSAPException, NoSuchMethodException {

		final SimpleJSAP jsap = new SimpleJSAP( TernaryIntervalSearchTree.class.getName(), "Builds a ternary interval search tree reading from standard input a newline-separated list of terms.",
			new Parameter[] {
				new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read terms." ),
				new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding." ),
				new UnflaggedOption( "tree", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised tree." )
		});

		JSAPResult jsapResult = jsap.parse( arg );
		if ( jsap.messagePrinted() ) return;

		final TernaryIntervalSearchTree tree = new TernaryIntervalSearchTree();
		
		MutableString term = new MutableString();
		final ProgressLogger pl = new ProgressLogger();
		pl.itemsName = "terms";
		final FastBufferedReader terms = new FastBufferedReader( new InputStreamReader( System.in, (Charset)jsapResult.getObject( "encoding" ) ), jsapResult.getInt( "bufferSize" ) );
				
		pl.start( "Reading terms..." );

		while( terms.readLine( term ) != null ) {
			pl.update();
			tree.add( term );
		}

		pl.done();

		BinIO.storeObject( tree, jsapResult.getString( "tree" ) );
	}
 
Example 23
@SuppressWarnings("unchecked")
public static void main( final String[] arg ) throws IOException, JSAPException, ClassNotFoundException, SecurityException, NoSuchMethodException {

	final SimpleJSAP jsap = new SimpleJSAP( LiterallySignedStringMap.class.getName(), "Builds a shift-add-xor signed string map by reading a newline-separated list of strings and a function built on the same list of strings.",
			new Parameter[] {
		new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The string file encoding." ),
		new Switch( "zipped", 'z', "zipped", "The string list is compressed in gzip format." ),
		new Switch( "text", 't', "text", "The string list actually a text file, with one string per line." ),
		new UnflaggedOption( "function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the function to be signed." ),
		new UnflaggedOption( "list", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the serialised list of strings, or of a text file containing a list of strings, if -t is specified." ),
		new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the resulting map." ),
	});

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;

	final String functionName = jsapResult.getString( "function" );
	final String listName = jsapResult.getString( "list" );
	final String mapName = jsapResult.getString( "map" );

	
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );
	final boolean zipped = jsapResult.getBoolean( "zipped" );
	final boolean text = jsapResult.getBoolean( "text" );
	
	ObjectList<MutableString> list = text ? new FileLinesCollection( listName, encoding.toString(), zipped ).allLines() : (ObjectList)BinIO.loadObject( listName );
	
	LOGGER.info( "Signing..." );
	BinIO.storeObject( new LiterallySignedStringMap( (Object2LongFunction)BinIO.loadObject( functionName ), list ), mapName );
	LOGGER.info( "Completed." );
}
 
Example 24
Source Project: database   Source File: BloomFilter.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main( final String[] arg ) throws IOException, JSAPException, NoSuchMethodException {
	
	final SimpleJSAP jsap = new SimpleJSAP( BloomFilter.class.getName(), "Creates a Bloom filter reading from standard input a newline-separated list of terms.",
			new Parameter[] {
				new FlaggedOption( "bufferSize", IntSizeStringParser.getParser(), "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read terms." ),
				new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding." ),
				new UnflaggedOption( "bloomFilter", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised front-coded list." ),
				new UnflaggedOption( "size", JSAP.INTSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The size of the filter (i.e., the expected number of elements in the filter; usually, the number of terms)." ),
				new UnflaggedOption( "precision", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The precision of the filter." )
	});
	
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;
	
	final int bufferSize = jsapResult.getInt( "bufferSize" );
	final String filterName = jsapResult.getString( "bloomFilter" );
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );

	BloomFilter filter = new BloomFilter( jsapResult.getInt( "size" ), jsapResult.getInt( "precision" ) );
	final ProgressLogger pl = new ProgressLogger();
	pl.itemsName = "terms";
	pl.start( "Reading terms..." );
	MutableString s = new MutableString();
	FastBufferedReader reader = new FastBufferedReader( new InputStreamReader( System.in, encoding ), bufferSize );
	while( reader.readLine( s ) != null ) { 
		filter.add( s );
		pl.lightUpdate();
	}
	pl.done();

	BinIO.storeObject( filter, filterName );
}
 
Example 25
Source Project: astor   Source File: CardumenApproach.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void loadIngredientPool() throws JSAPException, Exception {
	List<TargetElementProcessor<?>> ingredientProcessors = this.getTargetElementProcessors();
	ExpressionTypeIngredientSpace ingredientspace = ((ConfigurationProperties.getPropertyBool("uniformreplacement"))
			? new ExpressionClassTypeIngredientSpace(ingredientProcessors)
			: new ExpressionTypeIngredientSpace(ingredientProcessors));
	String scope = ConfigurationProperties.getProperty(ExtensionPoints.INGREDIENT_STRATEGY_SCOPE.identifier);
	if (scope != null) {
		ingredientspace.scope = IngredientPoolScope.valueOf(scope.toUpperCase());
	}
	this.setIngredientPool(ingredientspace);
}
 
Example 26
@Override
protected void loadIngredientPool() throws JSAPException, Exception {
	List<TargetElementProcessor<?>> ingredientProcessors = this.getTargetElementProcessors();
	ExpressionTypeIngredientSpace ingredientspace = ((ConfigurationProperties.getPropertyBool("uniformreplacement"))
			? new ExpressionClassTypeIngredientSpace(ingredientProcessors)
			: new ExpressionTypeIngredientSpace(ingredientProcessors));
	String scope = ConfigurationProperties.getProperty(ExtensionPoints.INGREDIENT_STRATEGY_SCOPE.identifier);
	if (scope != null) {
		ingredientspace.scope = IngredientPoolScope.valueOf(scope.toUpperCase());
	}
	this.setIngredientPool(ingredientspace);
}
 
Example 27
Source Project: astor   Source File: JKaliEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
public JKaliEngine(MutationSupporter mutatorExecutor, ProjectRepairFacade projFacade) throws JSAPException {
	super(mutatorExecutor, projFacade);
	ConfigurationProperties.properties.setProperty("regressionforfaultlocalization", "true");
	ConfigurationProperties.properties.setProperty("population", "1");
	setPropertyIfNotDefined(ExtensionPoints.OPERATORS_SPACE.identifier, "suppression");
	setPropertyIfNotDefined(ExtensionPoints.TARGET_CODE_PROCESSOR.identifier, "statements");
}
 
Example 28
Source Project: astor   Source File: TibraApproach.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TibraApproach(MutationSupporter mutatorExecutor, ProjectRepairFacade projFacade) throws JSAPException {
	super(mutatorExecutor, projFacade);

	ConfigurationProperties.setProperty("ingredienttransformstrategy",
			RandomTransformationStrategy.class.getCanonicalName());
	ConfigurationProperties.setProperty("consideryvarloops", "false");
}
 
Example 29
Source Project: astor   Source File: jMutRepairExhaustive.java    License: GNU General Public License v2.0 5 votes vote down vote up
public jMutRepairExhaustive(MutationSupporter mutatorExecutor, ProjectRepairFacade projFacade)
		throws JSAPException {
	super(mutatorExecutor, projFacade);
	ConfigurationProperties.properties.setProperty("regressionforfaultlocalization", "true");
	ConfigurationProperties.properties.setProperty("population", "1");
	setPropertyIfNotDefined(ExtensionPoints.OPERATORS_SPACE.identifier, "mutationspace");
	setPropertyIfNotDefined(ExtensionPoints.TARGET_CODE_PROCESSOR.identifier,
			"if-conditions" + File.pathSeparator + "return-op-mutation");
}
 
Example 30
Source Project: astor   Source File: Cardumen1HApproach.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Cardumen1HApproach(MutationSupporter mutatorExecutor, ProjectRepairFacade projFacade) throws JSAPException {

		super(mutatorExecutor, projFacade);

		ConfigurationProperties.setProperty(ExtensionPoints.TARGET_CODE_PROCESSOR.identifier, "expression");
		ConfigurationProperties.setProperty(ExtensionPoints.OPERATORS_SPACE.identifier, "r-expression");

		ConfigurationProperties.setProperty("nrPlaceholders", "1");
		ConfigurationProperties.setProperty("excludevariableplaceholder", "false");
		ConfigurationProperties.setProperty("excludeliteralplaceholder", "true");
		ConfigurationProperties.setProperty("excludeinvocationplaceholder", "true");
		ConfigurationProperties.setProperty("excludevarliteralplaceholder", "true");

	}