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.triplePane;
21  
22  import cz.zcu.mre.sparkle.gui.query.helpers.FieldType;
23  import cz.zcu.mre.sparkle.gui.query.other.TypedTextField;
24  import cz.zcu.mre.sparkle.tools.sparqlParser.SparqlParserTriple;
25  import static cz.zcu.mre.sparkle.gui.query.triplePane.TriplePane.XML_PREDICATE_ELEMENT_NAME;
26  
27  /**
28   * @author Klara Hlavacova
29   * @author Petr Vcelak (vcelak@kiv.zcu.cz)
30   */
31  class FieldProperties {
32  
33      private String elementValue;
34      private FieldType elementFieldType;
35      private String objectLang = null;
36      private String objectDataType = null;
37      private final TypedTextField field;
38      private final SparqlParserTriple triple;
39  
40      public FieldProperties(SparqlParserTriple triple, TypedTextField field) {
41          this.triple = triple;
42          this.field = field;
43          setTripleElementFieldType();
44      }
45  
46      private void setTripleElementFieldType() {
47          String type = this.field.getPlaceholder();
48          if (type.equalsIgnoreCase(TriplePane.XML_SUBJECT_ELEMENT_NAME)) {
49              this.elementValue = this.triple.getSubject();
50              this.elementFieldType = this.triple.getSubjectFieldType();
51          } else if (type.equalsIgnoreCase(XML_PREDICATE_ELEMENT_NAME)) {
52              this.elementValue = this.triple.getPredicate();
53              this.elementFieldType = this.triple.getPredicateFieldType();
54          } else {
55              this.elementValue = this.triple.getObject();
56              this.elementFieldType = this.triple.getObjectFieldType();
57              this.objectLang = this.triple.getLiteralLang();
58              this.objectDataType = this.triple.getLiteralDataType();
59          }
60      }
61  
62      public String getElementValue() {
63          return this.elementValue;
64      }
65  
66      public FieldType getElemeFieldType() {
67          return this.elementFieldType;
68      }
69  
70      public String getObjectLang() {
71          return this.objectLang;
72      }
73  
74      public String getObjectDataType() {
75          return this.objectDataType;
76      }
77  
78  }