View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.classification.tools;
19  
20  import com.sun.javadoc.DocErrorReporter;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  import java.util.Locale;
25  
26  class StabilityOptions {
27    public static final String STABLE_OPTION = "-stable";
28    public static final String EVOLVING_OPTION = "-evolving";
29    public static final String UNSTABLE_OPTION = "-unstable";
30  
31    public static Integer optionLength(String option) {
32      String opt = option.toLowerCase(Locale.ROOT);
33      if (opt.equals(UNSTABLE_OPTION)) return 1;
34      if (opt.equals(EVOLVING_OPTION)) return 1;
35      if (opt.equals(STABLE_OPTION)) return 1;
36      return null;
37    }
38  
39    public static void validOptions(String[][] options, DocErrorReporter reporter) {
40      for (int i = 0; i < options.length; i++) {
41        String opt = options[i][0].toLowerCase(Locale.ROOT);
42        if (opt.equals(UNSTABLE_OPTION)) {
43          RootDocProcessor.stability = UNSTABLE_OPTION;
44        } else if (opt.equals(EVOLVING_OPTION)) {
45          RootDocProcessor.stability = EVOLVING_OPTION;
46        } else if (opt.equals(STABLE_OPTION)) {
47          RootDocProcessor.stability = STABLE_OPTION;
48        }
49      }
50    }
51  
52    public static String[][] filterOptions(String[][] options) {
53      List<String[]> optionsList = new ArrayList<String[]>();
54      for (int i = 0; i < options.length; i++) {
55        if (!options[i][0].equalsIgnoreCase(UNSTABLE_OPTION)
56            && !options[i][0].equalsIgnoreCase(EVOLVING_OPTION)
57            && !options[i][0].equalsIgnoreCase(STABLE_OPTION)) {
58          optionsList.add(options[i]);
59        }
60      }
61      String[][] filteredOptions = new String[optionsList.size()][];
62      int i = 0;
63      for (String[] option : optionsList) {
64        filteredOptions[i++] = option;
65      }
66      return filteredOptions;
67    }
68  
69  }