1 /* 2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.properties.reports; 17 18 import java.util.ArrayList; 19 import java.util.Collections; 20 import java.util.List; 21 22 import de.smartics.properties.report.app.ReportException; 23 import de.smartics.properties.report.data.PropertyReportItem; 24 import de.smartics.properties.report.data.PropertyReportSet; 25 26 /** 27 * Stores every report item in memory. 28 */ 29 public final class InMemoryPropertyReport extends AbstractPropertyReport 30 { 31 // ********************************* Fields ********************************* 32 33 // --- constants ------------------------------------------------------------ 34 35 // --- members -------------------------------------------------------------- 36 37 /** 38 * The list of report sets. 39 */ 40 private final List<PropertyReportSet> sets = 41 new ArrayList<PropertyReportSet>(); 42 43 /** 44 * The list of report items. 45 */ 46 private final List<PropertyReportItem> items = 47 new ArrayList<PropertyReportItem>(); 48 49 // ****************************** Initializer ******************************* 50 51 // ****************************** Constructors ****************************** 52 53 /** 54 * Default constructor. 55 */ 56 public InMemoryPropertyReport() 57 { 58 } 59 60 // ****************************** Inner Classes ***************************** 61 62 // ********************************* Methods ******************************** 63 64 // --- init ----------------------------------------------------------------- 65 66 // --- get&set -------------------------------------------------------------- 67 68 /** 69 * Returns the list of report sets. 70 * 71 * @return the list of report sets. 72 */ 73 public List<PropertyReportSet> getSets() 74 { 75 return Collections.unmodifiableList(sets); 76 } 77 78 /** 79 * Returns the list of report items. 80 * 81 * @return the list of report items. 82 */ 83 public List<PropertyReportItem> getItems() 84 { 85 return Collections.unmodifiableList(items); 86 } 87 88 // --- business ------------------------------------------------------------- 89 90 /** 91 * {@inheritDoc} 92 * 93 * @see de.smartics.properties.report.data.PropertyReport#handle(de.smartics.properties.report.data.PropertyReportSet) 94 */ 95 @Override 96 public void handle(final PropertyReportSet reportSet) throws ReportException 97 { 98 sets.add(reportSet); 99 } 100 101 /** 102 * {@inheritDoc} 103 * 104 * @see de.smartics.properties.report.data.PropertyReport#handle(de.smartics.properties.report.data.PropertyReportItem) 105 */ 106 @Override 107 public void handle(final PropertyReportItem item) throws ReportException 108 { 109 super.handle(item); 110 items.add(item); 111 } 112 113 // --- object basics -------------------------------------------------------- 114 115 }