Source Code Cross Referenced for Customer.java in  » Content-Management-System » openedit » org » openedit » store » customer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » openedit » org.openedit.store.customer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Mar 4, 2004
003:         *
004:         */
005:        package org.openedit.store.customer;
006:
007:        import java.util.ArrayList;
008:        import java.util.Iterator;
009:        import java.util.List;
010:
011:        import org.openedit.money.Fraction;
012:        import org.openedit.store.PaymentMethod;
013:
014:        import com.openedit.users.User;
015:        import com.openedit.users.filesystem.FileSystemUser;
016:
017:        /**
018:         * A customer with nice getters and setters on top of the standard user object.
019:         * 
020:         * @author dbrown
021:         */
022:        public class Customer {
023:            public static final String PHONE1 = "Phone1";
024:            public static final String FAX = "Fax";
025:            public static final String TITLE = "Title";
026:            public static final String ALLOW_EMAIL = "AllowEmail";
027:            public static final String REFERENCE = "ReferenceNumber";
028:            public static final String TAX_RATE = "TaxRate";
029:            public static final String TAX_EXEMPT_ID = "TaxExemptId";
030:            public static final String COMPANY = "Company";
031:            public static final String USERFIELD1 = "userfield1";
032:            public static final String USERFIELD2 = "userfield2";
033:
034:            protected User fieldUser; // used to store information in Open Edit
035:            protected PaymentMethod fieldPaymentMethod;
036:            // protected Address fieldBillingAddress;
037:            // protected Address fieldShippingAddress;
038:            protected String fieldUserName;
039:            protected List addressList;
040:
041:            /**
042:             * Creates a customer that uses the given user to store its information.
043:             * 
044:             * @param inUser
045:             */
046:            public Customer(User inUser) {
047:                fieldUser = inUser;
048:
049:            }
050:
051:            public Customer() {
052:                FileSystemUser user = new FileSystemUser();
053:                fieldUser = user;
054:            }
055:
056:            public User getUser() {
057:                return fieldUser;
058:            }
059:
060:            public String getUserName() {
061:                return getUser().getUserName();
062:            }
063:
064:            public String getFirstName() {
065:                return getUser().getFirstName();
066:            }
067:
068:            public void setFirstName(String inFirstName) {
069:                getUser().setFirstName(inFirstName);
070:            }
071:
072:            public String getLastName() {
073:                return getUser().getLastName();
074:            }
075:
076:            public void setLastName(String inLastName) {
077:                getUser().setLastName(inLastName);
078:            }
079:
080:            public String getEmail() {
081:                return getUser().getEmail();
082:            }
083:
084:            public void setEmail(String inEmail) {
085:                getUser().setEmail(inEmail);
086:            }
087:
088:            public String getPassword() {
089:                return getUser().getPassword();
090:            }
091:
092:            public boolean isAllowEmail() {
093:                return getUser().getBoolean(ALLOW_EMAIL);
094:            }
095:
096:            public void setAllowEmail(boolean inValue) {
097:                getUser().safePut(ALLOW_EMAIL, String.valueOf(inValue));
098:            }
099:
100:            public String getTaxExemptId() {
101:                return getUser().getString(TAX_EXEMPT_ID);
102:            }
103:
104:            public void setTaxExemptId(String inString) {
105:                getUser().safePut(TAX_EXEMPT_ID, inString);
106:            }
107:
108:            public String getName() {
109:                return getFirstName() + " " + getLastName();
110:            }
111:
112:            public PaymentMethod getPaymentMethod() {
113:                return fieldPaymentMethod;
114:            }
115:
116:            public void setPaymentMethod(PaymentMethod inPaymentMethod) {
117:                fieldPaymentMethod = inPaymentMethod;
118:            }
119:
120:            public String getPhone1() {
121:                return getUser().getString(PHONE1);
122:            }
123:
124:            public void setPhone1(String inPhone1) {
125:                getUser().safePut(PHONE1, inPhone1);
126:            }
127:
128:            public String getCompany() {
129:                return getUser().getString(COMPANY);
130:            }
131:
132:            public void setCompany(String inCompany) {
133:                getUser().safePut(COMPANY, inCompany);
134:            }
135:
136:            public Fraction getTaxRate() {
137:                String taxRateString = getUser().getString(TAX_RATE);
138:                if (taxRateString == null) {
139:                    taxRateString = Fraction.ZERO.toString();
140:                    getUser().safePut(TAX_RATE, taxRateString);
141:                }
142:                return new Fraction(taxRateString);
143:            }
144:
145:            public void setTaxRate(Fraction inTaxRate) {
146:                if (inTaxRate == null) {
147:                    inTaxRate = Fraction.ZERO;
148:                }
149:                getUser().safePut(TAX_RATE, inTaxRate.toString());
150:            }
151:
152:            public String getReferenceNumber() {
153:                return getUser().getString(REFERENCE);
154:            }
155:
156:            public void setReferenceNumber(String inReferenceNumber) {
157:                getUser().safePut(REFERENCE, inReferenceNumber);
158:            }
159:
160:            public String getTitle() {
161:                return getUser().getString(TITLE);
162:            }
163:
164:            public void setTitle(String inTitle) {
165:                getUser().safePut(TITLE, inTitle);
166:            }
167:
168:            // See UserManagerModule.clean
169:            public String cleanPhoneNumber() {
170:                String phoneNumber = getPhone1();
171:                if (phoneNumber != null) {
172:                    StringBuffer out = new StringBuffer();
173:                    for (int i = 0; i < phoneNumber.length(); i++) {
174:                        if (Character.isDigit(phoneNumber.charAt(i))) {
175:                            out.append(phoneNumber.charAt(i));
176:                        }
177:                    }
178:                    phoneNumber = out.toString();
179:                }
180:                return phoneNumber;
181:            }
182:
183:            public Address getBillingAddress() {
184:                Address billing = getAddress("billing");
185:                if (billing == null) {
186:                    billing = new Address(getUser());
187:                    billing.setPrefix("billing"); // only used to store the data
188:                }
189:                return billing;
190:            }
191:
192:            public void setBillingAddress(Address inAddress) {
193:                inAddress.setPrefix("billing");
194:                Address billing = getAddress("billing");
195:                if (getAddress("billing") != null) {
196:                    getAddressList().remove("billing");
197:                }
198:                getAddressList().add(inAddress);
199:
200:            }
201:
202:            public Address getAddress(String inString) {
203:                for (Iterator iterator = getAddressList().iterator(); iterator
204:                        .hasNext();) {
205:                    Address address = (Address) iterator.next();
206:                    if (inString.equals(address.getPrefix())) {
207:                        return address;
208:                    }
209:                }
210:                return null;
211:            }
212:
213:            public Address getShippingAddress() {
214:                Address shipping = getAddress("shipping");
215:                if (shipping == null) {
216:                    shipping = new Address(getUser());
217:                    shipping.setPrefix("shipping");
218:                    addAddress(shipping);
219:                }
220:                return shipping;
221:            }
222:
223:            public void setShippingAddress(Address inShippingAddress) {
224:                inShippingAddress.setPrefix("shipping");
225:                Address shipping = getAddress("shipping");
226:                if (shipping != null) {
227:                    getAddressList().remove("shipping");
228:                }
229:                getAddressList().add(inShippingAddress);
230:            }
231:
232:            public String getFax() {
233:                return getUser().getString(FAX);
234:            }
235:
236:            public void setFax(String inFax) {
237:                getUser().safePut(FAX, inFax);
238:            }
239:
240:            public String getUserField1() {
241:                return getUser().getString(USERFIELD1);
242:            }
243:
244:            public void setUserField1(String inUserField1) {
245:                getUser().safePut(USERFIELD1, inUserField1);
246:            }
247:
248:            public String getUserField2() {
249:                return getUser().getString(USERFIELD2);
250:            }
251:
252:            public void setUserField2(String inUserField2) {
253:                getUser().safePut(USERFIELD2, inUserField2);
254:            }
255:
256:            public void setUserName(String inUserName) {
257:                getUser().setUserName(inUserName);
258:            }
259:
260:            public void setPassword(String inPassword) {
261:                getUser().setPassword(inPassword);
262:            }
263:
264:            public List getAddressList() {
265:                if (addressList == null) {
266:                    addressList = new ArrayList();
267:                    getShippingAddress();
268:
269:                }
270:
271:                return addressList;
272:            }
273:
274:            public void setAddressList(List addressList) {
275:                this .addressList = addressList;
276:            }
277:
278:            public void addAddress(Address inAddress) {
279:                removeAddress(inAddress);
280:                getAddressList().add(inAddress);
281:            }
282:
283:            public void removeAddress(Address inAddress) {
284:                Address toRemove = getAddress(inAddress.getPrefix());
285:                if (toRemove != null) {
286:                    getAddressList().remove(toRemove);
287:                }
288:
289:            }
290:
291:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.