Example #1
0
 private Category parseCategory(final String baseURI, final Element eCategory) {
   final Category category = new Category();
   String att = getAttributeValue(eCategory, "term");
   if (att != null) {
     category.setTerm(att);
   }
   att = getAttributeValue(eCategory, "scheme");
   if (att != null) {
     category.setScheme(att);
     if (isRelativeURI(att)) {
       category.setSchemeResolved(resolveURI(baseURI, eCategory, att));
     }
   }
   att = getAttributeValue(eCategory, "label");
   if (att != null) {
     category.setLabel(att);
   }
   return category;
 }
  protected Element generateCategoryElement(Category cat) {
    Element catElement = new Element("category", getFeedNamespace());

    if (cat.getTerm() != null) {
      Attribute termAttribute = new Attribute("term", cat.getTerm());
      catElement.setAttribute(termAttribute);
    }

    if (cat.getLabel() != null) {
      Attribute labelAttribute = new Attribute("label", cat.getLabel());
      catElement.setAttribute(labelAttribute);
    }

    if (cat.getScheme() != null) {
      Attribute schemeAttribute = new Attribute("scheme", cat.getScheme());
      catElement.setAttribute(schemeAttribute);
    }
    return catElement;
  }