1. /*
  2. * @(#)Element.java 1.15 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.text;
  8. /**
  9. * Interface to describe a structural piece of a document. It
  10. * is intended to capture the spirit of an SGML element.
  11. *
  12. * @author Timothy Prinzing
  13. * @version 1.15 11/29/01
  14. */
  15. public interface Element {
  16. /**
  17. * Fetches the document associated with this element.
  18. *
  19. * @return the document
  20. */
  21. public Document getDocument();
  22. /**
  23. * Fetches the parent element. If the element is a root level
  24. * element returns null.
  25. *
  26. * @return the parent element
  27. */
  28. public Element getParentElement();
  29. /**
  30. * Fetches the name of the element. If the element is used to
  31. * represent some type of structure, this would be the type
  32. * name.
  33. *
  34. * @return the element name
  35. */
  36. public String getName();
  37. /**
  38. * Fetches the collection of attributes this element contains.
  39. *
  40. * @return the attributes for the element
  41. */
  42. public AttributeSet getAttributes();
  43. /**
  44. * Fetches the offset from the beginning of the document
  45. * that this element begins at. If this element has
  46. * children, this will be the offset of the first child.
  47. *
  48. * @return the starting offset >= 0
  49. */
  50. public int getStartOffset();
  51. /**
  52. * Fetches the offset from the beginning of the document
  53. * that this element ends at. If this element has
  54. * children, this will be the end offset of the last child.
  55. *
  56. * @return the ending offset >= 0
  57. */
  58. public int getEndOffset();
  59. /**
  60. * Gets the child element index closest to the given offset.
  61. * The offset is specified relative to the begining of the
  62. * document.
  63. *
  64. * @param offset the specified offset >= 0
  65. * @return the element index >= 0
  66. */
  67. public int getElementIndex(int offset);
  68. /**
  69. * Gets the number of child elements contained by this element.
  70. * If this element is a leaf, a count of zero is returned.
  71. *
  72. * @return the number of child elements >= 0
  73. */
  74. public int getElementCount();
  75. /**
  76. * Fetches the child element at the given index.
  77. *
  78. * @param index the specified index >= 0
  79. * @return the child element
  80. */
  81. public Element getElement(int index);
  82. /**
  83. * Is this element a leaf element?
  84. *
  85. * @return true if a leaf element else false
  86. */
  87. public boolean isLeaf();
  88. }