001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: TelecomAddressConstants.java,v $
031: * Revision 1.4 2005/10/11 18:53:07 colinmacleod
032: * Fixed some checkstyle and javadoc issues.
033: *
034: * Revision 1.3 2005/10/02 14:08:55 colinmacleod
035: * Added/improved log4j logging.
036: *
037: * Revision 1.2 2005/04/09 17:19:09 colinmacleod
038: * Changed copyright text to GPL v2 explicitly.
039: *
040: * Revision 1.1.1.1 2005/03/10 17:50:19 colinmacleod
041: * Restructured ivata op around Hibernate/PicoContainer.
042: * Renamed ivata groupware.
043: *
044: * Revision 1.4 2004/07/13 19:41:14 colinmacleod
045: * Moved project to POJOs from EJBs.
046: * Applied PicoContainer to services layer (replacing session EJBs).
047: * Applied Hibernate to persistence layer (replacing entity EJBs).
048: *
049: * Revision 1.3 2004/03/21 21:16:08 colinmacleod
050: * Shortened name to ivata op.
051: *
052: * Revision 1.2 2004/02/01 22:00:33 colinmacleod
053: * Added full names to author tags
054: *
055: * Revision 1.1.1.1 2004/01/27 20:57:54 colinmacleod
056: * Moved ivata openportal to SourceForge..
057: *
058: * Revision 1.3 2003/10/17 12:36:12 jano
059: * fixing problems with building
060: * converting intranet -> portal
061: * Eclipse building
062: *
063: * Revision 1.2 2003/10/15 13:18:02 colin
064: * fixing for XDoclet
065: *
066: * Revision 1.1 2003/02/24 19:09:21 colin
067: * moved to business
068: *
069: * Revision 1.3 2003/02/04 17:43:45 colin
070: * copyright notice
071: *
072: * Revision 1.2 2002/06/28 13:15:23 colin
073: * first addressbook release
074: *
075: * Revision 1.1 2002/06/17 07:28:30 colin
076: * improved and extended javadoc documentation
077: * -----------------------------------------------------------------------------
078: */
079: package com.ivata.groupware.business.addressbook.telecomaddress;
080:
081: import org.apache.log4j.Logger;
082:
083: /**
084: * <p>
085: * Contains all constants and constant conversion in use for telecom addresses.
086: * Use these constats to get the clear text name of the telecom address type, or
087: * to find the correct type to store in the EJB.</p>
088: *
089: * @since 2002-05-14
090: * @author Colin MacLeod
091: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
092: * @version $Revision: 1.4 $
093: */
094: public final class TelecomAddressConstants {
095: /**
096: * Logger for this class.
097: */
098: private static final Logger logger = Logger
099: .getLogger(TelecomAddressConstants.class);
100:
101: /**
102: * <p>Represents an email address.</p>
103: */
104: public static final int TYPE_EMAIL = 4;
105:
106: /**
107: * <p>Represents a fax telephone number.</p>
108: */
109: public static final int TYPE_FAX = 3;
110:
111: /**
112: * <p>Represents a home telephone number.</p>
113: */
114: public static final int TYPE_HOME = 0;
115:
116: /**
117: * <p>Represents a mobile telephone number.</p>
118: */
119: public static final int TYPE_MOBILE = 2;
120:
121: /**
122: * <p>This is used to translate the different address types.</p>
123: *
124: * @see #getTelecomAddressTypeName( int telecomAddressType )
125: */
126: private static final String[] TYPE_NAMES = {
127: "person.label.telecomaddress.home",
128: "person.label.telecomaddress.work",
129: "person.label.telecomaddress.mobile",
130: "person.label.telecomaddress.fax",
131: "person.label.telecomaddress.email",
132: "person.label.telecomaddress.uRL" };
133:
134: /**
135: * <p>Represents a web site address.</p>
136: */
137: public static final int TYPE_URL = 5;
138:
139: /**
140: * <p>Represents a work telephone number.</p>
141: */
142: public static final int TYPE_WORK = 1;
143:
144: /**
145: * <p>Tell client routines how many telecom address types there are.</p>
146: *
147: * @return the number of telecom address types.
148: */
149: public static int countTypes() {
150: if (logger.isDebugEnabled()) {
151: logger.debug("countTypes() - start");
152: }
153:
154: if (logger.isDebugEnabled()) {
155: logger.debug("countTypes() - end - return value = "
156: + TYPE_NAMES.length);
157: }
158: return TYPE_NAMES.length;
159: }
160:
161: /**
162: * <p>Translates the code assigned to a a telecom address type into a text
163: * representing it.<p>
164: *
165: * @param type the numeric type to be converted into a text.
166: * @return the code assigned to a a telecom address type translated into a
167: * text representing it.
168: */
169: public static String getTypeName(final int type) {
170: if (logger.isDebugEnabled()) {
171: logger
172: .debug("getTypeName(int type = " + type
173: + ") - start");
174: }
175:
176: String returnString = TYPE_NAMES[type];
177: if (logger.isDebugEnabled()) {
178: logger.debug("getTypeName(int) - end - return value = "
179: + returnString);
180: }
181: return returnString;
182: }
183:
184: /**
185: * Private default constructor enforces utility class behavior.
186: */
187: private TelecomAddressConstants() {
188: }
189:
190: }
|