List of usage examples for com.google.common.collect Iterables toArray
static <T> T[] toArray(Iterable<? extends T> iterable, T[] array)
From source file:edu.cmu.lti.oaqa.baseqa.providers.ml.classifiers.WekaProvider.java
@Override public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { boolean ret = super.initialize(aSpecifier, aAdditionalParams); // model// w ww .j ava 2s. c o m if ((modelFile = new File((String) getParameterValue("model-file"))).exists()) { try { classifier = (Classifier) SerializationHelper.read(modelFile.getAbsolutePath()); } catch (Exception e) { throw new ResourceInitializationException(e); } } // dataset schema if ((datasetSchemaFile = new File((String) getParameterValue("dataset-schema-file"))).exists()) { try { datasetSchema = (Instances) SerializationHelper.read(datasetSchemaFile.getAbsolutePath()); } catch (Exception e) { throw new ResourceInitializationException(e); } } // training instances backup as arff Object datasetExport; if ((datasetExport = getParameterValue("dataset-export")) != null) { datasetExportFile = new File(String.class.cast(datasetExport)); } // classifier classifierName = String.class.cast(getParameterValue("classifier-name")); options = Iterables.toArray((Iterable<String>) getParameterValue("options"), String.class); balanceWeight = (boolean) getParameterValue("balance-weight"); return ret; }
From source file:com.clarkparsia.geneious.SBOLDesignerPlugin.java
@Override public GeneiousService[] getServices() { List<GeneiousService> services = Lists.newArrayList(); try {/*from ww w .j a v a 2 s.co m*/ services.add(new VersioningService("http://localhost:5822/rvt")); services.add(new VersioningService("http://ec2-174-129-47-60.compute-1.amazonaws.com:8080/demo")); } catch (Exception e) { e.printStackTrace(); } return Iterables.toArray(services, GeneiousService.class); }
From source file:org.openqa.selenium.firefox.FirefoxBinary.java
public void startProfile(FirefoxProfile profile, File profileDir, String... commandLineFlags) throws IOException { String profileAbsPath = profileDir.getAbsolutePath(); setEnvironmentProperty("XRE_PROFILE_PATH", profileAbsPath); setEnvironmentProperty("MOZ_NO_REMOTE", "1"); setEnvironmentProperty("MOZ_CRASHREPORTER_DISABLE", "1"); // Disable Breakpad setEnvironmentProperty("NO_EM_RESTART", "1"); // Prevent the binary from detaching from the // console if (isOnLinux() && (profile.areNativeEventsEnabled() || profile.shouldLoadNoFocusLib())) { modifyLinkLibraryPath(profileDir); }/*from w w w. jav a 2 s . c o m*/ List<String> cmdArray = Lists.newArrayList(getExecutable().getPath()); cmdArray.addAll(extraOptions); cmdArray.addAll(Lists.newArrayList(commandLineFlags)); CommandLine command = new CommandLine(Iterables.toArray(cmdArray, String.class)); command.setEnvironmentVariables(getExtraEnv()); executable.setLibraryPath(command, getExtraEnv()); if (stream == null) { stream = getExecutable().getDefaultOutputStream(); } command.copyOutputTo(stream); startFirefoxProcess(command); }
From source file:org.opentestsystem.authoring.testauth.service.impl.PublishingRecordServiceImpl.java
@Override public PublishingRecord retrievePublishingRecordWithAllowablePurposes(final String assessmentId) { final PublishingRecord publishingRecord = retrieveCurrentPublishingRecord(assessmentId); if (publishingRecord != null) { publishingRecord.setPurpose(Iterables.toArray( this.publishingRecordValidationHelper.determineAvailableSpecTypesForAssessment(assessmentId), Purpose.class)); try {//from w w w.j a v a 2 s . co m this.publishingRecordValidationHelper.verifyCanPublish(publishingRecord, false); } catch (final LocalizedException e) { publishingRecord.setErrorMessageText( this.messageSource.getMessage(e.getMessageCode(), e.getMessageArgs(), Locale.US)); } finally { this.publishingRecordRepository.save(publishingRecord); } } return publishingRecord; }
From source file:org.sonar.server.computation.batch.ComponentTreeRule.java
private Component[] buildChildren(BatchReport.Component component, final BUILD_OPTIONS build_options) { return Iterables .toArray(Iterables.transform(component.getChildRefList(), new Function<Integer, Component>() { @Override/*from w ww .jav a 2 s .c om*/ public Component apply(@Nonnull Integer componentRef) { return newComponent(batchReportReader.readComponent(componentRef), build_options); } }), Component.class); }
From source file:com.inmobi.grill.cli.commands.GrillFactCommands.java
@CliCommand(value = "update fact", help = "update fact table") public String updateFactTable(@CliOption(key = { "", "table" }, mandatory = true, help = "<table-name> <table-spec>") String specPair) { Iterable<String> parts = Splitter.on(' ').trimResults().omitEmptyStrings().split(specPair); String[] pair = Iterables.toArray(parts, String.class); if (pair.length != 2) { return "Syntax error, please try in following " + "format. create fact <fact spec path> <storage spec path>"; }//w w w .ja v a 2 s . com File f = new File(pair[1]); if (!f.exists()) { return "Fact spec path" + f.getAbsolutePath() + " does not exist. Please check the path"; } APIResult result = client.updateFactTable(pair[0], pair[1]); if (result.getStatus() == APIResult.Status.SUCCEEDED) { return "Update of " + pair[0] + " succeeded"; } else { return "Update of " + pair[0] + " failed"; } }
From source file:mods.railcraft.common.core.Railcraft.java
@Mod.EventHandler public void processIMCRequests(FMLInterModComms.IMCEvent event) { Splitter splitter = Splitter.on("@").trimResults(); for (FMLInterModComms.IMCMessage mess : event.getMessages()) { if (mess.key.equals("ballast")) { String[] tokens = Iterables.toArray(splitter.split(mess.getStringValue()), String.class); if (tokens.length != 2) { Game.log(Level.WARN, String.format("Mod %s attempted to register a ballast, but failed: %s", mess.getSender(), mess.getStringValue())); continue; }/*from w w w .jav a 2s .co m*/ String blockName = tokens[0]; Integer metadata = Ints.tryParse(tokens[1]); if (blockName == null || metadata == null) { Game.log(Level.WARN, String.format("Mod %s attempted to register a ballast, but failed: %s", mess.getSender(), mess.getStringValue())); continue; } BallastRegistry.registerBallast(Block.getBlockFromName(blockName), metadata); Game.log(Level.DEBUG, String.format("Mod %s registered %s as a valid ballast", mess.getSender(), mess.getStringValue())); } else if (mess.key.equals("boiler-fuel-liquid")) { String[] tokens = Iterables.toArray(splitter.split(mess.getStringValue()), String.class); if (tokens.length != 2) { Game.log(Level.WARN, String.format("Mod %s attempted to register a liquid Boiler fuel, but failed: %s", mess.getSender(), mess.getStringValue())); continue; } Fluid fluid = FluidRegistry.getFluid(tokens[0]); Integer fuel = Ints.tryParse(tokens[1]); if (fluid == null || fuel == null) { Game.log(Level.WARN, String.format("Mod %s attempted to register a liquid Boiler fuel, but failed: %s", mess.getSender(), mess.getStringValue())); continue; } FuelManager.addBoilerFuel(fluid, fuel); Game.log(Level.DEBUG, String.format("Mod %s registered %s as a valid liquid Boiler fuel", mess.getSender(), mess.getStringValue())); } else if (mess.key.equals("rock-crusher")) { NBTTagCompound nbt = mess.getNBTValue(); ItemStack input = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("input")); IRockCrusherRecipe recipe = RailcraftCraftingManager.rockCrusher.createNewRecipe(input, nbt.getBoolean("matchMeta"), nbt.getBoolean("matchNBT")); for (int i = 0; i < 9; i++) { if (nbt.hasKey("output" + i)) { NBTTagCompound outputNBT = nbt.getCompoundTag("output" + i); recipe.addOutput(ItemStack.loadItemStackFromNBT(outputNBT), outputNBT.getFloat("chance")); } } } } }
From source file:org.apache.lens.cli.commands.LensFactCommands.java
/** * Update fact table./*from w ww. j a v a 2s . c o m*/ * * @param specPair the spec pair * @return the string */ @CliCommand(value = "update fact", help = "update fact table") public String updateFactTable(@CliOption(key = { "", "table" }, mandatory = true, help = "<table-name> <path to table-spec>") String specPair) { Iterable<String> parts = Splitter.on(' ').trimResults().omitEmptyStrings().split(specPair); String[] pair = Iterables.toArray(parts, String.class); if (pair.length != 2) { return "Syntax error, please try in following " + "format. create fact <fact spec path> <storage spec path>"; } File f = new File(pair[1]); if (!f.exists()) { return "Fact spec path" + f.getAbsolutePath() + " does not exist. Please check the path"; } APIResult result = getClient().updateFactTable(pair[0], pair[1]); if (result.getStatus() == APIResult.Status.SUCCEEDED) { return "Update of " + pair[0] + " succeeded"; } else { return "Update of " + pair[0] + " failed"; } }
From source file:org.apache.samza.table.remote.TableWriteFunction.java
/** * Asynchronously store the table {@code records} with specified {@code keys}. This method must be thread-safe. * The default implementation calls putAsync for each entry and return a combined future. * @param records table records to be written * @return CompletableFuture for the put request *//* www. j av a2s .c o m*/ default CompletableFuture<Void> putAllAsync(Collection<Entry<K, V>> records) { List<CompletableFuture<Void>> putFutures = records.stream().map(e -> putAsync(e.getKey(), e.getValue())) .collect(Collectors.toList()); return CompletableFuture.allOf(Iterables.toArray(putFutures, CompletableFuture.class)); }
From source file:com.inmobi.grill.cli.commands.GrillDimensionCommands.java
@CliCommand(value = "update dimension", help = "update dimension table") public String updateDimensionTable(@CliOption(key = { "", "table" }, mandatory = true, help = "<table-name> <table-spec>") String specPair) { Iterable<String> parts = Splitter.on(' ').trimResults().omitEmptyStrings().split(specPair); String[] pair = Iterables.toArray(parts, String.class); if (pair.length != 2) { return "Syntax error, please try in following " + "format. create fact <fact spec path> <storage spec path>"; }//from ww w.j a v a 2s . c om File f = new File(pair[1]); if (!f.exists()) { return "Fact spec path" + f.getAbsolutePath() + " does not exist. Please check the path"; } APIResult result = client.updateDimensionTable(pair[0], pair[1]); if (result.getStatus() == APIResult.Status.SUCCEEDED) { return "Update of " + pair[0] + " succeeded"; } else { return "Update of " + pair[0] + " failed"; } }