d076ae96 |
1 | /* |
2 | * To change this template, choose Tools | Templates |
3 | * and open the template in the editor. |
4 | */ |
5 | package org.ufcspa.simdecs.diagram.elements; |
6 | |
7 | import java.io.Serializable; |
8 | import java.util.Date; |
9 | import java.util.Locale; |
10 | import org.ufcspa.simdecs.diagram.util.MessageResourceUtils; |
11 | |
12 | /** |
13 | * |
14 | * @author Maroni |
15 | */ |
16 | public abstract class Element implements Serializable { |
17 | |
18 | protected String id; |
19 | protected String messageBundle; |
20 | protected Locale locale; |
21 | |
22 | @Override |
23 | public boolean equals(Object obj) { |
24 | if (obj == null) { |
25 | return false; |
26 | } |
27 | if (getClass() != obj.getClass()) { |
28 | return false; |
29 | } |
30 | final Element other = (Element) obj; |
31 | if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) { |
32 | return false; |
33 | } |
34 | return true; |
35 | } |
36 | |
37 | @Override |
38 | public int hashCode() { |
39 | int hash = 7; |
40 | hash = 29 * hash + (this.id != null ? this.id.hashCode() : 0); |
41 | return hash; |
42 | } |
43 | |
44 | public Element(String messageBundle, Locale locale) { |
45 | this.id = this.getClass().getSimpleName() + "-" + String.valueOf((new Date()).getTime()); |
46 | this.locale = locale; |
47 | this.messageBundle = messageBundle; |
48 | } |
49 | |
50 | public String getMessageBundle() { |
51 | return messageBundle; |
52 | } |
53 | |
54 | public void setMessageBundle(String messageBundle) { |
55 | this.messageBundle = messageBundle; |
56 | } |
57 | |
58 | public Locale getLocale() { |
59 | return locale; |
60 | } |
61 | |
62 | public void setLocale(Locale locale) { |
63 | this.locale = locale; |
64 | } |
65 | |
66 | protected String getResourceMessage(String key, Object params[]) { |
67 | return MessageResourceUtils.getMessageResourceString(messageBundle, key, params, locale); |
68 | } |
69 | |
70 | protected String getResourceMessage(String key) { |
71 | return getResourceMessage(key, null); |
72 | } |
73 | |
74 | public String getId() { |
75 | return id; |
76 | } |
77 | |
78 | public void setId(String id) { |
79 | this.id = id; |
80 | } |
81 | |
82 | } |