GeocoderParams.java revision 8754be5cac3aca54f83e2eb2c199bc01e934034e
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.location;
18
19import android.content.Context;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23import java.util.Locale;
24
25/**
26 * This class contains extra parameters to pass to an IGeocodeProvider
27 * implementation from the Geocoder class.  Currently this contains the
28 * language, country and variant information from the Geocoder's locale
29 * as well as the Geocoder client's package name for geocoder server
30 * logging.  This information is kept in a separate class to allow for
31 * future expansion of the IGeocodeProvider interface.
32 *
33 * @hide
34 */
35public class GeocoderParams implements Parcelable {
36    private Locale mLocale;
37    private String mPackageName;
38
39    // used only for parcelling
40    private GeocoderParams() {
41    }
42
43    /**
44     * This object is only constructed by the Geocoder class
45     *
46     * @hide
47     */
48    public GeocoderParams(Context context, Locale locale) {
49        mLocale = locale;
50        mPackageName = context.getPackageName();
51    }
52
53    /**
54     * returns the Geocoder's locale
55     */
56    public Locale getLocale() {
57        return mLocale;
58    }
59
60    /**
61     * returns the package name of the Geocoder's client
62     */
63    public String getClientPackage() {
64        return mPackageName;
65    }
66
67    public static final Parcelable.Creator<GeocoderParams> CREATOR =
68        new Parcelable.Creator<GeocoderParams>() {
69        public GeocoderParams createFromParcel(Parcel in) {
70            GeocoderParams gp = new GeocoderParams();
71            String language = in.readString();
72            String country = in.readString();
73            String variant = in.readString();
74            gp.mLocale = new Locale(language, country, variant);
75            gp.mPackageName = in.readString();
76            return gp;
77        }
78
79        public GeocoderParams[] newArray(int size) {
80            return new GeocoderParams[size];
81        }
82    };
83
84    public int describeContents() {
85        return 0;
86    }
87
88    public void writeToParcel(Parcel parcel, int flags) {
89        parcel.writeString(mLocale.getLanguage());
90        parcel.writeString(mLocale.getCountry());
91        parcel.writeString(mLocale.getVariant());
92        parcel.writeString(mPackageName);
93    }
94}
95