List of usage examples for java.util LinkedList addAll
public boolean addAll(Collection<? extends E> c)
From source file:com.ikanow.infinit.e.data_model.custom.InfiniteEsInputFormat.java
@Override public List getSplits(JobContext arg0) throws IOException, InterruptedException { LinkedList<InputSplit> fullList = new LinkedList<InputSplit>(); String indexes[] = arg0.getConfiguration().get("es.resource").split("\\s*,,\\s*"); for (String index : indexes) { _delegate = new EsInputFormat(); // create a new input format for each object arg0.getConfiguration().set("es.resource.read", index.replace(" ", "%20")); // (spaces in types cause problems) @SuppressWarnings("unchecked") List<InputSplit> list = _delegate.getSplits(arg0); if (LOCAL_DEBUG_MODE) enableInputSplitDebugMode(list); fullList.addAll(list); }//from www . j av a 2 s.c o m return fullList; }
From source file:edu.illinois.cs.cogcomp.nlp.corpusreaders.ereReader.EREDocumentReader.java
/** * ERE corpus directory has two directories: source/ and ere/. The source/ directory contains * original text in an xml format. The ere/ directory contains markup files corresponding in a * many-to-one relationship with the source/ files: related annotation files have the same * prefix as the corresponding source file (up to the .xml suffix). * (NOTE: release 1 (LDC2015E29) has two subdirectories for both source and annotation: one version is slightly * modified by adding xml markup to make the source documents well-formed, which changes the annotation offsets. * * This method generates a List of List of Paths: each component List has the source file as its * first element, and markup files as its remaining elements. It expects {@link * super.getSourceDirectory()} to return the root directory of the ERE corpus, under which * should be data/source/ and data/ere/ directories containing source files and annotation files * respectively./*from w ww .j av a 2 s. c o m*/ * * @return a list of Path objects corresponding to files containing corpus documents to process. */ @Override public List<List<Path>> getFileListing() throws IOException { FilenameFilter sourceFilter = (dir, name) -> true; if (!"".equals(getRequiredSourceFileExtension())) sourceFilter = (dir, name) -> name.endsWith(getRequiredAnnotationFileExtension()); /* * returns the FULL PATH of each file */ String sourceDir = resourceManager.getString(CorpusReaderConfigurator.SOURCE_DIRECTORY.key); List<String> sourceFileList = Arrays.asList(IOUtils.lsFilesRecursive(sourceDir, sourceFilter)); LinkedList<String> annotationFileList = new LinkedList<>(); FilenameFilter annotationFilter = (dir, name) -> name.endsWith(getRequiredAnnotationFileExtension()); String annotationDir = resourceManager.getString(CorpusReaderConfigurator.ANNOTATION_DIRECTORY.key); annotationFileList.addAll(Arrays.stream(IOUtils.lsFilesRecursive(annotationDir, annotationFilter)) .map(IOUtils::getFileName).collect(Collectors.toList())); List<List<Path>> pathList = new ArrayList<>(); /* * fileList has multiple entries per single annotation: a source file plus one or more * annotation files. These files share a prefix -- the stem of the file containing * the source text. */ for (String fileName : sourceFileList) { List<Path> sourceAndAnnotations = new ArrayList<>(); Path fPath = Paths.get(fileName); // source file sourceAndAnnotations.add(fPath); String stem = this.getFileStem(fPath, getRequiredSourceFileExtension()); // strip *source* extension for (String annFile : annotationFileList) { if (annFile.startsWith(stem)) { logger.debug("Processing file '{}'", annFile); sourceAndAnnotations.add( Paths.get(resourceManager.getString(CorpusReaderConfigurator.ANNOTATION_DIRECTORY.key) + annFile)); } } pathList.add(sourceAndAnnotations); } return pathList; }
From source file:org.pdfsam.plugin.decrypt.listeners.RunButtonActionListener.java
public void actionPerformed(ActionEvent e) { if (WorkExecutor.getInstance().getRunningThreads() > 0 || panel.getSelectionPanel().isAdding()) { DialogUtility.showWarningAddingDocument(panel); return;/*w ww. j a v a 2 s. c o m*/ } PdfSelectionTableItem[] items = panel.getSelectionPanel().getTableRows(); if (ArrayUtils.isEmpty(items)) { DialogUtility.showWarningNoDocsSelected(panel, DialogUtility.AT_LEAST_ONE_DOC); return; } final LinkedList<String> args = new LinkedList<String>(); try { // overwrite confirmation if (panel.getOverwriteCheckbox().isSelected() && Configuration.getInstance().isAskOverwriteConfirmation()) { int dialogRet = DialogUtility.askForOverwriteConfirmation(panel); if (JOptionPane.NO_OPTION == dialogRet) { panel.getOverwriteCheckbox().setSelected(false); } else if (JOptionPane.CANCEL_OPTION == dialogRet) { return; } } args.addAll(getInputFilesArguments(items)); args.add("-" + DecryptParsedCommand.O_ARG); if (StringUtils.isEmpty(panel.getDestinationTextField().getText())) { String suggestedDir = getSuggestedDestinationDirectory(items[items.length - 1]); int chosenOpt = DialogUtility.showConfirmOuputLocationDialog(panel, suggestedDir); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getDestinationTextField().setText(suggestedDir); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } args.add(panel.getDestinationTextField().getText()); if (panel.getOverwriteCheckbox().isSelected()) { args.add("-" + DecryptParsedCommand.OVERWRITE_ARG); } if (panel.getOutputCompressedCheck().isSelected()) { args.add("-" + DecryptParsedCommand.COMPRESSED_ARG); } args.add("-" + EncryptParsedCommand.P_ARG); args.add(panel.getOutPrefixTextField().getText()); args.add("-" + DecryptParsedCommand.PDFVERSION_ARG); args.add(((StringItem) panel.getVersionCombo().getSelectedItem()).getId()); args.add(AbstractParsedCommand.COMMAND_DECRYPT); String[] myStringArray = args.toArray(new String[args.size()]); WorkExecutor.getInstance().execute(new WorkThread(myStringArray)); } catch (Exception ex) { log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error: "), ex); SoundPlayer.getInstance().playErrorSound(); } }
From source file:org.pdfsam.plugin.rotate.listeners.RunButtonActionListener.java
public void actionPerformed(ActionEvent e) { if (WorkExecutor.getInstance().getRunningThreads() > 0 || panel.getSelectionPanel().isAdding()) { DialogUtility.showWarningAddingDocument(panel); return;// w ww. j a v a 2 s.c om } PdfSelectionTableItem[] items = panel.getSelectionPanel().getTableRows(); if (ArrayUtils.isEmpty(items)) { DialogUtility.showWarningNoDocsSelected(panel, DialogUtility.AT_LEAST_ONE_DOC); return; } LinkedList<String> args = new LinkedList<String>(); try { // overwrite confirmation if (panel.getOverwriteCheckbox().isSelected() && Configuration.getInstance().isAskOverwriteConfirmation()) { int dialogRet = DialogUtility.askForOverwriteConfirmation(panel); if (JOptionPane.NO_OPTION == dialogRet) { panel.getOverwriteCheckbox().setSelected(false); } else if (JOptionPane.CANCEL_OPTION == dialogRet) { return; } } args.addAll(getInputFilesArguments(items)); args.add("-" + RotateParsedCommand.O_ARG); if (StringUtils.isEmpty(panel.getDestinationTextField().getText())) { String suggestedDir = getSuggestedDestinationDirectory(items[items.length - 1]); int chosenOpt = DialogUtility.showConfirmOuputLocationDialog(panel, suggestedDir); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getDestinationTextField().setText(suggestedDir); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } args.add(panel.getDestinationTextField().getText()); if (panel.getOverwriteCheckbox().isSelected()) { args.add("-" + RotateParsedCommand.OVERWRITE_ARG); } if (panel.getOutputCompressedCheck().isSelected()) { args.add("-" + RotateParsedCommand.COMPRESSED_ARG); } args.add("-" + RotateParsedCommand.R_ARG); args.add(((StringItem) panel.getRotationPagesBox().getSelectedItem()).getId() + ":" + panel.getRotationBox().getSelectedItem()); args.add("-" + RotateParsedCommand.P_ARG); args.add(panel.getOutPrefixTextField().getText()); args.add("-" + RotateParsedCommand.PDFVERSION_ARG); args.add(((StringItem) panel.getVersionCombo().getSelectedItem()).getId()); args.add(AbstractParsedCommand.COMMAND_ROTATE); String[] myStringArray = args.toArray(new String[args.size()]); WorkExecutor.getInstance().execute(new WorkThread(myStringArray)); } catch (Exception ex) { log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error: "), ex); SoundPlayer.getInstance().playErrorSound(); } }
From source file:fr.inria.oak.paxquery.common.xml.navigation.NavigationTreePattern.java
public ArrayList<String> getColumnsNames() { LinkedList<NavigationTreePatternNode> nodes = this.getNodes(); LinkedList<String> list = new LinkedList<String>(); list.add("Document ID"); for (NavigationTreePatternNode node : nodes) list.addAll(node.getColumnsName()); return new ArrayList<String>(list); }
From source file:org.squashtest.tm.domain.library.structures.LibraryTree.java
/** * removes a node and its subtree//from w w w.j a v a 2 s . c om * * @param key */ public void cut(IDENT key) { T node = getNode(key); T parent = node.getParent(); if (parent != null) { parent.getChildren().remove(node); } LinkedList<T> processing = new LinkedList<>(); processing.add(node); while (!processing.isEmpty()) { T current = processing.pop(); List<T> layer = layers.get(current.getDepth()); layer.remove(current); processing.addAll(current.getChildren()); } }
From source file:org.jahia.services.seo.urlrewrite.UrlRewriteService.java
protected List<HandlerMapping> getRenderMapping() { if (renderMapping == null) { LinkedList<HandlerMapping> mapping = new LinkedList<HandlerMapping>(); ApplicationContext ctx = (ApplicationContext) servletContext.getAttribute( "org.springframework.web.servlet.FrameworkServlet.CONTEXT.RendererDispatcherServlet"); if (ctx != null) { mapping.addAll(ctx.getBeansOfType(HandlerMapping.class).values()); mapping.addAll(ctx.getParent().getBeansOfType(HandlerMapping.class).values()); renderMapping = mapping;/*from w w w . j a va 2 s .c o m*/ } } if (renderMapping != null) { List<HandlerMapping> l = new LinkedList<HandlerMapping>(renderMapping); l.addAll(ServicesRegistry.getInstance().getJahiaTemplateManagerService().getTemplatePackageRegistry() .getSpringHandlerMappings()); return l; } return null; }
From source file:org.pdfsam.plugin.unpack.listeners.RunButtonActionListener.java
public void actionPerformed(ActionEvent arg0) { if (WorkExecutor.getInstance().getRunningThreads() > 0 || panel.getSelectionPanel().isAdding()) { DialogUtility.showWarningAddingDocument(panel); return;// ww w . j a v a 2 s . com } PdfSelectionTableItem[] items = panel.getSelectionPanel().getTableRows(); if (ArrayUtils.isEmpty(items)) { DialogUtility.showWarningNoDocsSelected(panel, DialogUtility.AT_LEAST_ONE_DOC); return; } LinkedList<String> args = new LinkedList<String>(); // validation and permission check are demanded to the CmdParser object try { // overwrite confirmation if (panel.getOverwriteCheckbox().isSelected() && Configuration.getInstance().isAskOverwriteConfirmation()) { int dialogRet = DialogUtility.askForOverwriteConfirmation(panel); if (JOptionPane.NO_OPTION == dialogRet) { panel.getOverwriteCheckbox().setSelected(false); } else if (JOptionPane.CANCEL_OPTION == dialogRet) { return; } } args.addAll(getInputFilesArguments(items)); args.add("-" + UnpackParsedCommand.O_ARG); if (StringUtils.isEmpty(panel.getDestinationTextField().getText())) { String suggestedDir = getSuggestedDestinationDirectory(items[items.length - 1]); int chosenOpt = DialogUtility.showConfirmOuputLocationDialog(panel, suggestedDir); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getDestinationTextField().setText(suggestedDir); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } args.add(panel.getDestinationTextField().getText()); if (panel.getOverwriteCheckbox().isSelected()) { args.add("-" + UnpackParsedCommand.OVERWRITE_ARG); } args.add(UnpackParsedCommand.COMMAND_UNPACK); String[] myStringArray = (String[]) args.toArray(new String[args.size()]); WorkExecutor.getInstance().execute(new WorkThread(myStringArray)); } catch (Exception e) { log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error: "), e); SoundPlayer.getInstance().playErrorSound(); } }
From source file:org.apache.hadoop.mapred.util.ProcfsBasedProcessTree.java
/** * Get the process-tree with latest state. If the root-process is not alive, * an empty tree will be returned.//from w ww . ja v a 2 s . com * * @return the process-tree with latest state. */ public ProcfsBasedProcessTree getProcessTree() { if (pid != -1) { // Get the list of processes List<Integer> processList = getProcessList(); Map<Integer, ProcessInfo> allProcessInfo = new HashMap<Integer, ProcessInfo>(); // cache the processTree to get the age for processes Map<Integer, ProcessInfo> oldProcs = new HashMap<Integer, ProcessInfo>(processTree); processTree.clear(); ProcessInfo me = null; for (Integer proc : processList) { // Get information for each process ProcessInfo pInfo = new ProcessInfo(proc); if (constructProcessInfo(pInfo, procfsDir) != null) { allProcessInfo.put(proc, pInfo); if (proc.equals(this.pid)) { me = pInfo; // cache 'me' processTree.put(proc, pInfo); } } } if (me == null) { return this; } // Add each process to its parent. for (Map.Entry<Integer, ProcessInfo> entry : allProcessInfo.entrySet()) { Integer pID = entry.getKey(); if (pID != 1) { ProcessInfo pInfo = entry.getValue(); ProcessInfo parentPInfo = allProcessInfo.get(pInfo.getPpid()); if (parentPInfo != null) { parentPInfo.addChild(pInfo); } } } // now start constructing the process-tree LinkedList<ProcessInfo> pInfoQueue = new LinkedList<ProcessInfo>(); pInfoQueue.addAll(me.getChildren()); while (!pInfoQueue.isEmpty()) { ProcessInfo pInfo = pInfoQueue.remove(); if (!processTree.containsKey(pInfo.getPid())) { processTree.put(pInfo.getPid(), pInfo); } pInfoQueue.addAll(pInfo.getChildren()); } // update age values and compute the number of jiffies since last update for (Map.Entry<Integer, ProcessInfo> procs : processTree.entrySet()) { ProcessInfo oldInfo = oldProcs.get(procs.getKey()); if (procs.getValue() != null) { procs.getValue().updateJiffy(oldInfo); if (oldInfo != null) { procs.getValue().updateAge(oldInfo); } } } if (LOG.isDebugEnabled()) { // Log.debug the ProcfsBasedProcessTree LOG.debug(this.toString()); } } return this; }
From source file:org.pdfsam.plugin.mix.listeners.RunButtonActionListener.java
public void actionPerformed(ActionEvent arg0) { if (WorkExecutor.getInstance().getRunningThreads() > 0 || panel.getSelectionPanel().isAdding()) { DialogUtility.showWarningAddingDocument(panel); return;/*from ww w. ja v a 2 s . c om*/ } PdfSelectionTableItem[] items = panel.getSelectionPanel().getTableRows(); if (items == null || items.length != 2) { DialogUtility.showWarningNoDocsSelected(panel, DialogUtility.TWO_DOC); return; } if (StringUtils.isEmpty(panel.getDestinationTextField().getText())) { DialogUtility.showWarningNoDestinationSelected(panel, DialogUtility.FILE_DESTINATION); return; } LinkedList<String> args = new LinkedList<String>(); try { // overwrite confirmation if (panel.getOverwriteCheckbox().isSelected() && Configuration.getInstance().isAskOverwriteConfirmation()) { int dialogRet = DialogUtility.askForOverwriteConfirmation(panel); if (JOptionPane.NO_OPTION == dialogRet) { panel.getOverwriteCheckbox().setSelected(false); } else if (JOptionPane.CANCEL_OPTION == dialogRet) { return; } } args.addAll(getInputFilesArguments(items)); String destination = ""; // if no extension given ensurePdfExtensionOnTextField(panel.getDestinationTextField()); File destinationDir = new File(panel.getDestinationTextField().getText()); File parent = destinationDir.getParentFile(); if (!(parent != null && parent.exists())) { String suggestedDir = getSuggestedOutputFile(items[items.length - 1], destinationDir.getName()); int chosenOpt = DialogUtility.showConfirmOuputLocationDialog(panel, suggestedDir); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getDestinationTextField().setText(suggestedDir); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } destination = panel.getDestinationTextField().getText(); // check if the file already exists and the user didn't select to overwrite File destFile = (destination != null) ? new File(destination) : null; if (destFile != null && destFile.exists() && !panel.getOverwriteCheckbox().isSelected()) { int chosenOpt = DialogUtility.askForOverwriteOutputFileDialog(panel, destFile.getName()); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getOverwriteCheckbox().setSelected(true); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } args.add("-" + MixParsedCommand.O_ARG); args.add(destination); String step = panel.getStepTextField().getText(); if (StringUtils.isNotEmpty(step)) { args.add("-" + MixParsedCommand.STEP_ARG); args.add(step); } String secondStep = panel.getSecondStepTextField().getText(); if (StringUtils.isNotEmpty(secondStep)) { args.add("-" + MixParsedCommand.SECOND_STEP_ARG); args.add(secondStep); } if (panel.getOverwriteCheckbox().isSelected()) args.add("-" + MixParsedCommand.OVERWRITE_ARG); if (panel.getOutputCompressedCheck().isSelected()) args.add("-" + MixParsedCommand.COMPRESSED_ARG); if (panel.getReverseFirstCheckbox().isSelected()) args.add("-" + MixParsedCommand.REVERSE_FIRST_ARG); if (panel.getReverseSecondCheckbox().isSelected()) args.add("-" + MixParsedCommand.REVERSE_SECOND_ARG); args.add("-" + MixParsedCommand.PDFVERSION_ARG); args.add(((StringItem) panel.getVersionCombo().getSelectedItem()).getId()); args.add(MixParsedCommand.COMMAND_MIX); String[] myStringArray = args.toArray(new String[args.size()]); WorkExecutor.getInstance().execute(new WorkThread(myStringArray)); } catch (Exception ex) { log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error: "), ex); SoundPlayer.getInstance().playErrorSound(); } }