blob: d3267383e54347a55d2055567492be01ee2584bf [file] [log] [blame]
Adnan Begovicd5fdee92015-11-13 15:28:21 -08001/*
2 * Copyright (C) 2015 The CyanogenMod 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
17import java.io.Serializable;
18
19/**
20 * A simple concept of a "setting" within the provider
21 */
22public class Setting implements Serializable, Comparable<Setting> {
23 private static final long serialVersionUID = 0;
24
25 private String key;
26 private String value;
27 private String keyType;
28 private String valueType;
29
30 public Setting() {
31 this.keyType = SettingType.TYPE_NULL;
32 this.valueType = SettingType.TYPE_NULL;
33 }
34
35 public String getValue() {
36 return value;
37 }
38
39 public void setValue(String value) {
40 this.value = value;
41 }
42
43 public String getKey() {
44 return key;
45 }
46
47 public void setKey(String key) {
48 this.key = key;
49 }
50
51 public String getKeyType() {
52 return keyType;
53 }
54
55 public void setKeyType(String type) {
56 this.keyType = type;
57 }
58
59 public String getValueType() {
60 return valueType;
61 }
62
63 public void setValueType(String valueType) {
64 this.valueType = valueType;
65 }
66
67 /** s - string, i - integer, f - float */
68 public static class SettingType {
69 private static final String TYPE_NULL = "NULL";
70 private static final String TYPE_STRING = "s";
71 private static final String TYPE_INTEGER = "i";
72 private static final String TYPE_FLOAT = "f";
73 private static final String TYPE_BLOB = "d";
74
75 //THIS IS FROM CURSOR.JAVA, DO NOT MODIFY
76 /** Value returned by {@link #getType(int)} if the specified column is null */
77 static final int FIELD_TYPE_NULL = 0;
78 /** Value returned by {@link #getType(int)} if the specified column type is integer */
79 static final int FIELD_TYPE_INTEGER = 1;
80 /** Value returned by {@link #getType(int)} if the specified column type is float */
81 static final int FIELD_TYPE_FLOAT = 2;
82 /** Value returned by {@link #getType(int)} if the specified column type is string */
83 static final int FIELD_TYPE_STRING = 3;
84 /** Value returned by {@link #getType(int)} if the specified column type is blob */
85 static final int FIELD_TYPE_BLOB = 4;
86
87
88 public static String mapNumericToType(int numeric) {
89 switch (numeric) {
90 case FIELD_TYPE_NULL:
91 return TYPE_NULL;
92 case FIELD_TYPE_STRING:
93 return TYPE_STRING;
94 case FIELD_TYPE_INTEGER:
95 return TYPE_INTEGER;
96 case FIELD_TYPE_FLOAT:
97 return TYPE_FLOAT;
98 case FIELD_TYPE_BLOB:
99 return TYPE_BLOB;
100 default:
101 return TYPE_NULL;
102 }
103 }
104 }
105
106 @Override
107 public int compareTo(Setting o) {
108 return this.key.compareTo(o.getKey());
109 }
110}