2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.usecases.rolodex.Contact
 
Classes in this File Line Coverage Branch Coverage Complexity
Contact
100%
23/23
N/A
1.4
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.shale.usecases.rolodex;
 19  
 
 20  
 import java.io.UnsupportedEncodingException;
 21  
 import java.net.URLEncoder;
 22  
 
 23  
 /**
 24  
  * <p>
 25  
  * Represents an entity in the rolodex.
 26  
  * </p>
 27  
  */
 28  112
 public class Contact {
 29  112
     String name = null;
 30  
 
 31  112
     String email = null;
 32  
 
 33  112
     String residentialPhone = null;
 34  
 
 35  112
     Address residentialAddress = null;
 36  
 
 37  112
     String businessPhone = null;
 38  
 
 39  112
     Address businessAddress = null;
 40  
 
 41  
     /**
 42  
      * <p>
 43  
      * Returns the first char of the name use by the rolodex index.
 44  
      * </p>
 45  
      */
 46  
     public char getTabIndex() {
 47  158
         return getSortName().charAt(0);
 48  
     }
 49  
 
 50  
     /**
 51  
      * <p>
 52  
      * Returns the business {@link Address}.
 53  
      * </p>
 54  
      */
 55  
     public Address getBusinessAddress() {
 56  
         if (businessAddress == null)
 57  
             businessAddress = new Address();
 58  
 
 59  
         return businessAddress;
 60  
     }
 61  
 
 62  
     /**
 63  
      * <p>
 64  
      * Sets the business {@link Address}.
 65  
      * </p>
 66  
      */
 67  
     public void setBusinessAddress(Address businessAddress) {
 68  30
         this.businessAddress = businessAddress;
 69  30
     }
 70  
 
 71  
     /**
 72  
      * <p>
 73  
      * Returns the business phone number.
 74  
      * </p>
 75  
      */
 76  
     public String getBusinessPhone() {
 77  
         return businessPhone;
 78  
     }
 79  
 
 80  
     /**
 81  
      * <p>
 82  
      * Sets the business phone number.
 83  
      * </p>
 84  
      */
 85  
     public void setBusinessPhone(String businessPhone) {
 86  35
         this.businessPhone = businessPhone;
 87  35
     }
 88  
 
 89  
     /**
 90  
      * <p>
 91  
      * Returns the email address.
 92  
      * </p>
 93  
      */
 94  
     public String getEmail() {
 95  
         return email;
 96  
     }
 97  
 
 98  
     /**
 99  
      * <p>
 100  
      * Sets the email address.
 101  
      * </p>
 102  
      */
 103  
     public void setEmail(String email) {
 104  65
         this.email = email;
 105  65
     }
 106  
 
 107  
     /**
 108  
      * <p>
 109  
      * Gets the entity name.
 110  
      * </p>
 111  
      */
 112  
     public String getName() {
 113  93
         return name;
 114  
     }
 115  
 
 116  
     /**
 117  
      * <p>
 118  
      * Sets the entity name.
 119  
      * </p>
 120  
      */
 121  
     public void setName(String name) {
 122  103
         this.name = name;
 123  103
     }
 124  
 
 125  
     /**
 126  
      * <p>
 127  
      * Gets the residential {@link Address}.
 128  
      * </p>
 129  
      */
 130  
     public Address getResidentialAddress() {
 131  
         if (residentialAddress == null) {
 132  
             residentialAddress = new Address();
 133  
         }
 134  
         return residentialAddress;
 135  
     }
 136  
 
 137  
     /**
 138  
      * <p>
 139  
      * Sets the residential {@link Address}.
 140  
      * </p>
 141  
      */
 142  
     public void setResidentialAddress(Address residentialAddress) {
 143  30
         this.residentialAddress = residentialAddress;
 144  30
     }
 145  
 
 146  
     /**
 147  
      * <p>
 148  
      * Gets the residential phone number.
 149  
      * </p>
 150  
      */
 151  
     public String getResidentialPhone() {
 152  
         return residentialPhone;
 153  
     }
 154  
 
 155  
     /**
 156  
      * <p>
 157  
      * Sets the residential phone number.
 158  
      * </p>
 159  
      */
 160  
     public void setResidentialPhone(String residentialPhone) {
 161  35
         this.residentialPhone = residentialPhone;
 162  35
     }
 163  
 
 164  
     /**
 165  
      * <p>Returns the <code>name</code> in upper case.</p>
 166  
      */
 167  
     public String getSortName() {
 168  872
        if (name != null)
 169  872
           return name.toUpperCase();
 170  
        
 171  
        return null;
 172  
     }
 173  
     
 174  
     /**
 175  
      * <p>Returns the <code>name</code> encoded.</p>
 176  
      */
 177  
     public String getEncodedName() {
 178  
         String encName = null;
 179  
 
 180  
         if (name != null) {
 181  
           try {
 182  
             encName =  URLEncoder.encode(name, "UTF-8");
 183  
           } catch (UnsupportedEncodingException e) {}          
 184  
        }
 185  
        return encName;
 186  
     }
 187  
     
 188  
     
 189  
 }