• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2009 The Android Open Source Project
2 
3 package com.google.wireless.gdata2.data;
4 
5 import com.google.wireless.gdata2.parser.ParseException;
6 
7 /**
8  * The extendedProperty gdata type
9  * Allows you to store a limited amount of custom data as an auxiliary
10  * property of the enclosing entity.
11  * Note that the presence of anyForeignElement allows feed to optionally
12  * embed any valid XML within gd:extendedProperty element
13  * (mutually exclusive with value attribute).
14  */
15 public class ExtendedProperty {
16   private String name;
17   private String value;
18   private String xmlBlob;
19 
ExtendedProperty()20   public ExtendedProperty() {}
ExtendedProperty(String name, String value, String xmlBlob)21   public ExtendedProperty(String name, String value, String xmlBlob) {
22       this.name = name;
23       this.value = value;
24       this.xmlBlob = xmlBlob;
25   }
26 
27   /**
28    * Returns the xml embedded inside the extended property
29    * element
30    * Mutually exclusive with the value property
31    * @return the xml as a string
32    */
getXmlBlob()33   public String getXmlBlob() {
34     return xmlBlob;
35   }
36 
37   /**
38    * Sets the embedded xml for the extended property element.
39    * Mutually exclusive with the value property
40    * @param xmlBlob xml as a string
41    */
setXmlBlob(String xmlBlob)42   public void setXmlBlob(String xmlBlob) {
43     this.xmlBlob = xmlBlob;
44   }
45 
46   /**
47    * @return the name of the extended property expressed as a URI. Extended
48    * property URIs usually follow the {scheme}#{local-name} convention.
49    */
getName()50   public String getName() {
51     return name;
52   }
53 
54   /**
55    * @param name set's the name of the extended property
56    */
setName(String name)57   public void setName(String name) {
58     this.name = name;
59   }
60 
61   /**
62    * Returns the value attribute of the extended property
63    * element.Mutually exclusive with the xmlBlob property
64    * @return the value
65    */
getValue()66   public String getValue() {
67     return value;
68   }
69 
70   /**
71    * Sets the value attribute of the extended property. Mutually
72    * exclusive with the xmlBlog property
73    * @param value
74    */
setValue(String value)75   public void setValue(String value) {
76     this.value = value;
77   }
78 
toString(StringBuffer sb)79   public void toString(StringBuffer sb) {
80     sb.append("ExtendedProperty");
81     if (name != null) sb.append(" name:").append(name);
82     if (value != null) sb.append(" value:").append(value);
83     if (xmlBlob != null) sb.append(" xmlBlob:").append(xmlBlob);
84   }
85 
validate()86   public void validate() throws ParseException {
87     if (name == null) {
88       throw new ParseException("name must not be null");
89     }
90 
91     if ((value == null && xmlBlob == null) || (value != null && xmlBlob != null)) {
92       throw new ParseException("exactly one of value and xmlBlob must be present");
93     }
94   }
95 }
96