Coverage Report - org.kuali.rice.core.impl.style.StyleExportDataSet
 
Classes in this File Line Coverage Branch Coverage Complexity
StyleExportDataSet
0%
0/15
0%
0/6
1.75
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php
 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 org.kuali.rice.core.impl.style;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.xml.namespace.QName;
 22  
 
 23  
 import org.kuali.rice.core.api.impex.ExportDataSet;
 24  
 
 25  
 /**
 26  
  * A utility class for managing an {@link ExportDataSet} containing StyleBo
 27  
  * data.  Provides a mechanism to convert instances of this class to a
 28  
  * populated {@link ExportDataSet}.
 29  
  * 
 30  
  * @see ExportDataSet
 31  
  * @see StyleBo
 32  
  *
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  */
 35  0
 public class StyleExportDataSet {
 36  
 
 37  0
         public static final QName STYLES = new QName("CORE", "styles");
 38  
         
 39  0
         private List<StyleBo> styles = new ArrayList<StyleBo>();
 40  
 
 41  
         public List<StyleBo> getStyles() {
 42  0
                 return styles;
 43  
         }
 44  
         
 45  
         /**
 46  
          * Populates the given {@link ExportDataSet} with the data from this data set.
 47  
          * 
 48  
          * @param exportDataSet the data set to populate the data into
 49  
          */
 50  
         public void populateExportDataSet(ExportDataSet exportDataSet) {
 51  0
                 if (styles != null && !styles.isEmpty()) {
 52  0
                         exportDataSet.addDataSet(STYLES, styles);
 53  
                 }
 54  0
         }
 55  
         
 56  
         /**
 57  
          * Converts this data set to a standard {@link ExportDataSet}, populating
 58  
          * it with the data from this data set.
 59  
          * 
 60  
          * @return the populated ExportDataSet
 61  
          */
 62  
         public ExportDataSet createExportDataSet() {
 63  0
                 ExportDataSet exportDataSet = new ExportDataSet();
 64  0
                 populateExportDataSet(exportDataSet);
 65  0
                 return exportDataSet;
 66  
         }
 67  
         
 68  
         /**
 69  
          * A static utility for creating a {@link StyleExportDataSet} from an
 70  
          * {@link ExportDataSet}.  This method will only populate the returned
 71  
          * style data set with style data from the given export data set.  The
 72  
          * rest of the data in the given export data set will be ignored.
 73  
          * 
 74  
          * @param exportDataSet the ExportDataSet to pull style data from
 75  
          * @return a StyleExportDataSet with any style data from the given exportDataSet populated
 76  
          */
 77  
         public static StyleExportDataSet fromExportDataSet(ExportDataSet exportDataSet) {
 78  0
                 StyleExportDataSet coreExportDataSet = new StyleExportDataSet();
 79  
                 
 80  0
                 List<StyleBo> styles = (List<StyleBo>)exportDataSet.getDataSets().get(STYLES);
 81  0
                 if (styles != null) {
 82  0
                         coreExportDataSet.getStyles().addAll(styles);
 83  
                 }
 84  
                 
 85  0
                 return coreExportDataSet;
 86  
         }
 87  
         
 88  
 }