Debian Codegraph @

core/java/com/google/android/util/SmileyResources.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2007 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
17 package com.google.android.util;
18
19 import com.google.android.util.AbstractMessageParser.TrieNode;
20
21 import java.util.HashMap;
22 import java.util.Set;
23
24 /**
25 * Resources for smiley parser.
26 */
27 public class SmileyResources implements AbstractMessageParser.Resources {
28 private HashMap<String, Integer> mSmileyToRes = new HashMap<String, Integer>();
29
30 /**
31 *
32 * @param smilies Smiley text, e.g. ":)", "8-)"
33 * @param smileyResIds Resource IDs associated with the smileys.
34 */
35 public SmileyResources(String[] smilies, int[] smileyResIds) {
36 for (int i = 0; i < smilies.length; i++) {
37 TrieNode.addToTrie(smileys, smilies[i], "");
38 mSmileyToRes.put(smilies[i], smileyResIds[i]);
39 }
40 }
41
42 /**
43 * Looks up the resource id of a given smiley.
44 * @param smiley The smiley to look up.
45 * @return the resource id of the specified smiley, or -1 if no resource
46 * id is associated with it.
47 */
48 public int getSmileyRes(String smiley) {
49 Integer i = mSmileyToRes.get(smiley);
50 if (i == null) {
51 return -1;
52 }
53 return i.intValue();
54 }
55
56 private final TrieNode smileys = new TrieNode();
57
58 public Set<String> getSchemes() {
59 return null;
60 }
61
62 public TrieNode getDomainSuffixes() {
63 return null;
64 }
65
66 public TrieNode getSmileys() {
67 return smileys;
68 }
69
70 public TrieNode getAcronyms() {
71 return null;
72 }
73
74 }