List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:ivory.app.PreprocessGov2.java
public static void main(String[] args) throws Exception { Map<String, String> map = new ImmutableMap.Builder<String, String>() .put(PreprocessCollection.COLLECTION_NAME, "Gov2") .put(PreprocessCollection.DOCNO_MAPPING, Gov2DocnoMapping.class.getCanonicalName()) .put(PreprocessCollection.INPUTFORMAT, SequenceFileInputFormat.class.getCanonicalName()) .put(PreprocessCollection.TOKENIZER, GalagoTokenizer.class.getCanonicalName()) .put(PreprocessCollection.MIN_DF, "10").build(); List<String> s = Lists.newArrayList(args); for (Map.Entry<String, String> e : map.entrySet()) { s.add("-" + e.getKey()); s.add(e.getValue());/* w ww. j ava 2s. co m*/ } ToolRunner.run(new PreprocessGov2(), s.toArray(new String[s.size()])); }
From source file:ivory.app.PreprocessWt10g.java
public static void main(String[] args) throws Exception { Map<String, String> map = new ImmutableMap.Builder<String, String>() .put(PreprocessCollection.COLLECTION_NAME, "Wt10g") .put(PreprocessCollection.DOCNO_MAPPING, Wt10gDocnoMapping.class.getCanonicalName()) .put(PreprocessCollection.INPUTFORMAT, SequenceFileInputFormat.class.getCanonicalName()) .put(PreprocessCollection.TOKENIZER, GalagoTokenizer.class.getCanonicalName()) .put(PreprocessCollection.MIN_DF, "10").build(); List<String> s = Lists.newArrayList(args); for (Map.Entry<String, String> e : map.entrySet()) { s.add("-" + e.getKey()); s.add(e.getValue());//from ww w. j a va 2 s. c o m } ToolRunner.run(new PreprocessWt10g(), s.toArray(new String[s.size()])); }
From source file:ivory.app.PreprocessTrec45.java
public static void main(String[] args) throws Exception { Map<String, String> map = new ImmutableMap.Builder<String, String>() .put(PreprocessCollection.COLLECTION_NAME, "TREC_vol45") .put(PreprocessCollection.DOCNO_MAPPING, TrecDocnoMapping.class.getCanonicalName()) .put(PreprocessCollection.INPUTFORMAT, TrecDocumentInputFormat.class.getCanonicalName()) .put(PreprocessCollection.TOKENIZER, GalagoTokenizer.class.getCanonicalName()) .put(PreprocessCollection.MIN_DF, "2").build(); List<String> s = Lists.newArrayList(args); for (Map.Entry<String, String> e : map.entrySet()) { s.add("-" + e.getKey()); s.add(e.getValue());//from ww w. j a va 2 s . c o m } ToolRunner.run(new PreprocessTrec45(), s.toArray(new String[s.size()])); }
From source file:ivory.app.PreprocessTrecCollection.java
public static void main(String[] args) throws Exception { Map<String, String> map = new ImmutableMap.Builder<String, String>() .put(PreprocessCollection.DOCNO_MAPPING, TrecDocnoMapping.class.getCanonicalName()) .put(PreprocessCollection.INPUTFORMAT, TrecDocumentInputFormat.class.getCanonicalName()) .put(PreprocessCollection.TOKENIZER, GalagoTokenizer.class.getCanonicalName()) .put(PreprocessCollection.MIN_DF, "2").build(); List<String> s = Lists.newArrayList(args); for (Map.Entry<String, String> e : map.entrySet()) { s.add("-" + e.getKey()); s.add(e.getValue());// ww w .java 2s .co m } ToolRunner.run(new PreprocessTrecCollection(), s.toArray(new String[s.size()])); }
From source file:ivory.app.PreprocessMedline.java
public static void main(String[] args) throws Exception { Map<String, String> map = new ImmutableMap.Builder<String, String>() .put(PreprocessCollection.COLLECTION_NAME, "Medline") .put(PreprocessCollection.DOCNO_MAPPING, MedlineDocnoMapping.class.getCanonicalName()) .put(PreprocessCollection.INPUTFORMAT, MedlineCitationInputFormat.class.getCanonicalName()) .put(PreprocessCollection.TOKENIZER, GalagoTokenizer.class.getCanonicalName()) .put(PreprocessCollection.MIN_DF, "2").build(); List<String> s = Lists.newArrayList(args); for (Map.Entry<String, String> e : map.entrySet()) { s.add("-" + e.getKey()); s.add(e.getValue());/*from w ww .j a va2 s . c o m*/ } ToolRunner.run(new PreprocessMedline(), s.toArray(new String[s.size()])); }
From source file:ivory.app.PreprocessEnglishWikipediaSimple.java
public static void main(String[] args) throws Exception { Map<String, String> map = new ImmutableMap.Builder<String, String>() .put(PreprocessCollection.COLLECTION_NAME, "Wikipedia") .put(PreprocessCollection.DOCNO_MAPPING, WikipediaDocnoMapping.class.getCanonicalName()) .put(PreprocessCollection.INPUTFORMAT, WikipediaPageInputFormat.class.getCanonicalName()) .put(PreprocessCollection.TOKENIZER, GalagoTokenizer.class.getCanonicalName()) .put(PreprocessCollection.MIN_DF, "2").build(); List<String> s = Lists.newArrayList(args); for (Map.Entry<String, String> e : map.entrySet()) { s.add("-" + e.getKey()); s.add(e.getValue());/* w w w. j av a 2s . c o m*/ } ToolRunner.run(new PreprocessTrec45(), s.toArray(new String[s.size()])); }
From source file:com.facebook.swift.generator.swift2thrift.Main.java
public static void main(final String... args) throws Exception { Swift2ThriftGeneratorCommandLineConfig cliConfig = new Swift2ThriftGeneratorCommandLineConfig(); JCommander jCommander = new JCommander(cliConfig, args); jCommander.setProgramName(Swift2ThriftGenerator.class.getSimpleName()); if (cliConfig.inputFiles == null) { jCommander.usage();// w ww . ja va 2 s . c o m return; } ImmutableMap.Builder<String, String> mapBuilder = ImmutableMap.builder(); if (cliConfig.includeMap != null) { Iterator<String> iter = cliConfig.includeMap.iterator(); while (iter.hasNext()) { String key = iter.next(); String value = iter.next(); mapBuilder.put(key, value); } } ImmutableMap.Builder<String, String> namespaceMapBuilder = ImmutableMap.builder(); if (cliConfig.namespaceMap != null) { Iterator<String> iter = cliConfig.namespaceMap.iterator(); while (iter.hasNext()) { String key = iter.next(); String value = iter.next(); namespaceMapBuilder.put(key, value); } } Swift2ThriftGeneratorConfig.Builder configBuilder = Swift2ThriftGeneratorConfig.builder() .outputFile(cliConfig.outputFile).includeMap(mapBuilder.build()).verbose(cliConfig.verbose) .defaultPackage(cliConfig.defaultPackage).namespaceMap(namespaceMapBuilder.build()) .allowMultiplePackages(cliConfig.allowMultiplePackages).recursive(cliConfig.recursive); new Swift2ThriftGenerator(configBuilder.build()).parse(cliConfig.inputFiles); }
From source file:com.sk89q.intake.example.sender.SenderExample.java
public static void main(String[] args) throws AuthorizationException, InvocationCommandException, CommandException { Map<String, User> users = new ImmutableMap.Builder<String, User>().put("aaron", new User("Aaron")) .put("michelle", new User("Michelle")).build(); Namespace namespace = new Namespace(); namespace.put("sender", users.get("aaron")); // Our sender Injector injector = Intake.createInjector(); injector.install(new SenderModule(users)); ParametricBuilder builder = new ParametricBuilder(injector); Dispatcher dispatcher = new SimpleDispatcher(); builder.registerMethodsAsCommands(dispatcher, new SenderExample()); dispatcher.call("greet", namespace, ImmutableList.<String>of()); dispatcher.call("privmsg aaron", namespace, ImmutableList.<String>of()); dispatcher.call("privmsg michelle", namespace, ImmutableList.<String>of()); dispatcher.call("poke aaron", namespace, ImmutableList.<String>of()); dispatcher.call("poke michelle", namespace, ImmutableList.<String>of()); }
From source file:Dictconvert.java
public static void main(String args[]) throws Exception { final ImmutableMap<String, String> nameMap = new ImmutableMap.Builder<String, String>() .put("ebucoreMainFramework", "ebucoreMainFramework") .put("ebucorePartFramework", "ebucorePartFramework") .put("ebucoreMetadataSchemeInformation", "ebucoreMetadataSchemeInformation") /* List mainly generated using AWK: awk '{t=$2; gsub(/ebucore/, "", t); print "\x27"$2"\x27:\x27" tolower(substr(t, 1, 1))substr(t, 2)"\x27," }' < tmp.txt > tmpout.txt *//*from ww w . jav a 2s .c om*/ .put("ebucoreEntity", "entity").put("ebucoreContact", "contact") .put("ebucoreContactDetails", "details").put("ebucoreAddress", "address") .put("ebucoreRegion", "region").put("ebucoreCompoundName", "compoundName") .put("ebucoreRole", "role").put("ebucoreCountry", "country") .put("ebucoreTextualAnnotation", "textualAnnotation").put("ebucoreBasicLink", "basicLink") .put("ebucoreTypeGroup", "typeGroup").put("ebucoreOrganisation", "organisation") .put("ebucoreOrganisationDepartment", "organisationDepartment") .put("ebucoreCoreMetadata", "coreMetadata").put("ebucoreIdentifier", "identifier") .put("ebucoreTitle", "title").put("ebucoreAlternativeTitle", "alternativeTitle") .put("ebucoreFormatGroup", "formatGroup").put("ebucoreStatusGroup", "statusGroup") .put("ebucoreSubject", "subject").put("ebucoreDescription", "description") .put("ebucoreDate", "date").put("ebucoreDateType", "dateType").put("ebucoreType", "type") .put("ebucoreObjectType", "objectType").put("ebucoreGenre", "genre") .put("ebucoreTargetAudience", "targetAudience").put("ebucoreLanguage", "language") .put("ebucoreCoverage", "coverage").put("ebucoreSpatial", "spatial") .put("ebucoreLocation", "location").put("ebucoreCoordinates", "coordinates") .put("ebucoreTemporal", "temporal").put("ebucorePeriodOfTime", "periodOfTime") .put("ebucoreRights", "rights").put("ebucoreVersion", "version").put("ebucoreRating", "rating") .put("ebucorePublicationHistoryEvent", "publicationHistoryEvent") .put("ebucorePublicationHistory", "publicationHistory") .put("ebucorePublicationChannel", "publicationChannel") .put("ebucorePublicationMedium", "publicationMedium") .put("ebucorePublicationService", "publicationService") .put("ebucoreCustomRelation", "customRelation").put("ebucoreBasicRelation", "basicRelation") .put("ebucorePartMetadata", "partMetadata").put("ebucoreFormat", "format") .put("ebucoreVideoFormat", "videoFormat").put("ebucoreImageFormat", "imageFormat") .put("ebucoreAudioFormat", "audioFormat").put("ebucoreTrack", "track") .put("ebucoreDataFormat", "dataFormat").put("ebucoreCaptioning", "captioning") .put("ebucoreSubtitling", "subtitling").put("ebucoreAncillaryData", "ancillaryData") .put("ebucoreSigningFormat", "signingFormat") .put("ebucoreTechnicalAttributeString", "technicalAttributeString") .put("ebucoreTechnicalAttributeInt8", "technicalAttributeInt8") .put("ebucoreTechnicalAttributeInt16", "technicalAttributeInt16") .put("ebucoreTechnicalAttributeInt32", "technicalAttributeInt32") .put("ebucoreTechnicalAttributeInt64", "technicalAttributeInt64") .put("ebucoreTechnicalAttributeUInt8", "technicalAttributeUInt8") .put("ebucoreTechnicalAttributeUInt16", "technicalAttributeUInt16") .put("ebucoreTechnicalAttributeUInt32", "technicalAttributeUInt32") .put("ebucoreTechnicalAttributeUInt64", "technicalAttributeUInt64") .put("ebucoreTechnicalAttributeFloat", "technicalAttributeFloat") .put("ebucoreTechnicalAttributeRational", "technicalAttributeRational") .put("ebucoreTechnicalAttributeAnyURI", "technicalAttributeAnyURI") .put("ebucoreTechnicalAttributeBoolean", "technicalAttributeBoolean") .put("ebucoreDimension", "dimension").put("ebucoreWidth", "width").put("ebucoreHeight", "height") .put("ebucorePackageInfo", "packageInfo").put("ebucoreMedium", "medium") .put("ebucoreCodec", "codec").put("ebucoreRational", "rational") .put("ebucoreAspectRatio", "aspectRatio").build(); String key_ns_ebucore_1 = "urn:ebu:metadata-schema:smpteclass13/groups/ebucore_2013"; Map<String, String> namespaces = ImmutableMap.<String, String>of(key_ns_ebucore_1, "key_ns_ebucore_1"); HashMap<String, String> keys = new HashMap<String, String>(); DocumentBuilderFactory builderF = DocumentBuilderFactory.newInstance(); builderF.setNamespaceAware(true); DocumentBuilder builder = builderF.newDocumentBuilder(); Document xmlDictionary = builder.parse(args[0]); Map<String, String> localKeys = new HashMap<String, String>(); for (Map.Entry<String, String> e : namespaces.entrySet()) { System.out.println("XMLCh " + e.getValue() + "[] = {" + Joiner.on(",") .join(Iterables.transform(Lists.charactersOf(e.getKey()), new Function<Character, String>() { public String apply(Character o) { return "\'" + o + "\'"; } })) + ",\'\\0\'};"); } for (Element e : Iterables.filter(getElements(xmlDictionary.getDocumentElement()), new Predicate<Element>() { public boolean apply(Element element) { return element.getAttribute("type").equals("localSet"); } })) { String name = nameMap.get(e.getLocalName()); String keyName = "key_" + Joiner.on("").join(e.getAttribute("key").split("\\s")); localKeys.put(keyName, keyName + "_name"); System.out.println("const mxfKey " + keyName + " = {" + Joiner.on(",").join(Iterables .transform(Arrays.asList(e.getAttribute("key").split("\\s")), new Function<String, String>() { public String apply(String o) { return "0x" + o; } })) + "};"); System.out.println("const XMLCh " + keyName + "_name[] = {" + Joiner.on(",") .join(Iterables.transform(Lists.charactersOf(name), new Function<Character, String>() { public String apply(Character o) { return "\'" + o + "\'"; } })) + ",\'\\0\'};"); //System.out.println("st434dict.insert(std::pair<const mxfKey, st434info*>("); //System.out.println('\t' + keyName + ','); //System.out.println("\tnew st434info(/* " + e.getLocalName() + " */ " + keyName + "_name, /* " + key_ns_ebucore_1 + " */ " + namespaces.get(key_ns_ebucore_1) + ")"); //System.out.println("));"); } if (localKeys.size() > 0) { String arrayName = "arr_ebucore_elems"; System.out.println("const void* " + arrayName + "[][2] = {"); System.out.println(Joiner.on(", \n").join( Iterables.transform(localKeys.entrySet(), new Function<Map.Entry<String, String>, String>() { @Override public String apply(java.util.Map.Entry<String, String> e) { return "{ &" + e.getKey() + ", " + e.getValue() + " }"; } }))); System.out.println("};"); System.out.println("for (int i=0; i<" + localKeys.size() + ";i++) {"); System.out.println("\tst434dict.insert(std::pair<const mxfKey, st434info*>("); System.out.println("\t*(const mxfKey*)" + arrayName + "[i][0], "); System.out.println("\tnew st434info((const XMLCh*)" + arrayName + "[i][1], key_ns_ebucore_1)"); System.out.println("));"); System.out.println("}"); } }
From source file:io.vitess.example.VitessClientExample.java
public static void main(String[] args) { if (args.length != 1) { System.out.println("usage: VitessClientExample <vtgate-host:port>"); System.exit(1);//from w w w. j a v a 2 s .com } Context ctx = Context.getDefault().withDeadlineAfter(Duration.millis(5 * 1000)); try (RpcClient client = new GrpcClientFactory().create(ctx, args[0]); VTGateBlockingConnection conn = new VTGateBlockingConnection(client)) { VTSession session = new VTSession("@master", ExecuteOptions.getDefaultInstance()); // Insert some messages on random pages. System.out.println("Inserting into master..."); Random rand = new Random(); for (int i = 0; i < 3; i++) { Instant timeCreated = Instant.now(); Map<String, Object> bindVars = new ImmutableMap.Builder<String, Object>() .put("page", rand.nextInt(100) + 1) .put("time_created_ns", timeCreated.getMillis() * 1000000).put("message", "V is for speed") .build(); conn.execute(ctx, "begin", null, session); conn.execute(ctx, "INSERT INTO messages (page,time_created_ns,message) VALUES (:page,:time_created_ns,:message)", bindVars, session); conn.execute(ctx, "commit", null, session); } // Read it back from the master. System.out.println("Reading from master..."); try (Cursor cursor = conn.execute(ctx, "SELECT page, time_created_ns, message FROM messages", null, session)) { Row row; while ((row = cursor.next()) != null) { UnsignedLong page = row.getULong("page"); UnsignedLong timeCreated = row.getULong("time_created_ns"); byte[] message = row.getBytes("message"); System.out.format("(%s, %s, %s)\n", page, timeCreated, new String(message)); } } } catch (Exception e) { System.out.println("Vitess Java example failed."); System.out.println("Error Details:"); e.printStackTrace(); System.exit(2); } }