All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleframework.xml.strategy.Value Maven / Gradle / Ivy

Go to download

Simple is a high performance XML serialization and configuration framework for Java

There is a newer version: 2.7.1
Show newest version
/*
 * Value.java January 2007
 *
 * Copyright (C) 2007, Niall Gallagher 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General 
 * Public License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 * Boston, MA  02111-1307  USA
 */

package org.simpleframework.xml.strategy;

/**
 * The Value object describes a type that is represented 
 * by an XML element. This enables a Strategy to define
 * not only the type an element represents, but also defines if that
 * type needs to be created. This allows arrays as well as standard
 * object types to be described. When instantiated the instance should
 * be set on the value object for use by the strategy to detect cycles.
 * 
 * @author Niall Gallagher
 * 
 * @see org.simpleframework.xml.strategy.Strategy
 */
public interface Value {

   /**
    * This method is used to acquire an instance of the type that
    * is defined by this object. If the value has not been set
    * then this method will return null if this is not a reference.
    * 
    * @return an instance of the type this object represents
    */
   public Object getValue();
   
   /**
    * This method is used set the value within this object. Once
    * this is set then the getValue method will return
    * the object that has been provided for consistency. 
    * 
    * @param value this is the value to insert as the type
    */
   public void setValue(Object value);
   
   /**
    * This is the type of the object instance this represents. The
    * type returned by this is used to instantiate an object which
    * will be set on this value and the internal graph maintained.
    * 
    * @return the type of the object that must be instantiated
    */
   public Class getType();
   
   /**
    * This returns the length of the array that is to be allocated.
    * If this value does not represent an array then this should
    * return zero to indicate that it is not an array object.
    * 
    * @return this returns the number of elements for the array
    */
   public int getLength();
   
   /**
    * This will return true if the object represents a reference.
    * A reference will provide a valid instance when this objects 
    * getter is invoked. A valid instance can be a null.
    * 
    * @return this returns true if this represents a reference
    */
   public boolean isReference();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy