1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.model.Address;
20  import com.liferay.portal.model.Country;
21  import com.liferay.portal.model.ListType;
22  import com.liferay.portal.model.Region;
23  import com.liferay.portal.service.CountryServiceUtil;
24  import com.liferay.portal.service.ListTypeServiceUtil;
25  import com.liferay.portal.service.RegionServiceUtil;
26  
27  /**
28   * <a href="AddressImpl.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class AddressImpl extends AddressModelImpl implements Address {
33  
34      public AddressImpl() {
35      }
36  
37      public Region getRegion() {
38          Region region = null;
39  
40          try {
41              region = RegionServiceUtil.getRegion(getRegionId());
42          }
43          catch (Exception e) {
44              region = new RegionImpl();
45  
46              _log.warn(e);
47          }
48  
49          return region;
50      }
51  
52      public Country getCountry() {
53          Country country = null;
54  
55          try {
56              country = CountryServiceUtil.getCountry(getCountryId());
57          }
58          catch (Exception e) {
59              country = new CountryImpl();
60  
61              _log.warn(e);
62          }
63  
64          return country;
65      }
66  
67      public ListType getType() {
68          ListType type = null;
69  
70          try {
71              type = ListTypeServiceUtil.getListType(getTypeId());
72          }
73          catch (Exception e) {
74              type = new ListTypeImpl();
75  
76              _log.warn(e);
77          }
78  
79          return type;
80      }
81  
82      private static Log _log = LogFactoryUtil.getLog(AddressImpl.class);
83  
84  }