source: josm/trunk/src/org/openstreetmap/josm/data/osm/DatasetFactory.java @ 5241

Revision 5170, 1.4 KB checked in by Don-vip, 6 weeks ago (diff)

cleanup svn:mime-type properties preventing Java sources from being viewed as such on Trac

  • Property svn:eol-style set to native
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4/**
5 * Convenience class allowing to manage primitives in the dataset. Useful especially for tests
6 *
7 */
8public class DatasetFactory {
9
10    private final DataSet ds;
11
12    public DatasetFactory() {
13        ds = new DataSet();
14    }
15
16    public DatasetFactory(DataSet ds) {
17        this.ds = ds;
18    }
19
20    public Node getNode(long id) {
21        return (Node) ds.getPrimitiveById(id, OsmPrimitiveType.NODE);
22    }
23
24    public Way getWay(long id) {
25        return (Way) ds.getPrimitiveById(id, OsmPrimitiveType.WAY);
26    }
27
28    public Relation getRelation(long id) {
29        return (Relation) ds.getPrimitiveById(id, OsmPrimitiveType.RELATION);
30    }
31
32    public Node addNode(long id) {
33        return addNode(id, 0);
34    }
35
36    public Way addWay(long id) {
37        return addWay(id, 0);
38    }
39
40    public Relation addRelation(long id) {
41        return addRelation(id, 0);
42    }
43
44    public Node addNode(long id, int version) {
45        Node n = new Node(id, version);
46        ds.addPrimitive(n);
47        return n;
48    }
49
50    public Way addWay(long id, int version) {
51        Way w = new Way(id, version);
52        ds.addPrimitive(w);
53        return w;
54    }
55
56    public Relation addRelation(long id, int version) {
57        Relation e = new Relation(id, version);
58        ds.addPrimitive(e);
59        return e;
60    }
61
62}
Note: See TracBrowser for help on using the repository browser.