View Javadoc

1   /**********************************************
2    * Copyright (C) 2009 Lukas Laag
3    * This file is part of Vectomatic.
4    * 
5    * Vectomatic is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * 
10   * Vectomatic is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License
16   * along with Vectomatic.  If not, see http://www.gnu.org/licenses/
17   **********************************************/
18  package org.vectomatic.common.rpc;
19  
20  import java.util.Date;
21  
22  import com.google.gwt.user.client.rpc.IsSerializable;
23  
24  public class Drawing implements IsSerializable {
25  	public static final String ID_ATTRIBUTE = "id";
26  	public static final String IDS_ATTRIBUTE = "ids";
27  	public static final String FORMAT_ATTRIBUTE = "format";
28  	private String _id;						// ID
29  	private String _name;					// NAME
30  	private boolean _published;				// PUBLISHED
31  	private Date _modificationDate;
32  	
33  	///////////////////////////////////////
34  	// Constructors
35  	///////////////////////////////////////
36  	
37  	public Drawing() {
38  	}
39  	
40  	public Drawing(String id, String name, boolean published, Date modificationDate) {
41  		_id = id;
42  		_name = name;
43  		_published = published;
44  		_modificationDate = modificationDate;
45  	}
46  
47  	///////////////////////////////////////
48  	// Identity
49  	///////////////////////////////////////
50  
51  	@Override
52  	public boolean equals(Object obj)  {
53  		if (obj instanceof Drawing) {
54  			// id is assigned so it can be used for identity
55  			return _id.equals(((Drawing)obj)._id);
56  		}
57  		return false;
58  	}
59  	
60  	@Override
61  	public int hashCode() {
62  		return _id.hashCode();
63  	}
64  	
65  
66  	///////////////////////////////////////
67  	// Persistent Properties
68  	///////////////////////////////////////
69  
70  	public void setId(String id) {
71  		_id = id;
72  	}
73  	public String getId() {
74  		return _id;
75  	}
76  	public void setName(String name) {
77  		_name = name;
78  	}
79  	public String getName() {
80  		return _name;
81  	}
82  	public void setPublished(boolean published) {
83  		_published = published;
84  	}
85  	public boolean isPublished() {
86  		return _published;
87  	}
88  
89  	///////////////////////////////////////
90  	// Non Persistent Properties
91  	///////////////////////////////////////
92  	
93  	public void setModificationDate(Date modificationDate) {
94  		_modificationDate = modificationDate;
95  	}
96  	public Date getModificationDate() {
97  		return _modificationDate;
98  	}
99  
100 	///////////////////////////////////////
101 	// Debugging
102 	///////////////////////////////////////
103 
104 	@Override
105 	public String toString() {
106 		StringBuffer buffer = new StringBuffer("Drawing {id = ");
107 		buffer.append(_id);
108 		buffer.append("; name = ");
109 		buffer.append(_name);
110 		buffer.append("; published = ");
111 		buffer.append(_published);
112 		buffer.append(" }");
113 		return buffer.toString();
114 	}
115 
116 }