Example usage for java.util Stack Stack

List of usage examples for java.util Stack Stack

Introduction

In this page you can find the example usage for java.util Stack Stack.

Prototype

public Stack() 

Source Link

Document

Creates an empty Stack.

Usage

From source file:com.github.jasonruckman.sidney.generator.BeanBuilder.java

public static <R> BeanBuilder<R> stub(final Class<R> type) {
    InstanceFactory<R> fact = new DefaultInstanceFactory<>(type);
    R stub = fact.newInstance();//from  w w  w  .ja va  2 s . com
    ProxyFactory factory = new ProxyFactory(stub);
    final Stack<Method> m = new Stack<>();
    factory.addAdvice(new MethodInterceptor() {
        @Override
        public Object invoke(MethodInvocation methodInvocation) throws Throwable {
            PropertyDescriptor descriptor = BeanUtils.findPropertyForMethod(methodInvocation.getMethod());
            if (descriptor == null) {
                throw new IllegalStateException(String.format("Method %s is not a getter or setter",
                        methodInvocation.getMethod().getName()));
            }
            m.push(methodInvocation.getMethod());
            return defaultReturnObjects.get(methodInvocation.getMethod().getReturnType());
        }
    });
    return new BeanBuilder<>((R) factory.getProxy(), fact, m);
}

From source file:BreadthFirstFileTreeIterator.java

/** Construct a new BreadthFirstFileTreeIterator with the specified root.
        /*from   w w w. ja va2s .  com*/
@param root The root directory
*/

public BreadthFirstFileTreeIterator(File root) {
    this.root = root;
    this.currentList = root.listFiles();
    this.directories = new Stack();
}

From source file:importer.handler.post.stages.StandoffPair.java

StandoffPair(String stil, String text, String vid) {
    try {//from   w w  w .j  a  v a  2s.  c  o m
        this.text = text;
        this.data = this.text.getBytes("UTF-8");
    } catch (Exception e) {
        this.data = this.text.getBytes();
    }
    this.sb = new StringBuilder();
    this.stack = new Stack<JSONObject>();
    this.stil = stil;
    this.vid = vid;
}

From source file:RoomInfo.java

void route(String to) {
    Stack rev = new Stack();
    RoomInfo r;//  ww w .  j a va2s . c  om
    int num = btStack.size();

    // Reverse the stack to display path.
    for (int i = 0; i < num; i++)
        rev.push(btStack.pop());

    for (int i = 0; i < num; i++) {
        r = (RoomInfo) rev.pop();
        System.out.print(r.from + " to ");
    }

    System.out.println(to);
}

From source file:DepthFirstFileTreeIterator.java

/** Construct a new DepthFirstFileTreeIterator with the specified root.
        //from   w ww.  j a v  a2 s .c  o  m
@param root The root directory
*/

public DepthFirstFileTreeIterator(File root) {
    this.root = root;
    this.currentIndex = 0;
    this.currentList = root.listFiles();
    this.directories = new Stack();
    this.indeces = new Stack();
}

From source file:com.webcohesion.ofx4j.io.nanoxml.TestNanoXMLOFXReader.java

/**
 * tests using sax to parse an OFX doc./*  w ww.j  a va  2s. c o  m*/
 */
public void testVersion1() throws Exception {
    NanoXMLOFXReader reader = new NanoXMLOFXReader();
    final Map<String, List<String>> headers = new HashMap<String, List<String>>();
    final Stack<Map<String, List<Object>>> aggregateStack = new Stack<Map<String, List<Object>>>();
    TreeMap<String, List<Object>> root = new TreeMap<String, List<Object>>();
    aggregateStack.push(root);

    reader.setContentHandler(getNewDefaultHandler(headers, aggregateStack));
    reader.parse(TestNanoXMLOFXReader.class.getResourceAsStream("example-response.ofx"));
    assertEquals(9, headers.size());
    assertEquals(1, aggregateStack.size());
    assertSame(root, aggregateStack.pop());

    TreeMap<String, List<Object>> OFX = (TreeMap<String, List<Object>>) root.remove("OFX").get(0);
    assertNotNull(OFX);

    TreeMap<String, List<Object>> SIGNONMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("SIGNONMSGSRSV1")
            .get(0);
    assertNotNull(SIGNONMSGSRSV1);
    TreeMap<String, List<Object>> SONRS = (TreeMap<String, List<Object>>) SIGNONMSGSRSV1.remove("SONRS").get(0);
    assertNotNull(SONRS);
    TreeMap<String, List<Object>> STATUS = (TreeMap<String, List<Object>>) SONRS.remove("STATUS").get(0);
    assertNotNull(STATUS);
    assertEquals("0", STATUS.remove("CODE").get(0).toString().trim());
    assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim());
    assertTrue(STATUS.isEmpty());
    assertEquals("20071015021529.000[-8:PST]", SONRS.remove("DTSERVER").get(0).toString().trim());
    assertEquals("ENG", SONRS.remove("LANGUAGE").get(0).toString().trim());
    assertEquals("19900101000000", SONRS.remove("DTACCTUP").get(0).toString().trim());
    TreeMap<String, List<Object>> FI = (TreeMap<String, List<Object>>) SONRS.remove("FI").get(0);
    assertEquals("Bank&Cd", FI.remove("ORG").get(0).toString().trim());
    assertEquals("01234", FI.remove("FID").get(0).toString().trim());
    assertTrue(FI.isEmpty());
    assertTrue(SONRS.isEmpty());
    assertTrue(SIGNONMSGSRSV1.isEmpty());

    TreeMap<String, List<Object>> BANKMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("BANKMSGSRSV1")
            .get(0);
    TreeMap<String, List<Object>> STMTTRNRS = (TreeMap<String, List<Object>>) BANKMSGSRSV1.remove("STMTTRNRS")
            .get(0);
    assertEquals("23382938", STMTTRNRS.remove("TRNUID").get(0).toString().trim());
    STATUS = (TreeMap<String, List<Object>>) STMTTRNRS.remove("STATUS").get(0);
    assertNotNull(STATUS);
    assertEquals("0", STATUS.remove("CODE").get(0).toString().trim());
    assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim());
    assertTrue(STATUS.isEmpty());
    TreeMap<String, List<Object>> STMTRS = (TreeMap<String, List<Object>>) STMTTRNRS.remove("STMTRS").get(0);
    assertEquals("USD", STMTRS.remove("CURDEF").get(0).toString().trim());
    TreeMap<String, List<Object>> BANKACCTFROM = (TreeMap<String, List<Object>>) STMTRS.remove("BANKACCTFROM")
            .get(0);
    assertEquals("SAVINGS", BANKACCTFROM.remove("ACCTTYPE").get(0).toString().trim());
    assertEquals("098-121", BANKACCTFROM.remove("ACCTID").get(0).toString().trim());
    assertEquals("987654321", BANKACCTFROM.remove("BANKID").get(0).toString().trim());
    assertTrue(BANKACCTFROM.isEmpty());
    TreeMap<String, List<Object>> BANKTRANLIST = (TreeMap<String, List<Object>>) STMTRS.remove("BANKTRANLIST")
            .get(0);
    assertEquals("20070101", BANKTRANLIST.remove("DTSTART").get(0).toString().trim());
    assertEquals("20071015", BANKTRANLIST.remove("DTEND").get(0).toString().trim());
    TreeMap<String, List<Object>> STMTTRN = (TreeMap<String, List<Object>>) BANKTRANLIST.remove("STMTTRN")
            .get(0);
    assertEquals("CREDIT", STMTTRN.remove("TRNTYPE").get(0).toString().trim());
    assertEquals("20070329", STMTTRN.remove("DTPOSTED").get(0).toString().trim());
    assertEquals("20070329", STMTTRN.remove("DTUSER").get(0).toString().trim());
    assertEquals("150.00", STMTTRN.remove("TRNAMT").get(0).toString().trim());
    assertEquals("980310001", STMTTRN.remove("FITID").get(0).toString().trim());
    assertEquals("TRANSFER", STMTTRN.remove("NAME").get(0).toString().trim());
    assertEquals("Transfer from checking &<> etc.", STMTTRN.remove("MEMO").get(0).toString().trim());
    assertTrue(STMTTRN.isEmpty());
    assertTrue(BANKTRANLIST.isEmpty());
    TreeMap<String, List<Object>> LEDGERBAL = (TreeMap<String, List<Object>>) STMTRS.remove("LEDGERBAL").get(0);
    assertEquals("5250.00", LEDGERBAL.remove("BALAMT").get(0).toString().trim());
    assertEquals("20071015021529.000[-8:PST]", LEDGERBAL.remove("DTASOF").get(0).toString().trim());
    assertTrue(LEDGERBAL.isEmpty());
    TreeMap<String, List<Object>> AVAILBAL = (TreeMap<String, List<Object>>) STMTRS.remove("AVAILBAL").get(0);
    assertEquals("5250.00", AVAILBAL.remove("BALAMT").get(0).toString().trim());
    assertEquals("20071015021529.000[-8:PST]", AVAILBAL.remove("DTASOF").get(0).toString().trim());
    assertTrue(AVAILBAL.isEmpty());
    assertTrue(LEDGERBAL.isEmpty());
    assertTrue(STMTRS.isEmpty());
    assertTrue(STMTTRNRS.isEmpty());
    assertTrue(BANKMSGSRSV1.isEmpty());

    assertTrue(OFX.isEmpty());
    assertTrue(root.isEmpty());
}

From source file:org.neo4j.nlp.examples.sentiment.main.java

private static Stack<Integer> getRandomizedIndex(int lowerBound, int upperBound) {
    List<Integer> randomIndex = new ArrayList<>();

    Collections.addAll(randomIndex, ArrayUtils.toObject(IntStream.range(lowerBound, upperBound).toArray()));

    //randomIndex.sort((a, b) -> new Random().nextInt(2) == 0 ? -1 : 1 );

    Stack<Integer> integerStack = new Stack<>();

    integerStack.addAll(randomIndex);//ww  w . j a v a 2s .  com

    return integerStack;
}

From source file:com.stimulus.archiva.search.FileNameFilter.java

public FileNameFilter(TokenStream in) {
    super(in);
    filenameTokenStack = new Stack<Token>();
}

From source file:org.obp.remote.RemoteBodiesService.java

public Collection<Body> getAll() {
    Collection<Body> bodies = new Stack<>();
    for (Map.Entry<Object, Element> entry : cache.getAll(cache.getKeysWithExpiryCheck()).entrySet()) {
        bodies.add((Body) entry.getValue().getObjectValue());
    }//from w  w  w . j  a v a  2 s. c  o m
    return bodies;
}

From source file:com.w20e.socrates.servlet.ValidatorHelper.java

/**
 * Determine UI properties for given list of renderables.
 * //from   w  ww. j  a v a  2s.c  o m
 * @param items
 *            List of items to use.
 * @throws Exception
 *             in case of Velocity errors, or output stream errors.
 */
public static void getRenderableProperties(final Collection<Renderable> items,
        final Map<String, Map<String, String>> props, final RunnerContext pContext) throws Exception {

    Locale locale = pContext.getLocale();

    Configuration cfg = pContext.getConfiguration();

    String base = cfg.getString("formatter.locale.prefix");

    UTF8ResourceBundle bundle = UTF8ResourceBundleImpl.getBundle(base, locale);

    Stack<Group> parents = new Stack<Group>();

    // Let's loop over renderable items.
    //
    for (Renderable rItem : items) {

        addItem(rItem, parents, props, pContext.getInstance(), pContext.getModel(), pContext.getRenderConfig(),
                bundle, locale);

    }
}