1 18 package org.apache.roller.webservices.adminapi.sdk; 19 20 import java.util.Arrays ; 21 import java.util.List ; 22 import org.jdom.Document; 23 import org.jdom.Element; 24 25 31 public abstract class EntrySet extends Entry { 32 33 public static interface Types { 34 38 public static final String USERS = "users"; 39 44 public static final String WEBLOGS = "weblogs"; 45 50 public static final String MEMBERS = "members"; 51 60 public static final String SERVICE = "service"; 61 62 public static final String WORKSPACE = "workspace"; 63 } 64 65 private List entries = null; 66 67 68 public abstract String getType(); 69 70 71 public Entry[] getEntries() { 72 return (Entry[])entries.toArray(new Entry[0]); 73 } 74 75 76 public void setEntries(Entry[] entryArray) { 77 entries = Arrays.asList(entryArray); 78 } 79 80 81 public boolean isEmpty() { 82 return entries == null || entries.size() == 0; 83 } 84 85 86 public Document toDocument() { 87 Element e = new Element(getType(), NAMESPACE); 88 Document doc = new Document(e); 89 90 e.setAttribute(Attributes.HREF, getHref()); 92 93 for (int i = 0; i < getEntries().length; i++) { 95 e.addContent(getEntries()[i].toDocument().detachRootElement()); 96 } 97 98 return doc; 99 } 100 101 public boolean equals(Object o) { 102 if ( o == null || o.getClass() != this.getClass()) { 103 return false; 104 } 105 106 EntrySet other = (EntrySet)o; 107 108 if (!areEqual(getHref(), other.getHref())) { 109 return false; 110 } 111 if (!areEqual(getType(), other.getType())) { 112 return false; 113 } 114 if (!areEqual(getEntries(), other.getEntries())) { 115 return false; 116 } 117 118 return true; 119 } 120 } 121 | Popular Tags |