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  
25  class StabilityOptions {
26    public static final String STABLE_OPTION = "-stable";
27    public static final String EVOLVING_OPTION = "-evolving";
28    public static final String UNSTABLE_OPTION = "-unstable";
29  
30    public static Integer optionLength(String option) {
31      String opt = option.toLowerCase();
32      if (opt.equals(UNSTABLE_OPTION)) return 1;
33      if (opt.equals(EVOLVING_OPTION)) return 1;
34      if (opt.equals(STABLE_OPTION)) return 1;
35      return null;
36    }
37  
38    public static void validOptions(String[][] options, DocErrorReporter reporter) {
39      for (int i = 0; i < options.length; i++) {
40        String opt = options[i][0].toLowerCase();
41        if (opt.equals(UNSTABLE_OPTION)) {
42          RootDocProcessor.stability = UNSTABLE_OPTION;
43        } else if (opt.equals(EVOLVING_OPTION)) {
44          RootDocProcessor.stability = EVOLVING_OPTION;
45        } else if (opt.equals(STABLE_OPTION)) {
46          RootDocProcessor.stability = STABLE_OPTION;
47        }
48      }
49    }
50  
51    public static String[][] filterOptions(String[][] options) {
52      List<String[]> optionsList = new ArrayList<String[]>();
53      for (int i = 0; i < options.length; i++) {
54        if (!options[i][0].equalsIgnoreCase(UNSTABLE_OPTION)
55            && !options[i][0].equalsIgnoreCase(EVOLVING_OPTION)
56            && !options[i][0].equalsIgnoreCase(STABLE_OPTION)) {
57          optionsList.add(options[i]);
58        }
59      }
60      String[][] filteredOptions = new String[optionsList.size()][];
61      int i = 0;
62      for (String[] option : optionsList) {
63        filteredOptions[i++] = option;
64      }
65      return filteredOptions;
66    }
67  
68  }