KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > core > SourceRef


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19
20 package sync4j.framework.core;
21
22 /**
23  * This class represents the <SourceRef> element as defined by the SyncML
24  * representation specifications
25  *
26  * @author Stefano Fornari @ Funambol
27  *
28  * @version $Id: SourceRef.java,v 1.4 2005/06/07 16:51:07 luigiafassina Exp $
29  */

30 public final class SourceRef
31 implements java.io.Serializable JavaDoc {
32
33     // ------------------------------------------------------------ Private data
34
private String JavaDoc value;
35     private Source source;
36     
37     // ------------------------------------------------------------ Constructors
38

39     /**
40      * In order to expose the server configuration like WS this constructor
41      * must be public
42      */

43     public SourceRef() {}
44     
45     /**
46      * Creates a new SourceRef object given the referenced value. A null value
47      * is considered an empty string
48      *
49      * @param value the referenced value - NULL ALLOWED
50      *
51      * @throws IllegalArgumentException if value is null
52      */

53     public SourceRef(final String JavaDoc value) {
54         setValue(value);
55     }
56     
57     /**
58      * Creates a new SourceRef object from an existing Source.
59      *
60      * @param source the source to extract the reference from - NOT NULL
61      *
62      * @throws IllegalArgumentException if source is null
63      *
64      */

65     public SourceRef(final Source source) {
66         setSource(source);
67         
68         value = source.getLocURI();
69     }
70     
71     // ---------------------------------------------------------- Public methods
72

73     /**
74      * Returns the value
75      *
76      * @return the value
77      */

78     public String JavaDoc getValue() {
79         return value;
80     }
81     
82     /**
83      * Sets the reference value. If value is null, the empty string is adopted.
84      *
85      * @param value the reference value - NULL
86      */

87     public void setValue(String JavaDoc value) {
88         this.value = (value == null) ? "" : value;
89     }
90     
91     /**
92      * Gets the Source property
93      *
94      * @return source the Source object property
95      */

96     public Source getSource() {
97         return this.source;
98     }
99     
100     /**
101      * Sets the Source property
102      *
103      * @param source the Source object property - NOT NULL
104      */

105     public void setSource(Source source) {
106         if (source == null) {
107             throw new IllegalArgumentException JavaDoc("source cannot be null");
108         }
109         this.source = source;
110     }
111 }
Popular Tags