List of usage examples for java.util Stack Stack
public Stack()
From source file:controller.PlayController.java
public PlayController() { changes = new Stack<>(); if (currentPlay == null) { currentPlay = new Play(); }//from ww w . ja v a2 s.c o m //System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "20");+ }
From source file:net.sf.jabref.HelpContent.java
public HelpContent(JabRefPreferences prefs_) { super();/* www.jav a 2 s . co m*/ pane = new JScrollPane(this, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); pane.setDoubleBuffered(true); prefs = prefs_; history = new Stack<URL>(); forw = new Stack<URL>(); setEditorKitForContentType("text/html", new MyEditorKit()); setContentType("text/html"); setText(""); setEditable(false); // Handles Anchors final HyperlinkListener hyperLinkListener = new HyperlinkListener() { public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getDescription().startsWith("#")) { scrollToReference(e.getDescription().substring(1)); } } }; addHyperlinkListener(hyperLinkListener); }
From source file:com.joliciel.csvLearner.features.NormalisationLimitReader.java
public Map<String, Float> read() { Map<String, Float> featureToMaxMap = new TreeMap<String, Float>(); try {/*from w ww . j a v a 2 s . com*/ if (inputStream != null) { this.readCSVFile(inputStream, featureToMaxMap); } else if (file.isDirectory()) { Stack<File> directoryStack = new Stack<File>(); directoryStack.add(file); while (!directoryStack.isEmpty()) { File directory = directoryStack.pop(); LOG.debug("Scanning directory: " + directory.getName()); File[] files = directory.listFiles(); if (files == null) { continue; } for (File oneFile : files) { if (oneFile.isDirectory()) { directoryStack.push(oneFile); } else if (oneFile.getName().endsWith(".nrm_limits.csv")) { LOG.debug("Scanning limits file : " + oneFile.getName()); this.readCSVFile(new FileInputStream(oneFile), featureToMaxMap); } else { LOG.trace("Ignoring : " + oneFile.getName()); } } } } else { LOG.debug("Scanning limits file : " + file.getName()); this.readCSVFile(new FileInputStream(file), featureToMaxMap); } } catch (FileNotFoundException e) { throw new RuntimeException(e); } return featureToMaxMap; }
From source file:de.ep3.ftpc.model.CrawlerDirectories.java
public CrawlerDirectories(FTPClient ftpClient, String includePaths, String excludePaths) { this.ftpClient = ftpClient; if (includePaths == null || includePaths.length() == 0) { includePaths = "/"; }//from www .jav a 2 s . c om if (excludePaths == null || excludePaths.length() == 0) { excludePaths = null; } this.includePaths = new Vector<>(); for (String includePath : includePaths.split("\n")) { this.includePaths.add(includePath.trim()); } this.excludePaths = new Vector<>(); if (excludePaths != null) { for (String excludePath : excludePaths.split("\n")) { this.excludePaths.add(excludePath.trim()); } } directoryStack = new Stack<>(); }
From source file:com.autentia.bcbp.elements.ConditionalItemsRepeated.java
private ConditionalItemsRepeated(String airlineNumericCode, String serialNumber, String selecteeIndicator, String internationalDocumentVerification, String marketingCarrierDesignator, String frecuentFlyerAirlineDesignator, String frecuentFlyerNumber, String iDADIndicator, String freeBaggageAllowance, String fastTrack) { Stack<Item> items = new Stack<Item>(); items.push(new Item(airlineNumericCode, airlineNumericCodeLength, 142, PaddingType.Number)); items.push(new Item(serialNumber, serialNumberLength, 143, PaddingType.Number)); items.push(new Item(selecteeIndicator, selecteeIndicatorLength, 18, PaddingType.String)); items.push(new Item(internationalDocumentVerification, internationalDocumentVerificationLength, 108, PaddingType.String)); items.push(new Item(marketingCarrierDesignator, marketingCarrierDesignatorLength, 19, PaddingType.String)); items.push(new Item(frecuentFlyerAirlineDesignator, frecuentFlyerAirlineDesignatorLength, 20, PaddingType.String)); items.push(new Item(frecuentFlyerNumber, frecuentFlyerNumberLength, 236, PaddingType.String)); items.push(new Item(iDADIndicator, IDADIndicatorLength, 89, PaddingType.String)); items.push(new Item(freeBaggageAllowance, freeBaggageAllowanceLength, 118, PaddingType.String)); items.push(new Item(fastTrack, fastTrackLength, 254, PaddingType.String)); final StringBuilder codeBuilder = new StringBuilder(); boolean starting = true; while (!items.isEmpty()) { Item item = items.pop();/*from www . jav a2 s .c o m*/ if (starting && StringUtils.isNotBlank(item.getEncoded()) || !removeEndingEmptyElements) starting = false; if (!starting) codeBuilder.insert(0, item.getEncoded()); } final String baseCode = codeBuilder.toString(); if (StringUtils.isBlank(baseCode)) { code = ""; } else { code = StringUtils.leftPad(Integer.toHexString(baseCode.length()), variableSizeLength, "0") .toUpperCase() + baseCode; } }
From source file:BooleanRetrieval.java
private void initialize(String indexPath, String collectionPath, FileSystem fs) throws IOException { index = new MapFile.Reader(new Path(indexPath + "/part-r-00000"), fs.getConf()); collection = fs.open(new Path(collectionPath)); stack = new Stack<Set<Integer>>(); }
From source file:com.amalto.core.history.UniqueIdTransformer.java
public void addIds(org.w3c.dom.Document document) { Stack<Integer> levels = new Stack<Integer>(); levels.push(0);//from www. ja va2s. c o m { Element documentElement = document.getDocumentElement(); if (documentElement != null) { _addIds(document, documentElement, levels); } } levels.pop(); }
From source file:EditorPaneTest.java
public EditorPaneFrame() { setTitle("EditorPaneTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); final Stack<String> urlStack = new Stack<String>(); final JEditorPane editorPane = new JEditorPane(); final JTextField url = new JTextField(30); // set up hyperlink listener editorPane.setEditable(false);/*from w w w . ja v a2 s.c om*/ editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); add(new JScrollPane(editorPane), BorderLayout.CENTER); // put all control components in a panel JPanel panel = new JPanel(); panel.add(new JLabel("URL")); panel.add(url); panel.add(loadButton); panel.add(backButton); panel.add(new JLabel("Editable")); panel.add(editable); add(panel, BorderLayout.SOUTH); }
From source file:com.galenframework.parser.IndentationStructureParser.java
public List<StructNode> parse(InputStream stream, String source) throws IOException { Stack<IndentationNode> nodeStack = new Stack<IndentationNode>(); StructNode rootNode = new StructNode(); nodeStack.push(new IndentationNode(-1, rootNode, null)); List<String> lines = IOUtils.readLines(stream); int lineNumber = 0; for (String line : lines) { lineNumber++;// www. j a v a2s . c o m if (isProcessable(line)) { processLine(nodeStack, line, lineNumber, source); } } return rootNode.getChildNodes(); }
From source file:org.apache.bigtop.bigpetstore.qstream.HttpLoadGen.java
/** * Appends via REST calls.//from w w w. j av a 2 s . c om */ public LinkedBlockingQueue<Transaction> startWriteQueue(final int milliseconds) { /** * Write queue. Every 5 seconds, write */ final LinkedBlockingQueue<Transaction> transactionQueue = new LinkedBlockingQueue<Transaction>( getQueueSize()); new Thread() { @Override public void run() { int fileNumber = 0; while (true) { waitFor(milliseconds, transactionQueue); System.out.println("CLEARING " + transactionQueue.size() + " elements from queue."); Stack<Transaction> transactionsToWrite = new Stack<Transaction>(); transactionQueue.drainTo(transactionsToWrite); /** * pop transactions from the queue, and sent them over http as json. */ while (!transactionsToWrite.isEmpty()) { try { String trAsJson = URLEncoder.encode(Utils.toJson(transactionsToWrite.pop())); /** * i.e. wget http://localhost:3000/rpush/guestbook/{"name":"cos boudnick", "state":"...",...} */ HttpResponse resp = Utils.get(path + "/" + trAsJson); if (total % 20 == 0) System.out.println("wrote customer " + trAsJson); total++; } catch (Throwable t) { System.err.println("transaction failed.... !"); t.printStackTrace(); } System.out.println("TRANSACTIONS SO FAR " + total++ + " RATE " + total / ((System.currentTimeMillis() - startTime) / 1000)); } } } }.start(); return transactionQueue; }