List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:net.robotmedia.billing.BillingController.java
/** * Requests to confirm all pending notifications for the specified item. * // www .j a v a 2 s .c om * @param context * @param itemId * id of the item whose purchase must be confirmed. * @return true if pending notifications for this item were found, false * otherwise. */ public static boolean confirmNotifications(Context context, String itemId) { final Set<String> notifications = manualConfirmations.get(itemId); if (notifications != null) { confirmNotifications(context, notifications.toArray(new String[] {})); return true; } else { return false; } }
From source file:com.huawei.streaming.cql.DriverContext.java
/** * classpathjar//w ww . jav a 2 s. co m * * @param pathsToRemove jar * @throws IOException jar */ private static void removeFromClassPath(String[] pathsToRemove) throws IOException { Thread curThread = Thread.currentThread(); URLClassLoader loader = (URLClassLoader) curThread.getContextClassLoader(); Set<URL> newPath = new HashSet<URL>(Arrays.asList(loader.getURLs())); if (pathsToRemove != null) { for (String onestr : pathsToRemove) { if (StringUtils.indexOf(onestr, FILE_PREFIX) == 0) { onestr = StringUtils.substring(onestr, CQLConst.I_7); } URL oneurl = (new File(onestr)).toURI().toURL(); newPath.remove(oneurl); } } loader = new URLClassLoader(newPath.toArray(new URL[0])); curThread.setContextClassLoader(loader); }
From source file:Os.java
private static OsFamily[] determineAllFamilies() { // Determine all families the current OS belongs to Set allFamilies = new HashSet(); if (OS_FAMILY != null) { List queue = new ArrayList(); queue.add(OS_FAMILY);// ww w . ja va2 s . c om while (queue.size() > 0) { final OsFamily family = (OsFamily) queue.remove(0); allFamilies.add(family); final OsFamily[] families = family.getFamilies(); for (int i = 0; i < families.length; i++) { OsFamily parent = families[i]; queue.add(parent); } } } return (OsFamily[]) allFamilies.toArray(new OsFamily[allFamilies.size()]); }
From source file:io.sloeber.core.managers.InternalPackageManager.java
/** * This method removes the json files from disk and removes memory references to * these files or their content/*from w ww .j a v a2 s .co m*/ * * @param packageUrlsToRemove */ public static void removePackageURLs(Set<String> packageUrlsToRemove) { // remove the files from memory Set<String> activeUrls = new HashSet<>(Arrays.asList(ConfigurationPreferences.getJsonURLList())); activeUrls.removeAll(packageUrlsToRemove); ConfigurationPreferences.setJsonURLs(activeUrls.toArray(null)); // remove the files from disk for (String curJson : packageUrlsToRemove) { File localFile = getLocalFileName(curJson, true); if (localFile != null) { if (localFile.exists()) { localFile.delete(); } } } // reload the indices (this will remove all potential remaining // references // existing files do not need to be refreshed as they have been // refreshed at startup loadJsons(false); }
From source file:com.francetelecom.clara.cloud.stepdefs.CreateAppStepdefs.java
private static SSOId[] getSsoIdsArrayFromStrings(Collection<String> ssoIdStrings) { Set<SSOId> ssoIds = getSsoIdsSetFromStrings(ssoIdStrings); return ssoIds.toArray(SSO_IDS_TYPE); }
From source file:com.iisigroup.cap.utils.CapBeanUtil.java
/** * ?Clazz?(?super class)/*w ww . j a v a 2 s . c om*/ * * @param clazz * class * @param containSuperClazz * ??Class? * @return Field[] */ @SuppressWarnings({ "rawtypes" }) public static Field[] getField(Class clazz, boolean containSuperClazz) { Set<Field> cols = new LinkedHashSet<Field>(); Class searchClazz = clazz; while (!Object.class.equals(searchClazz) && searchClazz != null) { Field[] fields = searchClazz.getDeclaredFields(); for (Field f : fields) { if ("serialVersionUID".equals(f.getName())) continue; cols.add(f); } searchClazz = containSuperClazz ? searchClazz.getSuperclass() : null; } return cols.toArray(new Field[] {}); }
From source file:com.iisigroup.cap.utils.CapBeanUtil.java
/** * ?Clazz?(?super class)/*from w w w. ja v a 2 s . c o m*/ * * @param clazz * class * @param containSuperClazz * ??Class? * @return String[] */ @SuppressWarnings({ "rawtypes" }) public static String[] getFieldName(Class clazz, boolean containSuperClazz) { Set<String> cols = new LinkedHashSet<String>(); Class searchClazz = clazz; while (!Object.class.equals(searchClazz) && searchClazz != null) { Field[] fields = searchClazz.getDeclaredFields(); for (Field f : fields) { if ("serialVersionUID".equals(f.getName())) continue; cols.add(f.getName()); } searchClazz = containSuperClazz ? searchClazz.getSuperclass() : null; } return cols.toArray(new String[cols.size()]); }
From source file:com.haulmont.cuba.core.global.filter.ParametersHelper.java
public static ParameterInfo[] parseQuery(String query, @Nullable QueryFilter filter) { Set<ParameterInfo> infos = new HashSet<>(); Matcher matcher = QUERY_PARAMETERS_PATTERN.matcher(query); while (matcher.find()) { final ParameterInfo info = parse(matcher); infos.add(info);/*from w w w . ja va 2s . c om*/ } // Add parameters used by freemarker clauses Matcher templMatcher = TEMPL_CLAUSE_PATTERN.matcher(query); while (templMatcher.find()) { String templClause = templMatcher.group(); Matcher paramMatcher = TEMPL_PARAM_PATTERN.matcher(templClause); while (paramMatcher.find()) { String param = paramMatcher.group(); infos.add(parse(param, false)); } } if (filter != null) { infos.addAll(filter.getParameters()); } return infos.toArray(new ParameterInfo[infos.size()]); }
From source file:biz.netcentric.cq.tools.actool.installationhistory.impl.HistoryUtils.java
/** * Method that returns a string which contains a number, path of a stored * history log in CRX, and the success status of that installation * /*from w w w.java 2s . c o m*/ * @param acHistoryRootNode * node in CRX under which the history logs get stored * @return String array which holds the single history infos * @throws RepositoryException * @throws PathNotFoundException */ static String[] getHistoryInfos(final Session session) throws RepositoryException, PathNotFoundException { Node acHistoryRootNode = getAcHistoryRootNode(session); Set<String> messages = new LinkedHashSet<String>(); int cnt = 1; for (NodeIterator iterator = acHistoryRootNode.getNodes(); iterator.hasNext();) { Node node = (Node) iterator.next(); if (node != null && node.getName().startsWith("history_")) { String successStatusString = "failed"; if (node.getProperty(PROPERTY_SUCCESS).getBoolean()) { successStatusString = "ok"; } String installationDate = node.getProperty(PROPERTY_INSTALLATION_DATE).getString(); messages.add(cnt + ". " + node.getPath() + " " + "" + "(" + installationDate + ")" + "(" + successStatusString + ")"); } cnt++; } return messages.toArray(new String[messages.size()]); }
From source file:ch.entwine.weblounge.contentrepository.index.SearchIndexFulltextTest.java
/** * Sets up the solr search index. Since solr sometimes has a hard time * shutting down cleanly, it's done only once for all the tests. * // w w w. j ava 2 s. c o m * @throws Exception */ @BeforeClass public static void setupClass() throws Exception { // Template template = EasyMock.createNiceMock(PageTemplate.class); EasyMock.expect(template.getIdentifier()).andReturn("templateid").anyTimes(); EasyMock.expect(template.getStage()).andReturn("non-existing").anyTimes(); EasyMock.replay(template); Set<Language> languages = new HashSet<Language>(); languages.add(LanguageUtils.getLanguage("en")); languages.add(LanguageUtils.getLanguage("de")); // Site site = EasyMock.createNiceMock(Site.class); EasyMock.expect(site.getIdentifier()).andReturn("test").anyTimes(); EasyMock.expect(site.getTemplate((String) EasyMock.anyObject())).andReturn(template).anyTimes(); EasyMock.expect(site.getDefaultTemplate()).andReturn(template).anyTimes(); EasyMock.expect(site.getLanguages()).andReturn(languages.toArray(new Language[languages.size()])) .anyTimes(); EasyMock.replay(site); // Resource serializer serializer = new ResourceSerializerServiceImpl(); serializer.addSerializer(new PageSerializer()); serializer.addSerializer(new FileResourceSerializer()); serializer.addSerializer(new ImageResourceSerializer()); serializer.addSerializer(new MovieResourceSerializer()); String rootPath = PathUtils.concat(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); idxRoot = new File(rootPath); System.setProperty("weblounge.home", rootPath); ElasticSearchUtils.createIndexConfigurationAt(idxRoot); idx = new SearchIndex(site, serializer, isReadOnly); // Prepare the pages PageReader pageReader = new PageReader(); InputStream is = null; // Add the live page try { is = SearchIndexFulltextTest.class.getResourceAsStream(pageFile); livePage = pageReader.read(is, site); pagelet = livePage.getPagelets()[0]; idx.add(livePage); } finally { IOUtils.closeQuietly(is); } // Add the work page try { is = SearchIndexFulltextTest.class.getResourceAsStream(pageFile); workPage = pageReader.read(is, site); workPage.setVersion(Resource.WORK); idx.add(workPage); } finally { IOUtils.closeQuietly(is); } }