1 package org.cacert.gigi.dbObjects;
3 import java.io.PrintWriter;
6 import org.cacert.gigi.localisation.Language;
7 import org.cacert.gigi.output.template.Outputable;
8 import org.cacert.gigi.util.HTMLEncoder;
10 public class Name implements Outputable {
12 private final String fname;
14 private final String mname;
16 private final String lname;
18 private final String suffix;
20 public Name(String fname, String lname, String mname, String suffix) {
28 public void output(PrintWriter out, Language l, Map<String, Object> vars) {
29 out.println("<span class=\"accountdetail\">");
30 out.print("<span class=\"fname\">");
31 out.print(HTMLEncoder.encodeHTML(fname));
32 out.print("</span> ");
33 out.print("<span class=\"lname\">");
34 out.print(HTMLEncoder.encodeHTML(lname));
36 out.println("</span>");
40 public String toString() {
41 return fname + " " + lname;
45 public int hashCode() {
48 result = prime * result + ((fname == null) ? 0 : fname.hashCode());
49 result = prime * result + ((lname == null) ? 0 : lname.hashCode());
50 result = prime * result + ((mname == null) ? 0 : mname.hashCode());
51 result = prime * result + ((suffix == null) ? 0 : suffix.hashCode());
56 public boolean equals(Object obj) {
63 if (getClass() != obj.getClass()) {
66 Name other = (Name) obj;
68 if (other.fname != null) {
71 } else if ( !fname.equals(other.fname)) {
75 if (other.lname != null) {
78 } else if ( !lname.equals(other.lname)) {
82 if (other.mname != null) {
85 } else if ( !mname.equals(other.mname)) {
89 if (other.suffix != null) {
92 } else if ( !suffix.equals(other.suffix)) {
98 public boolean matches(String text) {
99 return text.equals(fname + " " + lname) || //
100 (mname != null && text.equals(fname + " " + mname + " " + lname)) || //
101 (suffix != null && text.equals(fname + " " + lname + " " + suffix)) || //
102 (mname != null && suffix != null && text.equals(fname + " " + mname + " " + lname + " " + suffix));
105 public String getFname() {
109 public String getLname() {
113 public String getMname() {
117 public String getSuffix() {