source: josm/trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java@ 2284

Last change on this file since 2284 was 2284, checked in by jttt, 15 years ago

Added PrimitiveData classes. Uses PrimitiveData as storage for Command's undo function

  • Property svn:eol-style set to native
File size: 25.4 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.osm;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.ArrayList;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.Collections;
10import java.util.Date;
11import java.util.HashMap;
12import java.util.HashSet;
13import java.util.LinkedList;
14import java.util.List;
15import java.util.Locale;
16import java.util.Map;
17import java.util.Set;
18import java.util.Map.Entry;
19import java.util.concurrent.atomic.AtomicLong;
20
21import org.openstreetmap.josm.Main;
22import org.openstreetmap.josm.data.osm.visitor.Visitor;
23import org.openstreetmap.josm.gui.mappaint.ElemStyle;
24
25
26/**
27 * An OSM primitive can be associated with a key/value pair. It can be created, deleted
28 * and updated within the OSM-Server.
29 *
30 * Although OsmPrimitive is designed as a base class, it is not to be meant to subclass
31 * it by any other than from the package {@link org.openstreetmap.josm.data.osm}. The available primitives are a fixed set that are given
32 * by the server environment and not an extendible data stuff.
33 *
34 * @author imi
35 */
36abstract public class OsmPrimitive implements Comparable<OsmPrimitive>, Tagged {
37
38 private static AtomicLong idCounter = new AtomicLong(0);
39
40 private static final int FLAG_MODIFIED = 1 << 0;
41 private static final int FLAG_VISIBLE = 1 << 1;
42 private static final int FLAG_DISABLED = 1 << 2;
43 private static final int FLAG_DELETED = 1 << 3;
44 private static final int FLAG_FILTERED = 1 << 4;
45 private static final int FLAG_SELECTED = 1 << 5;
46 private static final int FLAG_HAS_DIRECTIONS = 1 << 6;
47 private static final int FLAG_TAGGED = 1 << 7;
48
49 /**
50 * Replies the sub-collection of {@see OsmPrimitive}s of type <code>type</code> present in
51 * another collection of {@see OsmPrimitive}s. The result collection is a list.
52 *
53 * If <code>list</code> is null, replies an empty list.
54 *
55 * @param <T>
56 * @param list the original list
57 * @param type the type to filter for
58 * @return the sub-list of OSM primitives of type <code>type</code>
59 */
60 static public <T extends OsmPrimitive> List<T> getFilteredList(Collection<OsmPrimitive> list, Class<T> type) {
61 if (list == null) return Collections.emptyList();
62 List<T> ret = new LinkedList<T>();
63 for(OsmPrimitive p: list) {
64 if (type.isInstance(p)) {
65 ret.add(type.cast(p));
66 }
67 }
68 return ret;
69 }
70
71 /**
72 * Replies the sub-collection of {@see OsmPrimitive}s of type <code>type</code> present in
73 * another collection of {@see OsmPrimitive}s. The result collection is a set.
74 *
75 * If <code>list</code> is null, replies an empty set.
76 *
77 * @param <T>
78 * @param list the original collection
79 * @param type the type to filter for
80 * @return the sub-set of OSM primitives of type <code>type</code>
81 */
82 static public <T extends OsmPrimitive> Set<T> getFilteredSet(Collection<OsmPrimitive> set, Class<T> type) {
83 if (set == null) return Collections.emptySet();
84 HashSet<T> ret = new HashSet<T>();
85 for(OsmPrimitive p: set) {
86 if (type.isInstance(p)) {
87 ret.add(type.cast(p));
88 }
89 }
90 return ret;
91 }
92
93
94 /* mappaint data */
95 public ElemStyle mappaintStyle = null;
96 public Integer mappaintVisibleCode = 0;
97 public Integer mappaintDrawnCode = 0;
98 public Collection<String> errors;
99
100 public void putError(String text, Boolean isError)
101 {
102 if(errors == null) {
103 errors = new ArrayList<String>();
104 }
105 String s = isError ? tr("Error: {0}", text) : tr("Warning: {0}", text);
106 errors.add(s);
107 }
108 public void clearErrors()
109 {
110 errors = null;
111 }
112 /* This should not be called from outside. Fixing the UI to add relevant
113 get/set functions calling this implicitely is preferred, so we can have
114 transparent cache handling in the future. */
115 protected void clearCached()
116 {
117 mappaintVisibleCode = 0;
118 mappaintDrawnCode = 0;
119 mappaintStyle = null;
120 }
121 /* end of mappaint data */
122
123 /**
124 * Unique identifier in OSM. This is used to identify objects on the server.
125 * An id of 0 means an unknown id. The object has not been uploaded yet to
126 * know what id it will get.
127 *
128 */
129 private long id = 0;
130
131 private volatile byte flags = FLAG_VISIBLE; // visible per default
132
133 /**
134 * User that last modified this primitive, as specified by the server.
135 * Never changed by JOSM.
136 */
137 public User user = null;
138
139 /**
140 * If set to true, this object is incomplete, which means only the id
141 * and type is known (type is the objects instance class)
142 */
143 public boolean incomplete = false;
144
145 /**
146 * Contains the version number as returned by the API. Needed to
147 * ensure update consistency
148 */
149 private int version = 0;
150
151 /**
152 * Creates a new primitive for the given id. If the id > 0, the primitive is marked
153 * as incomplete.
154 *
155 * @param id the id. > 0 required
156 * @param allowNegativeId Allows to set negative id. For internal use
157 * @throws IllegalArgumentException thrown if id < 0 and allowNegativeId is false
158 */
159 protected OsmPrimitive(long id, boolean allowNegativeId) throws IllegalArgumentException {
160 if (allowNegativeId) {
161 this.id = id;
162 } else {
163 if (id < 0) {
164 throw new IllegalArgumentException(tr("Expected ID >= 0. Got {0}.", id));
165 } else if (id == 0) {
166 this.id = idCounter.decrementAndGet();
167 } else {
168 this.id = id;
169 }
170
171 }
172 this.version = 0;
173 this.incomplete = id > 0;
174 }
175
176 protected OsmPrimitive(PrimitiveData data) {
177 version = data.getVersion();
178 id = data.getId();
179 }
180
181 /* ------------------------------------------------------------------------------------ */
182 /* accessors */
183 /* ------------------------------------------------------------------------------------ */
184 /**
185 * Sets whether this primitive is disabled or not.
186 *
187 * @param selected true, if this primitive is disabled; false, otherwise
188 */
189 public void setDisabled(boolean disabled) {
190 if (disabled) {
191 flags |= FLAG_DISABLED;
192 } else {
193 flags &= ~FLAG_DISABLED;
194 }
195
196 }
197
198 /**
199 * Replies true, if this primitive is disabled.
200 *
201 * @return true, if this primitive is disabled
202 */
203 public boolean isDisabled() {
204 return (flags & FLAG_DISABLED) != 0;
205 }
206 /**
207 * Sets whether this primitive is filtered out or not.
208 *
209 * @param selected true, if this primitive is filtered out; false, otherwise
210 */
211 public void setFiltered(boolean filtered) {
212 if (filtered) {
213 flags |= FLAG_FILTERED;
214 } else {
215 flags &= ~FLAG_FILTERED;
216 }
217 }
218 /**
219 * Replies true, if this primitive is filtered out.
220 *
221 * @return true, if this primitive is filtered out
222 */
223 public boolean isFiltered() {
224 return (flags & FLAG_FILTERED) != 0;
225 }
226
227 /**
228 * Sets whether this primitive is selected or not.
229 *
230 * @param selected true, if this primitive is selected; false, otherwise
231 * @since 1899
232 */
233 @Deprecated public void setSelected(boolean selected) {
234 if (selected) {
235 flags |= FLAG_SELECTED;
236 } else {
237 flags &= ~FLAG_SELECTED;
238 }
239 }
240 /**
241 * Replies true, if this primitive is selected.
242 *
243 * @return true, if this primitive is selected
244 * @since 1899
245 */
246 @Deprecated public boolean isSelected() {
247 return (flags & FLAG_SELECTED) != 0;
248 }
249
250 /**
251 * Marks this primitive as being modified.
252 *
253 * @param modified true, if this primitive is to be modified
254 */
255 public void setModified(boolean modified) {
256 if (modified) {
257 flags |= FLAG_MODIFIED;
258 } else {
259 flags &= ~FLAG_MODIFIED;
260 }
261 }
262
263 /**
264 * Replies <code>true</code> if the object has been modified since it was loaded from
265 * the server. In this case, on next upload, this object will be updated.
266 *
267 * Deleted objects are deleted from the server. If the objects are added (id=0),
268 * the modified is ignored and the object is added to the server.
269 *
270 * @return <code>true</code> if the object has been modified since it was loaded from
271 * the server
272 */
273 public boolean isModified() {
274 return (flags & FLAG_MODIFIED) != 0;
275 }
276
277 /**
278 * Replies <code>true</code>, if the object has been deleted.
279 *
280 * @return <code>true</code>, if the object has been deleted.
281 * @see #setDeleted(boolean)
282 */
283 public boolean isDeleted() {
284 return (flags & FLAG_DELETED) != 0;
285 }
286
287 /**
288 * Replies <code>true</code>, if the object is usable.
289 *
290 * @return <code>true</code>, if the object is unusable.
291 * @see #delete(boolean)
292 */
293 public boolean isUsable() {
294 return !isDeleted() && !incomplete && !isDisabled();
295 }
296
297 /**
298 * Replies true if this primitive is either unknown to the server (i.e. its id
299 * is 0) or it is known to the server and it hasn't be deleted on the server.
300 * Replies false, if this primitive is known on the server and has been deleted
301 * on the server.
302 *
303 * @see #setVisible(boolean)
304 */
305 public boolean isVisible() {
306 return (flags & FLAG_VISIBLE) != 0;
307 }
308
309 /**
310 * Sets whether this primitive is visible, i.e. whether it is known on the server
311 * and not deleted on the server.
312 *
313 * @see #isVisible()
314 * @throws IllegalStateException thrown if visible is set to false on an primitive with
315 * id==0
316 */
317 public void setVisible(boolean visible) throws IllegalStateException{
318 if (isNew() && visible == false)
319 throw new IllegalStateException(tr("A primitive with ID = 0 can't be invisible."));
320 if (visible) {
321 flags |= FLAG_VISIBLE;
322 } else {
323 flags &= ~FLAG_VISIBLE;
324 }
325 }
326
327 /**
328 * Replies the version number as returned by the API. The version is 0 if the id is 0 or
329 * if this primitive is incomplete.
330 *
331 * @see #setVersion(int)
332 */
333 public long getVersion() {
334 return version;
335 }
336
337 /**
338 * Replies the id of this primitive.
339 *
340 * @return the id of this primitive.
341 */
342 public long getId() {
343 return id >= 0?id:0;
344 }
345
346 /**
347 *
348 * @return Osm id if primitive already exists on the server. Unique negative value if primitive is new
349 */
350 public long getUniqueId() {
351 return id;
352 }
353
354 /**
355 *
356 * @return True if primitive is new (not yet uploaded the server, id <= 0)
357 */
358 public boolean isNew() {
359 return id <= 0;
360 }
361
362 /**
363 * Sets the id and the version of this primitive if it is known to the OSM API.
364 *
365 * Since we know the id and its version it can't be incomplete anymore. incomplete
366 * is set to false.
367 *
368 * @param id the id. > 0 required
369 * @param version the version > 0 required
370 * @throws IllegalArgumentException thrown if id <= 0
371 * @throws IllegalArgumentException thrown if version <= 0
372 */
373 public void setOsmId(long id, int version) {
374 if (id <= 0)
375 throw new IllegalArgumentException(tr("ID > 0 expected. Got {0}.", id));
376 if (version <= 0)
377 throw new IllegalArgumentException(tr("Version > 0 expected. Got {0}.", version));
378 this.id = id;
379 this.version = version;
380 this.incomplete = false;
381 }
382
383 /**
384 * Clears the id and version known to the OSM API. The id and the version is set to 0.
385 * incomplete is set to false.
386 *
387 * <strong>Caution</strong>: Do not use this method on primitives which are already added to a {@see DataSet}.
388 * Ways and relations might already refer to the primitive and clearing the OSM ID
389 * result in corrupt data.
390 *
391 * Here's an example use case:
392 * <pre>
393 * // create a clone of an already existing node
394 * Node copy = new Node(otherExistingNode);
395 *
396 * // reset the clones OSM id
397 * copy.clearOsmId();
398 * </pre>
399 *
400 */
401 public void clearOsmId() {
402 this.id = 0;
403 this.version = 0;
404 this.incomplete = false;
405 }
406
407 public void setTimestamp(Date timestamp) {
408 this.timestamp = (int)(timestamp.getTime() / 1000);
409 }
410
411 /**
412 * Time of last modification to this object. This is not set by JOSM but
413 * read from the server and delivered back to the server unmodified. It is
414 * used to check against edit conflicts.
415 *
416 */
417 public Date getTimestamp() {
418 return new Date(timestamp * 1000l);
419 }
420
421 public boolean isTimestampEmpty() {
422 return timestamp == 0;
423 }
424
425 /**
426 * If set to true, this object is highlighted. Currently this is only used to
427 * show which ways/nodes will connect
428 */
429 public volatile boolean highlighted = false;
430
431 private int timestamp;
432
433 private static Collection<String> uninteresting = null;
434 /**
435 * Contains a list of "uninteresting" keys that do not make an object
436 * "tagged".
437 * Initialized by checkTagged()
438 */
439 public static Collection<String> getUninterestingKeys() {
440 if (uninteresting == null) {
441 uninteresting = Main.pref.getCollection("tags.uninteresting",
442 Arrays.asList(new String[]{"source","note","comment","converted_by","created_by"}));
443 }
444 return uninteresting;
445 }
446
447
448 private static Collection<String> directionKeys = null;
449
450 /**
451 * Contains a list of direction-dependent keys that make an object
452 * direction dependent.
453 * Initialized by checkDirectionTagged()
454 */
455 public static Collection<String> getDirectionKeys() {
456 if(directionKeys == null) {
457 directionKeys = Main.pref.getCollection("tags.direction",
458 Arrays.asList(new String[]{"oneway","incline","incline_steep","aerialway"}));
459 }
460 return directionKeys;
461 }
462
463 /**
464 * Implementation of the visitor scheme. Subclasses have to call the correct
465 * visitor function.
466 * @param visitor The visitor from which the visit() function must be called.
467 */
468 abstract public void visit(Visitor visitor);
469
470 /**
471 * Sets whether this primitive is deleted or not.
472 *
473 * Also marks this primitive as modified if deleted is true and sets selected to false.
474 *
475 * @param deleted true, if this primitive is deleted; false, otherwise
476 */
477 public void setDeleted(boolean deleted) {
478 if (deleted) {
479 flags |= FLAG_DELETED;
480 } else {
481 flags &= ~FLAG_DELETED;
482 }
483 setModified(deleted);
484 setSelected(false);
485 }
486
487 /**
488 * Equal, if the id (and class) is equal.
489 *
490 * An primitive is equal to its incomplete counter part.
491 */
492 @Override public boolean equals(Object obj) {
493 if (isNew()) return obj == this;
494 if (obj instanceof OsmPrimitive)
495 return ((OsmPrimitive)obj).id == id && obj.getClass() == getClass();
496 return false;
497 }
498
499 /**
500 * Return the id plus the class type encoded as hashcode or super's hashcode if id is 0.
501 *
502 * An primitive has the same hashcode as its incomplete counterpart.
503 */
504 @Override public final int hashCode() {
505 if (id == 0)
506 return super.hashCode();
507 final int[] ret = new int[1];
508 Visitor v = new Visitor(){
509 public void visit(Node n) { ret[0] = 0; }
510 public void visit(Way w) { ret[0] = 1; }
511 public void visit(Relation e) { ret[0] = 2; }
512 public void visit(Changeset cs) { ret[0] = 3; }
513 };
514 visit(v);
515 return id == 0 ? super.hashCode() : (int)(id<<2)+ret[0];
516 }
517
518 /*------------
519 * Keys handling
520 ------------*/
521
522 /**
523 * The key/value list for this primitive.
524 *
525 */
526 private Map<String, String> keys;
527
528 /**
529 * Replies the map of key/value pairs. Never replies null. The map can be empty, though.
530 *
531 * @return Keys of this primitive. Changes made in returned map are not mapped
532 * back to the primitive, use setKeys() to modify the keys
533 * @since 1924
534 */
535 public Map<String, String> getKeys() {
536 // TODO More effective map
537 // fix for #3218
538 if (keys == null)
539 return new HashMap<String, String>();
540 else
541 return new HashMap<String, String>(keys);
542 }
543
544 /**
545 * Sets the keys of this primitives to the key/value pairs in <code>keys</code>.
546 * If <code>keys</code> is null removes all existing key/value pairs.
547 *
548 * @param keys the key/value pairs to set. If null, removes all existing key/value pairs.
549 * @since 1924
550 */
551 public void setKeys(Map<String, String> keys) {
552 if (keys == null) {
553 this.keys = null;
554 } else {
555 this.keys = new HashMap<String, String>(keys);
556 }
557 keysChangedImpl();
558 }
559
560 /**
561 * Set the given value to the given key. If key is null, does nothing. If value is null,
562 * removes the key and behaves like {@see #remove(String)}.
563 *
564 * @param key The key, for which the value is to be set. Can be null, does nothing in this case.
565 * @param value The value for the key. If null, removes the respective key/value pair.
566 *
567 * @see #remove(String)
568 */
569 public final void put(String key, String value) {
570 if (key == null)
571 return;
572 else if (value == null) {
573 remove(key);
574 } else {
575 if (keys == null) {
576 keys = new HashMap<String, String>();
577 }
578 keys.put(key, value);
579 }
580 mappaintStyle = null;
581 keysChangedImpl();
582 }
583 /**
584 * Remove the given key from the list
585 *
586 * @param key the key to be removed. Ignored, if key is null.
587 */
588 public final void remove(String key) {
589 if (keys != null) {
590 keys.remove(key);
591 if (keys.isEmpty()) {
592 keys = null;
593 }
594 }
595 mappaintStyle = null;
596 keysChangedImpl();
597 }
598
599 /**
600 * Removes all keys from this primitive.
601 *
602 * @since 1843
603 */
604 public final void removeAll() {
605 keys = null;
606 mappaintStyle = null;
607 keysChangedImpl();
608 }
609
610 /**
611 * Replies the value for key <code>key</code>. Replies null, if <code>key</code> is null.
612 * Replies null, if there is no value for the given key.
613 *
614 * @param key the key. Can be null, replies null in this case.
615 * @return the value for key <code>key</code>.
616 */
617 public final String get(String key) {
618 if (key == null) return null;
619 return keys == null ? null : keys.get(key);
620 }
621
622 public final Collection<Entry<String, String>> entrySet() {
623 if (keys == null)
624 return Collections.emptyList();
625 return keys.entrySet();
626 }
627
628 public final Collection<String> keySet() {
629 if (keys == null)
630 return Collections.emptyList();
631 return keys.keySet();
632 }
633
634 /**
635 * Replies true, if the map of key/value pairs of this primitive is not empty.
636 *
637 * @return true, if the map of key/value pairs of this primitive is not empty; false
638 * otherwise
639 *
640 * @since 1843
641 */
642 public final boolean hasKeys() {
643 return keys != null && !keys.isEmpty();
644 }
645
646 private void keysChangedImpl() {
647 updateHasDirectionKeys();
648 updateTagged();
649 }
650
651 /**
652 * Get and write all attributes from the parameter. Does not fire any listener, so
653 * use this only in the data initializing phase
654 */
655 public void cloneFrom(OsmPrimitive osm) {
656 keys = osm.keys == null ? null : new HashMap<String, String>(osm.keys);
657 id = osm.id;
658 timestamp = osm.timestamp;
659 version = osm.version;
660 incomplete = osm.incomplete;
661 flags = osm.flags;
662 user= osm.user;
663 clearCached();
664 clearErrors();
665 }
666
667 /**
668 * Replies true if this primitive and other are equal with respect to their
669 * semantic attributes.
670 * <ol>
671 * <li>equal id</ol>
672 * <li>both are complete or both are incomplete</li>
673 * <li>both have the same tags</li>
674 * </ol>
675 * @param other
676 * @return true if this primitive and other are equal with respect to their
677 * semantic attributes.
678 */
679 public boolean hasEqualSemanticAttributes(OsmPrimitive other) {
680 if (!isNew() && id != other.id)
681 return false;
682 if (incomplete && ! other.incomplete || !incomplete && other.incomplete)
683 return false;
684 return (keys == null ? other.keys==null : keys.equals(other.keys));
685 }
686
687 /**
688 * Replies true if this primitive and other are equal with respect to their
689 * technical attributes. The attributes:
690 * <ol>
691 * <li>deleted</ol>
692 * <li>modified</ol>
693 * <li>timestamp</ol>
694 * <li>version</ol>
695 * <li>visible</ol>
696 * <li>user</ol>
697 * </ol>
698 * have to be equal
699 * @param other the other primitive
700 * @return true if this primitive and other are equal with respect to their
701 * technical attributes
702 */
703 public boolean hasEqualTechnicalAttributes(OsmPrimitive other) {
704 if (other == null) return false;
705
706 return
707 isDeleted() == other.isDeleted()
708 && isModified() == other.isModified()
709 && timestamp == other.timestamp
710 && version == other.version
711 && isVisible() == other.isVisible()
712 && (user == null ? other.user==null : user==other.user);
713 }
714
715 private void updateTagged() {
716 getUninterestingKeys();
717 if (keys != null) {
718 for (Entry<String,String> e : keys.entrySet()) {
719 if (!uninteresting.contains(e.getKey())) {
720 flags |= FLAG_TAGGED;
721 return;
722 }
723 }
724 }
725 flags &= ~FLAG_TAGGED;
726 }
727
728 /**
729 * true if this object is considered "tagged". To be "tagged", an object
730 * must have one or more "interesting" tags. "created_by" and "source"
731 * are typically considered "uninteresting" and do not make an object
732 * "tagged".
733 */
734 public boolean isTagged() {
735 return (flags & FLAG_TAGGED) != 0;
736 }
737
738 private void updateHasDirectionKeys() {
739 getDirectionKeys();
740 if (keys != null) {
741 for (Entry<String,String> e : keys.entrySet()) {
742 if (directionKeys.contains(e.getKey())) {
743 flags |= FLAG_HAS_DIRECTIONS;
744 return;
745 }
746 }
747 }
748 flags &= ~FLAG_HAS_DIRECTIONS;
749 }
750 /**
751 * true if this object has direction dependent tags (e.g. oneway)
752 */
753 public boolean hasDirectionKeys() {
754 return (flags & FLAG_HAS_DIRECTIONS) != 0;
755 }
756
757
758 /**
759 * Replies the name of this primitive. The default implementation replies the value
760 * of the tag <tt>name</tt> or null, if this tag is not present.
761 *
762 * @return the name of this primitive
763 */
764 public String getName() {
765 if (get("name") != null)
766 return get("name");
767 return null;
768 }
769
770 /**
771 * Replies the a localized name for this primitive given by the value of the tags (in this order)
772 * <ul>
773 * <li>name:lang_COUNTRY_Variant of the current locale</li>
774 * <li>name:lang_COUNTRY of the current locale</li>
775 * <li>name:lang of the current locale</li>
776 * <li>name of the current locale</li>
777 * </ul>
778 *
779 * null, if no such tag exists
780 *
781 * @return the name of this primitive
782 */
783 public String getLocalName() {
784 String key = "name:" + Locale.getDefault().toString();
785 if (get(key) != null)
786 return get(key);
787 key = "name:" + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
788 if (get(key) != null)
789 return get(key);
790 key = "name:" + Locale.getDefault().getLanguage();
791 if (get(key) != null)
792 return get(key);
793 return getName();
794 }
795
796 /**
797 * Replies the display name of a primitive formatted by <code>formatter</code>
798 *
799 * @return the display name
800 */
801 public abstract String getDisplayName(NameFormatter formatter);
802
803 /**
804 * Loads (clone) this primitive from provided PrimitiveData
805 * @param data
806 * @param dataSet Dataset this primitive is part of. This parameter is used only
807 * temporarily. OsmPrimitive will have final field dataset in future
808 */
809 public void load(PrimitiveData data, DataSet dataSet) {
810 setKeys(data.getKeys());
811 timestamp = data.getTimestamp();
812 user = data.getUser();
813 setDeleted(data.isDeleted());
814 setModified(data.isModified());
815 setVisible(data.isVisible());
816 }
817
818 /**
819 * Save parameters of this primitive to the transport object
820 * @return
821 */
822 public abstract PrimitiveData save();
823
824 protected void saveCommonAttributes(PrimitiveData data) {
825 data.getKeys().clear();
826 data.getKeys().putAll(getKeys());
827 data.setTimestamp(timestamp);
828 data.setUser(user);
829 data.setDeleted(isDeleted());
830 data.setModified(isModified());
831 data.setVisible(isVisible());
832 }
833
834}
835
Note: See TracBrowser for help on using the repository browser.