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


Java JSAPResult.getClass方法代码示例

本文整理汇总了Java中com.martiansoftware.jsap.JSAPResult.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java JSAPResult.getClass方法的具体用法?Java JSAPResult.getClass怎么用?Java JSAPResult.getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.martiansoftware.jsap.JSAPResult的用法示例。


在下文中一共展示了JSAPResult.getClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String args[] ) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException  {
	String sourceBasename, destBasename;
	Class<?> graphClass;
	
	SimpleJSAP jsap = new SimpleJSAP( ArcListASCIIGraph.class.getName(), "Reads a graph with a given basename and writes it out in ASCII format with another basename",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph" ),
					new FlaggedOption( "shift", JSAP.INTEGER_PARSER, null, JSAP.NOT_REQUIRED, 'S', "shift", "A shift that will be added to each node index." ),
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
					new UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph" ),
					new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the destination graph" ),
				}		
			);
			
	JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	graphClass = jsapResult.getClass( "graphClass" );
	sourceBasename = jsapResult.getString( "sourceBasename" );
	destBasename = jsapResult.getString( "destBasename" );

	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	final ImmutableGraph graph = graphClass != null 
		? (ImmutableGraph)graphClass.getMethod( "loadOffline", CharSequence.class, ProgressLogger.class ).invoke( null, sourceBasename, pl )
		: ImmutableGraph.loadOffline( sourceBasename, pl );
	if ( jsapResult.userSpecified( "shift" ) ) ArcListASCIIGraph.store( graph, destBasename, jsapResult.getInt( "shift" ) );
	else ArcListASCIIGraph.store( graph, destBasename );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:30,代码来源:ArcListASCIIGraph.java

示例2: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String args[] ) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException, ClassNotFoundException, InstantiationException  {
	String sourceBasename, destBasename;
	Class<?> graphClass;

	SimpleJSAP jsap = new SimpleJSAP( ASCIIGraph.class.getName(), "Reads a graph with a given basename, or a given spec, and writes it out in ASCII format with another basename",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph" ),
					new FlaggedOption( "shift", JSAP.INTEGER_PARSER, null, JSAP.NOT_REQUIRED, 'S', "shift", "A shift that will be added to each node index." ),
					new Switch( "spec", 's', "spec", "The source is not a basename but rather a spec of the form ImmutableGraphClass(arg,arg,...)." ),
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
					new UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph, or a source spec if --spec was given; it is immaterial when --once is specified." ),
					new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the destination graph" ),
				}		
			);
			
	JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	graphClass = jsapResult.getClass( "graphClass" );
	sourceBasename = jsapResult.getString( "sourceBasename" );
	destBasename = jsapResult.getString( "destBasename" );
	final boolean spec = jsapResult.getBoolean( "spec" );

	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	if ( graphClass != null && spec ) {
		System.err.println( "Options --graphClass and --spec are incompatible" );
		return;
	}

	ImmutableGraph graph;
	if ( !spec )
		graph = graphClass != null 
		? (ImmutableGraph)graphClass.getMethod( "loadSequential", CharSequence.class, ProgressLogger.class ).invoke( null, sourceBasename, pl )
		: ImmutableGraph.loadSequential( sourceBasename, pl );
	else
		graph = ObjectParser.fromSpec( sourceBasename, ImmutableGraph.class, GraphClassParser.PACKAGE );
	if ( jsapResult.userSpecified( "shift" ) ) ASCIIGraph.store( graph, jsapResult.getInt( "shift" ), destBasename );
	else ASCIIGraph.store( graph, destBasename );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:41,代码来源:ASCIIGraph.java

示例3: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
static public void main( String arg[] ) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, JSAPException, IOException, ClassNotFoundException {
	SimpleJSAP jsap = new SimpleJSAP( Stats.class.getName(), "Computes statistical data of a given graph.",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph." ),
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
					new Switch( "saveDegrees", 's', "save-degrees", "Save indegrees and outdegrees in text format." ),
					new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
					new UnflaggedOption( "resultsBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The basename of the resulting files." ),
				}		
			);
	
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );

	final Class<?> graphClass = jsapResult.getClass( "graphClass" );
	final String basename = jsapResult.getString( "basename" );
	final String resultsBasename = jsapResult.userSpecified( "resultsBasename" ) ? jsapResult.getString( "resultsBasename" ) : basename;
	
	final ProgressLogger pl = new ProgressLogger();
	pl.logInterval = jsapResult.getLong( "logInterval" );
	
	final ImmutableGraph graph;

	if ( graphClass != null ) graph = (ImmutableGraph)graphClass.getMethod( "loadOffline", CharSequence.class ).invoke( null, basename );
	else graph = ImmutableGraph.loadOffline( basename, pl );

	final LongArrayBitVector buckets = (LongArrayBitVector)( new File( basename + ".buckets" ).exists() ? BinIO.loadObject( basename + ".buckets" ) : null );
	final int[] sccsize = new File( basename + ".sccsizes" ).exists() ? BinIO.loadInts( basename + ".sccsizes" ) : null;

	run( graph, buckets, sccsize, resultsBasename, jsapResult.getBoolean( "saveDegrees" ), pl );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:32,代码来源:Stats.java

示例4: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws JSAPException, IOException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException, InstantiationException {
	final SimpleJSAP jsap = new SimpleJSAP( ArcRelabelledImmutableGraph.class.getName(), 
			"Relabels a graph with given basename, with integer labels, saving it with a different basename and " +
			"using another (typically: different) type of integer labels, specified via a spec, and possibly using " +
			"a different kind of graph class.",
			new Parameter[] {
					new FlaggedOption( "underlyingGraphClass", GraphClassParser.getParser(), BVGraph.class.getName(), JSAP.NOT_REQUIRED, 'u', "underlying-graph-class", "Forces a Java immutable graph class to be used for saving the underlying graph (if the latter did not exist before)." ),
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), BitStreamArcLabelledImmutableGraph.class.getName(), JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java arc-labelled graph class to be used for saving." ),
					new UnflaggedOption( "spec", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The label spec (e.g. FixedWidthIntLabel(FOO,10))." ),
					new UnflaggedOption( "source", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source arc-labelled graph." ),
					new UnflaggedOption( "target", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the target arc-labelled graph." ),
				}		
			);
	
	final JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	final Class<?> destClass = jsapResult.getClass( "graphClass" );
	final Class<?> underlyingDestClass = jsapResult.getClass( "underlyingGraphClass" );
	final String sourceBasename = jsapResult.getString( "source" );
	final String targetBasename = jsapResult.getString( "target" );
	final String spec = jsapResult.getString( "spec" );
	final Label label = ObjectParser.fromSpec( new File( sourceBasename ).getParent(), spec, Label.class );
	
	ImmutableGraph source = ImmutableGraph.loadOffline( sourceBasename );
	if ( ! ( source instanceof ArcLabelledImmutableGraph ) ) throw new IllegalArgumentException( "The graph " + sourceBasename + " of class " + sourceBasename.getClass().getName() + " is not arc-labelled" );
	ArcLabelledImmutableGraph labSource = (ArcLabelledImmutableGraph)source;
	
	if ( ! ( labSource.prototype() instanceof AbstractIntLabel && label instanceof AbstractIntLabel ) ) throw new IllegalArgumentException( "Relabelling from command line is only allowed for int labels, not for " + labSource.prototype().getClass().getName() + " -> " + label.getClass().getName());
	ArcLabelledImmutableGraph labTarget = new ArcRelabelledImmutableGraph( labSource, label, ArcRelabelledImmutableGraph.INT_LABEL_CONVERSION_STRATEGY );

	ProgressLogger pl = new ProgressLogger( LOGGER );

	Properties prop = new Properties();
	prop.load( new FileInputStream( sourceBasename + ImmutableGraph.PROPERTIES_EXTENSION ) );
	String underlyingBasename = prop.getProperty( ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY ); // Tries to get the underlying basename
	if ( underlyingBasename == null ) 
		// If the underlying did not exist, we store it with a fixed basename variant
		underlyingDestClass.getMethod( "store", ImmutableGraph.class, CharSequence.class, ProgressLogger.class )
		.invoke( null, labTarget, underlyingBasename = targetBasename + ArcLabelledImmutableGraph.UNDERLYINGGRAPH_SUFFIX, pl ); 		
	
	destClass.getMethod( "store", ArcLabelledImmutableGraph.class, CharSequence.class, CharSequence.class, ProgressLogger.class )
		.invoke( null, labTarget, targetBasename, underlyingBasename, pl ); 
	
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:45,代码来源:ArcRelabelledImmutableGraph.java

示例5: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String args[] ) throws IOException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, JSAPException {
	Class<?> graphClass = null;
	boolean offline = false, sequential = false;

	SimpleJSAP jsap = new SimpleJSAP( Check.class.getName(), 
			"Checks properties of a graph. All checks require, after the name,\n" +
			"some parameters specified below:\n" +
			"\n" +
			"symmetry             sourceBasename\n" +
			"symmetryOffline      sourceBasename [batchSize] [tempDir]\n" +
			"\n" +
			"Please consult the Javadoc documentation for more information on each check.",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class to load the graph." ),
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
					new Switch( "offline", 'o', "offline", "Use the offline load method to reduce memory consumption." ),
					new Switch( "sequential", 'S', "sequential", "Use the sequential load method to reduce memory consumption." ),
					new UnflaggedOption( "check", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The check." ),
					new UnflaggedOption( "param", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.GREEDY, "The remaining parameters." ),
				}	
			);
	
	JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );

	graphClass = jsapResult.getClass( "graphClass");
	offline = jsapResult.getBoolean( "offline" );
	sequential = jsapResult.getBoolean( "sequential" );
	String check = jsapResult.getString( "check" );
	String[] param = jsapResult.getStringArray( "param" );
	
	String source[] = null;
	int batchSize = 1000000;
	File tempDir = null;
	
	if ( ! ensureNumArgs( param, -1 ) ) return;
	
	if ( check.equals( "symmetry" ) ) {
		if ( ! ensureNumArgs( param, 1 ) ) return;
		source = new String[] { param[ 0 ] };
	}
	else if ( check.equals( "symmetryOffline" ) ) {
		source = new String[] { param[ 0 ] };
		if ( param.length >= 2 ) {
			batchSize = ((Integer)JSAP.INTSIZE_PARSER.parse( param[ 1 ] )).intValue();
			if ( param.length == 3 ) tempDir = new File( param[ 2 ] );
			else if ( ! ensureNumArgs( param, 2 ) )	return;
		}
		else if ( ! ensureNumArgs( param, 1 ) )	return;
	}
	else {
		System.err.println( "Unknown check: " + check );
		return;
	}

	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );
	final ImmutableGraph[] graph = new ImmutableGraph[ source.length ];
	
	for ( int i = 0; i < source.length; i++ ) 
		if ( source[ i ] == null ) graph[ i ] = null;
		else graph[ i ] = load( graphClass, source[ i ], sequential, offline, pl );
	
	if ( check.equals( "symmetry" ) ) {
		System.out.println( symmetry( graph[ 0 ], pl ) );
	}
	else if ( check.equals( "symmetryOffline" ) ) {
		System.out.println( symmetryOffline( graph[ 0 ], batchSize, tempDir, pl ) );
	}
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:70,代码来源:Check.java

示例6: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String args[] ) throws SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException, ClassNotFoundException,
		InstantiationException {
	String source, dest;
	Class<?> graphClass;

	final SimpleJSAP jsap = new SimpleJSAP(
			BVGraph.class.getName(),
			"Compresses a graph using the Elias-Fano representation. Source and destination are basenames from which suitable filenames will be stemmed; alternatively, if the suitable option was specified, source is a spec (see below). For more information about the compression techniques, see the Javadoc documentation.",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph." ),
					new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval",
							"The minimum time interval between activity logs in milliseconds." ),
					new FlaggedOption( "log2Quantum", JSAP.INTEGER_PARSER, Integer.toString( DEFAULT_LOG_2_QUANTUM ), JSAP.NOT_REQUIRED, 'q', "--log2-quantum",
							"The base-two logarithm of the indexing quantum." ),
					new Switch( "offline", 'o', "offline", "Use the offline load method to reduce memory consumption." ),
					new Switch( "once", '1', "once", "Use the read-once load method to read a graph from standard input." ),
					new Switch( "list", 'L', "list", "Precomputes an Elias-Fano list of offsets for the source graph." ),
					new Switch( "fixedWidthList", 'F', "fixed-width-list", "Precomputes a list of fixed-width offsets for the source graph." ),
					new UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
							"The basename of the source graph, or a source spec if --spec was given; it is immaterial when --once is specified." ),
					new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY,
							"The basename of the destination graph; if omitted, no recompression is performed. This is useful in conjunction with --offsets and --list." ),
			}
			);

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

	final boolean offline = jsapResult.getBoolean( "offline" );
	final boolean once = jsapResult.getBoolean( "once" );
	final boolean spec = jsapResult.getBoolean( "spec" );
	final boolean list = jsapResult.getBoolean( "list" );
	final boolean fixedWidthList = jsapResult.getBoolean( "fixedWidthList" );
	final int log2Quantum = jsapResult.getInt( "log2Quantum" );
	graphClass = jsapResult.getClass( "graphClass" );
	source = jsapResult.getString( "sourceBasename" );
	dest = jsapResult.getString( "destBasename" );

	final ImmutableGraph graph;
	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	if ( graphClass != null ) {
		if ( spec ) {
			System.err.println( "Options --graph-class and --spec are incompatible" );
			System.exit( 1 );
		}
		if ( once ) graph = (ImmutableGraph)graphClass.getMethod( LoadMethod.ONCE.toMethod(), InputStream.class ).invoke( null, System.in );
		else if ( list || fixedWidthList || offline ) graph = (ImmutableGraph)graphClass.getMethod( LoadMethod.OFFLINE.toMethod(), CharSequence.class ).invoke( null, source );
		else graph = (ImmutableGraph)graphClass.getMethod( LoadMethod.SEQUENTIAL.toMethod(), CharSequence.class, ProgressLogger.class ).invoke( null, source, pl );
	}
	else {
		if ( !spec ) graph = once ? ImmutableGraph.loadOnce( System.in ) : offline ? ImmutableGraph.loadOffline( source, pl ) : ImmutableGraph.loadSequential( source, pl );
		else graph = ObjectParser.fromSpec( source, ImmutableGraph.class, GraphClassParser.PACKAGE );
	}

	if ( dest != null ) {
		if ( list || fixedWidthList ) throw new IllegalArgumentException( "You cannot specify a destination graph with these options" );
		EFGraph.store( graph, dest, log2Quantum, DEFAULT_CACHE_SIZE, ByteOrder.nativeOrder(), pl );
	}
	else {
		if ( !( graph instanceof EFGraph ) ) throw new IllegalArgumentException( "The source graph is not an EFGraph" );
		final InputBitStream offsets = new InputBitStream( graph.basename() + OFFSETS_EXTENSION );
		final long sizeInBits = new File( graph.basename() + GRAPH_EXTENSION ).length() * Byte.SIZE + 1;
		final OffsetsLongIterator offsetsIterator = new OffsetsLongIterator( offsets, graph.numNodes() );
		if ( list ) {
			BinIO.storeObject( new EliasFanoMonotoneLongBigList( graph.numNodes() + 1, sizeInBits, offsetsIterator ), graph.basename() + OFFSETS_BIG_LIST_EXTENSION );
		}
		else if ( fixedWidthList ) {
			final LongBigList t = LongArrayBitVector.getInstance().asLongBigList( Fast.length( sizeInBits ) );
			while ( offsetsIterator.hasNext() )
				t.add( offsetsIterator.nextLong() );
			BinIO.storeObject( t, graph.basename() + OFFSETS_BIG_LIST_EXTENSION );
		}
		offsets.close();
	}
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:78,代码来源:EFGraph.java


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