Desktop tool for browsing account info from EVE-Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Parent.java 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*--
  2. $Id: Parent.java,v 1.13 2007/11/10 05:28:59 jhunter Exp $
  3. Copyright (C) 2000-2007 Jason Hunter & Brett McLaughlin.
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions, and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions, and the disclaimer that follows
  12. these conditions in the documentation and/or other materials
  13. provided with the distribution.
  14. 3. The name "JDOM" must not be used to endorse or promote products
  15. derived from this software without prior written permission. For
  16. written permission, please contact <request_AT_jdom_DOT_org>.
  17. 4. Products derived from this software may not be called "JDOM", nor
  18. may "JDOM" appear in their name, without prior written permission
  19. from the JDOM Project Management <request_AT_jdom_DOT_org>.
  20. In addition, we request (but do not require) that you include in the
  21. end-user documentation provided with the redistribution and/or in the
  22. software itself an acknowledgement equivalent to the following:
  23. "This product includes software developed by the
  24. JDOM Project (http://www.jdom.org/)."
  25. Alternatively, the acknowledgment may be graphical using the logos
  26. available at http://www.jdom.org/images/logos.
  27. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  28. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
  31. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  34. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  35. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  36. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38. SUCH DAMAGE.
  39. This software consists of voluntary contributions made by many
  40. individuals on behalf of the JDOM Project and was originally
  41. created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
  42. Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
  43. on the JDOM Project, please see <http://www.jdom.org/>.
  44. */
  45. package org.jdom;
  46. import java.io.Serializable;
  47. import java.util.*;
  48. import org.jdom.filter.Filter;
  49. /**
  50. * Superclass for JDOM objects which are allowed to contain
  51. * {@link Content} content.
  52. *
  53. * @see org.jdom.Content
  54. * @see org.jdom.Document
  55. * @see org.jdom.Element
  56. *
  57. * @author Bradley S. Huffman
  58. * @author Jason Hunter
  59. * @version $Revision: 1.13 $, $Date: 2007/11/10 05:28:59 $
  60. */
  61. public interface Parent extends Cloneable, Serializable {
  62. /**
  63. * Returns the number of children in this parent's content list.
  64. * Children may be any {@link Content} type.
  65. *
  66. * @return number of children
  67. */
  68. int getContentSize();
  69. /**
  70. * Returns the index of the supplied child in the content list,
  71. * or -1 if not a child of this parent.
  72. *
  73. * @param child child to search for
  74. * @return index of child, or -1 if not found
  75. */
  76. int indexOf(Content child);
  77. // /**
  78. // * Starting at the given index (inclusive), returns the index of
  79. // * the first child matching the supplied filter, or -1
  80. // * if none is found.
  81. // *
  82. // * @return index of child, or -1 if none found
  83. // */
  84. // int indexOf(int index, Filter filter);
  85. /**
  86. * Returns a list containing detached clones of this parent's content list.
  87. *
  88. * @return list of cloned child content
  89. */
  90. List cloneContent();
  91. /**
  92. * Returns the child at the given index.
  93. *
  94. * @param index location of desired child
  95. * @return child at the given index
  96. * @throws IndexOutOfBoundsException if index is negative or beyond
  97. * the current number of children
  98. * @throws IllegalStateException if parent is a Document
  99. * and the root element is not set
  100. */
  101. Content getContent(int index);
  102. /**
  103. * Returns the full content of this parent as a {@link java.util.List}
  104. * which contains objects of type {@link Content}. The returned list is
  105. * <b>"live"</b> and in document order. Any modifications
  106. * to it affect the element's actual contents. Modifications are checked
  107. * for conformance to XML 1.0 rules.
  108. * <p>
  109. * Sequential traversal through the List is best done with an Iterator
  110. * since the underlying implement of {@link java.util.List#size} may
  111. * require walking the entire list and indexed lookups may require
  112. * starting at the beginning each time.
  113. *
  114. * @return a list of the content of the parent
  115. * @throws IllegalStateException if parent is a Document
  116. * and the root element is not set
  117. */
  118. List getContent();
  119. /**
  120. * Returns as a {@link java.util.List} the content of
  121. * this parent that matches the supplied filter. The returned list is
  122. * <b>"live"</b> and in document order. Any modifications to it affect
  123. * the element's actual contents. Modifications are checked for
  124. * conformance to XML 1.0 rules.
  125. * <p>
  126. * Sequential traversal through the List is best done with an Iterator
  127. * since the underlying implement of {@link java.util.List#size} may
  128. * require walking the entire list and indexed lookups may require
  129. * starting at the beginning each time.
  130. *
  131. * @param filter filter to apply
  132. * @return a list of the content of the parent matching the filter
  133. * @throws IllegalStateException if parent is a Document
  134. * and the root element is not set
  135. */
  136. List getContent(Filter filter);
  137. /**
  138. * Removes all content from this parent and returns the detached
  139. * children.
  140. *
  141. * @return list of the old content detached from this parent
  142. */
  143. List removeContent();
  144. /**
  145. * Removes from this parent all child content matching the given filter
  146. * and returns a list of the detached children.
  147. *
  148. * @param filter filter to apply
  149. * @return list of the detached children matching the filter
  150. */
  151. List removeContent(Filter filter);
  152. /**
  153. * Removes a single child node from the content list.
  154. *
  155. * @param child child to remove
  156. * @return whether the removal occurred
  157. */
  158. boolean removeContent(Content child);
  159. /**
  160. * Removes and returns the child at the given
  161. * index, or returns null if there's no such child.
  162. *
  163. * @param index index of child to remove
  164. * @return detached child at given index or null if no
  165. * @throws IndexOutOfBoundsException if index is negative or beyond
  166. * the current number of children
  167. */
  168. Content removeContent(int index);
  169. /**
  170. * Obtain a deep, unattached copy of this parent and it's children.
  171. *
  172. * @return a deep copy of this parent and it's children.
  173. */
  174. Object clone();
  175. /**
  176. * Returns an {@link java.util.Iterator} that walks over all descendants
  177. * in document order.
  178. *
  179. * @return an iterator to walk descendants
  180. */
  181. Iterator getDescendants();
  182. /**
  183. * Returns an {@link java.util.Iterator} that walks over all descendants
  184. * in document order applying the Filter to return only elements that
  185. * match the filter rule. With filters you can match only Elements,
  186. * only Comments, Elements or Comments, only Elements with a given name
  187. * and/or prefix, and so on.
  188. *
  189. * @param filter filter to select which descendants to see
  190. * @return an iterator to walk descendants that match a filter
  191. */
  192. Iterator getDescendants(Filter filter);
  193. /**
  194. * Return this parent's parent, or null if this parent is currently
  195. * not attached to another parent. This is the same method as in Content but
  196. * also added to Parent to allow more easy up-the-tree walking.
  197. *
  198. * @return this parent's parent or null if none
  199. */
  200. Parent getParent();
  201. /**
  202. * Return this parent's owning document or null if the branch containing
  203. * this parent is currently not attached to a document.
  204. *
  205. * @return this child's owning document or null if none
  206. */
  207. Document getDocument();
  208. }