List of usage examples for java.util HashSet toArray
<T> T[] toArray(T[] a);
From source file:com.iflytek.spider.crawl.CrawlDb.java
public int run(String[] args) throws Exception { if (args.length < 2) { System.err.println(/* ww w . jav a 2s . c o m*/ "Usage: CrawlDb <crawldb> (-dir <segments> | <seg1> <seg2> ...) [-force] [-noAdditions]"); System.err.println("\tcrawldb\tCrawlDb to update"); System.err.println("\t-dir segments\tparent directory containing all segments to update from"); System.err.println("\tseg1 seg2 ...\tlist of segment names to update from"); System.err.println("\t-force\tforce update even if CrawlDb appears to be locked (CAUTION advised)"); System.err.println( "\t-noAdditions\tonly update already existing URLs, don't add any newly discovered URLs"); return -1; } boolean force = false; final FileSystem fs = FileSystem.get(getConf()); boolean additionsAllowed = getConf().getBoolean(CRAWLDB_ADDITIONS_ALLOWED, true); HashSet<Path> dirs = new HashSet<Path>(); for (int i = 1; i < args.length; i++) { if (args[i].equals("-force")) { force = true; } else if (args[i].equals("-noAdditions")) { additionsAllowed = false; } else if (args[i].equals("-dir")) { FileStatus[] paths = fs.listStatus(new Path(args[++i]), HadoopFSUtil.getPassDirectoriesFilter(fs)); dirs.addAll(Arrays.asList(HadoopFSUtil.getPaths(paths))); } else { dirs.add(new Path(args[i])); } } try { update(new Path(args[0]), dirs.toArray(new Path[dirs.size()]), additionsAllowed, force); return 0; } catch (Exception e) { LOG.fatal("CrawlDb update: " + StringUtils.stringifyException(e)); return -1; } }
From source file:blusunrize.immersiveengineering.common.items.ItemRailgun.java
public String[] compileRender(ItemStack stack) { HashSet<String> render = new HashSet<String>(); render.add("frame"); render.add("barrel"); render.add("grip"); render.add("capacitors"); render.add("sled"); render.add("wires"); NBTTagCompound upgrades = this.getUpgrades(stack); if (upgrades.getDouble("speed") > 0) render.add("upgrade_speed"); if (upgrades.getBoolean("scope")) render.add("upgrade_scope"); return render.toArray(new String[render.size()]); }
From source file:org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.java
@Override public List<OperationDocumentation> getDocumentation() throws OperationException { List<OperationDocumentation> result = new ArrayList<OperationDocumentation>(); HashSet<OperationType> ops = new HashSet<>(operations.lookup().values()); OperationCompoundExceptionBuilder errorBuilder = new OperationCompoundExceptionBuilder(); for (OperationType ot : ops.toArray(new OperationType[ops.size()])) { try {/*w w w . ja v a2 s .c o m*/ result.add(ot.getDocumentation()); } catch (OperationNotFoundException e) { errorBuilder.add(e); } } errorBuilder.throwOnError(); Collections.sort(result); return result; }
From source file:org.compass.core.lucene.engine.store.DefaultLuceneSearchEngineStore.java
public String[] calcSubIndexes(String[] subIndexes, String[] aliases) { if (aliases == null) { if (subIndexes == null) { return getSubIndexes(); }/* w w w .j a v a2 s.c o m*/ // filter out any duplicates HashSet<String> ret = new HashSet<String>(); ret.addAll(Arrays.asList(subIndexes)); return ret.toArray(new String[ret.size()]); } HashSet<String> ret = new HashSet<String>(); for (String aliase : aliases) { List<String> subIndexesList = subIndexesByAlias.get(aliase); if (subIndexesList == null) { throw new IllegalArgumentException("No sub-index is mapped to alias [" + aliase + "]"); } for (String subIndex : subIndexesList) { ret.add(subIndex); } } if (subIndexes != null) { ret.addAll(Arrays.asList(subIndexes)); } return ret.toArray(new String[ret.size()]); }
From source file:org.openmainframe.ade.ext.output.ExtJaxbAnalyzedIntervalV2XmlStorer.java
/** * Copy the XSL Resources//from w w w.j a v a2 s. c om */ @Override protected String[] getXSLResources() { if (s_xslResources == null) { HashSet<String> allXSLResourcesSet = new HashSet<String>(); List<String> thisXSLResourcesList = Arrays.asList(s_thisXSLResources); allXSLResourcesSet.addAll(thisXSLResourcesList); s_xslResources = new String[allXSLResourcesSet.size()]; s_xslResources = allXSLResourcesSet.toArray(s_xslResources); } return s_xslResources; }
From source file:org.jboss.dashboard.workspace.PanelsProvidersManagerImpl.java
/** * Returns all panels providers installed in the system allowed for given workspace * * @param workspace Workspace that allows returned providers. *///from ww w. j ava 2s . c o m public PanelProvider[] getProviders(Workspace workspace) { HashSet<PanelProvider> panelProviders = new HashSet<PanelProvider>(); for (PanelProvider p : panels.values()) { if (!p.isEnabled()) continue; if (workspace != null && !workspace.isProviderAllowed(p.getId()) && !workspace.isProviderAllowed("*")) continue; panelProviders.add(p); } PanelProvider[] p = panelProviders.toArray(new PanelProvider[panels.size()]); // Sort providers by description (just for display purpouses) Arrays.sort(p, new PanelProviderComparator()); return p; }
From source file:com.rc.droid_stalker.components.NetworkStats.java
/** * Return list of unique interfaces known by this data structure. *//*w ww.ja v a 2 s .c om*/ public String[] getUniqueIfaces() { final HashSet<String> ifaces = new HashSet<String>(); for (String iface : this.iface) { if (iface != IFACE_ALL) { ifaces.add(iface); } } return ifaces.toArray(new String[ifaces.size()]); }
From source file:org.hippoecm.repository.jackrabbit.SessionImplHelper.java
/** * Before this method the JackRabbiit Session.checkPermission is called. * That function checks the validity of absPath and the default JCR permissions: * read, remove, add_node and set_property. So we don't have to check for those * things again here.// w ww . j a v a2 s . c om * @param absPath * @param actions * @throws AccessControlException * @throws RepositoryException */ public void checkPermission(String absPath, String actions) throws AccessControlException, RepositoryException { AccessControlManager acMgr = session.getAccessControlManager(); // build the set of actions to be checked HashSet<Privilege> privileges = new HashSet<Privilege>(); for (String action : actions.split(",")) { privileges.add(acMgr.privilegeFromName(action)); } privileges.removeAll(jcrPrivileges); if (privileges.size() > 0) { if (!acMgr.hasPrivileges(absPath, privileges.toArray(new Privilege[privileges.size()]))) { throw new AccessControlException("Privileges '" + actions + "' denied for " + absPath); } } }
From source file:org.metaservice.core.utils.GitUtil.java
public String[] getParentHashes(@NotNull String revision) throws GitException { Process process = execInWorkdir("git rev-list --parents -n 1 " + revision); try {/*from w w w . ja va2 s . c o m*/ String s = IOUtils.toString(process.getInputStream()); debug(process); //ignore current LOGGER.info(s); s = s.replaceAll("^" + revision + "[^\\s]*", "").trim(); HashSet<String> parents = new HashSet<>(); int i = 0; LOGGER.info(s); while (!s.isEmpty() && i++ < 10) { String x = s.replaceAll("^([^\\s])+", "$0"); LOGGER.info("X " + x); if (x.length() > 1) parents.add(x); s = s.replaceAll("^([^\\s])+", "").trim(); LOGGER.info(s); } LOGGER.info("parents: " + revision + " -> " + parents); return parents.toArray(new String[parents.size()]); } catch (IOException e) { throw new GitException(e); } }
From source file:org.apache.axis.encoding.TypeMappingImpl.java
/** * Returns an array of all the classes contained within this mapping *///from w w w . j av a2 s. co m public Class[] getAllClasses(TypeMappingDelegate next) { java.util.HashSet temp = new java.util.HashSet(); if (next != null) { temp.addAll(java.util.Arrays.asList(next.getAllClasses())); } temp.addAll(class2Pair.keySet()); return (Class[]) temp.toArray(new Class[temp.size()]); }