List of usage examples for org.apache.commons.lang ArrayUtils toString
public static String toString(Object array)
Outputs an array as a String, treating null
as an empty array.
From source file:org.sonar.api.utils.WorkUnit.java
public static WorkUnit create(@Nullable Double value, @Nullable String unit) { String defaultIfEmptyUnit = StringUtils.defaultIfEmpty(unit, DEFAULT_UNIT); if (!ArrayUtils.contains(UNITS, defaultIfEmptyUnit)) { throw new IllegalArgumentException("Unit can not be: " + defaultIfEmptyUnit + ". Possible values are " + ArrayUtils.toString(UNITS)); }//w w w .j a va 2s . c o m double d = value != null ? value : DEFAULT_VALUE; if (d < 0.0) { throw new IllegalArgumentException("Value can not be negative: " + d); } return new WorkUnit(d, defaultIfEmptyUnit); }
From source file:org.sonar.core.technicaldebt.WorkUnit.java
public static WorkUnit create(@Nullable Double value, @Nullable String unit) { unit = StringUtils.defaultIfEmpty(unit, DEFAULT_UNIT); if (!ArrayUtils.contains(UNITS, unit)) { throw new IllegalArgumentException("Remediation factor unit can not be: " + unit + ". Possible values are " + ArrayUtils.toString(UNITS)); }//from w ww.j a va2 s .c o m double d = value != null ? value : DEFAULT_VALUE; if (d < 0.0) { throw new IllegalArgumentException("Remediation factor can not be negative: " + d); } return new WorkUnit(d, unit); }
From source file:org.sonatype.flexmojos.compiler.SwcMojo.java
@Override public void setUp() throws MojoExecutionException, MojoFailureException { // need to initialize builder before go super builder = new Library(); if (directory != null) { builder.setDirectory(directory); }/*from w w w. j a v a 2 s. c om*/ super.setUp(); builder.setOutput(getOutput()); if (checkNullOrEmpty(includeClasses) && checkNullOrEmpty(includeFiles) && checkNullOrEmpty(includeNamespaces) && checkNullOrEmpty(includeSources) && checkNullOrEmpty(includeStylesheet) && checkNullOrEmpty(includeResourceBundles) && checkNullOrEmpty(includeAsClasses)) { getLog().warn("Nothing expecified to include. Assuming source and resources folders."); List<File> sourcePaths = new ArrayList<File>(Arrays.asList(this.sourcePaths)); sourcePaths.remove(new File(resourceBundlePath)); includeSources = sourcePaths.toArray(new File[0]); includeFiles = listAllResources(); } if (!checkNullOrEmpty(includeAsClasses)) { String[] includedClasses = this.getClassesFromPaths(); getLog().info( "Including " + includedClasses.length + " classes to compile with <includeAsClasses> option."); if (getLog().isDebugEnabled()) { getLog().debug("Classes included with <includeAsClasses> option: " + ArrayUtils.toString(includedClasses) + "."); } for (String includeClass : includedClasses) { builder.addComponent(includeClass); } } if (!checkNullOrEmpty(includeClasses)) { for (String asClass : includeClasses) { builder.addComponent(asClass); } } if (!checkNullOrEmpty(includeFiles)) { List<String> includeFilesNames = new ArrayList<String>(); List<String> includeFilesPaths = new ArrayList<String>(); for (String includeFile : includeFiles) { if (includeFile == null) { throw new MojoFailureException("Cannot include a null file"); } File file = MavenUtils.resolveResourceFile(project, includeFile); File folder = getResourceFolder(file); // If the resource is external to project add on root String relativePath = PathUtil.getRelativePath(folder, file); if (relativePath.startsWith("..")) { relativePath = file.getName(); } relativePath = relativePath.replace('\\', '/'); if (configurationReport) { includeFilesNames.add(relativePath); includeFilesPaths.add(file.getAbsolutePath()); } builder.addArchiveFile(relativePath, file); } if (configurationReport) { this.includeFilesNames = includeFilesNames; this.includeFilesPaths = includeFilesPaths; } } if (!checkNullOrEmpty(includeNamespaces)) { for (String uri : includeNamespaces) { try { builder.addComponent(new URI(uri)); } catch (URISyntaxException e) { throw new MojoExecutionException("Invalid URI " + uri, e); } } } if (!checkNullOrEmpty(includeSources)) { for (File file : includeSources) { if (file == null) { throw new MojoFailureException("Cannot include a null file"); } if (!file.getName().contains("{locale}") && !file.exists()) { throw new MojoFailureException("File " + file + " not found"); } builder.addComponent(file); } } includeStylesheet(); computeDigest(); if (addMavenDescriptor) { builder.addArchiveFile("maven/" + project.getGroupId() + "/" + project.getArtifactId() + "/pom.xml", new File(project.getBasedir(), "pom.xml")); } }
From source file:org.springbyexample.web.service.EmbeddedJetty.java
@PostConstruct public void init() throws Exception { ctx = new ClassPathXmlApplicationContext(); ((AbstractApplicationContext) ctx).getEnvironment().setActiveProfiles(activeProfiles); ((AbstractXmlApplicationContext) ctx).setConfigLocations(configLocations); if (logger.isInfoEnabled()) { logger.info("Creating embedded jetty context. activeProfiles='{}' configLocations='{}'", new Object[] { ArrayUtils.toString(activeProfiles), ArrayUtils.toString(configLocations) }); }//from w w w. j a va2s . co m ((AbstractXmlApplicationContext) ctx).refresh(); ((AbstractApplicationContext) ctx).registerShutdownHook(); Server server = (Server) ctx.getBean("jettyServer"); if (port > 0) { Connector connector = server.getConnectors()[0]; connector.setPort(port); } ServletContext servletContext = null; for (Handler handler : server.getHandlers()) { if (handler instanceof Context) { Context context = (Context) handler; if (StringUtils.hasText(contextPath)) { context.setContextPath("/" + contextPath); } servletContext = context.getServletContext(); // setup Spring Security Filter FilterHolder filterHolder = new FilterHolder(); filterHolder.setName(SECURITY_FILTER_NAME); filterHolder.setClassName(DelegatingFilterProxy.class.getName()); context.getServletHandler().addFilterWithMapping(filterHolder, "/*", 0); break; } } XmlWebApplicationContext wctx = new XmlWebApplicationContext(); wctx.setParent(ctx); wctx.setConfigLocation(""); wctx.setServletContext(servletContext); wctx.refresh(); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wctx); server.start(); logger.info("Server started."); }
From source file:org.talend.librariesmanager.ui.dialogs.ExternalModulesInstallDialogWithProgress.java
/** * show the dialog/*from w w w. jav a2 s . co m*/ * * @param block, whether the this method is blocked until the dialog is closed * @param requiredJars, list of required jars */ public void showDialog(boolean block, String[] requiredJars) { if (ArrayUtils.contains(Platform.getApplicationArgs(), EclipseCommandLine.TALEND_DISABLE_EXTERNAL_MODULE_INSTALL_DIALOG_COMMAND)) { CommonExceptionHandler.warn("missing jars: " + ArrayUtils.toString(requiredJars)); //$NON-NLS-1$ return; } IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance() .getNotInstalledModulesRunnable(requiredJars, inputList); setBlockOnOpen(block); setInitialRunnable(notInstalledModulesRunnable); open(); }
From source file:org.terrier.tests.BlockOnDiskShakespeareEndToEndTest.java
@Override protected void doIndexing(String... trec_terrier_args) throws Exception { String indextype = "blocks"; if (ArrayUtils.toString(trec_terrier_args).contains("FieldTags.process")) indextype = "fieldsblocks"; else/* w w w . j a v a 2 s . co m*/ FieldScore.FIELDS_COUNT = 0; Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".direct.bf", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".direct.bf"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".document.fsarrayfile", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".document.fsarrayfile"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".inverted.bf", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".inverted.bf"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".lexicon.fsomapfile", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".lexicon.fsomapfile"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".lexicon.fsomaphash", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".lexicon.fsomaphash"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".lexicon.fsomapid", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".lexicon.fsomapid"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".meta-0.fsomapfile", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".meta-0.fsomapfile"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".meta.idx", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".meta.idx"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".meta.zdata", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".meta.zdata"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".properties", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".properties"); //check that indexing actually created an index assertTrue( "Index does not exist at [" + ApplicationSetup.TERRIER_INDEX_PATH + "," + ApplicationSetup.TERRIER_INDEX_PREFIX + "]", Index.existsIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX)); IndexOnDisk i = Index.createIndex(); assertNotNull(Index.getLastIndexLoadError(), i); assertEquals(ApplicationSetup.TERRIER_VERSION, i.getIndexProperty("index.terrier.version", "")); assertTrue("Index does not have an inverted structure", i.hasIndexStructure("inverted")); assertTrue("Index does not have an lexicon structure", i.hasIndexStructure("lexicon")); assertTrue("Index does not have an document structure", i.hasIndexStructure("document")); assertTrue("Index does not have an meta structure", i.hasIndexStructure("meta")); addDirectStructure(i); i.close(); finishIndexing(); }
From source file:org.terrier.tests.OnDiskShakespeareEndToEndTest.java
@Override protected void doIndexing(String... trec_terrier_args) throws Exception { String indextype = "basic"; if (ArrayUtils.toString(trec_terrier_args).contains("FieldTags.process")) indextype = "fields"; else/* w ww . j av a 2s . c om*/ FieldScore.FIELDS_COUNT = 0; Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".direct.bf", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".direct.bf"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".document.fsarrayfile", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".document.fsarrayfile"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".inverted.bf", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".inverted.bf"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".lexicon.fsomapfile", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".lexicon.fsomapfile"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".lexicon.fsomaphash", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".lexicon.fsomaphash"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".lexicon.fsomapid", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".lexicon.fsomapid"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".meta-0.fsomapfile", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".meta-0.fsomapfile"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".meta.idx", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".meta.idx"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".meta.zdata", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".meta.zdata"); Files.copyFile("share/tests/shakespeare/indices/terrier-3.x/shak-" + indextype + ".properties", ApplicationSetup.TERRIER_INDEX_PATH + ApplicationSetup.FILE_SEPARATOR + ApplicationSetup.TERRIER_INDEX_PREFIX + ".properties"); //check that indexing actually created an index assertTrue( "Index does not exist at [" + ApplicationSetup.TERRIER_INDEX_PATH + "," + ApplicationSetup.TERRIER_INDEX_PREFIX + "]", Index.existsIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX)); IndexOnDisk i = Index.createIndex(); assertNotNull(Index.getLastIndexLoadError(), i); assertEquals(ApplicationSetup.TERRIER_VERSION, i.getIndexProperty("index.terrier.version", "")); assertTrue("Index does not have an inverted structure", i.hasIndexStructure("inverted")); assertTrue("Index does not have an lexicon structure", i.hasIndexStructure("lexicon")); assertTrue("Index does not have an document structure", i.hasIndexStructure("document")); assertTrue("Index does not have an meta structure", i.hasIndexStructure("meta")); addDirectStructure(i); i.close(); finishIndexing(); }
From source file:org.xwiki.contrib.mail.internal.AbstractMailStore.java
@Override public ArrayList<FolderItem> getFolderTree() throws MessagingException { getLogger().debug("getFolderTree"); assert (getMailSource() != null); ArrayList<FolderItem> folderItems = new ArrayList<FolderItem>(); Store store = getJavamailStore();/*from www .ja v a2 s .com*/ store.connect(); Folder defaultFolder = store.getDefaultFolder(); FolderItem item = new FolderItem(); item.setIndex(0); item.setLevel(0); item.setName(defaultFolder.getName()); item.setFullName(defaultFolder.getFullName()); if ((defaultFolder.getType() & javax.mail.Folder.HOLDS_MESSAGES) != 0) { item.setMessageCount(defaultFolder.getMessageCount()); item.setUnreadMessageCount(defaultFolder.getUnreadMessageCount()); item.setNewMessageCount(defaultFolder.getNewMessageCount()); } Folder[] folders = defaultFolder.list("*"); if (ArrayUtils.isEmpty(folders)) { folders = defaultFolder.list(); } getLogger().debug("Found folders {}", ArrayUtils.toString(folders)); int index = 1; int level = 1; // TODO not really managing folders here, just listing them for (Folder folder : folders) { item = new FolderItem(); item.setIndex(index); item.setLevel(level); item.setName(folder.getName()); item.setFullName(folder.getFullName()); if ((folder.getType() & javax.mail.Folder.HOLDS_MESSAGES) != 0) { item.setMessageCount(folder.getMessageCount()); item.setUnreadMessageCount(folder.getUnreadMessageCount()); item.setNewMessageCount(folder.getNewMessageCount()); folderItems.add(item); } } store.close(); return folderItems; }
From source file:psidev.psi.mi.tab.model.builder.MitabParserUtils.java
public static List<CrossReference> splitCrossReferences(String column) throws IllegalFormatException { List<CrossReference> objects = new ArrayList<CrossReference>(); CrossReference object = null;// w w w . j a v a 2 s .c om if (column != null && !column.isEmpty()) { String[] fields = MitabParserUtils.quoteAwareSplit(column, new char[] { '|' }, false); for (String field : fields) { if (field != null) { String[] result = MitabParserUtils.quoteAwareSplit(field, new char[] { ':', '(', ')' }, true); if (result != null) { int length = result.length; // some exception handling if (length == 0 || length > 3) { throw new IllegalFormatException( "String cannot be parsed to create a cross reference (check the syntax): " + Arrays.asList(result).toString()); } if (length == 1) { //Backward compatibility if (field.equalsIgnoreCase("spoke")) { object = new CrossReferenceImpl("psi-mi", "MI:1060", "spoke expansion"); } else if (field.equalsIgnoreCase("matrix")) { object = new CrossReferenceImpl("psi-mi", "MI:1061", "matrix expansion"); } else if (field.equalsIgnoreCase("bipartite")) { object = new CrossReferenceImpl("psi-mi", "MI:1062", "bipartite expansion"); } else if (!result[0].equalsIgnoreCase("-")) { throw new IllegalFormatException( "String cannot be parsed to create a cross reference (check the syntax): " + ArrayUtils.toString(result)); } } else if (length == 2) { object = new CrossReferenceImpl(result[0], result[1]); } else if (length == 3) { object = new CrossReferenceImpl(result[0], result[1], result[2]); } if (object != null) { objects.add(object); } } } } } return objects; }
From source file:pt.lsts.neptus.console.plugins.planning.VerticalFormationWizard.java
private void generatePlan() throws Exception { System.out.println("GENERATE PLAN"); PlanType plan = planSelection.getSelection().iterator().next(); ArrayList<VehicleType> vehicles = new ArrayList<>(); vehicles.addAll(vehicleSelection.getSelection()); VerticalFormationOptions params = options.getSelection(); ArrayList<ManeuverLocation> locations = new ArrayList<>(); locations.addAll(PlanUtil.getPlanWaypoints(plan)); double bearing = 0; if (locations.size() > 1) bearing = locations.get(1).getXYAngle(locations.get(0)); long arrivalTime = System.currentTimeMillis() + params.startInMins * 60 * 1000; double depth = params.firstDepthMeters; int v = 0;// w ww . j ava2s. c om for (VehicleType vehicle : vehicles) { PlanType generated = new PlanType(getConsole().getMission()); generated.setVehicle(vehicle); generated.setId(params.planId + "_" + vehicle.getId()); ManeuverLocation first = new ManeuverLocation(locations.get(0)); first.setZ(depth); first.setZUnits(Z_UNITS.DEPTH); FollowTrajectory formation = new FollowTrajectory(); formation.setManeuverLocation(new ManeuverLocation(first)); formation.setSpeedUnits(Maneuver.SPEED_UNITS.METERS_PS); formation.setSpeed(params.speedMps); formation.setId("3"); Vector<double[]> waypoints = new Vector<>(); LocationType previous = first; for (LocationType l : locations) { double[] point = new double[4]; double[] offsets = l.getOffsetFrom(first); double time = l.getHorizontalDistanceInMeters(previous) / params.speedMps; point[0] = offsets[0]; point[1] = offsets[1]; point[2] = 0; point[3] = time; System.out .println("Using time " + time + " to travel " + l.getHorizontalDistanceInMeters(previous)); previous = l; System.out.println(ArrayUtils.toString(point)); waypoints.addElement(point); } formation.setOffsets(waypoints); double offsetX = 50 * Math.cos(bearing); double offsetY = 50 * Math.sin(bearing); ManeuverLocation s1 = new ManeuverLocation(first); s1.translatePosition(offsetX, offsetY, 0); ScheduledGoto man1 = new ScheduledGoto(); man1.setId("1"); man1.setManeuverLocation(s1); man1.setArrivalTime(new Date(arrivalTime)); ScheduledGoto man2 = new ScheduledGoto(); man2.setId("2"); man2.setManeuverLocation(new ManeuverLocation(first)); man2.setArrivalTime(new Date(arrivalTime + 50 * 1000)); ManeuverLocation end1 = new ManeuverLocation(formation.getEndLocation()); double off = (v % 2 == 1) ? v * 30 : v * -30; end1.translatePosition(30, off, 0); Goto man3 = new Goto(); man3.setId("4"); man3.setManeuverLocation(end1); ManeuverLocation end2 = new ManeuverLocation(end1); end2.setZ(0); StationKeeping sk = new StationKeeping(); sk.setDuration(0); sk.setId("5"); sk.setManeuverLocation(end2); generated.getGraph().addManeuver(man1); generated.getGraph().addManeuver(man2); generated.getGraph().addManeuver(formation); generated.getGraph().addManeuver(man3); generated.getGraph().addManeuver(sk); generated.getGraph().addTransition(man1.getId(), man2.getId(), "true"); generated.getGraph().addTransition(man2.getId(), formation.getId(), "true"); generated.getGraph().addTransition(formation.getId(), man3.getId(), "true"); generated.getGraph().addTransition(man3.getId(), sk.getId(), "true"); PlanUtil.setPlanSpeed(generated, params.speedMps); getConsole().getMission().addPlan(generated); v++; depth += params.depthSeparationMeters; } getConsole().getMission().save(true); getConsole().warnMissionListeners(); }