Coverage Report - org.simpleframework.xml.strategy.Value
 
Classes in this File Line Coverage Branch Coverage Complexity
Value
N/A
N/A
1
 
 1  
 /*
 2  
  * Value.java January 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>Value</code> object describes a type that is represented 
 23  
  * by an XML element. This enables a <code>Strategy</code> to define
 24  
  * not only the type an element represents, but also defines if that
 25  
  * type needs to be created. This allows arrays as well as standard
 26  
  * object types to be described. When instantiated the instance should
 27  
  * be set on the value object for use by the strategy to detect cycles.
 28  
  * 
 29  
  * @author Niall Gallagher
 30  
  * 
 31  
  * @see org.simpleframework.xml.strategy.Strategy
 32  
  */
 33  
 public interface Value {
 34  
 
 35  
    /**
 36  
     * This method is used to acquire an instance of the type that
 37  
     * is defined by this object. If the value has not been set
 38  
     * then this method will return null if this is not a reference.
 39  
     * 
 40  
     * @return an instance of the type this object represents
 41  
     */
 42  
    Object getValue();
 43  
    
 44  
    /**
 45  
     * This method is used set the value within this object. Once
 46  
     * this is set then the <code>getValue</code> method will return
 47  
     * the object that has been provided for consistency. 
 48  
     * 
 49  
     * @param value this is the value to insert as the type
 50  
     */
 51  
    void setValue(Object value);
 52  
    
 53  
    /**
 54  
     * This is the type of the object instance this represents. The
 55  
     * type returned by this is used to instantiate an object which
 56  
     * will be set on this value and the internal graph maintained.
 57  
     * 
 58  
     * @return the type of the object that must be instantiated
 59  
     */
 60  
    Class getType();
 61  
    
 62  
    /**
 63  
     * This returns the length of the array that is to be allocated.
 64  
     * If this value does not represent an array then this should
 65  
     * return zero to indicate that it is not an array object.
 66  
     * 
 67  
     * @return this returns the number of elements for the array
 68  
     */
 69  
    int getLength();
 70  
    
 71  
    /**
 72  
     * This will return true if the object represents a reference.
 73  
     * A reference will provide a valid instance when this objects 
 74  
     * getter is invoked. A valid instance can be a null.
 75  
     * 
 76  
     * @return this returns true if this represents a reference
 77  
     */
 78  
    boolean isReference();
 79  
 }