4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SugBinaryAttribute.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: SugBinaryAttribute.java
5  * Description: Class representing attribute of type Binary for prupose of suggestion
6  */
7 
8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
9 
11 import javax.persistence.DiscriminatorValue;
12 import javax.persistence.Entity;
13 
14 /**
15  * @file SugBinaryAttribute.java
16  *
17  * @brief Class representing attribute of type Binary for prupose of suggestion
18  */
19 
20 /**
21  * Class representing attribute of type Binary for prupose of suggestion
22  *
23  * @brief Class representing attribute of type Binary for prupose of suggestion
24  */
25 @Entity
26 @DiscriminatorValue("Binary")
27 public class SugBinaryAttribute extends SugBaseAttribute {
28  /**
29  * Sets value of the attribute. Value should already be a native java value.
30  *
31  * @param value new value of the attribute
32  */
33  @Override
34  public void setValue(Object value) {
35  this.binValue = (byte[]) value;
36  }
37 
38  /**
39  * Gets value of the attribute
40  *
41  * @return value of the attribute
42  */
43  @Override
44  public Object getValue() {
45  return (Object) this.binValue;
46  }
47 
48 
49  /**
50  * Converts string value, which should be encoded in base64 and sets its
51  * binary representation as attribute value
52  *
53  * @param value Value of attribute encoded in base64
54  */
55  @Override
56  public void setRawValue(String value) throws IllegalArgumentException {
57  this.binValue = org.apache.commons.codec.binary.Base64.decodeBase64(value);
58  }
59 
60 
61  /**
62  * Formats attribute value for XML.
63  *
64  * @return base64 encoded attribute value
65  */
66  @Override
67  protected String xmlFormatValue() {
68  if (this.binValue == null) {
69  return "";
70  }
71  return org.apache.commons.codec.binary.Base64.encodeBase64String(this.binValue);
72  }
73 
74  /**
75  * Gets URI address in ontology for this type of attribute
76  *
77  * @return Return URI address in ontology for this type of attribute.
78  */
79  @Override
80  public String getTypeOntologyUri(){
81  return Constants.BINARY_URI;
82  }
83 }
Class representing attribute of type Binary for prupose of suggestion.