4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SugIntegerAttribute.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: SugIntegerAttribute.java
5  * Description: Class representing attribute of type Integer for prupose of suggestion
6  */
7 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
8 
11 import javax.persistence.DiscriminatorValue;
12 import javax.persistence.Entity;
13 import javax.persistence.NamedQueries;
14 import javax.persistence.NamedQuery;
15 
16 /**
17  * @file SugIntegerAttribute.java
18  *
19  * @brief Class representing attribute of type Integer for prupose of suggestion
20  */
21 
22 /**
23  * Class representing attribute of type Integer for prupose of suggestion
24  *
25  * @brief Class representing attribute of type Integer for prupose of suggestion
26  */
27 @Entity
28 @DiscriminatorValue("Integer")
29 @NamedQueries({
30  @NamedQuery(name = "SuggestionAttribute.findByIntValue", query = "SELECT a FROM SuggestionAttribute a WHERE a.intValue = :intValue"),
31 })
33  /**
34  * Constructor
35  */
37  }
38 
39  /**
40  * Constructor
41  *
42  * @param name Name of attribute
43  * @param value Value of attribute
44  * @param refSuggestion Suggestion to which this attribute belongs
45  */
46  public SugIntegerAttribute(String name, Integer value, Suggestion refSuggestion) {
47  this.name = name;
48  this.simpleType = "Integer";
49  this.intValue = value;
50  this.refSuggestion = refSuggestion;
51  }
52 
53  /**
54  * Constructor
55  *
56  * @param name Name of attribute
57  * @param value Value of attribute
58  * @param refSuggestion Suggestion to which this attribute belongs
59  * @param priority Priority of attribute
60  */
61  public SugIntegerAttribute(String name, Integer value, Suggestion refSuggestion, Integer priority) {
62  this.name = name;
63  this.simpleType = "Integer";
64  this.intValue = value;
65  this.refSuggestion = refSuggestion;
66  this.priority = priority;
67  }
68 
69  /**
70  * Gets value of the attribute
71  *
72  * @return value of the attribute
73  */
74  @Override
75  public Object getValue() {
76  return this.intValue;
77  }
78 
79  /**
80  * Sets value of the attribute. Value should already be a native java Integer value.
81  *
82  * @param value New value of the attribute
83  */
84  @Override
85  public void setValue(Object value) {
86  this.intValue = (Integer) value;
87  }
88 
89 
90  /**
91  * Parses integer represented by string value and sets it as attribute
92  * value
93  *
94  * @param value String with value of type Integer
95  */
96  @Override
97  public void setRawValue(String value) throws IllegalArgumentException {
98  try {
99  this.intValue = Integer.parseInt(value);
100  } catch (NumberFormatException e) {
101  throw new IllegalArgumentException("Value " + value + " is not a valid integer value");
102  }
103  }
104 
105  /**
106  * Gets URI addres in ontology for this type of attribute
107  *
108  * @return Return URI addres in ontology for this type of attribute.
109  */
110  @Override
111  public String getTypeOntologyUri(){
112  return Constants.INTEGER_URI;
113  }
114 }
Class representing suggestion of annotation.
Definition: Suggestion.java:87
SugIntegerAttribute(String name, Integer value, Suggestion refSuggestion, Integer priority)
Class representing attribute of type Integer for prupose of suggestion.