comparison src/uk/ac/qmul/eecs/ccmi/xmlparser/Node.java @ 0:e0ee6ac3a45f

first import
author Fiore Martin <fiore@eecs.qmul.ac.uk>
date Thu, 13 Dec 2012 20:00:21 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e0ee6ac3a45f
1 /*
2 CCmI Diagram Editor for Android
3
4 Copyright (C) 2012 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package uk.ac.qmul.eecs.ccmi.xmlparser;
20
21 import java.util.ArrayList;
22
23 import org.simpleframework.xml.Attribute;
24 import org.simpleframework.xml.ElementList;
25 import org.simpleframework.xml.Root;
26
27 @Root(name="Node",strict=false)
28 public class Node implements HierarchyItem {
29 private static int idCounter = 0;
30
31 @Attribute(name="Name")
32 private String name;
33 @Attribute(name="Type")
34 private String type;
35 @Attribute(name="id")
36 private int id;
37
38 public Node(){
39 id = ++idCounter;
40 name = "New Node "+id;
41 }
42
43 public Node(String type, ArrayList<NodeProperty> properties){
44 this();
45 this.type = type;
46 name = "New "+type+" "+id;
47 this.properties = properties;
48 }
49
50 @ElementList(name="Properties",required=false)
51 private ArrayList<NodeProperty> properties = new ArrayList<NodeProperty>();
52
53 public String getName() {
54 return name;
55 }
56
57 public void setName(String name) {
58 this.name = name;
59 }
60
61 public String getType() {
62 return type;
63 }
64
65 public int getId() {
66 return id;
67 }
68
69 public void setId(int id) {
70 /* catch up with the highest value entered */
71 if(id > idCounter){
72 idCounter = id;
73 }
74 this.id = id;
75 }
76
77 public ArrayList<NodeProperty> getProperties() {
78 return properties;
79 }
80
81 public void setProperties(ArrayList<NodeProperty> properties) {
82 this.properties = properties;
83 }
84
85 @Override
86 public String toString(){
87 return name;
88 }
89 }