Coverage Report - org.simpleframework.xml.strategy.Contract
 
Classes in this File Line Coverage Branch Coverage Complexity
Contract
100%
10/10
N/A
1
 
 1  
 /*
 2  
  * Contract.java April 2007
 3  
  *
 4  
  * Copyright (C) 2007, 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.strategy;
 20  
 
 21  
 /**
 22  
  * The <code>Contract</code> object is used to expose the attribute
 23  
  * names used by the cycle strategy. This ensures that reading and
 24  
  * writing of the XML document is done in a consistent manner. Each
 25  
  * attribute is used to mark special meta-data for the object graph. 
 26  
  * 
 27  
  * @author Niall Gallagher
 28  
  * 
 29  
  * @see org.simpleframework.xml.strategy.CycleStrategy
 30  
  */
 31  
 class Contract {
 32  
              
 33  
    /**
 34  
     * This is used to specify the length of array instances.
 35  
     */
 36  
    private String length;
 37  
    
 38  
    /**
 39  
     * This is the label used to mark the type of an object.
 40  
     */
 41  
    private String label;
 42  
    
 43  
    /**
 44  
     * This is the attribute used to mark the identity of an object.
 45  
     */
 46  
    private String mark;
 47  
    
 48  
    /**
 49  
     * This is the attribute used to refer to an existing instance.
 50  
     */
 51  
    private String refer;
 52  
    
 53  
    /**
 54  
     * Constructor for the <code>Syntax</code> object. This is used
 55  
     * to expose the attribute names used by the strategy. All the
 56  
     * names can be acquired and shared by the read and write graph
 57  
     * objects, which ensures consistency between the two objects.
 58  
     * 
 59  
     * @param mark this is used to mark the identity of an object
 60  
     * @param refer this is used to refer to an existing object
 61  
     * @param label this is used to specify the class for the field
 62  
     * @param length this is the length attribute used for arrays
 63  
     */   
 64  261
    public Contract(String mark, String refer, String label, String length){  
 65  261
       this.length = length;
 66  261
       this.label = label;
 67  261
       this.refer = refer;
 68  261
       this.mark = mark;
 69  261
    }
 70  
    
 71  
    /**
 72  
     * This is returns the attribute used to store information about
 73  
     * the type to the XML document. This attribute name is used to 
 74  
     * add data to XML elements to enable the deserialization process
 75  
     * to know the exact instance to use when creating a type.
 76  
     * 
 77  
     * @return the name of the attribute used to store the type
 78  
     */
 79  
    public String getLabel() {
 80  3466
       return label;
 81  
    }
 82  
    
 83  
    /**
 84  
     * This returns the attribute used to store references within the
 85  
     * serialized XML document. The reference attribute is added to
 86  
     * the serialized XML element so that cycles in the object graph 
 87  
     * can be recreated. This is an optional attribute.
 88  
     * 
 89  
     * @return this returns the name of the reference attribute
 90  
     */
 91  
    public String getReference() {
 92  3466
       return refer;
 93  
    }
 94  
    
 95  
    /**
 96  
     * This returns the attribute used to store the identities of all
 97  
     * objects serialized to the XML document. The identity attribute
 98  
     * stores a unique identifiers, which enables this strategy to
 99  
     * determine an objects identity within the serialized XML.
 100  
     * 
 101  
     * @return this returns the name of the identity attribute used
 102  
     */
 103  
    public String getIdentity() {
 104  3466
       return mark;
 105  
    }
 106  
    
 107  
    /**
 108  
     * This returns the attribute used to store the array length in
 109  
     * the serialized XML document. The array length is required so
 110  
     * that the deserialization process knows how to construct the
 111  
     * array before any of the array elements are deserialized.
 112  
     * 
 113  
     * @return this returns the name of the array length attribute
 114  
     */
 115  
    public String getLength() {
 116  3466
       return length;
 117  
    } 
 118  
 }