List of usage examples for java.util Stack push
public E push(E item)
From source file:maltcms.ui.fileHandles.properties.tools.SceneExporter.java
private void lock(FileObject fo, Stack<FileLock> s) { if (fo.isLocked()) { return;/*from w w w.j a v a2s.c o m*/ } FileLock fl = FileLock.NONE; try { fl = fo.lock(); } catch (Throwable ex) { // Exceptions.printStackTrace(ex); } if (fl.equals(FileLock.NONE)) { return; } s.push(fl); }
From source file:com.inmobi.conduit.distcp.tools.mapred.TestCopyCommitter.java
private boolean checkDirectoryPermissions(FileSystem fs, String targetBase, FsPermission sourcePerm) throws IOException { Path base = new Path(targetBase); Stack<Path> stack = new Stack<Path>(); stack.push(base); while (!stack.isEmpty()) { Path file = stack.pop();/*from ww w . jav a 2 s . c o m*/ if (!fs.exists(file)) continue; FileStatus[] fStatus = fs.listStatus(file); if (fStatus == null || fStatus.length == 0) continue; for (FileStatus status : fStatus) { if (status.isDir()) { stack.push(status.getPath()); Assert.assertEquals(status.getPermission(), sourcePerm); } } } return true; }
From source file:ome.formats.importer.gui.FileQueueChooser.java
/** * Get all JLists and JTables if the LAF uses lists/tables * /*from w ww.ja v a2s . c o m*/ * @param fileChooser fileChooser * @return fileListObjects */ public Component[] getFileListObjects(JFileChooser fileChooser) { Vector<Component> v = new Vector<Component>(); Stack<Component> s = new Stack<Component>(); s.push(fileChooser); while (!s.isEmpty()) { Component c = (Component) s.pop(); if (c instanceof Container) { Container d = (Container) c; for (int i = 0; i < d.getComponentCount(); i++) { if (d.getComponent(i) instanceof JTable) { v.add(d.getComponent(i)); } else s.push(d.getComponent(i)); } } } Component[] arr = new Component[v.size()]; for (int i = 0; i < arr.length; i++) arr[i] = v.get(i); return arr; }
From source file:edu.mit.lib.tools.Modernize.java
private void communityManifest(Community comm) throws IOException, SQLException { Stack<Community> parents = new Stack<>(); Community parent = comm.getParentCommunity(); while (parent != null) { parents.push(parent); parent = parent.getParentCommunity(); }//from ww w .jav a 2 s. c o m int level = manif.addParents(parents); manif.addCommunity(comm, level); }
From source file:com.tune.reporting.base.endpoints.EndpointBase.java
/** * Validate any parentheses within string are balanced. * @param str Contents partitioned with parentheses. * @return Boolean If contents contains balanced parentheses returns true. *///w w w. j a v a 2 s . co m public static boolean isParenthesesBalanced(final String str) { if (str.isEmpty()) { return true; } Stack<Character> stack = new Stack<Character>(); for (int i = 0; i < str.length(); i++) { char current = str.charAt(i); if (current == '{' || current == '(' || current == '[') { stack.push(current); } if (current == '}' || current == ')' || current == ']') { if (stack.isEmpty()) { return false; } char last = stack.peek(); if (current == '}' && last == '{' || current == ')' && last == '(' || current == ']' && last == '[') { stack.pop(); } else { return false; } } } return stack.isEmpty(); }
From source file:edu.mit.lib.tools.Modernize.java
private void collectionManifest(Collection coll) throws IOException, SQLException { Stack<Community> parents = new Stack<>(); Community parent = (Community) coll.getParentObject(); while (parent != null) { parents.push(parent); parent = parent.getParentCommunity(); }/*w w w . j ava 2 s . c om*/ int level = manif.addParents(parents); manif.addCollection(coll, level); }
From source file:gr.omadak.leviathan.asp.AspParser.java
public void parseDir(File sdir, boolean vbDefault) { FileFilter filter = new FileFilter() { public boolean accept(File f) { boolean result = f.isDirectory(); if (!result) { String name = f.getName(); int lastDot = name.lastIndexOf('.'); result = lastDot > 0 && "asp".equalsIgnoreCase(name.substring(lastDot + 1)); }/*from w ww.java 2s . c o m*/ return result; } }; Stack stack = new Stack(); stack.push(sdir); while (!stack.isEmpty()) { File dir = (File) stack.pop(); for (Iterator it = IteratorUtils.arrayIterator(dir.listFiles(filter)); it.hasNext();) { File f = (File) it.next(); if (f.isDirectory()) { stack.push(f); } else { try { parseFile(f, vbDefault); } catch (ANTLRException ae) { LOG.error("Failed to parse file:" + f.getAbsolutePath(), ae); } catch (Exception ex) { LOG.error("Failed to parse file:" + f.getAbsolutePath() + " with error", ex); } } } } }
From source file:com.quiltplayer.core.storage.neo.NeoStorage.java
@Override @Transactional//from ww w . j a v a 2 s. c om public Stack<Album> getAlbumsAsStack(final Collection<Artist> artists) { final Stack<Album> albums = new Stack<Album>(); for (final Artist artist : artists) { for (Album album : artist.getAlbums()) { albums.push(album); } } return albums; }
From source file:csns.importer.parser.csula.RosterParserImpl.java
/** * This parser handles the format under Self Service -> Faculty Center -> My * Schedule on GET. A sample record is as follows: * "Doe,John M 302043188 3.00 Engr, Comp Sci, & Tech CS MS". Again, not all * fields may be present.//w ww . j ava 2 s . co m */ private List<ImportedUser> parse2(String text) { List<ImportedUser> students = new ArrayList<ImportedUser>(); Stack<String> stack = new Stack<String>(); Scanner scanner = new Scanner(text); scanner.useDelimiter("\\s+|\\r\\n|\\r|\\n"); while (scanner.hasNext()) { String name = ""; do { String token = scanner.next(); if (!isName(token)) stack.push(token); else { name = token; while (!stack.isEmpty() && !isDegree(stack.peek())) name = stack.pop() + " " + name; break; } } while (scanner.hasNext()); String cin = ""; boolean cinFound = false; while (scanner.hasNext()) { cin = scanner.next(); if (isCin(cin)) { cinFound = true; break; } else name += " " + cin; } if (cinFound) { ImportedUser student = new ImportedUser(); student.setCin(cin); student.setName(name); students.add(student); } } scanner.close(); return students; }
From source file:org.apache.hadoop.hbase.backup.mapreduce.MapReduceBackupMergeJob.java
/** * Converts path before copying//from www . j ava 2 s .c om * @param p path * @param backupDirPath backup root * @return converted path */ protected Path convertToDest(Path p, Path backupDirPath) { String backupId = backupDirPath.getName(); Stack<String> stack = new Stack<String>(); String name = null; while (true) { name = p.getName(); if (!name.equals(backupId)) { stack.push(name); p = p.getParent(); } else { break; } } Path newPath = new Path(backupDirPath.toString()); while (!stack.isEmpty()) { newPath = new Path(newPath, stack.pop()); } return newPath; }