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:adalid.commons.velocity.VelocityAid.java

/**
 * @return a new instance of Stack
 */
public static Stack getNewStack() {
    return new Stack();
}

From source file:com.pironet.tda.SunJDKParser.java

/**
 * parse the next thread dump from the stream passed with the constructor.
 *
 * @return null if no more thread dumps were found.
 *//*from w  w  w  .j  a v a2s .  c o m*/
public MutableTreeNode parseNext() {
    if (nextDump != null) {
        MutableTreeNode tmpDump = nextDump;
        nextDump = null;
        return (tmpDump);
    }
    boolean retry = false;
    String line = null;

    do {

        try {
            Map<String, String> threads = new HashMap<>();
            ThreadDumpInfo overallTDI = new ThreadDumpInfo("Dump No. " + counter++, 0);
            if (withCurrentTimeStamp) {
                overallTDI.setStartTime((new Date(System.currentTimeMillis())).toString());
            }
            DefaultMutableTreeNode threadDump = new DefaultMutableTreeNode(overallTDI);

            DefaultMutableTreeNode catThreads = new DefaultMutableTreeNode(
                    new TableCategory("Threads", IconFactory.THREADS));
            threadDump.add(catThreads);

            DefaultMutableTreeNode catWaiting = new DefaultMutableTreeNode(
                    new TableCategory("Threads waiting for Monitors", IconFactory.THREADS_WAITING));

            DefaultMutableTreeNode catSleeping = new DefaultMutableTreeNode(
                    new TableCategory("Threads sleeping on Monitors", IconFactory.THREADS_SLEEPING));

            DefaultMutableTreeNode catLocking = new DefaultMutableTreeNode(
                    new TableCategory("Threads locking Monitors", IconFactory.THREADS_LOCKING));

            // create category for monitors with disabled filtering.
            // NOTE:  These strings are "magic" in that the methods
            // TDA#displayCategory and TreeCategory#getCatComponent both
            // checks these literal strings and the behavior differs.
            DefaultMutableTreeNode catMonitors = new DefaultMutableTreeNode(
                    new TreeCategory("Monitors", IconFactory.MONITORS, false));
            DefaultMutableTreeNode catMonitorsLocks = new DefaultMutableTreeNode(
                    new TreeCategory("Monitors without locking thread", IconFactory.MONITORS_NO_LOCKS, false));
            DefaultMutableTreeNode catBlockingMonitors = new DefaultMutableTreeNode(
                    new TreeCategory("Threads blocked by Monitors", IconFactory.THREADS_LOCKING, false));

            String title = null;
            String dumpKey = null;
            StringBuffer content = null;
            boolean inLocking = false;
            boolean inSleeping = false;
            boolean inWaiting = false;
            int threadCount = 0;
            int waiting = 0;
            int locking = 0;
            int sleeping = 0;
            boolean locked = true;
            boolean finished = false;
            final MonitorMap mmap = new MonitorMap();
            final Stack<String> monitorStack = new Stack<>();
            long startTime = 0;
            int singleLineCounter = 0;
            boolean concurrentSyncsFlag = false;
            Matcher matched = getDm().getLastMatch();

            while (getBis().ready() && !finished) {
                line = getNextLine();
                lineCounter++;
                singleLineCounter++;
                if (locked) {
                    if (line.contains("Full thread dump")) {
                        locked = false;
                        if (!withCurrentTimeStamp) {
                            overallTDI.setLogLine(lineCounter);

                            if (startTime != 0) {
                                startTime = 0;
                            } else if (matched != null && matched.matches()) {

                                String parsedStartTime = matched.group(1);
                                if (!getDm().isDefaultMatches() && isMillisTimeStamp()) {
                                    try {
                                        // the factor is a hack for a bug in oc4j timestamp printing (pattern timeStamp=2342342340)
                                        if (parsedStartTime.length() < 13) {
                                            startTime = Long.parseLong(parsedStartTime)
                                                    * (long) Math.pow(10, 13 - parsedStartTime.length());
                                        } else {
                                            startTime = Long.parseLong(parsedStartTime);
                                        }
                                    } catch (NumberFormatException nfe) {
                                        startTime = 0;
                                    }
                                    if (startTime > 0) {
                                        overallTDI.setStartTime((new Date(startTime)).toString());
                                    }
                                } else {
                                    overallTDI.setStartTime(parsedStartTime);
                                }
                                matched = null;
                                getDm().resetLastMatch();
                            }
                        }
                        dumpKey = overallTDI.getName();
                    } else if (!getDm().isPatternError() && (getDm().getRegexPattern() != null)) {
                        Matcher m = getDm().checkForDateMatch(line);
                        if (m != null) {
                            matched = m;
                        }
                    }
                } else {
                    if (line.startsWith("\"")) {
                        // We are starting a group of lines for a different thread
                        // First, flush state for the previous thread (if any)
                        concurrentSyncsFlag = false;
                        String stringContent = content != null ? content.toString() : null;
                        if (title != null) {
                            threads.put(title, content.toString());
                            content.append("</pre></pre>");
                            addToCategory(catThreads, title, null, stringContent, singleLineCounter, true);
                            threadCount++;
                        }
                        if (inWaiting) {
                            addToCategory(catWaiting, title, null, stringContent, singleLineCounter, true);
                            inWaiting = false;
                            waiting++;
                        }
                        if (inSleeping) {
                            addToCategory(catSleeping, title, null, stringContent, singleLineCounter, true);
                            inSleeping = false;
                            sleeping++;
                        }
                        if (inLocking) {
                            addToCategory(catLocking, title, null, stringContent, singleLineCounter, true);
                            inLocking = false;
                            locking++;
                        }
                        singleLineCounter = 0;
                        while (!monitorStack.empty()) {
                            mmap.parseAndAddThread(monitorStack.pop(), title, content.toString());
                        }

                        // Second, initialize state for this new thread
                        title = line;
                        content = new StringBuffer("<body bgcolor=\"ffffff\"><pre><font size="
                                + TDA.getFontSizeModifier(-1) + '>');
                        content.append(line);
                        content.append('\n');
                    } else if (line.contains("at ")) {
                        content.append(line);
                        content.append('\n');
                    } else if (line.contains("java.lang.Thread.State")) {
                        content.append(line);
                        content.append('\n');
                        if (title.indexOf("t@") > 0) {
                            // in this case the title line is missing state informations
                            String state = line.substring(line.indexOf(':') + 1).trim();
                            if (state.indexOf(' ') > 0) {
                                title += " state=" + state.substring(0, state.indexOf(' '));
                            } else {
                                title += " state=" + state;
                            }
                        }
                    } else if (line.contains("Locked ownable synchronizers:")) {
                        concurrentSyncsFlag = true;
                        content.append(line);
                        content.append('\n');
                    } else if (line.contains("- waiting on")) {
                        content.append(linkifyMonitor(line));
                        monitorStack.push(line);
                        inSleeping = true;
                        content.append('\n');
                    } else if (line.contains("- parking to wait")) {
                        content.append(linkifyMonitor(line));
                        monitorStack.push(line);
                        inSleeping = true;
                        content.append('\n');
                    } else if (line.contains("- waiting to")) {
                        content.append(linkifyMonitor(line));
                        monitorStack.push(line);
                        inWaiting = true;
                        content.append('\n');
                    } else if (line.contains("- locked")) {
                        content.append(linkifyMonitor(line));
                        inLocking = true;
                        monitorStack.push(line);
                        content.append('\n');
                    } else if (line.contains("- ")) {
                        if (concurrentSyncsFlag) {
                            content.append(linkifyMonitor(line));
                            monitorStack.push(line);
                        } else {
                            content.append(line);
                        }
                        content.append('\n');
                    }

                    // last thread reached?
                    if ((line.contains("\"Suspend Checker Thread\""))
                            || (line.contains("\"VM Periodic Task Thread\""))
                            || (line.contains("<EndOfDump>"))) {
                        finished = true;
                        getBis().mark(getMarkSize());
                        if ((checkForDeadlocks(threadDump)) == 0) {
                            // no deadlocks found, set back original position.
                            getBis().reset();
                        }

                        if (!checkThreadDumpStatData(overallTDI)) {
                            // no statistical data found, set back original position.
                            getBis().reset();
                        }

                        getBis().mark(getMarkSize());
                        if (!(foundClassHistograms = checkForClassHistogram(threadDump))) {
                            getBis().reset();
                        }
                    }
                }
            }
            // last thread
            String stringContent = content != null ? content.toString() : null;
            if (title != null) {
                threads.put(title, content.toString());
                content.append("</pre></pre>");
                addToCategory(catThreads, title, null, stringContent, singleLineCounter, true);
                threadCount++;
            }
            if (inWaiting) {
                addToCategory(catWaiting, title, null, stringContent, singleLineCounter, true);
                waiting++;
            }
            if (inSleeping) {
                addToCategory(catSleeping, title, null, stringContent, singleLineCounter, true);
                sleeping++;
            }
            if (inLocking) {
                addToCategory(catLocking, title, null, stringContent, singleLineCounter, true);
                locking++;
            }
            while (!monitorStack.empty()) {
                mmap.parseAndAddThread(monitorStack.pop(), title, content.toString());
            }

            int monitorCount = mmap.size();

            int monitorsWithoutLocksCount = 0;
            int contendedMonitors = 0;
            int blockedThreads = 0;
            // dump monitors 
            if (mmap.size() > 0) {
                int[] result = dumpMonitors(catMonitors, catMonitorsLocks, mmap);
                monitorsWithoutLocksCount = result[0];
                overallTDI.setOverallThreadsWaitingWithoutLocksCount(result[1]);

                result = dumpBlockingMonitors(catBlockingMonitors, mmap);
                contendedMonitors = result[0];
                blockedThreads = result[1];
            }

            // display nodes with stuff to display
            if (waiting > 0) {
                overallTDI.setWaitingThreads((Category) catWaiting.getUserObject());
                threadDump.add(catWaiting);
            }

            if (sleeping > 0) {
                overallTDI.setSleepingThreads((Category) catSleeping.getUserObject());
                threadDump.add(catSleeping);
            }

            if (locking > 0) {
                overallTDI.setLockingThreads((Category) catLocking.getUserObject());
                threadDump.add(catLocking);
            }

            if (monitorCount > 0) {
                overallTDI.setMonitors((Category) catMonitors.getUserObject());
                threadDump.add(catMonitors);
            }

            if (contendedMonitors > 0) {
                overallTDI.setBlockingMonitors((Category) catBlockingMonitors.getUserObject());
                threadDump.add(catBlockingMonitors);
            }

            if (monitorsWithoutLocksCount > 0) {
                overallTDI.setMonitorsWithoutLocks((Category) catMonitorsLocks.getUserObject());
                threadDump.add(catMonitorsLocks);
            }
            overallTDI.setThreads((Category) catThreads.getUserObject());

            ((Category) catThreads.getUserObject())
                    .setName(catThreads.getUserObject() + " (" + threadCount + " Threads overall)");
            ((Category) catWaiting.getUserObject())
                    .setName(catWaiting.getUserObject() + " (" + waiting + " Threads waiting)");
            ((Category) catSleeping.getUserObject())
                    .setName(catSleeping.getUserObject() + " (" + sleeping + " Threads sleeping)");
            ((Category) catLocking.getUserObject())
                    .setName(catLocking.getUserObject() + " (" + locking + " Threads locking)");
            ((Category) catMonitors.getUserObject())
                    .setName(catMonitors.getUserObject() + " (" + monitorCount + " Monitors)");
            ((Category) catBlockingMonitors.getUserObject()).setName(catBlockingMonitors.getUserObject() + " ("
                    + blockedThreads + " Threads blocked by " + contendedMonitors + " Monitors)");
            ((Category) catMonitorsLocks.getUserObject()).setName(
                    catMonitorsLocks.getUserObject() + " (" + monitorsWithoutLocksCount + " Monitors)");
            // add thread dump to passed dump store.
            if ((threadCount > 0) && (dumpKey != null)) {
                threadStore.put(dumpKey.trim(), threads);
            }

            // check custom categories
            addCustomCategories(threadDump);

            return (threadCount > 0 ? threadDump : null);
        } catch (StringIndexOutOfBoundsException e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null,
                    "Error during parsing of a found thread dump, skipping to next one!\n"
                            + "Check for possible broken dumps, sometimes, stream flushing mixes the logged data.\n"
                            + "Error Message is \"" + e.getLocalizedMessage() + "\". \n"
                            + (line != null ? "Last line read was \"" + line + "\". \n" : ""),
                    "Error during Parsing Thread Dump", JOptionPane.ERROR_MESSAGE);
            retry = true;
        } catch (IOException e) {
            e.printStackTrace();
        }
    } while (retry);

    return (null);
}

From source file:com.clust4j.algo.DBSCAN.java

@Override
protected DBSCAN fit() {
    synchronized (fitLock) {

        if (null != labels) // Then we've already fit this...
            return this;

        // First get the dist matrix
        final LogTimer timer = new LogTimer();

        // Do the neighborhood assignments, get sample weights, find core samples..
        final LogTimer neighbTimer = new LogTimer();
        labels = new int[m]; // Initialize labels...
        sampleWeights = new double[m]; // Init sample weights...
        coreSamples = new boolean[m];

        // Fit the nearest neighbor model...
        final LogTimer rnTimer = new LogTimer();
        final RadiusNeighbors rnModel = new RadiusNeighbors(data, new RadiusNeighborsParameters(eps)
                .setSeed(getSeed()).setMetric(getSeparabilityMetric()).setVerbose(false)).fit();

        info("fit RadiusNeighbors model in " + rnTimer.toString());
        int[][] nearest = rnModel.getNeighbors().getIndices();

        int[] ptNeighbs;
        ArrayList<int[]> neighborhoods = new ArrayList<>();
        int numCorePts = 0;
        for (int i = 0; i < m; i++) {
            // Each label inits to -1 as noise
            labels[i] = NOISE_CLASS;//from   ww  w .j ava  2s  .  c  o m
            ptNeighbs = nearest[i];

            // Add neighborhood...
            int pts;
            neighborhoods.add(ptNeighbs);
            sampleWeights[i] = pts = ptNeighbs.length;
            coreSamples[i] = pts >= minPts;

            if (coreSamples[i])
                numCorePts++;
        }

        // Log checkpoint
        info("completed density neighborhood calculations in " + neighbTimer.toString());
        info(numCorePts + " core point" + (numCorePts != 1 ? "s" : "") + " found");

        // Label the points...
        int nextLabel = 0, v;
        final Stack<Integer> stack = new Stack<>();
        int[] neighb;

        LogTimer stackTimer = new LogTimer();
        for (int i = 0; i < m; i++) {
            stackTimer = new LogTimer();

            // Want to look at unlabeled OR core points...
            if (labels[i] != NOISE_CLASS || !coreSamples[i])
                continue;

            // Depth-first search starting from i, ending at the non-core points.
            // This is very similar to the classic algorithm for computing connected
            // components, the difference being that we label non-core points as
            // part of a cluster (component), but don't expand their neighborhoods.
            int labelCt = 0;
            while (true) {
                if (labels[i] == NOISE_CLASS) {
                    labels[i] = nextLabel;
                    labelCt++;

                    if (coreSamples[i]) {
                        neighb = neighborhoods.get(i);

                        for (i = 0; i < neighb.length; i++) {
                            v = neighb[i];
                            if (labels[v] == NOISE_CLASS)
                                stack.push(v);
                        }
                    }
                }

                if (stack.size() == 0) {
                    fitSummary.add(new Object[] { nextLabel, labelCt, stackTimer.formatTime(),
                            stackTimer.wallTime() });

                    break;
                }

                i = stack.pop();
            }

            nextLabel++;
        }

        // Count missing
        numNoisey = 0;
        for (int lab : labels)
            if (lab == NOISE_CLASS)
                numNoisey++;

        // corner case: numNoisey == m (never gets a fit summary)
        if (numNoisey == m)
            fitSummary.add(new Object[] { Double.NaN, 0, stackTimer.formatTime(), stackTimer.wallTime() });

        info((numClusters = nextLabel) + " cluster" + (nextLabel != 1 ? "s" : "") + " identified, " + numNoisey
                + " record" + (numNoisey != 1 ? "s" : "") + " classified noise");

        // Encode to put in order
        labels = new NoiseyLabelEncoder(labels).fit().getEncodedLabels();

        sayBye(timer);
        return this;
    }

}

From source file:fr.inria.oak.paxquery.pact.operations.xml.navigation.SingleDocumentExtractor.java

/**
 * Not called currently, since it is the DocumentTuplesMultiExtractor which drives the process.
 * //from  w  w w  . j  a  va  2s .  co  m
 * This method matches the XAM xam obtained from the query against the
 * XML file XMLFileName
 * 
 * @param qp
 * @param DG_XML
 * @throws SummaryException
 */
public SingleDocumentExtractor(NavigationTreePattern qp, XMLStreamReader xmlReader) {
    this.currentQP = qp;
    this.streamReader = xmlReader;
    this.builder = new RecordBuilder();

    this.sb = new StringBuilder();
    this.characterSB = new StringBuilder();

    this.stacksByNodes = new HashMap<NavigationTreePatternNode, ExtractorMatchStack>();
    this.nodesByStacks = new HashMap<ExtractorMatchStack, NavigationTreePatternNode>();
    this.currentNodes = new Stack<Integer>();
    this.stacksByTag = new HashMap<String, ArrayList<ExtractorMatchStack>>();
    this.schemesByNode = new HashMap<NavigationTreePatternNode, NodeIDScheme>();

    this.childrenContexts = new HashMap<NavigationTreePatternNode, ArrayList<String>>();
    this.currentContexts = new HashMap<NavigationTreePatternNode, ArrayList<String>>();

    this.vTuples = new ArrayList<Record>();

    this.stacksNeedingContent = new ExtractorMatchStack[qp.getNodesNo()];
    this.prefixesDefined = new Stack[qp.getNodesNo()];
    this.defaultNamespaces = new Stack[qp.getNodesNo()];
    this.numberOfStacksNeedingContent = 0;
    this.stacksNeedingValue = new ExtractorMatchStack[qp.getNodesNo()];
    this.numberOfStacksNeedingValue = 0;

    NavigationTreePatternNode root = qp.getRoot();
    createStacks(root);
    this.currentContexts.put(root, this.childrenContexts.get(root));
    this.setSchemes(qp.getRoot());
    schemesBeginDocument();

    this.builder.setSchemesByNodes(this.schemesByNode);
    this.builder.setStacksByNodes(this.stacksByNodes);

    this.currentPathNo = -1;
    this.myPosition = -1;
}

From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java

public void transfrom(List list) {
    model.clear();/*from ww  w  .j  av  a 2  s  .  co  m*/

    if (list == null)
        return;

    boolean preserveHierarchy = transformer.isPreserveHierarchy();

    if (!transformer.isShowSummary()) {
        preserveHierarchy = false;
        removeSummaries(list);
    }
    Map<GraphicNode, List<GraphicNode>> assignmentsMap = null;
    if (!transformer.isShowAssignments())
        removeAssignments(list);
    if (!transformer.isShowEmptyLines())
        removeVoids(list);
    if (transformer.isShowEmptyLines() && !transformer.isShowEndEmptyLines())
        removeEndVoids(list);

    NodeTransformer composition = transformer.getTransformer();

    NodeFilter hiddenFilter = transformer.getHiddenFilter();
    if (hiddenFilter instanceof BaseFilter && !((BaseFilter) hiddenFilter).isActive())
        hiddenFilter = null; //to avoid useless filtering in case of BaseFilter
    NodeFilter userFilter = (transformer.isNoneFilter()) ? null : transformer.getUserFilter();
    boolean filtering = hiddenFilter != null || userFilter != null;

    NodeSorter sorter1 = transformer.getHiddenSorter();
    NodeSorter sorter2 = transformer.getUserSorter();
    boolean sorting = !(sorter1 == null && transformer.isNoneSorter());

    NodeGrouper grouper = transformer.getUserGrouper();
    boolean grouping = !transformer.isNoneGrouper();

    if (!filtering && !sorting && !grouping)
        return;

    if (transformer.isShowAssignments() && preserveHierarchy && !transformer.isTreatAssignmentsAsTasks())
        assignmentsMap = extractAssignments(list);

    List localList = null;
    Stack parents = null;
    boolean alreadyExcluded;
    if (preserveHierarchy) {
        localList = new ArrayList();
        parents = new Stack();
    } else
        localList = list;

    GraphicNode gnode, previous = null;
    Object current;
    for (Iterator i = list.iterator(); i.hasNext();) {
        gnode = (GraphicNode) i.next();
        gnode.setFiltered(false);
        if (!gnode.isVoid()) {
            current = (composition == null) ? gnode.getNode() : composition.evaluate(gnode.getNode());
            alreadyExcluded = false;
            if (hiddenFilter != null) {
                if (!hiddenFilter.evaluate(current)) {
                    if (!gnode.isSummary() || !preserveHierarchy) {
                        i.remove();
                        continue;
                    }
                    if (gnode.isSummary() && preserveHierarchy)
                        gnode.setFiltered(true);
                    alreadyExcluded = true;
                }
            }
            if (userFilter != null && !alreadyExcluded) {
                if (!userFilter.evaluate(current)) {
                    if (!gnode.isSummary() || !preserveHierarchy) {
                        i.remove();
                        continue;
                    }
                    if (gnode.isSummary() && preserveHierarchy)
                        gnode.setFiltered(true);
                }
            }
        }
        if (preserveHierarchy) {
            //contruct a temporary tree for sorting and grouping
            //                if (parents==null||previous==null){
            //                   System.out.println("null");
            //                }
            if (gnode.getLevel() == 1) {
                localList.add(gnode);
                parents.clear();
            } else {
                if (previous.getLevel() < gnode.getLevel()) {
                    parents.push(previous);
                } else if (previous.getLevel() >= gnode.getLevel()) {
                    while (parents.size() >= gnode.getLevel())
                        parents.pop();
                }
                ((GraphicNode) parents.peek()).getChildren().add(gnode);
            }
            previous = gnode;
        }
    }

    //remove parents without children
    if (preserveHierarchy) {
        list.clear();
        if (transformer.isShowEmptySummaries()) {
            if ("TaskUsage".equals(viewName))
                filterBadBranches(localList);
        } else
            filterEmptySummaries(localList, false);
    }

    if (sorting) {
        if (sorter1 != null)
            sorter1.sortList(localList, new GraphicNodeComparator(sorter1, composition), preserveHierarchy);
        if (!transformer.isNoneSorter())
            sorter2.sortList(localList, new GraphicNodeComparator(sorter2, composition), preserveHierarchy);
    }

    if (grouping) {
        List groups = grouper.getGroups();
        levelOffset = groups.size();
        List groupedList = new LinkedList();
        groupList(localList, groupedList, groups.listIterator(), null, composition, preserveHierarchy);
        localList.clear();
        localList.addAll(groupedList);
    }

    if (preserveHierarchy) { //converts tmp tree to list
        treeToList(localList, list);
    }

    if (assignmentsMap != null)
        recoverAssignments(list, assignmentsMap);

    //        if (transformer.isShowEmptyLines())
    //           placeVoidNodes(list);

}

From source file:com.runwaysdk.generation.loader.RunwayClassLoader.java

/**
 * Loads an array from the base component up. If an array is loaded without
 * its componentType already loaded then an error occurs. Thus it loads from
 * inside out.//w  ww.  j av a 2s  .  c  om
 * 
 * @param arrayType
 */
public static Class<?> loadArray(String arrayType) {
    // Keep track of what types of array we have (an array of Integers and an
    // array of
    // Business objects, for example)
    Stack<String> baseTypes = new Stack<String>();
    String baseType = arrayType;

    Class<?> arrayClass = null;

    // This loop strips the base type out of any n-dimensional array
    while (arrayPattern.matcher(baseType).matches()) {
        if (arrayPrefix.matcher(baseType).matches()) {
            baseType = baseType.replaceFirst("\\[L", "").replace(";", "").trim();
        } else {
            baseType = baseType.replaceFirst("\\[", "");
        }
        // Add the base type to the stack
        baseTypes.push(baseType);
    }

    // We must load all base types before we can try to load arrays of those
    // types
    while (!baseTypes.isEmpty()) {
        String type = baseTypes.pop();
        Class<?> componentType;
        componentType = LoaderDecorator.load(type);
        arrayClass = Array.newInstance(componentType, 0).getClass();
    }
    return arrayClass;
}

From source file:com.bluexml.xforms.controller.alfresco.agents.MappingAgent.java

/**
 * Creates the class forms instance./*  www  .j  av a  2s  .  c o  m*/
 * 
 * @param transaction
 *            the login
 * @param type
 *            the type
 * @param formIsReadOnly
 * 
 * @return the document
 */
private Document createClassFormsInstance(AlfrescoTransaction transaction, String type, boolean formIsReadOnly,
        boolean isServletRequest) {
    return mappingToolImplAlfrescoToXForms.createClassFormsInstance(transaction, type,
            transaction.getInitParams(), new Stack<AssociationType>(), formIsReadOnly, isServletRequest);
}

From source file:com.wavemaker.json.JSONMarshaller.java

/**
 * Marshal the given Object into a JSON-formatted character stream (written out onto the writer parameter).
 * //from  w  w  w .  j a  v a2s  .  c o m
 * @param writer The Writer to write the JSON-formatted representation of obj to.
 * @param obj The Object to marshal; this must be an JavaBean-style Object, a Collection, or an array.
 * @param jsonState Any configuration.
 * @param sort True if the output should be sorted (only bean properties will be sorted, currently).
 * @param prettyPrint True if the output should be formatted.
 */
public static void marshal(Writer writer, Object obj, JSONState jsonState, FieldDefinition rootFieldDefinition,
        boolean sort, boolean prettyPrint) throws IOException {

    TypeState typeState = jsonState.getTypeState();

    doMarshal(writer, obj, obj, jsonState, sort, true, new Stack<Object>(), new Stack<String>(),
            rootFieldDefinition, 0, typeState, prettyPrint, 0, Logger.getLogger(JSONMarshaller.class));
}

From source file:com.aurel.track.exchange.docx.importer.HTMLParser.java

@Override
public void startDocument() throws SAXException {
    htmlContent = new HTMLContent();
    stack = new Stack<ItemNode>();
}

From source file:edu.mit.lib.tools.Modernize.java

public void importToMds(String targetUrl) throws IOException {
    if (manif.isEmpty()) {
        manif.read();// ww  w  .j  av a 2s .c  om
    }
    Stack<String> parents = new Stack<>();
    parents.push(null); // indicates no parent object

    for (int i = 0; i < manif.entries.size(); i++) {
        String handle = manif.entries.get(i);
        uploadPackage(getPackage(handle), getPostUrl(targetUrl, parents.peek(), manif.ctypes.get(i)));
        if (i < manif.entries.size() - 1) {
            int diff = manif.levels.get(i) - manif.levels.get(i + 1);
            if (diff < 0) {
                // I have kids - put myself on the parents stack
                parents.push(handle);
            } else if (diff > 0) {
                // expose grandparents
                while (diff-- > 0) {
                    parents.pop();
                }
            } // if diff == 0 - next entry is a sibling, nothing to do
        }
    }
}