Coverage Report - org.apache.shindig.social.core.util.atom.AtomEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
AtomEntry
100%
24/24
100%
6/6
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.model.Activity;
 21  
 import org.apache.shindig.social.opensocial.model.Person;
 22  
 
 23  
 import java.util.Date;
 24  
 import java.util.Map.Entry;
 25  
 
 26  
 /**
 27  
  * This bean represents a Atom Entry for serialization. It contains, optionally
 28  
  * a person or an activity, from which are extracted the key atom fields.
 29  
  */
 30  
 public class AtomEntry {
 31  
 
 32  
   @SuppressWarnings("unused")
 33  
   private String id;
 34  
   @SuppressWarnings("unused")
 35  
   private String title;
 36  
   @SuppressWarnings("unused")
 37  
   private String summary;
 38  
   @SuppressWarnings("unused")
 39  
   private String icon;
 40  
   @SuppressWarnings("unused")
 41  
   private AtomSource source;
 42  
   @SuppressWarnings("unused")
 43  
   private AtomGenerator generator;
 44  
   @SuppressWarnings("unused")
 45  
   private AtomAuthor author;
 46  
   @SuppressWarnings("unused")
 47  
   private Date updated;
 48  
   @SuppressWarnings("unused")
 49  
   private AtomLink link;
 50  
   @SuppressWarnings("unused")
 51  
   private Object content;
 52  
 
 53  
   /**
 54  
    * @param o
 55  
    */
 56  10
   public AtomEntry(Object o) {
 57  10
     if (o instanceof Person) {
 58  1
       Person person = (Person) o;
 59  1
       content = new AtomContent(person);
 60  1
       id = "urn:guid:" + person.getId();
 61  1
       updated = person.getUpdated();
 62  1
     } else if (o instanceof Activity) {
 63  1
       Activity activity = (Activity) o;
 64  1
       content = new AtomContent(activity);
 65  1
       title = activity.getTitle();
 66  1
       summary = activity.getBody();
 67  1
       link = new AtomLink("self", activity.getUrl());
 68  1
       icon = activity.getStreamFaviconUrl();
 69  1
       source = new AtomSource(activity);
 70  1
       generator = new AtomGenerator(activity);
 71  1
       author = new AtomAuthor(activity);
 72  1
       updated = activity.getUpdated();
 73  1
     } else if ( o instanceof Entry ) {
 74  4
       Entry<?, ?> e = (Entry<?, ?>) o;
 75  4
       id = (String) e.getKey();
 76  4
       content = new AtomContent(e.getValue());
 77  4
     } else {
 78  4
       content = o;
 79  
     }
 80  10
   }
 81  
 
 82  
 }