KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.*;
23
24 /**
25  * This class represents the <Map> tag as defined by the SyncML r
26  * epresentation specifications.
27  *
28  * @author Stefano Fornari @ Funambol
29  *
30  * @version $Id: Map.java,v 1.4 2005/03/02 20:57:37 harrie Exp $
31  *
32  */

33 public final class Map
34 extends AbstractCommand
35 implements java.io.Serializable JavaDoc {
36     
37     // --------------------------------------------------------------- Constants
38

39     public static String JavaDoc COMMAND_NAME = "Map";
40     
41     // ------------------------------------------------------------ Private data
42

43     private Target target;
44     private Source source;
45     private ArrayList mapItems = new ArrayList();
46     
47     // ------------------------------------------------------------ Constructors
48

49     /**
50      * For serialization purposes
51      */

52     protected Map() {}
53     
54     /**
55      * Creates a new Map commands from its constituent information.
56      *
57      * @param cmdID command identifier - NOT NULL
58      * @param target the target - NOT NULL
59      * @param source the source - NOT NULL
60      * @param cred authentication credential - NULL ALLOWED
61      * @param meta the associated meta data - NULL ALLOWED
62      * @param mapItems the mapping items - NOT NULL
63      *
64      */

65     public Map(final CmdID cmdID,
66                final Target target,
67                final Source source,
68                final Cred cred,
69                final Meta meta,
70                final MapItem[] mapItems) {
71
72         super(cmdID);
73         setMeta(meta);
74         setCred(cred);
75         
76         setTarget (target );
77         setSource (source );
78         setMapItems(mapItems);
79     }
80     
81     // ---------------------------------------------------------- Public methods
82

83     /**
84      * Returns the target property
85      * @return the target property
86      *
87      */

88     public Target getTarget() {
89         return target;
90     }
91     
92     /**
93      * Sets the target property
94      *
95      * @param target the target - NOT NULL
96      *
97      * @throws IllegalArgumentException if target is null
98      */

99     public void setTarget(Target target) {
100         if (target == null) {
101             throw new IllegalArgumentException JavaDoc("target cannot be null");
102         }
103         this.target = target;
104     }
105     
106     /**
107      * Returns the source property
108      * @return the source property
109      *
110      */

111     public Source getSource() {
112         return source;
113     }
114     
115     /**
116      * Sets the source property
117      *
118      * @param source the source - NOT NULL
119      *
120      * @throws IllegalArgumentException if source is null
121      */

122     public void setSource(Source source) {
123         if (source == null) {
124             throw new IllegalArgumentException JavaDoc("source cannot be null");
125         }
126         this.source = source;
127     }
128     
129     /**
130      * Returns the map items
131      *
132      * @return the map items
133      *
134      */

135     public ArrayList getMapItems() {
136         return mapItems;
137     }
138     
139     /**
140      * Sets the mapItems property
141      *
142      * @param mapItems the map items - NOT NULL
143      *
144      * @throws IllegalArgumentException if mapItems is null
145      */

146     public void setMapItems(MapItem[] mapItems) {
147         if (mapItems == null) {
148             throw new IllegalArgumentException JavaDoc("mapItems cannot be null");
149         }
150         this.mapItems.clear();
151         this.mapItems.addAll(Arrays.asList(mapItems));
152     }
153        
154     /**
155      * Returns the command name
156      *
157      * @return the command name
158      */

159     public String JavaDoc getName() {
160         return Map.COMMAND_NAME;
161     }
162 }
163
Popular Tags