Home | History | Annotate | Download | only in indexing
      1 /*
      2  * Copyright (C) 2017 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 
     18 package com.android.settings.intelligence.search.indexing;
     19 
     20 import android.provider.SearchIndexableData;
     21 import android.util.Pair;
     22 
     23 import java.util.ArrayList;
     24 import java.util.HashMap;
     25 import java.util.List;
     26 import java.util.Map;
     27 import java.util.Set;
     28 
     29 
     30 /**
     31  * Holds Data sources for indexable data.
     32  */
     33 public class PreIndexData {
     34 
     35     private final List<SearchIndexableData> mDataToUpdate;
     36     private final Map<String, Set<String>> mNonIndexableKeys;
     37     private final List<Pair<String, String>> mSiteMapPairs;
     38 
     39     public PreIndexData() {
     40         mDataToUpdate = new ArrayList<>();
     41         mNonIndexableKeys = new HashMap<>();
     42         mSiteMapPairs = new ArrayList<>();
     43     }
     44 
     45     public Map<String, Set<String>> getNonIndexableKeys() {
     46         return mNonIndexableKeys;
     47     }
     48 
     49     public List<SearchIndexableData> getDataToUpdate() {
     50         return mDataToUpdate;
     51     }
     52 
     53     public List<Pair<String, String>> getSiteMapPairs() {
     54         return mSiteMapPairs;
     55     }
     56 
     57     public void addNonIndexableKeysForAuthority(String authority, Set<String> keys) {
     58         mNonIndexableKeys.put(authority, keys);
     59     }
     60 
     61     public void addDataToUpdate(List<? extends SearchIndexableData> data) {
     62         mDataToUpdate.addAll(data);
     63     }
     64 
     65     public void addSiteMapPairs(List<Pair<String, String>> siteMapPairs) {
     66         if (siteMapPairs == null) {
     67             return;
     68         }
     69         mSiteMapPairs.addAll(siteMapPairs);
     70     }
     71 
     72 }
     73