| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AtomLinkConverter |
|
| 1.6666666666666667;1.667 |
| 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 com.thoughtworks.xstream.converters.Converter; | |
| 21 | import com.thoughtworks.xstream.converters.MarshallingContext; | |
| 22 | import com.thoughtworks.xstream.converters.UnmarshallingContext; | |
| 23 | import com.thoughtworks.xstream.io.HierarchicalStreamReader; | |
| 24 | import com.thoughtworks.xstream.io.HierarchicalStreamWriter; | |
| 25 | ||
| 26 | /** | |
| 27 | * Serializes links for atom, taking account of attributes. | |
| 28 | */ | |
| 29 | 222 | public class AtomLinkConverter implements Converter { |
| 30 | ||
| 31 | /** | |
| 32 | * {@inheritDoc} | |
| 33 | * | |
| 34 | * @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object, | |
| 35 | * com.thoughtworks.xstream.io.HierarchicalStreamWriter, | |
| 36 | * com.thoughtworks.xstream.converters.MarshallingContext) | |
| 37 | */ | |
| 38 | public void marshal(Object object, HierarchicalStreamWriter writer, | |
| 39 | MarshallingContext context) { | |
| 40 | 2 | AtomLink link = (AtomLink) object; |
| 41 | 2 | if (link.getRel() != null) { |
| 42 | 2 | writer.addAttribute("rel", link.getRel()); |
| 43 | } | |
| 44 | 2 | if (link.getHref() != null) { |
| 45 | 0 | writer.setValue(link.getHref()); |
| 46 | } | |
| 47 | 2 | } |
| 48 | ||
| 49 | /** | |
| 50 | * {@inheritDoc} | |
| 51 | * | |
| 52 | * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader, | |
| 53 | * com.thoughtworks.xstream.converters.UnmarshallingContext) | |
| 54 | */ | |
| 55 | public Object unmarshal(HierarchicalStreamReader reader, | |
| 56 | UnmarshallingContext context) { | |
| 57 | 0 | reader.moveDown(); |
| 58 | 0 | AtomLink al = new AtomLink(reader.getAttribute("rel"), reader.getValue()); |
| 59 | 0 | reader.moveUp(); |
| 60 | 0 | return al; |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * {@inheritDoc} | |
| 65 | * | |
| 66 | * @see com.thoughtworks.xstream.converters.ConverterMatcher#canConvert(java.lang.Class) | |
| 67 | */ | |
| 68 | public boolean canConvert(Class clazz) { | |
| 69 | 315 | return AtomLink.class.equals(clazz); |
| 70 | } | |
| 71 | ||
| 72 | } |