View Javadoc
1   /*
2    * Copyright 2013-2023 Medical Information Systems Research Group (https://medical.zcu.cz),
3    * Department of Computer Science and Engineering, University of West Bohemia.
4    * Address: Univerzitni 8, 306 14 Plzen, Czech Republic.
5    *
6    * This file is part of Sparkle project.
7    *
8    * Sparkle is free software: you can redistribute it and/or modify
9    * it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License.
11   *
12   * Sparkle is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with Sparkle. If not, see <http://www.gnu.org/licenses/>.
19   */
20  package cz.zcu.mre.sparkle.gui.query.helpers;
21  
22  /**
23   * Stanovuje typ hodnoty v poli.
24   *
25   * @author Jan Smucr
26   * @author Petr Vcelak (vcelak@kiv.zcu.cz)
27   */
28  public enum FieldType {
29      /**
30       * Proměnná.
31       */
32      Variable,
33      /**
34       * Zkrácený IRI.
35       */
36      PrefixedName,
37      /**
38       * IRI.
39       */
40      IRI,
41      /**
42       * Zkratka pro rdf:type.
43       */
44      A,
45      /**
46       * Literál.
47       */
48      Literal,
49      /**
50       * Výraz.
51       */
52      Expression,
53      /**
54       * Aggregation modifier.
55       */
56      Modifier,
57      /**
58       * Blank node.
59       */
60      BlankNode,
61      /**
62       * Nil.
63       */
64      Nil,
65      /**
66       * UNDEF.
67       */
68      Undef,
69      /**
70       * Numeric literal.
71       */
72      Numeric,
73      /**
74       * Boolean algebra.
75       */
76      Boolean;
77  
78      public final boolean oneOf(final FieldType... fieldTypes) {
79          for (final FieldType fieldType : fieldTypes) {
80              if (this == fieldType) {
81                  return true;
82              }
83          }
84  
85          return false;
86      }
87  
88      public static final FieldType valueOfIgnoreCase(final String s) {
89          for (final FieldType type : values()) {
90              if (type.name().equalsIgnoreCase(s)) {
91                  return type;
92              }
93          }
94  
95          /* For compatibility reasons */
96          if (s.equalsIgnoreCase("node")) //$NON-NLS-1$
97          {
98              return FieldType.PrefixedName;
99          }
100 
101         return null;
102     }
103 }