001: /*
002: * This file is part of Thingamablog. ( http://thingamablog.sf.net )
003: *
004: * Copyright (c) 2004, Bob Tantlinger All Rights Reserved.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
019: * USA.
020: */
021:
022: package net.sf.thingamablog.blog;
023:
024: import java.text.Collator;
025:
026: /**
027: *
028: * Class which defines a weblog author
029: *
030: * @author Bob Tantlinger
031: *
032: *
033: */
034: public class Author implements Comparable {
035: private static Collator col = Collator.getInstance();
036:
037: private String name = "";
038: private String email = "";
039: private String url = "";
040:
041: /**
042: * Sets all the fields of an author at once
043: * @param str A String describing an author in the form of
044: * name/temail/turl with each field seperated by a tab
045: */
046: public void setString(String str) {
047: int n1 = str.indexOf("\t");
048: if (n1 < 0) {
049: name = str;
050: return;
051: }
052: int n2 = str.indexOf("\t", n1 + 1);
053: if (n2 < 0)
054: return;
055:
056: name = str.substring(0, n1).trim();
057: email = str.substring(n1, n2).trim();
058: url = str.substring(n2, str.length()).trim();
059: }
060:
061: /**
062: * Sets the name of the author
063: * @param n
064: */
065: public void setName(String n) {
066: name = n;
067: }
068:
069: /**
070: * Gets the name of the author
071: * @return
072: */
073: public String getName() {
074: return name;
075: }
076:
077: /**
078: * Sets the email address of the author
079: * @param n
080: */
081: public void setEmailAddress(String n) {
082: email = n;
083: }
084:
085: /**
086: * Gets the email address of the author
087: * @return
088: */
089: public String getEmailAddress() {
090: return email;
091: }
092:
093: /**
094: * Sets the author's url
095: * @param n
096: */
097: public void setUrl(String n) {
098: url = n;
099: }
100:
101: /**
102: * Gets the authors url
103: * @return
104: */
105: public String getUrl() {
106: return url;
107: }
108:
109: /**
110: * Gets the string representation of all the fields
111: * of this author, seperated by tabs
112: * @return
113: */
114: public String getString() {
115: return name + '\t' + email + '\t' + url;
116: }
117:
118: /**
119: * Synonomous with getName()
120: */
121: public String toString() {
122: return name;
123: }
124:
125: public int compareTo(Object o) {
126: String s1 = toString().toLowerCase();
127: String s2 = o.toString().toLowerCase();
128: return col.compare(s1, s2);
129: }
130: }
|