| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Contact |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Contact.java April 2007 | |
| 3 | * | |
| 4 | * Copyright (C) 2007, Niall Gallagher <niallg@users.sf.net> | |
| 5 | * | |
| 6 | * This library is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU Lesser General Public | |
| 8 | * License as published by the Free Software Foundation. | |
| 9 | * | |
| 10 | * This library is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | * GNU Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General | |
| 16 | * Public License along with this library; if not, write to the | |
| 17 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
| 18 | * Boston, MA 02111-1307 USA | |
| 19 | */ | |
| 20 | ||
| 21 | package org.simpleframework.xml.load; | |
| 22 | ||
| 23 | import java.lang.annotation.Annotation; | |
| 24 | ||
| 25 | /** | |
| 26 | * The <code>Contact</code> interface is used to provide a point of | |
| 27 | * contact with an object. Typically this will be used to get and | |
| 28 | * set to an from a field or a pair of matching bean methods. Each | |
| 29 | * contact must be labeled with an annotation. | |
| 30 | * | |
| 31 | * @author Niall Gallagher | |
| 32 | * | |
| 33 | * @see org.simpleframework.xml.load.Label | |
| 34 | */ | |
| 35 | interface Contact { | |
| 36 | ||
| 37 | /** | |
| 38 | * This is the annotation associated with the point of contact. | |
| 39 | * This will be an XML annotation that describes how the contact | |
| 40 | * should be serializaed and deserialized from the object. | |
| 41 | * | |
| 42 | * @return this provides the annotation associated with this | |
| 43 | */ | |
| 44 | public Annotation getAnnotation(); | |
| 45 | ||
| 46 | /** | |
| 47 | * This will provide the contact type. The contact type is the | |
| 48 | * class that is to be set and get on the object. Typically the | |
| 49 | * type will be a serializable object or a primitive type. | |
| 50 | * | |
| 51 | * @return this returns the type that this contact represents | |
| 52 | */ | |
| 53 | public Class getType(); | |
| 54 | ||
| 55 | /** | |
| 56 | * This provides the dependant class for the contact. This will | |
| 57 | * typically represent a generic type for the actual type. For | |
| 58 | * contacts that use a <code>Collection</code> type this will | |
| 59 | * be the generic type parameter for that collection. | |
| 60 | * | |
| 61 | * @return this returns the dependant type for the contact | |
| 62 | */ | |
| 63 | public Class getDependant(); | |
| 64 | ||
| 65 | /** | |
| 66 | * This provides the dependant classes for the contact. This will | |
| 67 | * typically represent a generic types for the actual type. For | |
| 68 | * contacts that use a <code>Map</code> type this will be the | |
| 69 | * generic type parameter for that map type declaration. | |
| 70 | * | |
| 71 | * @return this returns the dependant type for the contact | |
| 72 | */ | |
| 73 | public Class[] getDependants(); | |
| 74 | ||
| 75 | /** | |
| 76 | * This represents the name of the object contact. If the contact | |
| 77 | * is a field then the name of the field is provided. If however | |
| 78 | * the contact is a method then the Java Bean name of the method | |
| 79 | * is provided, which will be the decapatilized name of the | |
| 80 | * method without the get, set, or is prefix to the method. | |
| 81 | * | |
| 82 | * @return this returns the name of the contact represented | |
| 83 | */ | |
| 84 | public String getName(); | |
| 85 | ||
| 86 | /** | |
| 87 | * This is used to set the value on the specified object through | |
| 88 | * this contact. Depending on the type of contact this will set | |
| 89 | * the value given, typically this will be done by invoking a | |
| 90 | * method or setting the value on the object field. | |
| 91 | * | |
| 92 | * @param source this is the object to set the value on | |
| 93 | * @param value this is the value to be set through the contact | |
| 94 | */ | |
| 95 | public void set(Object source, Object value) throws Exception; | |
| 96 | ||
| 97 | /** | |
| 98 | * This is used to get the value from the specified object using | |
| 99 | * the point of contact. Typically the value is retrieved from | |
| 100 | * the specified object by invoking a get method of by acquiring | |
| 101 | * the value from a field within the specified object. | |
| 102 | * | |
| 103 | * @param source this is the object to acquire the value from | |
| 104 | * | |
| 105 | * @return this is the value acquired from the point of contact | |
| 106 | */ | |
| 107 | public Object get(Object source) throws Exception; | |
| 108 | ||
| 109 | /** | |
| 110 | * This is used to describe the contact as it exists within the | |
| 111 | * owning class. This is used to provide error messages that can | |
| 112 | * be used to debug issues that occur when processing a contact. | |
| 113 | * | |
| 114 | * @return this returns a string representation of the contact | |
| 115 | */ | |
| 116 | public String toString(); | |
| 117 | } |