List of usage examples for java.util Arrays sort
public static void sort(Object[] a)
From source file:com.alibaba.sample.petstore.dal.dao.ProductDaoTests.java
private void assertProductList(List<Product> products, String... ids) { String[] result = new String[products.size()]; int i = 0;/*from w ww.java 2 s . co m*/ for (Product prod : products) { result[i++] = prod.getProductId(); } Arrays.sort(result); Arrays.sort(ids); assertArrayEquals(ids, result); }
From source file:dao.EntriesListDaoTest.java
/** * Test of getListOfEntries method, of class EntriesListDao. *///ww w . j a v a 2 s . c o m @Test public void testGetListOfEntries() { System.out.println("getListOfEntries With Existant Entries"); EntriesListDao instance = new EntriesListDao(); String[] expResult = new String[3]; expResult[0] = "PAOK"; expResult[1] = "TexnologiaLogismikou2"; expResult[2] = "Trela"; Arrays.sort(expResult); String[] result = instance.getListOfEntries(); Arrays.sort(result); assertArrayEquals("getListOfEntries With Existant Entries", expResult, result); }
From source file:com.reactivetechnologies.analytics.mapper.DataMappers.java
DataMappers() { scanner = new ClassPathScanningCandidateComponentProvider(false); scanner.addIncludeFilter(new TypeFilter() { @Override/* ww w . j av a2 s.c o m*/ public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { if (metadataReader.getClassMetadata().getClassName().equals(DataMappers.class.getName())) return false; String[] iFaces = metadataReader.getClassMetadata().getInterfaceNames(); Arrays.sort(iFaces); return Arrays.binarySearch(iFaces, DataMapper.class.getName()) >= 0; } }); Set<BeanDefinition> set = scanner.findCandidateComponents(ClassUtils.getPackageName(DataMapper.class)); if (set.isEmpty()) { throw new BeanCreationException("No data mapper implementation classes could be found under package [" + ClassUtils.getPackageName(DataMapper.class) + "]"); } for (BeanDefinition bd : set) { try { DataMapper dm = (DataMapper) ObjenesisHelper.newInstance(Class.forName(bd.getBeanClassName())); cache.put(dm.type(), dm); log.debug("Found data mapper:: Type [" + dm.type() + "] \t" + dm.getClass()); } catch (ClassNotFoundException e) { throw new BeanCreationException("Unable to instantiate data mapper class", e); } } }
From source file:es.caib.zkib.jxpath.ri.model.dynabeans.DynaBeanPropertyPointer.java
public String[] getPropertyNames() { /* @todo do something about the sorting - LIKE WHAT? - MJB */ if (names == null) { DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty[] properties = dynaClass.getDynaProperties(); int count = properties.length; boolean hasClass = dynaClass.getDynaProperty("class") != null; if (hasClass) { count--; // Exclude "class" from properties }//from w w w. j a v a 2s . c o m names = new String[count]; for (int i = 0, j = 0; i < properties.length; i++) { String name = properties[i].getName(); if (!hasClass || !name.equals("class")) { names[j++] = name; } } Arrays.sort(names); } return names; }
From source file:org.venice.piazza.servicecontroller.Application.java
/** * Determines if the appropriate bean definitions are available *//*from w w w.j av a2s . c o m*/ public static void inspectSprintEnv(ApplicationContext ctx) { LOGGER.info("Spring Boot Beans"); LOGGER.info("-----------------"); String[] beanNames = ctx.getBeanDefinitionNames(); Arrays.sort(beanNames); for (String beanName : beanNames) { LOGGER.info(beanName); } }
From source file:eu.stratosphere.nephele.executiongraph.ExecutionSignature.java
/** * Calculates the execution signature from the given class name and job ID. * //w ww. jav a 2s .c o m * @param invokableClass * the name of the class to contain the task program * @param jobID * the ID of the job * @return the cryptographic signature of this vertex */ public static synchronized ExecutionSignature createSignature( final Class<? extends AbstractInvokable> invokableClass, final JobID jobID) { // First, try to load message digest algorithm, if necessary if (messageDigest == null) { try { messageDigest = MessageDigest.getInstance(HASHINGALGORITHM); } catch (NoSuchAlgorithmException e) { LOG.error("Unable to load message digest algorithm " + HASHINGALGORITHM); return null; } } // Reset digest buffer and add the name of the invokable class to the message digest buffer messageDigest.reset(); messageDigest.update(invokableClass.getName().getBytes()); String[] requiredJarFiles; // Next, retrieve the JAR-files associated with this job try { requiredJarFiles = LibraryCacheManager.getRequiredJarFiles(jobID); } catch (IOException ioe) { // Output an error message and return LOG.error("Cannot access library cache manager for job ID " + jobID); return null; } // Now, sort the list of JAR-files in order to always calculate the signature in the same manner Arrays.sort(requiredJarFiles); // Finally, add the names of the JAR-files to the hash calculation for (int i = 0; i < requiredJarFiles.length; i++) { messageDigest.update(requiredJarFiles[i].getBytes()); } return new ExecutionSignature(messageDigest.digest()); }
From source file:bb.mcmc.analysis.ConvergeStatUtils.java
protected static double quantileType7InR(double[] x, double q) { final double[] tempX = x.clone(); Arrays.sort(tempX); final int n = tempX.length; final double index = 1 + (n - 1) * q; final double lo = Math.floor(index); final double hi = Math.ceil(index); Arrays.sort(tempX);//from www .j a va 2s . c o m double qs = tempX[(int) lo - 1]; final double h = index - lo; if (h != 0) { qs = (1 - h) * qs + h * tempX[(int) hi - 1]; } return qs; }
From source file:net.minecraftforge.fml.common.discovery.DirectoryDiscoverer.java
public void exploreFileSystem(String path, File modDir, List<ModContainer> harvestedMods, ModCandidate candidate, @Nullable MetadataCollection mc) { if (path.length() == 0) { File metadata = new File(modDir, "mcmod.info"); try {/* ww w . j ava 2 s . c o m*/ FileInputStream fis = new FileInputStream(metadata); try { mc = MetadataCollection.from(fis, modDir.getName()); } finally { IOUtils.closeQuietly(fis); } FMLLog.fine("Found an mcmod.info file in directory %s", modDir.getName()); } catch (Exception e) { mc = MetadataCollection.from(null, ""); FMLLog.fine("No mcmod.info file found in directory %s", modDir.getName()); } } File[] content = modDir.listFiles(new ClassFilter()); // Always sort our content Arrays.sort(content); for (File file : content) { if (file.isDirectory()) { FMLLog.finer("Recursing into package %s", path + file.getName()); exploreFileSystem(path + file.getName() + "/", file, harvestedMods, candidate, mc); continue; } Matcher match = classFile.matcher(file.getName()); if (match.matches()) { ASMModParser modParser = null; FileInputStream fis = null; try { fis = new FileInputStream(file); modParser = new ASMModParser(fis); candidate.addClassEntry(path + file.getName()); } catch (LoaderException e) { FMLLog.log(Level.ERROR, e, "There was a problem reading the file %s - probably this is a corrupt file", file.getPath()); throw e; } catch (Exception e) { throw Throwables.propagate(e); } finally { IOUtils.closeQuietly(fis); } modParser.validate(); modParser.sendToTable(table, candidate); ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer(), candidate); if (container != null) { harvestedMods.add(container); container.bindMetadata(mc); } } } }
From source file:net.ontopia.topicmaps.utils.KeyGenerator.java
/** * PUBLIC: Makes a key for an association. The key is made up from * the type and for each role its type and player. * @param assoc The association to make a key for * @return string containing key/*www . j a va 2 s . c o m*/ */ public static String makeAssociationKey(AssociationIF assoc) { StringBuilder sb = new StringBuilder(); // asssociation type key fragment sb.append(makeTypedKey(assoc)).append(SPACER).append(makeScopeKey(assoc)).append(SPACER); List<AssociationRoleIF> roles = new ArrayList<AssociationRoleIF>(assoc.getRoles()); String[] rolekeys = new String[roles.size()]; for (int i = 0; i < rolekeys.length; i++) rolekeys[i] = makeAssociationRoleKey(roles.get(i)); Arrays.sort(rolekeys); sb.append(StringUtils.join(rolekeys, SPACER)); return sb.toString(); }
From source file:com.blockwithme.lessobjects.schema.StructBinding.java
/** Converts a Struct Child array into StructBinding array */ @SuppressWarnings("null") private static StructBinding[] convertChildren(@Nullable final Struct[] theChildren) { final StructBinding[] sbArray; if (theChildren != null && theChildren.length > 0) { Arrays.sort(theChildren); sbArray = new StructBinding[theChildren.length]; for (int i = 0; i < theChildren.length; i++) { sbArray[i] = new StructBinding(theChildren[i]); }/* www . j a v a 2 s . co m*/ } else { sbArray = STRUCT_BINDINGS_EMPTY_ARRAY; } return sbArray; }