Coverage Report - org.simpleframework.xml.core.Extractor
 
Classes in this File Line Coverage Branch Coverage Complexity
Extractor
N/A
N/A
1
 
 1  
 /*
 2  
  * Extractor.java March 2011
 3  
  *
 4  
  * Copyright (C) 2011, Niall Gallagher <niallg@users.sf.net>
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * 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, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 15  
  * implied. See the License for the specific language governing 
 16  
  * permissions and limitations under the License.
 17  
  */
 18  
 
 19  
 package org.simpleframework.xml.core;
 20  
 
 21  
 import java.lang.annotation.Annotation;
 22  
 
 23  
 /**
 24  
  * The <code>Extractor</code> interface is used to represent an object
 25  
  * that can be used to extract constituent parts from a union. Using
 26  
  * this allows a uniform interface to be used to interface with various
 27  
  * different union annotations. 
 28  
  * 
 29  
  * @author Niall Gallagher
 30  
  * 
 31  
  * @see org.simpleframework.xml.core.ExtractorFactory
 32  
  */
 33  
 interface Extractor<T extends Annotation>{
 34  
    
 35  
    /**
 36  
     * This is used to acquire each annotation that forms part of the
 37  
     * union group. Extracting the annotations in this way allows
 38  
     * the extractor to build a <code>Label</code> which can be used
 39  
     * to represent the annotation. Each label can then provide a
 40  
     * converter implementation to serialize objects.
 41  
     * 
 42  
     * @return this returns each annotation within the union group
 43  
     */
 44  
    T[] getAnnotations() throws Exception;
 45  
    
 46  
    /**
 47  
     * Each annotation can provide a class which is used to determine
 48  
     * which label is used to serialize an object. This ensures that
 49  
     * the correct label is selected whenever serialization occurs.
 50  
     * 
 51  
     * @param label this is the annotation to extract the type for
 52  
     * 
 53  
     * @return this returns the class associated with the annotation
 54  
     */
 55  
    Class getType(T label) throws Exception;
 56  
    
 57  
    /**
 58  
     * This creates a <code>Label</code> object used to represent the
 59  
     * annotation provided. Creating the label in this way ensures
 60  
     * that each union has access to the serialization methods 
 61  
     * defined for each type an XML element name.
 62  
     * 
 63  
     * @param label this is the annotation to create the label for
 64  
     * 
 65  
     * @return this is the label created for the annotation
 66  
     */
 67  
    Label getLabel(T label) throws Exception;
 68  
 }