Coverage Report - org.simpleframework.xml.core.Instantiator
 
Classes in this File Line Coverage Branch Coverage Complexity
Instantiator
N/A
N/A
1
 
 1  
 /*
 2  
  * Instantiator.java December 2009
 3  
  *
 4  
  * Copyright (C) 2009, 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.util.List;
 22  
 
 23  
 /**
 24  
  * The <code>Instantiator</code> object is used for instantiating 
 25  
  * objects using either the default no argument constructor or one
 26  
  * that takes deserialized values as parameters. This also exposes 
 27  
  * the parameters and constructors used to instantiate the object.
 28  
  *
 29  
  * @author Niall Gallagher
 30  
  */
 31  
 interface Instantiator {
 32  
 
 33  
    /**
 34  
     * This is used to determine if this <code>Instantiator</code> has 
 35  
     * a default constructor. If the only constructor this contains 
 36  
     * is a default no argument constructor this returns true.
 37  
     * 
 38  
     * @return true if the class only has a default constructor
 39  
     */
 40  
    boolean isDefault(); 
 41  
    
 42  
    /**
 43  
     * This is used to instantiate the object using the default no
 44  
     * argument constructor. If for some reason the object can not be
 45  
     * instantiated then this will throw an exception with the reason.
 46  
     * 
 47  
     * @return this returns the object that has been instantiated
 48  
     */
 49  
    Object getInstance() throws Exception; 
 50  
    
 51  
    /**
 52  
     * This is used to instantiate the object using a constructor that
 53  
     * takes deserialized objects as arguments. The object that have
 54  
     * been deserialized can be taken from the <code>Criteria</code>
 55  
     * object which contains the deserialized values.
 56  
     * 
 57  
     * @param criteria this contains the criteria to be used
 58  
     * 
 59  
     * @return this returns the object that has been instantiated
 60  
     */
 61  
    Object getInstance(Criteria criteria) throws Exception;
 62  
 
 63  
    /**
 64  
     * This is used to acquire the named <code>Parameter</code> from
 65  
     * the creator. A parameter is taken from the constructor which
 66  
     * contains annotations for each object that is required. These
 67  
     * parameters must have a matching field or method.
 68  
     * 
 69  
     * @param name this is the name of the parameter to be acquired
 70  
     * 
 71  
     * @return this returns the named parameter for the creator
 72  
     */
 73  
    Parameter getParameter(String name);
 74  
    
 75  
    /**
 76  
     * This is used to acquire all parameters annotated for the class
 77  
     * schema. Providing all parameters ensures that they can be
 78  
     * validated against the annotated methods and fields to ensure
 79  
     * that each parameter is valid and has a corresponding match.
 80  
     * 
 81  
     * @return this returns the parameters declared in the schema     
 82  
     */
 83  
    List<Parameter> getParameters();
 84  
    
 85  
    /**
 86  
     * This is used to acquire the <code>Creator</code> objects
 87  
     * used to create an instance of the object. Each represents a
 88  
     * constructor and contains the parameters to the constructor. 
 89  
     * This is primarily used to validate each constructor against the
 90  
     * fields and methods annotated to ensure they are compatible.
 91  
     *
 92  
     * @return this returns a list of creators for the type
 93  
     */ 
 94  
    List<Creator> getCreators();
 95  
 }