List of usage examples for java.util Stack Stack
public Stack()
From source file:com.autentia.bcbp.elements.ConditionalItemsUnique.java
public ConditionalItemsUnique(String passengerDescription, String sourceCheckin, String sourceBoardingPassIssuance, String dateOfIssueOfBoardingPass, String documentType, String airlineDesignatorOfBoardingPassIssuer, String baggageTagLicencePlateNumber, String firstNCBaggageTagLicencePlateNumber, String secondNCBaggageTagLicencePlateNumber) { super();/*from ww w .j a va2s.c om*/ Stack<Item> items = new Stack<Item>(); items.push(new Item(passengerDescription, passengerDescriptionLength, 142, PaddingType.String)); items.push(new Item(sourceCheckin, sourceCheckinLength, 143, PaddingType.String)); items.push(new Item(sourceBoardingPassIssuance, sourceBoardingPassIssuanceLength, 18, PaddingType.String)); items.push(new Item(dateOfIssueOfBoardingPass, dateOfIssueOfBoardingPassLength, 108, PaddingType.Number)); items.push(new Item(documentType, documentTypeLength, 19, PaddingType.String)); items.push(new Item(airlineDesignatorOfBoardingPassIssuer, airlineDesignatorOfBoardingPassIssuerLength, 20, PaddingType.String)); items.push(new Item(baggageTagLicencePlateNumber, baggageTagLicencePlateNumberLength, 236, PaddingType.String)); items.push(new Item(firstNCBaggageTagLicencePlateNumber, firstNCBaggageTagLicencePlateNumberLength, 89, PaddingType.String)); items.push(new Item(secondNCBaggageTagLicencePlateNumber, secondNCBaggageTagLicencePlateNumberLength, 118, PaddingType.String)); final StringBuilder codeBuilder = new StringBuilder(); boolean starting = true; while (!items.isEmpty()) { Item item = items.pop(); 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 = ">" + BCBPversion + StringUtils .leftPad(Integer.toHexString(baseCode.length()), variableSizeLength, "0").toUpperCase() + baseCode; }
From source file:fr.inria.oak.paxquery.common.xml.nodeidentifier.CompactDynamicDeweyScheme.java
public CompactDynamicDeweyScheme() { currentId = new int[0]; parentId = new int[0]; currentTag = new int[0]; parentTag = new int[0]; currentSiblingNo = 0;//from www . j a va 2 s. c o m s = new Stack<CompactDynamicDeweyID>(); lastID = null; depth = 0; lastDepth = 0; currentChildren = new HashMap<int[], Integer>(); }
From source file:csns.importer.parser.MFTScoreParser.java
public void parse(MFTScoreImporter importer) { Department department = importer.getDepartment(); Date date = importer.getDate(); Scanner scanner = new Scanner(importer.getText()); scanner.useDelimiter("\\s+|\\r\\n|\\r|\\n"); while (scanner.hasNext()) { // last name String lastName = scanner.next(); while (!lastName.endsWith(",")) lastName += " " + scanner.next(); lastName = lastName.substring(0, lastName.length() - 1); // first name String firstName = scanner.next(); // score// w w w.j a v a 2 s .c om Stack<String> stack = new Stack<String>(); String s = scanner.next(); while (!isScore(s)) { stack.push(s); s = scanner.next(); } int value = Integer.parseInt(s); // authorization code stack.pop(); // cin String cin = null; if (!stack.empty() && isCin(stack.peek())) cin = stack.pop(); // user User user = null; if (cin != null) user = userDao.getUserByCin(cin); else { List<User> users = userDao.getUsers(lastName, firstName); if (users.size() == 1) user = users.get(0); } if (user != null) { MFTScore score = mftScoreDao.getScore(department, date, user); if (score == null) { score = new MFTScore(); score.setDepartment(department); score.setDate(date); score.setUser(user); } else { logger.info(user.getId() + ": " + score.getValue() + " => " + value); } score.setValue(value); importer.getScores().add(score); } else { User failedUser = new User(); failedUser.setLastName(lastName); failedUser.setFirstName(firstName); failedUser.setCin(cin); importer.getFailedUsers().add(failedUser); } logger.debug(lastName + "," + firstName + "," + cin + "," + value); } scanner.close(); }
From source file:net.naonedbus.manager.impl.ParkingPublicManager.java
private ParkingPublicManager() { this.mCache = new ArrayList<ParkingPublic>(); this.mParkingsTasks = new Stack<ParkingPublicTaskInfo>(); }
From source file:FlightInfo.java
void route(String to) { Stack rev = new Stack(); int dist = 0; FlightInfo f;/* w w w . j av a 2 s .c o m*/ int num = btStack.size(); // Reverse the stack to display route. for (int i = 0; i < num; i++) rev.push(btStack.pop()); for (int i = 0; i < num; i++) { f = (FlightInfo) rev.pop(); System.out.print(f.from + " to "); dist += f.distance; } System.out.println(to); System.out.println("Distance is " + dist); }
From source file:com.jaeksoft.searchlib.util.XmlWriter.java
public XmlWriter(PrintWriter out, String encoding) throws TransformerConfigurationException, SAXException { StreamResult streamResult = new StreamResult(out); SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); transformerHandler = tf.newTransformerHandler(); Transformer serializer = transformerHandler.getTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, encoding); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.METHOD, "xml"); transformerHandler.setResult(streamResult); startedElementStack = new Stack<String>(); transformerHandler.startDocument();/* w w w.ja va 2s. c o m*/ elementAttributes = new AttributesImpl(); Pattern p = Pattern.compile("\\p{Cntrl}"); controlMatcher = p.matcher(""); }
From source file:com.aurel.track.admin.customize.category.filter.tree.io.TreeFilterParser.java
public QNode parseDocument(String xml) { stack = new Stack<QNode>(); parse(xml); return root; }
From source file:edu.umd.honghongie.BooleanRetrievalCompressed.java
private void initialize(String indexPath, String collectionPath, FileSystem fs) throws IOException { index = new MapFile.Reader(new Path(indexPath + "/part-r-00000"), fs.getConf()); //where index is collection = fs.open(new Path(collectionPath)); //where the text is stack = new Stack<Set<Integer>>(); }
From source file:edu.umn.cs.spatialHadoop.operations.ConvexHull.java
/** * Computes the convex hull of a set of points using a divide and conquer * in-memory algorithm. This function implements Andrew's modification to * the Graham scan algorithm.//from ww w . java2 s. c om * * @param points * @return */ public static <P extends Point> P[] convexHullInMemory(P[] points) { Stack<P> s1 = new Stack<P>(); Stack<P> s2 = new Stack<P>(); Arrays.sort(points); // Lower chain for (int i = 0; i < points.length; i++) { while (s1.size() > 1) { P p1 = s1.get(s1.size() - 2); P p2 = s1.get(s1.size() - 1); P p3 = points[i]; double crossProduct = (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x); if (crossProduct <= 0) s1.pop(); else break; } s1.push(points[i]); } // Upper chain for (int i = points.length - 1; i >= 0; i--) { while (s2.size() > 1) { P p1 = s2.get(s2.size() - 2); P p2 = s2.get(s2.size() - 1); P p3 = points[i]; double crossProduct = (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x); if (crossProduct <= 0) s2.pop(); else break; } s2.push(points[i]); } s1.pop(); s2.pop(); s1.addAll(s2); return s1.toArray((P[]) Array.newInstance(s1.firstElement().getClass(), s1.size())); }
From source file:edu.unc.lib.dl.services.FolderManager.java
/** * Given a repository path string, creates any folders that do not yet exist along this path. * //from w ww . j a va 2 s .c o m * @param path * the desired folder path * @throws IngestException * if the path cannot be created */ public PID createPath(String path, String owner, String user) throws IngestException { log.debug("attempting to create path: " + path); if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } if (!PathUtil.isValidPathString(path)) { throw new IngestException("The proposed path is not valid: " + path); } List<String> slugs = new ArrayList<String>(); slugs.addAll(Arrays.asList(path.split("/"))); slugs.remove(0); Stack<String> createFolders = new Stack<String>(); String containerPath = null; for (int i = slugs.size(); i >= 0; i--) { String test = "/" + StringUtils.join(slugs.subList(0, i), "/"); PID pid = this.getTripleStoreQueryService().fetchByRepositoryPath(test); if (pid == null) { // does not exist yet, must create it createFolders.add(slugs.get(i - 1)); } else { List<URI> types = this.getTripleStoreQueryService().lookupContentModels(pid); if (!types.contains(ContentModelHelper.Model.CONTAINER.getURI())) { StringBuffer s = new StringBuffer(); for (URI type : types) { s.append(type.toString()).append("\t"); } throw new IngestException("The object at the path '" + test + "' is not a folder. It has these content models:\n" + s.toString()); } containerPath = test; break; } } // add folders PID lastpid = null; while (createFolders.size() > 0) { String slug = createFolders.pop(); SingleFolderSIP sip = new SingleFolderSIP(); PID containerPID = this.getTripleStoreQueryService().fetchByRepositoryPath(containerPath); sip.setContainerPID(containerPID); if ("/".equals(containerPath)) { containerPath = containerPath + slug; } else { containerPath = containerPath + "/" + slug; } sip.setSlug(slug); sip.setAllowIndexing(true); DepositRecord record = new DepositRecord(user, owner, DepositMethod.Unspecified); record.setMessage("creating a new folder path"); IngestResult result = this.getDigitalObjectManager().addWhileBlocking(sip, record); lastpid = result.derivedPIDs.iterator().next(); } return lastpid; }