001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.model.Country;
020    import com.liferay.portal.model.ListType;
021    import com.liferay.portal.model.Region;
022    import com.liferay.portal.service.CountryServiceUtil;
023    import com.liferay.portal.service.ListTypeServiceUtil;
024    import com.liferay.portal.service.RegionServiceUtil;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class AddressImpl extends AddressBaseImpl {
030    
031            public AddressImpl() {
032            }
033    
034            public Region getRegion() {
035                    Region region = null;
036    
037                    try {
038                            region = RegionServiceUtil.getRegion(getRegionId());
039                    }
040                    catch (Exception e) {
041                            region = new RegionImpl();
042    
043                            _log.warn(e);
044                    }
045    
046                    return region;
047            }
048    
049            public Country getCountry() {
050                    Country country = null;
051    
052                    try {
053                            country = CountryServiceUtil.getCountry(getCountryId());
054                    }
055                    catch (Exception e) {
056                            country = new CountryImpl();
057    
058                            _log.warn(e);
059                    }
060    
061                    return country;
062            }
063    
064            public ListType getType() {
065                    ListType type = null;
066    
067                    try {
068                            type = ListTypeServiceUtil.getListType(getTypeId());
069                    }
070                    catch (Exception e) {
071                            type = new ListTypeImpl();
072    
073                            _log.warn(e);
074                    }
075    
076                    return type;
077            }
078    
079            private static Log _log = LogFactoryUtil.getLog(AddressImpl.class);
080    
081    }