List of usage examples for java.util Arrays toString
public static String toString(Object[] a)
From source file:Main.java
/** my code to convert from List<Double> to double[] * *///ww w. ja v a2s .c o m public static float[] toFloatArray(List<Float> lf) { float[] results = new float[lf.size()]; int i = 0; for (Float f : lf) { results[i++] = (f != null ? f : 0); } Log.i("TAG", "float conversion results " + Arrays.toString(results)); return results; }
From source file:Main.java
public static String findSettableValue(String name, Collection<String> supportedValues, String... desiredValues) { Log.i(TAG, "Requesting " + name + " value from among: " + Arrays.toString(desiredValues)); Log.i(TAG, "Supported " + name + " values: " + supportedValues); if (supportedValues != null) { for (String desiredValue : desiredValues) { if (supportedValues.contains(desiredValue)) { Log.i(TAG, "Can set " + name + " to: " + desiredValue); return desiredValue; }/*from w ww .j a va 2 s. c o m*/ } } Log.i(TAG, "No supported values match"); return null; }
From source file:Main.java
/** * {@link Arrays#toString(Object[])} with {@link Arrays#toString(Object[])} for array elements *//* w w w . j av a2 s . c o m*/ public static Object arrayToString(Object obj) { if (obj != null && obj.getClass().isArray()) { int len = Array.getLength(obj); String[] strings = new String[len]; for (int i = 0; i < len; i++) { strings[i] = String.valueOf(Array.get(obj, i)); } return Arrays.toString(strings); } else { return obj; } }
From source file:Main.java
/** * Returns a string composed from a {@link SparseArray}. *//*from w w w. j ava 2s .com*/ static String toString(SparseArray<byte[]> array) { if (array == null) { return "null"; } if (array.size() == 0) { return "{}"; } StringBuilder buffer = new StringBuilder(); buffer.append('{'); for (int i = 0; i < array.size(); ++i) { buffer.append(array.keyAt(i)).append("=").append(Arrays.toString(array.valueAt(i))); } buffer.append('}'); return buffer.toString(); }
From source file:eu.socialSensor.diverseImages2014.datasetCreation.MakeRelevanceDataset.java
/** * @param args//from w w w. ja va 2 s . c om * [0] collection path<br> * [1] comma separated feature types e.g. "HOG,SURF,CM" <br> * [2] comma separated individual feature normalizations e.g. "l2,no,l2" <br> * [3] the type of normalization to apply on the concatenation of the features that are * individually normalized, e.g. "l2" or "no" <br> * [4] the type of normalization to apply on the overall vector, e.g. "l2" or "no" <br> * [5] whether to include Wikipedia image vectors <br> * [6] whether to write the dataset in sparse format<br> * [7] the filename extension (typically "dev" or "test") * * @throws Exception */ public static void main(String[] args) throws Exception { String collectionPath = args[0]; String[] featureTypes = args[1].split(","); String[] individualNorms = args[2].split(","); if (featureTypes.length != individualNorms.length) { throw new Exception("Features types and normalizations have different sizes!"); } String level1Norm = args[3]; String finalNorm = args[4]; boolean includeWiki = Boolean.parseBoolean(args[5]); boolean writeSparse = Boolean.parseBoolean(args[6]); String datasetExtension = args[7]; MEDI2014Collection dataStoreTrain = new MEDI2014Collection(collectionPath); dataStoreTrain.loadAll(includeWiki, featureTypes, individualNorms); MakeRelevanceDataset marf = new MakeRelevanceDataset(dataStoreTrain, featureTypes); String arffFileName = Arrays.toString(featureTypes) + "-" + Arrays.toString(individualNorms) + "-" + level1Norm + "-" + finalNorm; arffFileName += "-" + datasetExtension + ".arff"; marf.writeFile(arffFileName, individualNorms, level1Norm, finalNorm, writeSparse); }
From source file:Main.java
/** * Finds the best possible value out of the list of supported values * @param name name of the desired mode the values are searched for * @param supportedValues the supported values * @param desiredValues the desired values with descending priority * @return the best possible value/* www. j ava 2 s . c o m*/ */ private static String findSettableValue(String name, Collection<String> supportedValues, String... desiredValues) { Log.i(TAG, "Requesting " + name + " value from among: " + Arrays.toString(desiredValues)); Log.i(TAG, "Supported " + name + " values: " + supportedValues); if (supportedValues != null) { for (String desiredValue : desiredValues) { if (supportedValues.contains(desiredValue)) { Log.i(TAG, "Can set " + name + " to: " + desiredValue); return desiredValue; } } } Log.i(TAG, "No supported values match"); return null; }
From source file:Main.java
public static Map<String, Object> toMap(String[] names, Object[] parameters) { Map<String, Object> map = new HashMap<String, Object>(); if (parameters == null || parameters.length == 0) { return map; }/*from w w w .j a va2 s . com*/ if (names == null || names.length < parameters.length) { throw new IllegalArgumentException("Mismatch parameters. names: " + Arrays.toString(names) + ", values: " + Arrays.toString(parameters)); } for (int i = 0; i < parameters.length; i++) { map.put(names[i], parameters[i]); } return map; }
From source file:Main.java
public static <E> String collectionToString(final Collection<E> collection) { return Arrays.toString( from(collection != null ? collection : new ArrayList<E>()).transform(new Function<E, String>() { @Override// ww w .j a va 2s. c o m public String apply(final E item) { return item != null ? item.toString() : null; } }).filter(notNull()).toArray(String.class)); }
From source file:Main.java
/** * Returns a string composed from a {@link Map}. *///from w w w. j a v a2s.c om public static <T> String toString(Map<T, byte[]> map) { if (map == null) { return "null"; } if (map.isEmpty()) { return "{}"; } StringBuilder buffer = new StringBuilder(); buffer.append('{'); Iterator<Map.Entry<T, byte[]>> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<T, byte[]> entry = it.next(); Object key = entry.getKey(); buffer.append(key).append("=").append(Arrays.toString(map.get(key))); if (it.hasNext()) { buffer.append(", "); } } buffer.append('}'); return buffer.toString(); }