/rg/pkg/kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeCharacterData.java

https://github.com/GunioRobot/MI424WR_GEN2_Rev_E-F · Java · 117 lines · 62 code · 14 blank · 41 comment · 0 complexity · 56e7290f64754503e942f8a95eecb0ca MD5 · raw file

  1. /* GnomeCharacterData.java -
  2. Copyright (C) 2004 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package gnu.xml.libxmlj.dom;
  32. import org.w3c.dom.CharacterData;
  33. import org.w3c.dom.DOMException;
  34. /**
  35. * A DOM character data node implemented in libxml2.
  36. *
  37. * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
  38. */
  39. abstract class GnomeCharacterData
  40. extends GnomeNode
  41. implements CharacterData
  42. {
  43. GnomeCharacterData(Object id)
  44. {
  45. super(id);
  46. }
  47. public String getData()
  48. throws DOMException
  49. {
  50. return getNodeValue();
  51. }
  52. public void setData(String data)
  53. throws DOMException
  54. {
  55. setNodeValue(data);
  56. }
  57. public int getLength()
  58. {
  59. return getData().length();
  60. }
  61. public String substringData(int offset, int count)
  62. throws DOMException
  63. {
  64. return getData().substring(offset, offset + count);
  65. }
  66. public void appendData(String arg)
  67. throws DOMException
  68. {
  69. setData(getData() + arg);
  70. }
  71. public void insertData(int offset, String arg)
  72. throws DOMException
  73. {
  74. String data = getData();
  75. setData(data.substring(0, offset) + arg + data.substring(offset));
  76. }
  77. public void deleteData(int offset, int count)
  78. throws DOMException
  79. {
  80. String data = getData();
  81. setData(data.substring(0, offset) + data.substring(offset + count));
  82. }
  83. public void replaceData(int offset, int count, String arg)
  84. {
  85. String data = getData();
  86. setData(data.substring(0, offset) + arg +
  87. data.substring(offset + count));
  88. }
  89. public String toString()
  90. {
  91. StringBuffer buffer = new StringBuffer(getClass().getName());
  92. buffer.append("[data=");
  93. buffer.append(getData());
  94. buffer.append("]");
  95. return buffer.toString();
  96. }
  97. }