List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:com.triarc.sync.LogCollector.java
@SuppressWarnings("unchecked") private void collectLog(List<String> outLines, String format, String buffer, String[] filterSpecs) { /*Usage: logcat [options] [filterspecs] options include:// w w w . j a v a 2s. c o m -s Set default filter to silent. Like specifying filterspec '*:s' -f <filename> Log to file. Default to stdout -r [<kbytes>] Rotate log every kbytes. (16 if unspecified). Requires -f -n <count> Sets max number of rotated logs to <count>, default 4 -v <format> Sets the log print format, where <format> is one of: brief process tag thread raw time threadtime long -c clear (flush) the entire log and exit -d dump the log and then exit (don't block) -g get the size of the log's ring buffer and exit -b <buffer> request alternate ring buffer ('main' (default), 'radio', 'events') -B output the log in binary filterspecs are a series of <tag>[:priority] where <tag> is a log component tag (or * for all) and priority is: V Verbose D Debug I Info W Warn E Error F Fatal S Silent (supress all output) '*' means '*:d' and <tag> by itself means <tag>:v If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS. If no filterspec is found, filter defaults to '*:I' If not specified with -v, format is set from ANDROID_PRINTF_LOG or defaults to "brief"*/ outLines.clear(); ArrayList<String> params = new ArrayList<String>(); if (format == null) { format = "time"; } params.add("-v"); params.add(format); if (buffer != null) { params.add("-b"); params.add(buffer); } if (filterSpecs != null) { for (String filterSpec : filterSpecs) { params.add(filterSpec); } } final StringBuilder log = new StringBuilder(); try { ArrayList<String> commandLine = new ArrayList<String>(); commandLine.add("logcat");//$NON-NLS-1$ commandLine.add("-d");//$NON-NLS-1$ commandLine.addAll(params); Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0])); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = bufferedReader.readLine()) != null) { outLines.add(line); } } catch (IOException e) { Log.e(LOG_TAG, String.format("collectAndSendLog failed - format:%s, buffer:%s, filterSpecs:%s", format, buffer, filterSpecs), e); } }
From source file:net.famzangl.minecraft.minebot.ai.command.CommandRegistry.java
public List<CommandDefinition> getAllCommands() { final ArrayList<CommandDefinition> defs = new ArrayList<CommandDefinition>(); for (final List<CommandDefinition> list : commandTable.values()) { defs.addAll(list); }/* ww w . jav a 2 s .c om*/ return defs; }
From source file:de.tudarmstadt.ukp.lmf.writer.xml.LMFXmlWriter.java
/** * This method consumes a LMF Object and transforms it to XML. The method * iterates over all fields of a class and searches for the {@link AccessType} annotations. * Depending on the value of the annotation, the method reads the values of the objects * fields by invoking a getter or by directly accessing the field. * /*from w w w . j a v a2 s. co m*/ * @param lmfObject An LMF Object for which an Element should be created * @param writeEndElement If TRUE the closing Tag for the XML-Element will be created * * @throws IllegalAccessException when a direct access to a field of the class is for some reason not possible * @throws IllegalArgumentException when a direct access to a field of the class is for some reason not possible * @throws SAXException if writing to XML-file is for some reason not possible */ @SuppressWarnings("unchecked") private void doTransform(Object lmfObject, boolean writeEndElement) throws IllegalArgumentException, IllegalAccessException, SAXException { Class<?> something = lmfObject.getClass(); String elementName = something.getSimpleName(); int hibernateSuffixIdx = elementName.indexOf("_$$"); if (hibernateSuffixIdx > 0) elementName = elementName.substring(0, hibernateSuffixIdx); AttributesImpl atts = new AttributesImpl(); List<Object> children = new ArrayList<Object>(); // find all field, also the inherited ones ArrayList<Field> fields = new ArrayList<Field>(); fields.addAll(Arrays.asList(something.getDeclaredFields())); Class<?> superClass = something.getSuperclass(); while (superClass != null) { fields.addAll(Arrays.asList(superClass.getDeclaredFields())); superClass = superClass.getSuperclass(); } // Iterating over all fields for (Field field : fields) { String fieldName = field.getName().replace("_", ""); Class<?> fieldClass = field.getType(); VarType varType = field.getAnnotation(VarType.class); // No VarType-Annotation found for the field, then don't save to XML if (varType == null) continue; EVarType type = varType.type(); // VarType is NONE, don't save to XML if (type.equals(EVarType.NONE)) continue; Object retObj = null; /* * Determine how to access the variable */ AccessType accessType = field.getAnnotation(AccessType.class); if (accessType == null || accessType.equals(EAccessType.GETTER)) { // access using a canonical getter String setFieldName = fieldName; if (fieldName.startsWith("is")) // E.g. isHead --> setHead setFieldName = setFieldName.replaceFirst("is", ""); // Get-Method for the field String getFuncName = setFieldName.substring(0, 1).toUpperCase() + setFieldName.substring(1); if (fieldClass.equals(Boolean.class)) { getFuncName = "is" + getFuncName; } else getFuncName = "get" + getFuncName; Method getMethod = null; try { getMethod = something.getMethod(getFuncName); retObj = getMethod.invoke(lmfObject); // Run the Get-Method } catch (Exception e) { logger.warn("There was an error on accessing the method " + getFuncName + " in " + elementName + " class. Falling back to field access"); field.setAccessible(true); retObj = field.get(lmfObject); } } else { // Directly read the value of the field field.setAccessible(true); retObj = field.get(lmfObject); } if (retObj != null) { if (type.equals(EVarType.ATTRIBUTE)) { // Save Attribute to the new element atts.addAttribute("", "", fieldName, "CDATA", retObj.toString()); } else if (type.equals(EVarType.IDREF)) { // Save IDREFs as attribute of the new element atts.addAttribute("", "", fieldName, "CDATA", ((IHasID) retObj).getId()); } else if (type.equals(EVarType.CHILD)) { // Transform children of the new element to XML children.add(retObj); } else if (type.equals(EVarType.CHILDREN) && writeEndElement) { for (Object obj : (Iterable<Object>) retObj) { children.add(obj); } } else if (type.equals(EVarType.ATTRIBUTE_OPTIONAL)) { atts.addAttribute("", "", fieldName, "CDATA", retObj.toString()); } else if (type.equals(EVarType.IDREFS)) { String attrValue = ""; for (Object obj : (Iterable<Object>) retObj) { attrValue += ((IHasID) obj).getId() + " "; } if (!attrValue.isEmpty()) atts.addAttribute("", "", fieldName, "CDATA", attrValue.substring(0, attrValue.length() - 1)); } } else { // Element is null, save only if it is a non-optional Attribute or IDREF if (type.equals(EVarType.ATTRIBUTE) || type.equals(EVarType.IDREF)) { // Save Attribute to the new element //atts.addAttribute("", "", fieldName, "CDATA", "NULL"); } } } // Save the current element and its children th.startElement("", "", elementName, atts); for (Object child : children) { //System.out.println("CHILD: "+child.getClass().getSimpleName()); doTransform(child, true); } if (writeEndElement) th.endElement("", "", elementName); }
From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.CrearElementoControllerImpl.java
private List listaSubmanifiestos(OdeVO[] submanifiesto) { ArrayList lista = new ArrayList(); lista.addAll(Arrays.asList(submanifiesto)); for (int i = 0; i < submanifiesto.length; i++) { if (submanifiesto[i].getSubmanifiestos().length > 0) { lista.addAll(Arrays.asList(submanifiesto[i].getSubmanifiestos())); lista.addAll(listaSubmanifiestos(submanifiesto[i].getSubmanifiestos())); }//from w w w . j a va2s . co m } return lista; }
From source file:com.github.haixing_hu.bean.DefaultProperty.java
@Override public final void setIndexedValue(final ArrayList<Object> list) { checkKind(PropertyKind.INDEXED);//w w w . j a v a2 s . c om requireNonNull("list", list); for (final Object obj : list) { checkType(obj); } @SuppressWarnings("unchecked") final ArrayList<Object> valueList = (ArrayList<Object>) value; valueList.clear(); valueList.addAll(list); }
From source file:org.jahia.modules.bootstrap.rules.BootstrapCompiler.java
public void compileBootstrapWithVariables(JCRSiteNode site, String variables) throws RepositoryException, IOException, LessException { if (module == null) { return;/*from w ww . java 2 s .c om*/ } Set<JahiaTemplatesPackage> packages = new TreeSet<JahiaTemplatesPackage>( TemplatePackageRegistry.TEMPLATE_PACKAGE_COMPARATOR); for (String s : site.getInstalledModulesWithAllDependencies()) { packages.add(jahiaTemplateManagerService.getTemplatePackageById(s)); } packages.remove(module); ArrayList<Resource> lessResources = new ArrayList<Resource>(); for (JahiaTemplatesPackage aPackage : packages) { lessResources.addAll(Arrays.asList(aPackage.getResources(LESS_RESOURCES_FOLDER))); } lessResources.addAll(Arrays.asList(module.getResources(LESS_RESOURCES_FOLDER))); compileBootstrap(site, lessResources, variables); }
From source file:ap.attack.ArgumentsHandler.java
public ArrayList<String> getCommandLine() throws Exception { String json = ""; String params = ""; ArrayList<String> cmds = new ArrayList<>(); cmds.add("run"); if (!workdir.isEmpty()) { cmds.addAll(Arrays.asList("-workdir", workdir)); }/*from ww w . j a va 2s.c o m*/ if (ud.isEmpty()) { // System.out.println("one Source JSON"); json += "workflows/oneSource.json"; if (!dataset.isEmpty()) { params += "urlES=" + dataset; } else if (!kd.isEmpty()) { params += "urlES=" + kd; } else { throw new Exception("At least one dataset has to entered with -d path"); } } else { json += "workflows/twoSource.json"; params = " urlUD=" + ud; if (!kd.isEmpty()) { params += " urlKD=" + kd; } else if (!dataset.isEmpty()) { params += " urlKD=" + dataset; } else { throw new Exception("-ud option given but -kd was not informed"); } } if (!kps.isEmpty()) { params += " startTrain=" + getKps(); } if (!kpe.isEmpty()) { params += " endTrain=" + getKpe(); } if (!ups.isEmpty()) { params += " startTest=" + getUps(); } if (!upe.isEmpty()) { params += " endTest=" + getUpe(); } if (!cellSize.isEmpty()) { params += " cellSize=" + getCellSize(); } if (!diameter.isEmpty()) { params += " diameter=" + getDiameter(); } if (!duration.isEmpty()) { params += " duration=" + getDiameter(); } cmds.add("-params"); cmds.add(params); cmds.add(json); return cmds; }
From source file:com.groupon.jenkins.dynamic.build.DynamicBuild.java
public void addCause(final Cause manualCause) { final List<Cause> exisitingCauses = this.getAction(CauseAction.class).getCauses(); final ArrayList<Cause> causes = new ArrayList<>(); causes.add(manualCause);/*from www . ja v a 2s . c o m*/ causes.addAll(exisitingCauses); this.replaceAction(new CauseAction(causes)); }
From source file:com.example.app.repository.ui.ResourceSelector.java
@SuppressWarnings("Duplicates") private void addConstraints(SearchModelImpl searchModel) { searchModel.getConstraints()/*from w w w. ja v a 2 s .c o m*/ .add(new SimpleConstraint("name").withLabel(LABEL_NAME()) .withProperty(ResourceRepositoryItem.RESOURCE_PROP + '.' + Resource.NAME_COLUMN_PROP) .withOperator(PropertyConstraint.Operator.like)); searchModel.getConstraints() .add(new ComboBoxConstraint(nullFirst(RepositoryItemStatus.values()), RepositoryItemStatus.Active, new CustomCellRenderer(CommonButtonText.ANY)).withLabel(CommonColumnText.STATUS) .withProperty(ResourceRepositoryItem.STATUS_COLUMN_PROP) .withOperator(PropertyConstraint.Operator.eq)); ArrayList<Label> categories = new ArrayList<>(); categories.add(null); categories.addAll(_rclp.getEnabledLabels(Optional.empty())); AbstractPropertyConstraint categoryConstraint = new ComboBoxConstraint(categories, null, CommonButtonText.ANY) { @Override public void addCriteria(QLBuilder builder, Component constraintComponent) { ComboBox component = (ComboBox) constraintComponent; Label category = (Label) component.getSelectedObject(); if (category != null && shouldReturnConstraintForValue(category)) { String categoriesPropPath = builder.getAlias() + '.' + ResourceRepositoryItem.RESOURCE_PROP + '.' + Resource.TAGS_PROP; builder.appendCriteria(":category in elements(" + categoriesPropPath + ')') .putParameter("category", category); } } }.withLabel(LABEL_CATEGORY()); searchModel.getConstraints().add(categoryConstraint); searchModel.getConstraints() .add(new SimpleConstraint("author").withLabel(LABEL_AUTHOR()) .withProperty(ResourceRepositoryItem.RESOURCE_PROP + '.' + Resource.AUTHOR_COLUMN_PROP) .withOperator(PropertyConstraint.Operator.like)); ArrayList<Label> types = new ArrayList<>(); types.add(null); types.addAll(_rtlp.getEnabledLabels(Optional.empty())); AbstractPropertyConstraint typeConstraint = new ComboBoxConstraint(types, null, CommonButtonText.ANY) .withLabel(LABEL_TYPE()) .withProperty(ResourceRepositoryItem.RESOURCE_PROP + '.' + Resource.CATEGORY_PROP) .withOperator(PropertyConstraint.Operator.eq).withCoerceValue(false).withValueType(Label.class); searchModel.getConstraints().add(typeConstraint); }
From source file:com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider.java
protected Object[] getXSDIdentityConstraintDefinitionChildren(XSDIdentityConstraintDefinition parent) { ArrayList<Object> list = new ArrayList<Object>(); list.add(parent.getSelector());//from ww w .jav a 2 s.c o m list.addAll(parent.getFields()); return list.toArray(new Object[list.size()]); }