Skip to main content
summaryrefslogtreecommitdiffstats
blob: 610755920f0afcb27942501c77fc6a5aa4359d46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*******************************************************************************
 * Copyright (c) 2012 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.util;

import java.util.regex.Pattern;
import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
import org.eclipse.osee.framework.core.enums.OptionVisitor;
import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.core.enums.TokenOrderType;

/**
 * @author John Misinco
 */
public class CheckedOptions implements OptionVisitor {

   private TokenOrderType orderType;
   private CaseType caseType;
   private MatchTokenCountType countType;
   private TokenDelimiterMatch delimiter;

   public CheckedOptions() {
      initialize();
   }

   private void initialize() {
      orderType = TokenOrderType.ANY_ORDER;
      caseType = CaseType.IGNORE_CASE;
      countType = MatchTokenCountType.IGNORE_TOKEN_COUNT;
      delimiter = TokenDelimiterMatch.ANY;
   }

   public TokenOrderType getOrderType() {
      return orderType;
   }

   public CaseType getCaseType() {
      return caseType;
   }

   public MatchTokenCountType getCountType() {
      return countType;
   }

   public Pattern getDelimiter() {
      return delimiter.getPattern();
   }

   public void accept(QueryOption... options) {
      initialize();
      for (QueryOption option : options) {
         option.accept(this);
      }
   }

   @Override
   public void asCaseType(CaseType option) {
      caseType = option;
   }

   @Override
   public void asTokenOrderType(TokenOrderType option) {
      orderType = option;
   }

   @Override
   public void asMatchTokenCountType(MatchTokenCountType option) {
      countType = option;
   }

   @Override
   public void asTokenDelimiterMatch(TokenDelimiterMatch delimiter) {
      this.delimiter = delimiter;
   }
};

Back to the top