List of usage examples for com.google.common.base Splitter limit
int limit
To view the source code for com.google.common.base Splitter limit.
Click Source Link
From source file:org.t3as.ner.resource.Configuration.java
/** Constructor. Read in the config file. */ public Configuration(final InputStream config, final boolean tracing) throws IOException, InterruptedException { this.tracing = tracing; final Pattern COLONS = Pattern.compile(":"); final Splitter SPACES = Splitter.on(' ').trimResults().omitEmptyStrings(); final ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); featureMap = new FeatureMap(tracing); try (final BufferedReader br = new BufferedReader(new InputStreamReader(config))) { for (String line; (line = br.readLine()) != null;) { final String s = line.trim(); if (s.startsWith("#")) continue; if (s.trim().isEmpty()) continue; final String[] parts = COLONS.split(s, 2); switch (parts[0]) { case "Feature": final List<String> l = SPACES.limit(4).splitToList(parts[1]); final String featureType = l.get(0); final String entityType = l.get(1); final int weight = Integer.parseInt(l.get(2)); final List<String> resourceNames = SPACES.splitToList(l.get(3)); final Feature f = Feature.generateFeatureByName(featureType, weight, resourceNames); featureMap.addFeature(entityType, f); exec.execute(new FeatureInitialiserRunnable(f)); break; default: throw new IllegalArgumentException("Unexpected config keyword: '" + parts[0] + "'"); }/* w w w . ja v a2 s . com*/ } } exec.shutdown(); exec.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); }
From source file:org.pshdl.model.simulation.codegenerator.CCodeGenerator.java
public Unit getUnit(final ExecutableModel model) { try {//ww w.ja v a 2 s . c om Unit unit = null; final Splitter annoSplitter = Splitter.on(SimulationTransformationExtension.ANNO_VALUE_SEP); boolean _tripleNotEquals = (this.em.annotations != null); if (_tripleNotEquals) { for (final String a : this.em.annotations) { boolean _startsWith = a.startsWith("busDescription"); if (_startsWith) { Splitter _limit = annoSplitter.limit(2); Iterable<String> _split = _limit.split(a); final String value = IterableExtensions.<String>last(_split); LinkedHashSet<Problem> _linkedHashSet = new LinkedHashSet<Problem>(); Unit _parseUnit = MemoryModelAST.parseUnit(value, _linkedHashSet, 0); unit = _parseUnit; } } } return unit; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }