Coverage Report - org.simpleframework.xml.core.Group
 
Classes in this File Line Coverage Branch Coverage Complexity
Group
N/A
N/A
1
 
 1  
 /*
 2  
  * Group.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  
 /**
 22  
  * The <code>Group</code> interface represents a group of labels
 23  
  * associated with a particular union annotation. A group allows
 24  
  * a <code>Label</code> to be acquired by name or type. Acquiring
 25  
  * the label by type allows the serialization process to dynamically
 26  
  * select a label, and thus converter, based on the instance type.
 27  
  * On deserialization a label is dynamically selected based on name.
 28  
  * 
 29  
  * @author Niall Gallagher
 30  
  */
 31  
 interface Group {
 32  
    
 33  
    /**
 34  
     * This is used to determine if the group is inline. A group is
 35  
     * inline if all of the elements in the group is inline. If any of
 36  
     * the <code>Label<code> objects in the group is not inline then
 37  
     * the entire group is not inline, although this is unlikely.
 38  
     * 
 39  
     * @return this returns true if each label in the group is inline
 40  
     */
 41  
    boolean isInline();
 42  
    
 43  
    /**
 44  
     * This is used to determine if an annotated list is a text 
 45  
     * list. A text list is a list of elements that also accepts
 46  
     * free text. Typically this will be an element list union that
 47  
     * will allow unstructured XML such as XHTML to be parsed.
 48  
     * 
 49  
     * @return returns true if the label represents a text list
 50  
     */
 51  
    boolean isTextList();
 52  
    
 53  
    /**
 54  
     * This is used to acquire a <code>Label</code> based on the type
 55  
     * of an object. Selecting a label based on the type ensures that
 56  
     * the serialization process can dynamically convert an object
 57  
     * to XML. If the type is not supported, this returns null.
 58  
     * 
 59  
     * @param type this is the type to select the label from
 60  
     * 
 61  
     * @return this returns the label based on the type
 62  
     */
 63  
    Label getLabel(Class type);
 64  
    
 65  
    /**
 66  
     * This is used to acquire a <code>LabelMap</code> containing the
 67  
     * labels available to the group. Providing a context object 
 68  
     * ensures that each of the labels is mapped to a name that is
 69  
     * styled according to its internal style.
 70  
     * 
 71  
     * @return this returns a label map containing the labels 
 72  
     */
 73  
    LabelMap getElements() throws Exception;
 74  
    
 75  
    /**
 76  
     * This is used to get a <code>Label</code> that represents the
 77  
     * text between elements on an element union. Providing a label
 78  
     * here ensures that the free text found between elements can
 79  
     * be converted in to strings and added to the list.
 80  
     * 
 81  
     * @return a label if a text annotation has been declared
 82  
     */
 83  
    Label getText() throws Exception;
 84  
    
 85  
    /**
 86  
     * This returns a string representation of the union group.
 87  
     * Providing a string representation in this way ensures that the
 88  
     * group can be used in exception messages and for any debugging.
 89  
     * 
 90  
     * @return this returns a string representation of the group
 91  
     */
 92  
    String toString();
 93  
 }