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