Skip to content

Commit 323ac3e

Browse files
author
pborissow
committed
- Updated logic used to set phone type.
git-svn-id: svn://192.168.0.80/JavaXT/javaxt-exchange@578 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent f34560f commit 323ac3e

File tree

1 file changed

+60
-23
lines changed

1 file changed

+60
-23
lines changed

src/javaxt/exchange/PhoneNumber.java

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ public class PhoneNumber {
1717
/** Static variable to support the getPhoneNumber method. */
1818
private final static String[] numbers = new String[]{"0","1","2","3","4","5","6","7","8","9"};
1919

20+
private final static String[] types = new String[]{
21+
22+
//Personal Phone
23+
"HomePhone","MobilePhone","HomeFax","HomePhone2",
24+
25+
//Work Phone
26+
"BusinessPhone","BusinessPhone2","BusinessFax",
27+
"CompanyMainPhone","AssistantPhone",
28+
29+
//Primary/Callback
30+
"PrimaryPhone","Callback",
31+
32+
//Other
33+
"OtherFax","OtherTelephone",
34+
35+
//Legacy
36+
"CarPhone","Pager","Isdn","RadioPhone","Telex","TtyTddPhone"
37+
};
38+
2039

2140
//**************************************************************************
2241
//** Constructor
@@ -85,6 +104,23 @@ public String getType(){
85104
}
86105

87106

107+
//**************************************************************************
108+
//** getTypes
109+
//**************************************************************************
110+
/** Returns a static list of phone number types:
111+
* <ul>
112+
* <li>AssistantPhone</li><li>BusinessFax</li><li>BusinessPhone</li>
113+
* <li>BusinessPhone2</li><li>Callback</li><li>CarPhone</li>
114+
* <li>CompanyMainPhone</li><li>HomeFax</li><li>HomePhone</li>
115+
* <li>HomePhone2</li><li>Isdn</li><li>MobilePhone</li><li>OtherFax</li>
116+
* <li>OtherTelephone</li><li>Pager</li><li>PrimaryPhone</li>
117+
* <li>RadioPhone</li><li>Telex</li><li>TtyTddPhone</li>
118+
* </ul>
119+
*/
120+
public static String[] getTypes(){
121+
return types;
122+
}
123+
88124
public String toString(){
89125
return type + ": " + number;
90126
}
@@ -102,7 +138,7 @@ public boolean equals(Object obj){
102138

103139

104140
//**************************************************************************
105-
//** getPhoneNumber
141+
//** getNumber
106142
//**************************************************************************
107143
/** Used to normalize a phone number into a common format. For example, if
108144
* you pass in "(555) 555-5555" or "555.555.5555" or "5555555555", the
@@ -140,36 +176,37 @@ private String getNumber(String phoneNumber){
140176
}
141177

142178

143-
144179
//**************************************************************************
145-
//** getPhoneType
180+
//** getType
146181
//**************************************************************************
147-
/** Used to normalize a phone number type.
182+
/** Returns a phone number type that most closely matches the given string.
148183
*/
149184
private String getType(String type){
150-
type = type.toUpperCase();
151-
if (type.contains("ASSISTANT")) return "AssistantPhone";
152-
if (type.contains("BUSINESSFAX") || type.contains("WORKFAX")) return "BusinessFax";
153-
if (type.contains("BUSINESS") || type.contains("WORK") || type.contains("OFFICE")) return "BusinessPhone";
154-
//else if (type.contains("BUSINESS2")) return "BusinessPhone2";
155-
if (type.contains("CALLBACK")) return "Callback";
156-
if (type.contains("CAR")) return "CarPhone";
157-
//else if (type.contains("COMPANYMAIN")) return "CompanyMainPhone";
158-
if (type.equals("HOMEFAX")) return "HomeFax";
185+
type = type.toUpperCase().replace(" ", "");
186+
for (String t : types){
187+
if (t.toUpperCase().equals(type)) return t;
188+
}
189+
190+
159191
if (type.contains("HOME")) return "HomePhone";
160-
//else if (type.contains("HOME2")) return "HomePhone2";
161-
if (type.contains("ISDN")) return "Isdn";
162192
if (type.contains("MOBILE")) return "MobilePhone";
163-
if (type.equals("OTHERFAX")) return "OtherFax";
164-
if (type.contains("PAGER")) return "Pager";
165-
if (type.contains("PRIMARY")) return "PrimaryPhone";
166-
if (type.contains("RADIO")) return "RadioPhone";
167-
if (type.contains("TELEX")) return "Telex";
168-
if (type.contains("TTYTDD")) return "TtyTddPhone";
169-
return "OtherTelephone";
170-
}
193+
194+
if (type.equals("FAX") || type.equals("COMPANYFAX") || type.equals("WORKFAX")) return "BusinessFax";
195+
if (type.equals("PERSONALFAX")) return "HomeFax";
196+
if (type.contains("FAX")) return "OtherFax";
171197

198+
if (type.contains("BUSINESS") || type.contains("WORK") || type.contains("OFFICE")) return "BusinessPhone";
199+
if (type.contains("ASSISTANT")) return "AssistantPhone";
172200

173201

202+
if (type.contains("PRIMARY")) return "PrimaryPhone";
203+
if (type.contains("CALLBACK")) return "Callback";
204+
205+
206+
if (type.contains("CAR")) return "CarPhone";
207+
if (type.contains("RADIO")) return "RadioPhone";
208+
if (type.contains("TTY") || type.contains("TDD")) return "TtyTddPhone";
174209

210+
return "OtherTelephone";
211+
}
175212
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy