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


Java MutableString类代码示例

本文整理汇总了Java中it.unimi.dsi.lang.MutableString的典型用法代码示例。如果您正苦于以下问题:Java MutableString类的具体用法?Java MutableString怎么用?Java MutableString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: dequeueKey

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
/** Returns the next key in the flow of new pairs remained after the check, and discards the corresponding value. Note that calling this method is blocking (it may take a long time
 *  to produce the next pair because check+update is performed in batch); in particular, if no thread calls {@link AbstractSieve#enqueue(Object, Object)} for a sufficient
 *  number of times or {@link #flush}, a call to this method may never return.
 *
 * @return the next key (the value is discarded).
 * @throws NoSuchElementException if there is no more pair to be returned; this may only happen if this new flow has been {@linkplain #close() closed}.
 */
public synchronized MutableString dequeueKey() throws NoSuchElementException, IOException, InterruptedException {
	if (closed && size() == 0) throw new NoSuchElementException();

	while (! closed && size() == 0) {
		wait();
		if (closed && size() == 0) throw new NoSuchElementException();
	}

	assert size() > 0 : size() + " <= 0";

	while(inputIndex == -1 || input.available() == 0) {
		if (inputIndex != -1) {
			input.close();
			new File(baseName + inputIndex).delete();
		}
		File file = new File(baseName + ++inputIndex);
		file.deleteOnExit();
		input = new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)));
	}
	input.readLong(); // ALERT: we throw it away (no values)
	size--;
	return new MutableString().readSelfDelimUTF8((InputStream)input);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:31,代码来源:AbstractSieve.java

示例2: fetch

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
public void fetch(URI uri) throws IOException {
	this.url = uri;
	MutableString s = new MutableString();
	s.append("<html><head><title>").append(uri).append("</title></head>\n");
	s.append("<body>\n");

	try {
		final int host = Integer.parseInt(uri.getHost());
		final int page = Integer.parseInt(uri.getRawPath().substring(1));
		final Random random = new Random(host << 32 | page);
		for(int i = 0; i < 10; i++)
			s.append("<a href=\"http://").append(host).append('/').append(random.nextInt(10000)).append("\">Link ").append(i).append("</a>\n");
		s.append("<a href=\"http://").append(random.nextInt(1000)).append('/').append(random.nextInt(10000)).append("\">External link ").append("</a>\n");

	}
	catch(NumberFormatException e) {}
	s.append("</body></html>\n");
	inspectableBufferedInputStream.write(ByteBuffer.wrap(Util.toByteArray(s.toString())));
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:20,代码来源:MockFetchedResponses.java

示例3: GobyAlignmentQueryReader

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
/**
 * Construct a query reader for this filename/basename.
 *
 * @param filename The filename of any file component for a Goby compact alignment, or the alignment basename.
 * @throws IOException If an error occurs reading the alignment.
 */
public GobyAlignmentQueryReader(String filename) throws IOException {
    basename = filename;
    reader = new AlignmentReaderImpl(filename);
    reader.readHeader();
    if (!reader.isIndexed()) {
        final String errorMessage = "Goby alignment files must be sorted in order to be loaded in IGV. See the IGV tutorial at http://goby.campagnelab.org/ for details.";
        System.err.println(errorMessage);
        throw new UnsupportedOperationException(errorMessage);
    }
    final IndexedIdentifier identifiers = reader.getTargetIdentifiers();
    // add MT as a synonym for M:
    identifiers.put(new MutableString("M"), identifiers.getInt(new MutableString("MT")));
    targetIdentifiers = new DoubleIndexedIdentifier(identifiers);
    isIndexed = reader.isIndexed();
    // reader.close();
    // reader = null;

    targetSequenceNames = new ArrayList();
    for (MutableString ms : identifiers.keySet()) {
        targetSequenceNames.add(ms.toString());
    }


}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:31,代码来源:GobyAlignmentQueryReader.java

示例4: query

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
/**
 * Obtain an iterator over a genomic window. The window on reference 'sequence' extends from
 * start to end. The attribute 'contained' is ignored (documentation required).
 *
 * @return An alignment iterator restricted to the sequence [start end] interval.
 */
public final CloseableIterator<Alignment> query(String sequence, int start, int end, boolean contained) {
    LOG.debug(String.format("query %s %d %d %b%n", sequence, start, end, contained));

    final MutableString id = new MutableString(sequence);
    int referenceIndex = targetIdentifiers.getIndex(id);
    if (referenceIndex == -1) {
        // try again removing a chr prefix:
        referenceIndex = targetIdentifiers.getIndex(id.replace("chr", ""));
    }
    try {
        if (referenceIndex == -1) {
            // the reference could not be found in the Goby alignment, probably a wrong reference choice. Not sure how
            // to inform the end user, but we send no results here:
            return EMPTY_ITERATOR;
        }
        return new GobyAlignmentIterator(getNewLocalReader(), targetIdentifiers, referenceIndex, sequence, start, end);
    } catch (IOException e) {
        LOG.error(e);
        return null;

    }

}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:30,代码来源:GobyAlignmentQueryReader.java

示例5: recToString

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
private void recToString(final Node n, final MutableString printPrefix, final MutableString result, final MutableString path, final int level) {
	if (n == null) return;

	result.append(printPrefix).append('(').append(level).append(')');

	if (n.path != null) {
		path.append(n.path);
		result.append(" path: (").append(n.path.length()).append(") :").append(n.path);
	}

	result.append('\n');

	path.append('0');
	recToString(n.left, printPrefix.append('\t').append("0 => "), result, path, level + 1);
	path.charAt(path.length() - 1, '1');
	recToString(n.right, printPrefix.replace(printPrefix.length() - 5, printPrefix.length(), "1 => "), result, path, level + 1);
	path.delete(path.length() - 1, path.length());
	printPrefix.delete(printPrefix.length() - 6, printPrefix.length());

	path.delete((int)(path.length() - n.path.length()), path.length());
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:22,代码来源:ZFastTrieDistributor.java

示例6: recToString

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
private void recToString(final Node n, final MutableString printPrefix, final MutableString result, final MutableString path, final int level) {
	if (n == null) return;

	result.append(printPrefix).append('(').append(level).append(')');

	if (n.path != null) {
		path.append(n.path);
		result.append(" path:").append(n.path);
	}

	result.append('\n');

	path.append('0');
	recToString(n.left, printPrefix.append('\t').append("0 => "), result, path, level + 1);
	path.charAt(path.length() - 1, '1');
	recToString(n.right, printPrefix.replace(printPrefix.length() - 5, printPrefix.length(), "1 => "), result, path, level + 1);
	path.delete(path.length() - 1, path.length());
	printPrefix.delete(printPrefix.length() - 6, printPrefix.length());

	//System.err.println("Path now: " + path + " Going to delete from " + (path.length() - n.pathLength));

	path.delete((int)(path.length() - n.path.length()), path.length());
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:24,代码来源:PaCoTrieDistributor.java

示例7: run

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
public static void run( final FastBufferedReader fbr, final DataOutputStream dos, ProgressLogger pl ) throws IOException {
	final MutableString s = new MutableString();
	Object2IntOpenHashMap<MutableString> map = new Object2IntOpenHashMap<MutableString>();
	map.defaultReturnValue( -1 );
	int slash, hostIndex = -1;

	if ( pl != null ) pl.start( "Reading URLS..." );
	while( fbr.readLine( s ) != null ) {
		slash = s.indexOf( '/', 8 );
		// Fix for non-BURL URLs
		if ( slash != -1 ) s.length( slash );
		if ( ( hostIndex = map.getInt( s ) ) == -1 ) map.put( s.copy(), hostIndex = map.size() );
		dos.writeInt( hostIndex );
		if ( pl != null ) pl.lightUpdate();
	}
	
	if ( pl != null ) pl.done();
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:19,代码来源:BuildHostMap.java

示例8: load

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
/** Creates a new immutable subgraph by loading the supergraph, delegating the 
 *  actual loading to the class specified in the <samp>supergraphclass</samp> property within the property
 *  file (named <samp><var>basename</var>.properties</samp>), and loading the subgraph array in memory.
 *  The exact load method to be used depends on the <code>method</code> argument.
 * 
 * @param method the method to be used to load the supergraph.
 * @param basename the basename of the graph.
 * @param pl the progress logger; it can be <code>null</code>.
 * @return an immutable subgraph containing the specified graph.
 */

protected static ImmutableGraph load( final LoadMethod method, final CharSequence basename, final ProgressLogger pl ) throws IOException {
	final FileInputStream propertyFile = new FileInputStream( basename + PROPERTIES_EXTENSION );
	final Properties properties = new Properties();
	properties.load( propertyFile );
	propertyFile.close();

	final String graphClassName = properties.getProperty( ImmutableGraph.GRAPHCLASS_PROPERTY_KEY );
	if ( ! graphClassName.equals( ImmutableSubgraph.class.getName() ) ) throw new IOException( "This class (" + ImmutableSubgraph.class.getName() + ") cannot load a graph stored using " + graphClassName );
	
	final String supergraphBasename = properties.getProperty( SUPERGRAPHBASENAME_PROPERTY_KEY );
	if ( supergraphBasename == null ) throw new IOException( "This property file does not specify the required property supergraphbasename" );
	
	final ImmutableGraph supergraph = ImmutableGraph.load( method, supergraphBasename, null, pl );
	
	if ( pl != null ) pl.start( "Reading nodes..." );
	final String nodes = properties.getProperty( SUBGRAPHNODES_PROPERTY_KEY );
	final ImmutableSubgraph isg = new ImmutableSubgraph( supergraph, BinIO.loadInts( nodes != null ? nodes : basename + ".nodes" ) );
	if ( pl != null ) {
		pl.count = isg.numNodes();
		pl.done();
	}
	isg.basename = new MutableString( basename );
	return isg;
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:36,代码来源:ImmutableSubgraph.java

示例9: process

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
private void process() throws IOException {
	final MutableString word = new MutableString(), nonWord = new MutableString();
	while (fbr.next(word, nonWord)) {
		final short index = (short)termSetOnthology.getLong(word.toLowerCase());
		if (index != -1) {
			final short oldValue = termCount.get(index);
			if (oldValue < Short.MAX_VALUE) termCount.put(index, (short)(oldValue + 1));
		}
	}
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:11,代码来源:SpamTextProcessor.java

示例10: append

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
@Override
public Appendable append(char c) throws IOException {
	final short index = (short)termSetOnthology.getLong(new MutableString().append(Character.toLowerCase(c)));
	if (index != -1) {
		final short oldValue = termCount.get(index);
		if (oldValue < Short.MAX_VALUE) termCount.put(index, (short)(oldValue + 1));
	}

	return this;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:11,代码来源:SpamTextProcessor.java

示例11: main

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
public static void main(String[] arg) throws IOException {
	if (arg.length == 0) {
		System.err.println("Usage: " + BuildRepetitionSet.class.getSimpleName() + " REPETITIONSET");
		System.exit(1);
	}

	final FastBufferedReader fastBufferedReader = new FastBufferedReader(new InputStreamReader(System.in, Charsets.US_ASCII));
	final MutableString s = new MutableString();
	final LongOpenHashSet repeatedSet = new LongOpenHashSet();
	final String outputFilename = arg[0];
	final ProgressLogger pl = new ProgressLogger();

	MutableString lastUrl = new MutableString();
	pl.itemsName = "lines";
	pl.start("Reading... ");
	while(fastBufferedReader.readLine(s) != null) {
		final int firstTab = s.indexOf('\t');
		final int secondTab = s.indexOf('\t', firstTab + 1);
		MutableString url = s.substring(secondTab + 1);
		if (url.equals(lastUrl)) {
			final int storeIndex = Integer.parseInt(new String(s.array(), 0, firstTab));
			final long storePosition = Long.parseLong(new String(s.array(), firstTab + 1, secondTab - firstTab - 1));
			repeatedSet.add((long)storeIndex << 48 | storePosition);
			System.out.print(storeIndex);
			System.out.print('\t');
			System.out.print(storePosition);
			System.out.print('\t');
			System.out.println(url);
		}

		lastUrl = url;
		pl.lightUpdate();
	}

	pl.done();

	fastBufferedReader.close();
	BinIO.storeObject(repeatedSet, outputFilename);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:40,代码来源:BuildRepetitionSet.java

示例12: handleSeedURL

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
private static URI handleSeedURL(final MutableString s) {
	final URI url = BURL.parse(s);
	if (url != null) {
		if (url.isAbsolute()) return url;
		else LOGGER.error("The seed URL " + s + " is relative");
	}
	else LOGGER.error("The seed URL " + s + " is malformed");
	return null;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:10,代码来源:RuntimeConfiguration.java

示例13: addBlackListedIPv4

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
/** Adds a (or a set of) new IPv4 to the black list; the IPv4 can be specified directly or it can be a file (prefixed by
 *  <code>file:</code>).
 *
 * @param spec the specification (an IP address, or a file prefixed by <code>file</code>).
 * @throws ConfigurationException
 * @throws FileNotFoundException
 */
public void addBlackListedIPv4(final String spec) throws ConfigurationException, FileNotFoundException {
		if (spec.length() == 0) return; // Skip empty specs
		if (spec.startsWith("file:")) {
			final LineIterator lineIterator = new LineIterator(new FastBufferedReader(new InputStreamReader(new FileInputStream(spec.substring(5)), Charsets.ISO_8859_1)));
			while (lineIterator.hasNext()) {
				final MutableString line = lineIterator.next();
				if (line.length() > 0) blackListedIPv4Addresses.add(handleIPv4(line.toString()));
			}
		}
		else blackListedIPv4Addresses.add(handleIPv4(spec));
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:19,代码来源:RuntimeConfiguration.java

示例14: addBlackListedHost

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
/** Adds a (or a set of) new host to the black list; the host can be specified directly or it can be a file (prefixed by
 *  <code>file:</code>).
 *
 * @param spec the specification (a host, or a file prefixed by <code>file</code>).
 * @throws ConfigurationException
 * @throws FileNotFoundException
 */
public void addBlackListedHost(final String spec) throws ConfigurationException, FileNotFoundException 	{
	if (spec.length() == 0) return; // Skip empty specs
	if (spec.startsWith("file:")) {
		final LineIterator lineIterator = new LineIterator(new FastBufferedReader(new InputStreamReader(new FileInputStream(spec.substring(5)), Charsets.ISO_8859_1)));
		while (lineIterator.hasNext()) {
			final MutableString line = lineIterator.next();
			blackListedHostHashes.add(line.toString().trim().hashCode());
		}
	}
	else blackListedHostHashes.add(spec.trim().hashCode());
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:19,代码来源:RuntimeConfiguration.java

示例15: main

import it.unimi.dsi.lang.MutableString; //导入依赖的package包/类
public static void main(String arg[]) throws IOException {
	char[][] robotsResult = URLRespectsRobots.parseRobotsReader(new FileReader(arg[0]), arg[1]);
	for(char[] a: robotsResult) System.err.println(new String(a));
	final FastBufferedReader in = new FastBufferedReader(new InputStreamReader(System.in, Charsets.US_ASCII));
	final MutableString s = new MutableString();
	while(in.readLine(s) != null) {
		final URI uri = BURL.parse(s);
		System.out.println(apply(robotsResult, uri) + "\t" + uri);
	}
	in.close();

}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:13,代码来源:URLRespectsRobots.java


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