Coverage Report - org.apache.shindig.social.core.util.atom.AtomFeed
 
Classes in this File Line Coverage Branch Coverage Complexity
AtomFeed
45%
17/38
50%
6/12
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements. See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership. The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License. You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied. See the License for the
 16  
  * specific language governing permissions and limitations under the License.
 17  
  */
 18  
 package org.apache.shindig.social.core.util.atom;
 19  
 
 20  
 import org.apache.shindig.social.opensocial.spi.DataCollection;
 21  
 import org.apache.shindig.social.opensocial.spi.RestfulCollection;
 22  
 
 23  
 import java.util.ArrayList;
 24  
 import java.util.Collection;
 25  
 import java.util.List;
 26  
 import java.util.Map;
 27  
 import java.util.Map.Entry;
 28  
 
 29  
 /**
 30  
  * represents an atom:feed entry
 31  
  */
 32  
 public class AtomFeed {
 33  
 
 34  
   @SuppressWarnings("unchecked")
 35  
   private Collection entry;
 36  
   @SuppressWarnings("unused")
 37  
   private int startIndex;
 38  
   @SuppressWarnings("unused")
 39  
   private int totalResults;
 40  
   @SuppressWarnings("unused")
 41  
   private int itemsPerPage;
 42  
   @SuppressWarnings("unused")
 43  
   private String author;
 44  
   @SuppressWarnings("unused")
 45  
   private AtomLink link;
 46  
 
 47  
   /**
 48  
    * @param obj
 49  
    */
 50  
   @SuppressWarnings("unchecked")
 51  8
   public AtomFeed(Object obj) {
 52  8
     if (obj instanceof Map) {
 53  2
       Map<?, ?> m = (Map<?, ?>) obj;
 54  2
       entry = new ArrayList();
 55  2
       for ( Entry<?, ?> o : m.entrySet()) {
 56  4
         entry.add(new AtomEntry(o));
 57  4
       }
 58  2
       startIndex = 0;
 59  2
       totalResults = entry.size();
 60  2
       itemsPerPage = entry.size();
 61  2
     } else if (obj instanceof RestfulCollection<?>) {
 62  0
       RestfulCollection<?> r = (RestfulCollection<?>) obj;
 63  0
       entry = new ArrayList();
 64  0
       List<?> entryList = r.getEntry();
 65  0
       for (Object o : entryList) {
 66  0
         entry.add(new AtomEntry(o));
 67  0
       }
 68  0
       startIndex = r.getStartIndex();
 69  0
       totalResults = r.getTotalResults();
 70  0
       itemsPerPage = entryList.size();
 71  0
       author = "?";
 72  0
       link = new AtomLink("rel", "???");
 73  0
     } else if ( obj instanceof DataCollection ) {
 74  0
       DataCollection dc = (DataCollection) obj;
 75  0
       entry = new ArrayList();
 76  0
       for ( Entry<String, Map<String,String>> o : dc.getEntry().entrySet()) {
 77  0
         entry.add(new AtomEntry(o));
 78  0
       }
 79  0
       startIndex = 0;
 80  0
       totalResults = entry.size();
 81  0
       itemsPerPage = entry.size();
 82  0
     } else {
 83  6
       entry = new ArrayList();
 84  6
       entry.add(new AtomEntry(obj));
 85  6
       startIndex = 0;
 86  6
       totalResults = 1;
 87  6
       itemsPerPage = 1;
 88  
     }
 89  8
   }
 90  
 
 91  
 }