1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* $Id: FormattingResults.java 1610839 2014-07-15 20:25:58Z vhennebert $ */ 19 20 package org.apache.fop.apps; 21 22 import java.util.List; 23 24 import org.apache.fop.fo.pagination.AbstractPageSequence; 25 26 /** 27 * Class for reporting back formatting results to the calling application. 28 */ 29 public class FormattingResults { 30 31 private int pageCount; 32 private List pageSequences; 33 34 /** 35 * Constructor for the FormattingResults object 36 */ FormattingResults()37 public FormattingResults() { 38 } 39 40 /** 41 * Gets the number of pages rendered 42 * 43 * @return The number of pages overall 44 */ getPageCount()45 public int getPageCount() { 46 return this.pageCount; 47 } 48 49 /** 50 * Gets the results for the individual page-sequences. 51 * 52 * @return A List with PageSequenceResults objects 53 */ getPageSequences()54 public List getPageSequences() { 55 return this.pageSequences; 56 } 57 58 /** 59 * Resets this object 60 */ reset()61 public void reset() { 62 this.pageCount = 0; 63 if (this.pageSequences != null) { 64 this.pageSequences.clear(); 65 } 66 } 67 68 /** 69 * Reports the result of one page sequence rendering 70 * back into this object. 71 * 72 * @param pageSequence the page sequence which just completed rendering 73 * @param pageCount the number of pages rendered for that PageSequence 74 */ haveFormattedPageSequence(AbstractPageSequence pageSequence, int pageCount)75 public void haveFormattedPageSequence(AbstractPageSequence pageSequence, int pageCount) { 76 this.pageCount += pageCount; 77 if (this.pageSequences == null) { 78 this.pageSequences = new java.util.ArrayList(); 79 } 80 this.pageSequences.add( 81 new PageSequenceResults(pageSequence.getId(), 82 pageCount)); 83 } 84 } 85 86