List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:ExifUtils.ExifReadWrite.java
private static List<meta> exifToMetaET(ArrayList<String> filenames, File dir) { String filename = null;//from w w w . j ava 2 s. co m if (filenames.size() == 1 && filenames.get(0).length() > 5) { filename = dir + "\\" + filenames.get(0); } filenames.add(0, "-OriginalDocumentID"); filenames.add(0, "-DocumentID"); filenames.add(0, "-InstanceID"); filenames.add(0, "-DateTimeOriginal"); filenames.add(0, "-xmp:DateTimeOriginal"); filenames.add(0, "-Model"); filenames.add(0, "exiftool"); ArrayList<String> exifTool = exifTool(filenames.toArray(new String[0]), dir); Iterator<String> iterator = exifTool.iterator(); ArrayList<meta> results = new ArrayList<>(); int i = -1; String model = null; String note = ""; String iID = null; String dID = null; String odID = null; String captureDate = null; Boolean dateFormat = null; while (iterator.hasNext()) { String line = iterator.next(); if (line.startsWith("========")) { if (i > -1) { meta meta = new meta(filename, getZonedTimeFromStr(captureDate), dateFormat, model, iID, dID, odID, note); System.out.println(meta); results.add(meta); } i++; String fileTemp = line.substring(9).replaceAll("./", "").replaceAll("/", "\\"); filename = dir + "\\" + fileTemp; model = null; captureDate = null; dID = null; odID = null; note = ""; dateFormat = false; //End of exiftool output } else if (line.contains("image files read")) { if (!line.contains(" 0 image files read")) { } } else if (line.contains("files could not be read")) { } else { String tagValue = ""; if (line.length() > 34) tagValue = line.substring(34); switch (line.substring(0, 4)) { case "Date": if (captureDate == null) captureDate = tagValue; else { if (Math.abs(captureDate.length() - tagValue.length()) == 6) dateFormat = true; captureDate = tagValue; } break; case "Came": model = tagValue; break; case "Orig": odID = tagValue; break; case "Docu": dID = tagValue; break; case "Inst": iID = tagValue; break; case "Warn": note = line; break; } } } if (filename != null) { meta meta = new meta(filename, getZonedTimeFromStr(captureDate), dateFormat, model, iID, dID, odID, note); System.out.println(meta); results.add(meta); // results.add(new meta(filename, getZonedTimeFromStr(captureDate), dateFormat, model, note, dID, odID)); } return results; }
From source file:com.esri.core.geometry.GeometryEngine.java
/** * Calculates the cut geometry from a target geometry using a polyline. For * Polylines, all left cuts will be grouped together in the first Geometry, * Right cuts and coincident cuts are grouped in the second Geometry, and * each undefined cut, along with any uncut parts, are output as separate * Polylines. For Polygons, all left cuts are grouped in the first Polygon, * all right cuts are in the second Polygon, and each undefined cut, along * with any left-over parts after cutting, are output as a separate Polygon. * If there were no cuts then the array will be empty. An undefined cut will * only be produced if a left cut or right cut was produced, and there was a * part left over after cutting or a cut is bounded to the left and right of * the cutter./*from w ww .j a va 2 s .c o m*/ * * @param cuttee * The geometry to be cut. * @param cutter * The polyline to cut the geometry. * @param spatialReference * The spatial reference of the geometries. * @return An array of geometries created from cutting. */ public static Geometry[] cut(Geometry cuttee, Polyline cutter, SpatialReference spatialReference) { if (cuttee == null || cutter == null) return null; OperatorCut op = (OperatorCut) factory.getOperator(Operator.Type.Cut); GeometryCursor cursor = op.execute(true, cuttee, cutter, spatialReference, null); ArrayList<Geometry> cutsList = new ArrayList<Geometry>(); Geometry geometry; while ((geometry = cursor.next()) != null) { if (!geometry.isEmpty()) { cutsList.add(geometry); } } return cutsList.toArray(new Geometry[0]); }
From source file:com.sic.bb.jenkins.plugins.sicci_for_xcode.io.XcodebuildOutputParser.java
private static String[] parseXcodebuildList(FilePath workspace, String arg, boolean useCache) { ArrayList<String> items = new ArrayList<String>(); boolean found = false; String itemsString;//ww w. j a va2 s . c o m if (useCache) itemsString = XcodebuildCommandCaller.getInstance().getOutput(workspace, "-list"); else itemsString = XcodebuildCommandCaller.getInstance().getOutputNoCache(workspace, "-list"); if (StringUtils.isBlank(itemsString)) return new String[0]; for (String item : itemsString.split("\n")) { if (item.contains(arg)) { found = true; continue; } if (!found) continue; if (item.isEmpty()) break; item = parseXcodeBuildListPattern1.matcher(item).replaceAll("$1"); items.add(parseXcodeBuildListPattern2.matcher(item).replaceAll("$1")); } return (String[]) items.toArray(new String[items.size()]); }
From source file:Main.java
public static Field[] getAllFiedFromClassAndSuper(Class clazz, boolean needStatic) { ArrayList<Field> fields = new ArrayList<>(); if (clazz != null) { Field[] classFields = clazz.getDeclaredFields(); if (classFields != null) { for (Field field : classFields) { boolean isStatic = Modifier.isStatic(field.getModifiers()); if (isStatic && !needStatic) { continue; }/*from w w w .j a v a 2s. c o m*/ fields.add(field); } } Field[] superFields = getAllFiedFromClassAndSuper(clazz.getSuperclass(), needStatic); if (superFields != null) { for (Field field : superFields) { boolean isStatic = Modifier.isStatic(field.getModifiers()); if (isStatic && !needStatic) { continue; } fields.add(field); } } } return fields.toArray(new Field[fields.size()]); }
From source file:com.yahoo.egads.utilities.AutoSensitivity.java
public static Float getLowDensitySensitivity(Float[] data, float sDAutoSensitivy, float amntAutoSensitivity) { Float toReturn = Float.POSITIVE_INFINITY; Arrays.sort(data, Collections.reverseOrder()); while (data.length > 0) { ArrayList<Float> fData = new ArrayList<Float>(); fData.add(data[0]);// w w w.j a v a 2s . c o m data = ((Float[]) ArrayUtils.remove(data, 0)); Float centroid = (float) fData.get(0); Float maxDelta = (float) sDAutoSensitivy * StatsUtils.getSD(data, StatsUtils.getMean(data)); logger.debug("AutoSensitivity: Adding: " + fData.get(0) + " SD: " + maxDelta); // Add points while it's in the same cluster or not part of the other cluster. String localDebug = null; while (data.length > 0 && (centroid - data[0]) <= ((float) (maxDelta))) { float maxDeltaInit = maxDelta; fData.add(data[0]); data = ((Float[]) ArrayUtils.remove(data, 0)); Float[] tmp = new Float[fData.size()]; tmp = fData.toArray(tmp); centroid = StatsUtils.getMean(tmp); if (data.length > 0) { Float sdOtherCluster = (float) StatsUtils.getSD(data, StatsUtils.getMean(data)); maxDelta = sDAutoSensitivy * sdOtherCluster; logger.debug( "AutoSensitivity: Adding: " + data[0] + " SD: " + maxDeltaInit + " SD': " + maxDelta); } } if (data.length > 0) { logger.debug("AutoSensitivity: Next Point I would have added is " + data[0]); } if (((double) fData.size() / (double) data.length) > amntAutoSensitivity) { // Cannot do anomaly detection. logger.debug("AutoSensitivity: Returning " + toReturn + " data size: " + data.length + " fData.size: " + fData.size()); return toReturn; } toReturn = fData.get(fData.size() - 1); logger.debug("AutoSensitivity: Updating toReturn: " + toReturn + " SD: " + maxDelta); return toReturn; } return toReturn; }
From source file:io.github.jeremgamer.editor.panels.Others.java
public static String[] getTextFields() { ArrayList<String> list = new ArrayList<String>(); try {//from ww w . j a v a 2 s . co m for (int i = 0; i < otherList.getModel().getSize(); i++) { OtherSave os = new OtherSave(); try { os.load(new File("projects/" + Editor.getProjectName() + "/others/" + otherList.getModel().getElementAt(i) + ".rbd")); } catch (IOException e) { e.printStackTrace(); } if (os.getInt("type") == 0) { list.add(otherList.getModel().getElementAt(i)); } } } catch (NullPointerException npe) { } return list.toArray(new String[0]); }
From source file:io.github.jeremgamer.editor.panels.Others.java
public static String[] getPasswordFields() { ArrayList<String> list = new ArrayList<String>(); try {//ww w . j a v a 2 s . c o m for (int i = 0; i < otherList.getModel().getSize(); i++) { OtherSave os = new OtherSave(); try { os.load(new File("projects/" + Editor.getProjectName() + "/others/" + otherList.getModel().getElementAt(i) + ".rbd")); } catch (IOException e) { e.printStackTrace(); } if (os.getInt("type") == 1) { list.add(otherList.getModel().getElementAt(i)); } } } catch (NullPointerException npe) { } return list.toArray(new String[0]); }
From source file:com.sun.faban.harness.webclient.ResultAction.java
/** * This method is responsible for uploading the runs to repository. * @param uploadSet/*from w w w. j a v a 2s . c o m*/ * @param replaceSet * @return HashSet * @throws java.io.IOException */ public static HashSet<String> uploadRuns(String[] runIds, HashSet<File> uploadSet, HashSet<String> replaceSet) throws IOException { // 3. Upload the run HashSet<String> duplicates = new HashSet<String>(); // Prepare run id set for cross checking. HashSet<String> runIdSet = new HashSet<String>(runIds.length); for (String runId : runIds) { runIdSet.add(runId); } // Prepare the parts for the request. ArrayList<Part> params = new ArrayList<Part>(); params.add(new StringPart("host", Config.FABAN_HOST)); for (String replaceId : replaceSet) { params.add(new StringPart("replace", replaceId)); } for (File jarFile : uploadSet) { params.add(new FilePart("jarfile", jarFile)); } Part[] parts = new Part[params.size()]; parts = params.toArray(parts); // Send the request for each reposotory. for (URL repository : Config.repositoryURLs) { URL repos = new URL(repository, "/controller/uploader/upload_runs"); PostMethod post = new PostMethod(repos.toString()); post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(post); if (status == HttpStatus.SC_FORBIDDEN) logger.warning("Server denied permission to upload run !"); else if (status == HttpStatus.SC_NOT_ACCEPTABLE) logger.warning("Run origin error!"); else if (status != HttpStatus.SC_CREATED) logger.warning( "Server responded with status code " + status + ". Status code 201 (SC_CREATED) expected."); for (File jarFile : uploadSet) { jarFile.delete(); } String response = post.getResponseBodyAsString(); if (status == HttpStatus.SC_CREATED) { StringTokenizer t = new StringTokenizer(response.trim(), "\n"); while (t.hasMoreTokens()) { String duplicateRun = t.nextToken().trim(); if (duplicateRun.length() > 0) duplicates.add(duplicateRun.trim()); } for (Iterator<String> iter = duplicates.iterator(); iter.hasNext();) { String runId = iter.next(); if (!runIdSet.contains(runId)) { logger.warning("Unexpected archive response from " + repos + ": " + runId); iter.remove(); } } } else { logger.warning("Message from repository: " + response); } } return duplicates; }
From source file:org.jdal.util.BeanUtils.java
/** * Get PropertyValues from Object// w w w. j a v a 2 s.com * @param obj Object to get PropertyValues * @return the property values */ public static PropertyValue[] getPropertyValues(Object obj) { PropertyDescriptor[] pds = getPropertyDescriptors(obj.getClass()); ArrayList<PropertyValue> pvs = new ArrayList<PropertyValue>(); List<String> excludedProperties = Arrays.asList(EXCLUDED_PROPERTIES); for (int i = 0; i < pds.length; i++) { Object value = null; String name = pds[i].getName(); if (!excludedProperties.contains(name)) { try { value = pds[i].getReadMethod().invoke(obj, (Object[]) null); } catch (IllegalAccessException e) { log.error("Error reading property name: " + name, e); } catch (IllegalArgumentException e) { log.error("Error reading property name: " + name, e); } catch (InvocationTargetException e) { log.error("Error reading property name: " + name, e); } pvs.add(new PropertyValue(name, value)); } } return (PropertyValue[]) pvs.toArray(new PropertyValue[pvs.size()]); }
From source file:com.microsoft.tfs.client.common.codemarker.CodeMarkerDispatch.java
/** * Notifies listeners that a code marker has been reached. * * @param event/*from www . j a va2 s.c om*/ */ public static void dispatch(final CodeMarker event) { synchronized (lock) { if (!listenersLoaded) { final IExtensionRegistry registry = Platform.getExtensionRegistry(); final IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_ID); final IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); final ArrayList<CodeMarkerListener> listenerList = new ArrayList<CodeMarkerListener>(); for (int i = 0; i < elements.length; i++) { try { final CodeMarkerListenerProvider provider = (CodeMarkerListenerProvider) elements[i] .createExecutableExtension("class"); //$NON-NLS-1$ if (provider != null) { final CodeMarkerListener listener = provider.getCodeMarkerListener(); if (listener != null) { listenerList.add(listener); } } } catch (final CoreException e) { log.warn("Could not create " + EXTENSION_POINT_ID + " class", e); //$NON-NLS-1$ //$NON-NLS-2$ } } if (listenerList.size() > 0) { listeners = listenerList.toArray(new CodeMarkerListener[listenerList.size()]); } listenersLoaded = true; } if (listeners != null) { for (int i = 0; i < listeners.length; i++) { try { listeners[i].onCodeMarker(event); } catch (final Throwable t) { log.warn("Exception while providing CodeMarker (" + event.toString() + ")", t); //$NON-NLS-1$ //$NON-NLS-2$ } } } } }