List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:gov.nih.nci.cabig.caaers.domain.dto.AeMappingsDTO.java
public static AeMappingsDTO deseralize(String s) { AeMappingsDTO m = new AeMappingsDTO(); int p1 = s.indexOf("relations:[") + 11; int p2 = s.indexOf("],eRejected:"); int p3 = s.indexOf("eRejected:[") + 11; int p4 = s.indexOf("],iRejected:"); int p5 = s.indexOf("iRejected:[") + 11; int p6 = s.indexOf("]", p5); String relations = p2 - p1 > 1 ? s.substring(p1, p2) : null; String eRejections = p4 - p3 > 1 ? s.substring(p3, p4) : null; String iRejections = p6 - p5 > 1 ? s.substring(p5, p6) : null; if (relations != null) { String[] rArr = StringUtils.split(relations, "}"); List<AeMergeDTO> merges = new ArrayList<AeMergeDTO>(); for (int i = 0; i < rArr.length; i++) { merges.add(AeMergeDTO.deseralize(rArr[i])); }//from w w w . ja v a 2 s . c o m m.setRelations(merges.toArray(new AeMergeDTO[] {})); } if (eRejections != null) { m.setRejectedExternalAeIds(AeMergeDTO.parseCommaSeperatedIntegers(eRejections)); } if (iRejections != null) { m.setRejectedInternalAeIds(AeMergeDTO.parseCommaSeperatedIntegers(iRejections)); } return m; }
From source file:net.eledge.android.toolkit.StringArrayUtils.java
public static String[] toArray(SparseArray<List<String>> sparseArray) { List<String> list = new ArrayList<>(); if ((sparseArray != null) && (sparseArray.size() > 0)) { for (int i = 0; i < sparseArray.size(); i++) { list.addAll(sparseArray.valueAt(i)); }//from ww w .ja va 2 s.c o m } return list.toArray(new String[list.size()]); }
From source file:Main.java
public static <T> T[] intersection(@NonNull final T[] array1, @NonNull final T[] array2) { final List<T> list1 = new ArrayList<>(); Collections.addAll(list1, array1); final List<T> list2 = new ArrayList<>(); Collections.addAll(list2, array2); list1.retainAll(list2);/* w w w . j a v a 2s . c o m*/ //noinspection unchecked return list1.toArray((T[]) Array.newInstance(array1.getClass().getComponentType(), list1.size())); }
From source file:de.micromata.genome.gwiki.utils.StringUtils.java
/** * //from w ww.j a va2 s . c o m * @param text * @param search * @return */ public static Pair<Integer, String> indexOfAny(String text, int offset, List<String> search) { if (search == null) { return INDEX_OF_ANY_NOT_FOUND_PAIR; } return indexOfAny(text, offset, search.toArray(new String[] {})); }
From source file:biz.deinum.jxl.util.JxlUtils.java
/** * Extract the content from the given row. * //w ww .ja v a2 s .c om * @param row the row * @return the content as String[] */ public static String[] extractContents(final Cell[] row) { final List<String> values = new ArrayList<String>(); for (final Cell cell : row) { if (!isEmpty(cell)) { values.add(cell.getColumn(), cell.getContents()); } } return values.toArray(new String[values.size()]); }
From source file:at.ac.tuwien.dsg.comot.m.common.Utils.java
@SuppressWarnings("unchecked") public static <T> T asObjectFromXml(String str, Class<T> clazz, Class<?>... otherClazz) throws JAXBException, IOException { List<Object> list = new ArrayList<Object>(Arrays.asList(otherClazz)); list.add(clazz);//w w w . ja v a2 s. c om JAXBContext context = JAXBContext.newInstance(list.toArray(new Class[list.size()])); Unmarshaller unmarshaller = context.createUnmarshaller(); return (T) unmarshaller.unmarshal(new StringReader(str)); }
From source file:Main.java
public static final String[] executeXPathExpression(InputSource inputSource, String xpathExpression, String namespace) throws XPathExpressionException, SAXException, IOException, ParserConfigurationException, TransformerException { // optional namespace spec: xmlns:prefix:URI String nsPrefix = null;// w ww . j a va 2s .co m String nsUri = null; if (namespace != null && namespace.startsWith("xmlns:")) { String[] nsDef = namespace.substring("xmlns:".length()).split("="); if (nsDef.length == 2) { nsPrefix = nsDef[0]; nsUri = nsDef[1]; } } // Parse XML to DOM DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); Document doc = dbFactory.newDocumentBuilder().parse(inputSource); // Find nodes by XPATH XPathFactory xpFactory = XPathFactory.newInstance(); XPath xpath = xpFactory.newXPath(); // namespace? if (nsPrefix != null) { final String myPrefix = nsPrefix; final String myUri = nsUri; xpath.setNamespaceContext(new NamespaceContext() { public String getNamespaceURI(String prefix) { return myPrefix.equals(prefix) ? myUri : null; } public String getPrefix(String namespaceURI) { return null; // we are not using this. } public Iterator<?> getPrefixes(String namespaceURI) { return null; // we are not using this. } }); } XPathExpression expr = xpath.compile(xpathExpression); NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); List<String> lines = new ArrayList<>(); for (int i = 0; i < nodes.getLength(); i++) { lines.add((indenting(nodes.item(i)))); } return lines.toArray(new String[lines.size()]); }
From source file:com.espertech.esper.epl.named.NamedWindowUpdateHelper.java
public static NamedWindowUpdateHelper make(String namedWindowName, EventTypeSPI eventTypeSPI, List<OnTriggerSetAssignment> assignments, String namedWindowAlias) throws ExprValidationException { List<NamedWindowUpdateItem> updateItems = new ArrayList<NamedWindowUpdateItem>(); List<String> properties = new ArrayList<String>(); for (int i = 0; i < assignments.size(); i++) { OnTriggerSetAssignment assignment = assignments.get(i); NamedWindowUpdateItem updateItem; // determine whether this is a "property=value" assignment, we use property setters in this case Pair<String, ExprNode> possibleAssignment = ExprNodeUtility .checkGetAssignmentToProp(assignment.getExpression()); // handle assignment "property = value" if (possibleAssignment != null) { String propertyName = possibleAssignment.getFirst(); EventPropertyDescriptor writableProperty = eventTypeSPI.getWritableProperty(propertyName); if (writableProperty == null) { Pair<String, EventPropertyDescriptor> nameWriteablePair = checkIndexedOrMappedProp( possibleAssignment.getFirst(), namedWindowName, namedWindowAlias, eventTypeSPI); propertyName = nameWriteablePair.getFirst(); writableProperty = nameWriteablePair.getSecond(); }/*from w w w. ja v a 2s. c o m*/ ExprEvaluator evaluator = possibleAssignment.getSecond().getExprEvaluator(); EventPropertyWriter writers = eventTypeSPI.getWriter(propertyName); boolean notNullableField = writableProperty.getPropertyType().isPrimitive(); properties.add(propertyName); TypeWidener widener = TypeWidenerFactory.getCheckPropertyAssignType( possibleAssignment.getSecond().toExpressionString(), possibleAssignment.getSecond().getExprEvaluator().getType(), writableProperty.getPropertyType(), propertyName); updateItem = new NamedWindowUpdateItem(evaluator, propertyName, writers, notNullableField, widener); } // handle non-assignment, i.e. UDF or other expression else { ExprEvaluator evaluator = assignment.getExpression().getExprEvaluator(); updateItem = new NamedWindowUpdateItem(evaluator, null, null, false, null); } updateItems.add(updateItem); } // obtain copy method List<String> propertiesUniqueList = new ArrayList<String>(new HashSet<String>(properties)); String[] propertiesArray = propertiesUniqueList.toArray(new String[propertiesUniqueList.size()]); EventBeanCopyMethod copyMethod = eventTypeSPI.getCopyMethod(propertiesArray); if (copyMethod == null) { throw new ExprValidationException("Event type does not support event bean copy"); } NamedWindowUpdateItem[] updateItemsArray = updateItems .toArray(new NamedWindowUpdateItem[updateItems.size()]); return new NamedWindowUpdateHelper(copyMethod, updateItemsArray); }
From source file:com.epam.dlab.core.parser.CommonFormat.java
/** * Print row to console./*from www .j a v a2 s. c o m*/ * * @param row list of values. */ public static void printRow(List<String> row) { printRow(row.toArray(new String[row.size()])); }
From source file:com.mirth.connect.connectors.dimse.DICOMConfigurationUtil.java
public static void configureDcmSnd(MirthDcmSnd dcmsnd, DICOMDispatcher connector, DICOMDispatcherProperties connectorProperties, String[] protocols) throws Exception { if (connectorProperties.getTls() != null && !connectorProperties.getTls().equals("notls")) { if (connectorProperties.getTls().equals("without")) dcmsnd.setTlsWithoutEncyrption(); if (connectorProperties.getTls().equals("3des")) dcmsnd.setTls3DES_EDE_CBC(); if (connectorProperties.getTls().equals("aes")) dcmsnd.setTlsAES_128_CBC();/*from w w w.ja va 2 s .c om*/ if (connectorProperties.getTrustStore() != null && !connectorProperties.getTrustStore().equals("")) dcmsnd.setTrustStoreURL(connectorProperties.getTrustStore()); if (connectorProperties.getTrustStorePW() != null && !connectorProperties.getTrustStorePW().equals("")) dcmsnd.setTrustStorePassword(connectorProperties.getTrustStorePW()); if (connectorProperties.getKeyPW() != null && !connectorProperties.getKeyPW().equals("")) dcmsnd.setKeyPassword(connectorProperties.getKeyPW()); if (connectorProperties.getKeyStore() != null && !connectorProperties.getKeyStore().equals("")) dcmsnd.setKeyStoreURL(connectorProperties.getKeyStore()); if (connectorProperties.getKeyStorePW() != null && !connectorProperties.getKeyStorePW().equals("")) dcmsnd.setKeyStorePassword(connectorProperties.getKeyStorePW()); dcmsnd.setTlsNeedClientAuth(connectorProperties.isNoClientAuth()); protocols = ArrayUtils.clone(protocols); if (connectorProperties.isNossl2()) { if (ArrayUtils.contains(protocols, "SSLv2Hello")) { List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols)); protocolsList.remove("SSLv2Hello"); protocols = protocolsList.toArray(new String[protocolsList.size()]); } } else if (!ArrayUtils.contains(protocols, "SSLv2Hello")) { List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols)); protocolsList.add("SSLv2Hello"); protocols = protocolsList.toArray(new String[protocolsList.size()]); } protocols = MirthSSLUtil.getEnabledHttpsProtocols(protocols); dcmsnd.setTlsProtocol(protocols); dcmsnd.initTLS(); } }