|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DefaultConverterLookup.java | 83.3% | 87.5% | 100% | 87.5% |
|
1 |
package com.thoughtworks.xstream.converters.lookup;
|
|
2 |
|
|
3 |
import com.thoughtworks.xstream.converters.ConversionException;
|
|
4 |
import com.thoughtworks.xstream.converters.Converter;
|
|
5 |
import com.thoughtworks.xstream.converters.ConverterLookup;
|
|
6 |
import com.thoughtworks.xstream.converters.basic.NullConverter;
|
|
7 |
|
|
8 |
import java.util.Iterator;
|
|
9 |
import java.util.LinkedList;
|
|
10 |
|
|
11 |
public class DefaultConverterLookup implements ConverterLookup { |
|
12 |
|
|
13 |
private LinkedList converters = new LinkedList(); |
|
14 |
private Converter nullConverter = new NullConverter(); |
|
15 |
|
|
16 | 260 |
public Converter lookupConverterForType(Class type) {
|
17 | 260 |
if (type == null) { |
18 | 2 |
return nullConverter;
|
19 |
} |
|
20 | 2549 |
for (Iterator iterator = converters.iterator(); iterator.hasNext();) {
|
21 | 2549 |
Converter converter = (Converter) iterator.next(); |
22 | 2549 |
if (converter.canConvert(type)) {
|
23 | 258 |
return converter;
|
24 |
} |
|
25 |
} |
|
26 | 0 |
throw new ConversionException("No converter specified for " + type); |
27 |
} |
|
28 |
|
|
29 | 562 |
public void registerConverter(Converter converter) { |
30 | 562 |
converters.addFirst(converter); |
31 |
} |
|
32 |
|
|
33 |
} |
|
34 |
|
|