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:edu.cornell.med.icb.R.script.TestRDataObject.java
/** * JUnit doesn't provide an assertArrayEquals for double[] values, so this is my version. * @param expected expected values/*from w w w . j a v a 2 s .co m*/ * @param actual actual values */ public static void assertDoubleArrayEquals(final double[] expected, final double[] actual) { assert expected.length == actual.length; String errorMessage = String.format("double[] values not equal. Expected=%s Actual=%s", ArrayUtils.toString(expected), ArrayUtils.toString(actual)); assertTrue(errorMessage, ArrayUtils.isEquals(expected, actual)); }
From source file:com.discursive.jccook.io.FilterExample.java
public void start() { File rootDir = new File("."); FilenameFilter fileFilter = new SuffixFileFilter(".xml"); String[] xmlFiles = rootDir.list(fileFilter); System.out.println("*** XML Files"); System.out.println(ArrayUtils.toString(xmlFiles)); rootDir = new File("./test"); IOFileFilter htmlFilter = new OrFileFilter(new SuffixFileFilter("htm"), new SuffixFileFilter("html")); IOFileFilter notDirectory = new NotFileFilter(DirectoryFileFilter.INSTANCE); fileFilter = new AndFileFilter(htmlFilter, notDirectory); String[] htmlFiles = rootDir.list(fileFilter); System.out.println("*** HTML Files"); System.out.println(ArrayUtils.toString(htmlFiles)); }
From source file:com.dianping.avatar.cache.CacheKey.java
@Override public String toString() { return "CacheKey[category:" + category + ", indexParams:" + ArrayUtils.toString(params) + "]"; }
From source file:de.inovex.auth.token.ignore.CustomCSRFWhitelistActionFilter.java
@Override public void init(final FilterConfig filterConfig) throws PortletException { LOG.debug("Filter init"); String[] whitelistKeyValues = getWhitelistKeyValues(filterConfig); LOG.debug("Configured values: " + ArrayUtils.toString(whitelistKeyValues)); if (whitelistKeyValues != null) { initParameterList(whitelistKeyValues); }/*from ww w . j a v a 2 s .c o m*/ LOG.debug("Filter init completed"); }
From source file:beans.HmacImpl.java
@Override public String sign(Object... objs) { try {//from w ww .j a v a 2s .c om List objects = CollectionUtils.addTo(new LinkedList(), objs); objects.add(conf.application.secret); // add the secret so no-one can reproduce this string. String joined = StringUtils.join(objs, SEPARATOR); byte[] base64Result = Base64.encodeBase64(joined.getBytes()); byte[] md5s = MessageDigest.getInstance("MD5").digest(base64Result); StringBuffer sb = new StringBuffer(); for (byte md5 : md5s) { sb.append(Integer.toString((md5 & 0xff) + 0x100, 16).substring(1)); } return sb.toString(); } catch (Exception e) { throw new RuntimeException("unable to sign Hmac for " + ArrayUtils.toString(objs), e); } }
From source file:net.sf.reportengine.util.TestCoefficients.java
/** * Test method for {@link net.sf.reportengine.util.CrossTabCoefficients#Coefficients(java.lang.String[][], boolean)}. *//*from w w w . j av a2 s . c om*/ public void testCoefficientsNoTotals1() { String[][] distinctValues = new String[][] { new String[] { "North", "South", "East", "West" }, new String[] { "M", "F" } }; classUnderTest = new CrossTabCoefficients(distinctValues, false); assertNotNull(classUnderTest); //test colcount and rowcount assertEquals(classUnderTest.getTemplateColumnCount(), 8); assertEquals(classUnderTest.getTemplateRowCount(), 2); //test number of distinct values per row int[] result = classUnderTest.getDistValuesCntInHeaderRow(); assertNotNull(result); System.out.println("Distinct Values : " + ArrayUtils.toString(result)); assertTrue(ArrayUtils.isEquals(result, new int[] { 4, 2 })); //test number of spaces result = classUnderTest.getSpacesCntInHeaderRow(); assertNotNull(result); System.out.println("Spaces Cnt (if totals were displayed): " + ArrayUtils.toString(result)); assertTrue(ArrayUtils.isEquals(result, new int[] { 0, 0 })); //test number of totals result = classUnderTest.getTotalsCntInHeaderRow(); assertNotNull(result); System.out.println("Totals Cnt : " + ArrayUtils.toString(result)); assertTrue(ArrayUtils.isEquals(result, new int[] { 0, 0 })); //test number of totals result = classUnderTest.getColspanPerRow(); assertNotNull(result); System.out.println("Distance between distinct header values : " + ArrayUtils.toString(result)); assertTrue(ArrayUtils.isEquals(result, new int[] { 2, 1 })); }
From source file:com.adguard.compiler.PackageUtils.java
private static void execute(String... commands) throws IOException, InterruptedException { ProcessBuilder pb = new ProcessBuilder(commands); Process p = pb.start();//www . j a va 2 s. c o m BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = reader.readLine()) != null) { log.debug(line); } p.waitFor(); if (p.exitValue() != 0) { reader = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((line = reader.readLine()) != null) { log.error(line); } throw new IOException("Command " + ArrayUtils.toString(commands) + " not success"); } }
From source file:it.grid.storm.griduser.LcmapsJNAMapper.java
public LocalUser map(String dn, String[] fqans) throws CannotMapUserException { LocalUser mappedUser = null;// ww w.j a va 2 s .co m synchronized (LcmapsJNAMapper.lock) { log.debug("Mapping user with dn = {} and fqans='{}'", dn, ArrayUtils.toString(fqans)); log.debug("Initializing Lcmaps"); String lcmapsLogFile = getLcmapsLogFile(); log.debug("Lcmaps log file is {}", lcmapsLogFile); int retVal = LcmapsInterface.INSTANCE.lcmaps_init_and_logfile(lcmapsLogFile, null, LCMAPS_LOG_TYPE); if (retVal != 0) { log.error("Unable to initialize lcmaps. Return value is {}", retVal); throw new CannotMapUserException("Unable to initialize lcmaps. Return value is " + retVal); } retVal = LcmapsAccountInterface.INSTANCE.lcmaps_account_info_init(account); if (retVal != 0) { throw new CannotMapUserException("Unable to initialize lcmaps. Return value is " + retVal); } int numFqans = (fqans == null ? 0 : fqans.length); try { retVal = LcmapsPoolindexInterface.INSTANCE.lcmaps_return_account_without_gsi(dn, fqans, numFqans, 0, account); } catch (LastErrorException e) { log.error("Unable to map user dn <{}> fqans <{}>. Error: {}. Error code: {}", dn, ArrayUtils.toString(fqans), e.getMessage(), e.getErrorCode(), e); throw new CannotMapUserException("Unable to initialize lcmaps. Return value is " + retVal); } if (retVal != 0) { log.error("Unable to map user dn <{}> fqans <{}>. Retval: {}", dn, ArrayUtils.toString(fqans), retVal); throw new CannotMapUserException("Unable to map user dn <" + dn + "> fqans <" + ArrayUtils.toString(fqans) + "> . Return value is " + retVal); } if (account.uid < 0) { log.error("Negative uid returned by lcmaps: {}", account.uid); throw new CannotMapUserException("Unacceptable lower than zero uid returned by Lcmaps : " + account.uid + " . Mapping error"); } if (account.npgid < 0 || account.nsgid < 0) { log.error("Negative primary or secondary gid array size. npgid: {} nsgid: {}", account.npgid, account.nsgid); throw new CannotMapUserException( "Negative primary or secondary gid array size returned by Lcmaps : primary = " + account.npgid + ", secondary = " + account.nsgid + ". Mapping error"); } int[] gids = null; int numGids = account.npgid + account.nsgid; if (numGids > account.npgid) { gids = new int[numGids]; int index = 0; if (account.npgid > 0) { for (int gid : account.pgid_list.getPointer().getIntArray(0, account.npgid)) { gids[index] = gid; index++; } } else { log.warn("No primary gid returned by Lcmaps! Mapping error"); } for (int gid : account.sgid_list.getPointer().getIntArray(0, account.nsgid)) { gids[index] = gid; index++; } } else { if (account.npgid > 0) { gids = account.pgid_list.getPointer().getIntArray(0, account.npgid); } } log.info("Mapped user to : <uid={},gids={}>", account.uid, ArrayUtils.toString(gids)); mappedUser = new LocalUser(account.uid, gids, numGids); } return mappedUser; }
From source file:net.sourceforge.atunes.kernel.modules.player.PlayerEngineSelector.java
/** * Selects player engine// w w w . j a va 2s.com * * @return player engine or null */ IPlayerEngine selectPlayerEngine() { List<AbstractPlayerEngine> availableEngines = getAvailableEngines(); if (availableEngines.isEmpty()) { return null; } engineNames = getEngineNames(availableEngines); Logger.info("List of availables engines : ", ArrayUtils.toString(engineNames)); // Get engine of application state (default or selected by user) String selectedEngine = statePlayer.getPlayerEngine(); // If selected engine is not available then try default engine or // another one if (!ArrayUtils.contains(engineNames, selectedEngine)) { Logger.info(selectedEngine, " is not availaible"); selectedEngine = selectDefaultEngine(availableEngines); } for (AbstractPlayerEngine engine : availableEngines) { if (engine.getEngineName().equals(selectedEngine)) { return engine; } } return null; }
From source file:com.kylinolap.metadata.validation.rule.MandatoryColumnRule.java
@Override public void validate(CubeDesc cube, ValidateContext context) { Set<String> mands = new HashSet<String>(); RowKeyColDesc[] cols = cube.getRowkey().getRowKeyColumns(); if (cols == null || cols.length == 0) { return;//from w w w .j ava 2 s .c o m } for (int i = 0; i < cols.length; i++) { RowKeyColDesc rowKeyColDesc = cols[i]; if (rowKeyColDesc.isMandatory()) { mands.add(rowKeyColDesc.getColumn()); } } if (mands.isEmpty()) { return; } String[][] groups = cube.getRowkey().getAggregationGroups(); for (int i = 0; i < groups.length; i++) { String[] group = groups[i]; for (int j = 0; j < group.length; j++) { String col = group[j]; if (mands.contains(col)) { context.addResult(ResultLevel.ERROR, "mandatory column " + col + " must not be in aggregation group [" + ArrayUtils.toString(group) + "]"); } } } }