4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SugDecimalAttribute.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: SugDecimalAttribute.java
5  * Description: Class representing attribute of type Decimal for prupose of suggestion
6  */
7 
8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
9 
11 import java.math.BigDecimal;
12 import javax.persistence.DiscriminatorValue;
13 import javax.persistence.Entity;
14 import javax.persistence.NamedQueries;
15 import javax.persistence.NamedQuery;
16 
17 /**
18  * @file SugDecimalAttribute.java
19  *
20  * @brief Class representing attribute of type Decimal for prupose of suggestion
21  */
22 
23 /**
24  * Class representing attribute of type Decimal for prupose of suggestion
25  *
26  * @brief Class representing attribute of type Decimal for prupose of suggestion
27  */
28 @Entity
29 @DiscriminatorValue("Decimal")
30 @NamedQueries({
31  @NamedQuery(name = "SuggestionAttribute.findByDecValue", query = "SELECT a FROM SuggestionAttribute a WHERE a.decValue = :decValue"),
32 })
33 public class SugDecimalAttribute extends SugBaseAttribute {
34 
35  /**
36  * Gets value of the attribute
37  *
38  * @return value of the attribute
39  */
40  @Override
41  public Object getValue() {
42  return this.decValue;
43  }
44 
45  /**
46  * Sets value of the attribute. Value should already be a native java BigDecimal value.
47  *
48  * @param value new value of the attribute
49  */
50  @Override
51  public void setValue(Object value) {
52  this.decValue = (BigDecimal) value;
53  }
54 
55  /**
56  * Parses BigDecimal value represented by string value and sets it as
57  * attribute value
58  *
59  * @param value String representing BigDecimal value
60  */
61  @Override
62  public void setRawValue(String value) throws IllegalArgumentException {
63  try {
64  this.decValue = new BigDecimal(value);
65  } catch (NumberFormatException e) {
66  throw new IllegalArgumentException("Value " + value + " is not a valid Decimal value");
67  }
68  }
69 
70  /**
71  * Gets URI addres in ontology for this type of attribute
72  *
73  * @return Return URI addres in ontology for this type of attribute.
74  */
75  @Override
76  public String getTypeOntologyUri(){
77  return Constants.DECIMAL_URI;
78  }
79 }
Class representing attribute of type Decimal for prupose of suggestion.