4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SugStringAttribute.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: SugStringAttribute.java
5  * Description: Class representing attribute of type String for prupose of suggestion
6  */
7 
8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
9 
12 import javax.persistence.DiscriminatorValue;
13 import javax.persistence.Entity;
14 import javax.persistence.NamedQueries;
15 import javax.persistence.NamedQuery;
16 
17 /**
18  * @file SugStringAttribute.java
19  *
20  * @brief Class representing attribute of type String for prupose of suggestion.
21  * Also provides functions for other string based attributes such as ImageUri, URI, ...
22  */
23 
24 /**
25  * Class representing attribute of type String for prupose of suggestion.
26  * Also provides functions for other string based attributes such as ImageUri, URI, ...
27  *
28  * @brief Class representing attribute of type String for prupose of suggestion
29  */
30 @Entity
31 @DiscriminatorValue(value="String")
32 @NamedQueries({
33  @NamedQuery(name = "SuggestionAttribute.findByStringValue", query = "SELECT a FROM SuggestionAttribute a WHERE a.stringValue = :stringValue"),
34 })
35 public class SugStringAttribute extends SugBaseAttribute{
36  /**
37  * Constructor
38  */
39  public SugStringAttribute() {
40  }
41 
42  /**
43  * Constructor
44  *
45  * @param name Name of the attribute
46  * @param value Value of the attribute
47  * @param refSuggestion Suggestion to which this attribute belongs
48  */
49  public SugStringAttribute(String name, String value, Suggestion refSuggestion) {
50  this.name = name;
51  this.simpleType = "String";
52  this.stringValue = value;
53  this.refSuggestion = refSuggestion;
54  }
55 
56  /**
57  * Constructor
58  *
59  * @param name Name of the attribute
60  * @param value Value of the attribute
61  * @param refSuggestion Suggestion to which this attribute belongs
62  * @param priority Priority of attribute
63  */
64  public SugStringAttribute(String name, String value, Suggestion refSuggestion, Integer priority) {
65  this.name = name;
66  this.simpleType = "String";
67  this.stringValue = value;
68  this.refSuggestion = refSuggestion;
69  this.priority = priority;
70  }
71 
72  /**
73  * Checks if attribute value is empty or default value
74  *
75  * @return true, if attribute value is empty
76  */
77  @Override
78  public boolean isEmpty() {
79  return stringValue == null || stringValue.equals("");
80  }
81 
82  /**
83  * Gets value of the attribute
84  *
85  * @return value of the attribute
86  */
87  @Override
88  public Object getValue() {
89  return this.stringValue;
90  }
91 
92  /**
93  * Sets value of the attribute. Value should already be a native java String value.
94  *
95  * @param value New value of the attribute
96  */
97  @Override
98  public void setValue(Object value) {
99  this.stringValue = (String) value;
100  }
101 
102  /**
103  * For string based attributes parseValue is exactly the same as setValue
104  *
105  * @param value value to be parsed
106  */
107  @Override
108  public void setRawValue(String value) {
109  this.stringValue = value;
110  }
111 
112  /**
113  * Gets URI addres in ontology for this type of attribute
114  *
115  * @return Return URI addres in ontology for this type of attribute.
116  */
117  @Override
118  public String getTypeOntologyUri(){
119  return Constants.STRING_URI;
120  }
121 }
Class representing attribute of type String for prupose of suggestion.
Class representing suggestion of annotation.
Definition: Suggestion.java:87
SugStringAttribute(String name, String value, Suggestion refSuggestion, Integer priority)