source: josm/trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java@ 12455

Last change on this file since 12455 was 9460, checked in by Don-vip, 8 years ago

javadoc

  • Property svn:eol-style set to native
File size: 7.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.Date;
5
6import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
7import org.openstreetmap.josm.tools.LanguageInfo;
8
9/**
10 * IPrimitive captures the common functions of {@link OsmPrimitive} and {@link PrimitiveData}.
11 * @since 4098
12 */
13public interface IPrimitive extends Tagged, PrimitiveId {
14
15 /**
16 * Replies <code>true</code> if the object has been modified since it was loaded from
17 * the server. In this case, on next upload, this object will be updated.
18 *
19 * Deleted objects are deleted from the server. If the objects are added (id=0),
20 * the modified is ignored and the object is added to the server.
21 *
22 * @return <code>true</code> if the object has been modified since it was loaded from
23 * the server
24 */
25 boolean isModified();
26
27 /**
28 * Marks this primitive as being modified.
29 *
30 * @param modified true, if this primitive is to be modified
31 */
32 void setModified(boolean modified);
33
34 /**
35 * Checks if object is known to the server.
36 * Replies true if this primitive is either unknown to the server (i.e. its id
37 * is 0) or it is known to the server and it hasn't be deleted on the server.
38 * Replies false, if this primitive is known on the server and has been deleted
39 * on the server.
40 *
41 * @return <code>true</code>, if the object is visible on server.
42 * @see #setVisible(boolean)
43 */
44 boolean isVisible();
45
46 /**
47 * Sets whether this primitive is visible, i.e. whether it is known on the server
48 * and not deleted on the server.
49 * @param visible {@code true} if this primitive is visible
50 *
51 * @throws IllegalStateException if visible is set to false on an primitive with id==0
52 * @see #isVisible()
53 */
54 void setVisible(boolean visible);
55
56 /**
57 * Replies <code>true</code>, if the object has been deleted.
58 *
59 * @return <code>true</code>, if the object has been deleted.
60 * @see #setDeleted(boolean)
61 */
62 boolean isDeleted();
63
64 /**
65 * Sets whether this primitive is deleted or not.
66 *
67 * Also marks this primitive as modified if deleted is true.
68 *
69 * @param deleted true, if this primitive is deleted; false, otherwise
70 */
71 void setDeleted(boolean deleted);
72
73 /**
74 * Determines if this primitive is incomplete.
75 * @return {@code true} if this primitive is incomplete, {@code false} otherwise
76 */
77 boolean isIncomplete();
78
79 /**
80 * Replies <code>true</code> if the object has been deleted on the server and was undeleted by the user.
81 * @return <code>true</code> if the object has been undeleted
82 */
83 boolean isUndeleted();
84
85 /**
86 * Replies <code>true</code>, if the object is usable
87 * (i.e. complete and not deleted).
88 *
89 * @return <code>true</code>, if the object is usable.
90 * @see #setDeleted(boolean)
91 */
92 boolean isUsable();
93
94 /**
95 * Determines if this primitive is new or undeleted.
96 * @return True if primitive is new or undeleted
97 * @see #isNew()
98 * @see #isUndeleted()
99 */
100 boolean isNewOrUndeleted();
101
102 /**
103 * Replies the id of this primitive.
104 *
105 * @return the id of this primitive.
106 */
107 long getId();
108
109 /**
110 * Replies the unique primitive id for this primitive
111 *
112 * @return the unique primitive id for this primitive
113 */
114 PrimitiveId getPrimitiveId();
115
116 /**
117 * Replies the version number as returned by the API. The version is 0 if the id is 0 or
118 * if this primitive is incomplete.
119 * @return the version number as returned by the API
120 *
121 * @see PrimitiveData#setVersion(int)
122 */
123 int getVersion();
124
125 /**
126 * Sets the id and the version of this primitive if it is known to the OSM API.
127 *
128 * Since we know the id and its version it can't be incomplete anymore. incomplete
129 * is set to false.
130 *
131 * @param id the id. &gt; 0 required
132 * @param version the version &gt; 0 required
133 * @throws IllegalArgumentException if id &lt;= 0
134 * @throws IllegalArgumentException if version &lt;= 0
135 * @throws DataIntegrityProblemException if id is changed and primitive was already added to the dataset
136 */
137 void setOsmId(long id, int version);
138
139 /**
140 * Replies the user who has last touched this object. May be null.
141 *
142 * @return the user who has last touched this object. May be null.
143 */
144 User getUser();
145
146 /**
147 * Sets the user who has last touched this object.
148 *
149 * @param user the user
150 */
151 void setUser(User user);
152
153 /**
154 * Time of last modification to this object. This is not set by JOSM but
155 * read from the server and delivered back to the server unmodified. It is
156 * used to check against edit conflicts.
157 *
158 * @return date of last modification
159 * @see #setTimestamp
160 */
161 Date getTimestamp();
162
163 /**
164 * Time of last modification to this object. This is not set by JOSM but
165 * read from the server and delivered back to the server unmodified. It is
166 * used to check against edit conflicts.
167 *
168 * @return last modification as timestamp
169 * @see #setRawTimestamp
170 */
171 int getRawTimestamp();
172
173 /**
174 * Sets time of last modification to this object
175 * @param timestamp date of last modification
176 * @see #getTimestamp
177 */
178 void setTimestamp(Date timestamp);
179
180 /**
181 * Sets time of last modification to this object
182 * @param timestamp date of last modification
183 * @see #getRawTimestamp
184 */
185 void setRawTimestamp(int timestamp);
186
187 /**
188 * Determines if this primitive has no timestam information.
189 * @return {@code true} if this primitive has no timestam information
190 * @see #getTimestamp
191 * @see #getRawTimestamp
192 */
193 boolean isTimestampEmpty();
194
195 /**
196 * Replies the id of the changeset this primitive was last uploaded to.
197 * 0 if this primitive wasn't uploaded to a changeset yet or if the
198 * changeset isn't known.
199 *
200 * @return the id of the changeset this primitive was last uploaded to.
201 */
202 int getChangesetId();
203
204 /**
205 * Sets the changeset id of this primitive. Can't be set on a new primitive.
206 *
207 * @param changesetId the id. &gt;= 0 required.
208 * @throws IllegalStateException if this primitive is new.
209 * @throws IllegalArgumentException if id &lt; 0
210 */
211 void setChangesetId(int changesetId);
212
213 /**
214 * Makes the given visitor visit this primitive.
215 * @param visitor visitor
216 */
217 void accept(PrimitiveVisitor visitor);
218
219 /**
220 * Replies the name of this primitive. The default implementation replies the value
221 * of the tag <tt>name</tt> or null, if this tag is not present.
222 *
223 * @return the name of this primitive
224 */
225 String getName();
226
227 /**
228 * Replies a localized name for this primitive given by the value of the name tags
229 * accessed from very specific (language variant) to more generic (default name).
230 *
231 * @return the name of this primitive, <code>null</code> if no name exists
232 * @see LanguageInfo#getLanguageCodes
233 */
234 String getLocalName();
235}
Note: See TracBrowser for help on using the repository browser.