Package com.volantis.mcs.dissection.annotation

Examples of com.volantis.mcs.dissection.annotation.DissectedDocumentImpl


        DissectionURLManager urlManager = new MyDissectionURLManager();
        DocumentInformationImpl docInfo = new DocumentInformationImpl();
        docInfo.setDocumentURL(new MarinerURL("common1.xml"));

        Dissector dissector = new Dissector();
        DissectedDocumentImpl dissected = (DissectedDocumentImpl)
            dissector.createDissectedDocument(context, characteristics,
                                              document, urlManager, docInfo);

        // Check the characteristics of the dissected document.
        NodeCounts expectedDocumentNodeCounts
            = expectedDocumentStats.nodeCounts;
        int dissectableAreaCount
            = expectedDocumentNodeCounts.dissectableAreaCount;
        assertEquals(failures,
                     "Incorrect number of dissectable areas,",
                     dissectableAreaCount,
                     dissected.getDissectableAreaCount());

        // Check the node counts.
        NodeCounts actualNodeCounts = null;

        // Gather statistics by visiting all the nodes.
        VisitingStatisticsGatherer visitor = new VisitingStatisticsGatherer();
        document.visitDocument(visitor);
        NodeCounts visitorStatistics = visitor.getStatistics().nodeCounts;

        // Gather statistics by iterating over all the nodes.
        IteratingStatisticsGatherer iterator = new IteratingStatisticsGatherer();
        document.visitDocument(iterator);
        NodeCounts iteratorStatistics = iterator.getStatistics().nodeCounts;

        // Make sure that all the different methods of gathering statistics
        // agree.
        assertEquals("Discrepancy between statistics gatherers",
                     visitorStatistics, iteratorStatistics);

        // Set the actualStatistics value so they can be output later.
        actualNodeCounts = visitorStatistics;

        // Check that the statistics match the expectation.
        checkNodeCount(failures,
                       expectedDocumentStats.nodeCounts,
                       actualNodeCounts);

        // Check the shared content usages.
        checkSharedContentUsages(failures,
                                 "Total Cost",
                                 details,
                                 expectedDocumentStats.getTotalContentUsages(),
                                 dissected.getTotalContentUsages());

        checkSharedContentUsages(failures,
                                 "Fixed Cost",
                                 details,
                                 expectedDocumentStats.getFixedContentUsages(),
                                 dissected.getFixedContentUsages());

        // Check that the dissectable areas are correct.
        for (int i = 0; i < dissectableAreaCount; i += 1) {
            DissectableArea area = dissected.getDissectableArea(i);
            DissectableAreaStats expectedDAStats
                = expectedDocumentStats.getDissectableAreaStats(i);
            checkDissectableArea(failures, details, context, area,
                                 expectedDAStats);
        }

        OutputDocument output = createOutputDocument();
        DissectedContentHandler outputHandler
            = createDissectedContentHandler(output);
        RequestedShards requestedShards = dissected.createRequestedShards();
        dissector.serialize(context, dissected,
                            requestedShards, outputHandler);
        int totalCost = dissected.getTotalCost();
        int outputSize = output.getSize();
        // Check output size is reasonable; we allow explicit output size to
        // be greater than the total cost to handle WBDOM generating WML.
        if (expectedDocumentStats.outputSize > 0) {
            int expectedOutputSize = expectedDocumentStats.outputSize +
                    expectedDocumentStats.totalCostMimasAdjust;
            // check that
            if (outputSize != expectedOutputSize) {
                failures.append("Output size (" + outputSize
                                + ") is not equal to expected output size ("
                                + expectedOutputSize + ")\n");
            }
        } else {
            if (outputSize > totalCost) {
                failures.append("Output size (" + outputSize
                                + ") is greater than total cost ("
                                + totalCost + ")\n");
            }
        }

        // Make sure that the total cost matches what we have set.
        assertEquals(failures,
                     "Total cost did not match,",
                     expectedDocumentStats.totalCost +
                        expectedDocumentStats.totalCostMimasAdjust,
                     totalCost);

        // Make sure that the fixed cost matches what we have set.
        int fixedCost = dissected.getFixedCost();
        assertEquals(failures,
                     "Fixed cost did not match,",
                     expectedDocumentStats.fixedCost +
                         expectedDocumentStats.fixedCostMimasAdjust,
                     fixedCost);
View Full Code Here


        throws DissectionException {

        // Annotate the dissectable document and in the process create a
        // DissectedDocument.
        Annotator annotator = new Annotator();
        DissectedDocumentImpl annotation
            = annotator.annotateDocument(dissectionContext, document, characteristics,
                                         urlManager, docInfo);

        // Get the DissectedDocument from the annotator.
        return annotation;
View Full Code Here

                                      DissectedDocument dissectedDocument,
                                      RequestedShards requestedShards,
                                      AvailableShards availableShards)
        throws DissectionException {

        DissectedDocumentImpl document
            = (DissectedDocumentImpl) dissectedDocument;

        // Select the shards from each area.
        SelectedShards selectedShards = getSelectedShards(dissectionContext,
                                                          document,
View Full Code Here

                            DissectedDocument dissectedDocument,
                            RequestedShards requestedShards,
                            AvailableShards availableShards)
        throws DissectionException {

        DissectedDocumentImpl document
            = (DissectedDocumentImpl) dissectedDocument;

        // Select the shards from each area.
        SelectedShards selectedShards = getSelectedShards(dissectionContext, document,
                                                          requestedShards,
                                                          availableShards);

        DissectableArea area = document.getDissectableArea(1);

        int shardIndex = requestedShards.getShard(area.getIndex());

        // Retrieve the appropriate shard from the area. If the shard index
        // is invalid for some reason then we may not get back exactly the
View Full Code Here

                          DissectedDocument dissectedDocument,
                          RequestedShards requestedShards,
                          DissectedContentHandler contentHandler)
        throws DissectionException {

        DissectedDocumentImpl document
            = (DissectedDocumentImpl) dissectedDocument;

        // Select the shards from each area.
        SelectedShards selectedShards = getSelectedShards(dissectionContext, document,
                                                          requestedShards,
View Full Code Here

TOP

Related Classes of com.volantis.mcs.dissection.annotation.DissectedDocumentImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.