Constructed.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Constructed.java -- Constructed type.
  2. Copyright (C) 2006 Free Software Foundation, Inc.
  3. This file is a 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 of the License, or (at
  7. your option) 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; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  15. 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.javax.net.ssl.provider;
  32. /**
  33. * The base interface to SSL constructed types.
  34. *
  35. * <p><b>Contract for ByteBuffer-based constructed types:</b>
  36. *
  37. * <p>Most implementations of this interface supported by this library
  38. * take a "view" of an underlying ByteBuffer. The general contract of
  39. * such classes is that they <em>will not</em> modify the position or
  40. * limit of the buffer when doing read operations. That is, the position
  41. * of the underlying buffer <em>should</em> remain at 0 throughout the
  42. * lifetime of the object, and the limit should be either set to the
  43. * capacity of the buffer, or to the size of the object (in most cases,
  44. * the length of the protocol object is determined by the contents of
  45. * the object, so the limit isn't useful in such cases. Of course, if the
  46. * limit is set to something other than the object's length, it must be
  47. * larger than the object length).
  48. *
  49. * <p>Setter methods (usually in a class that implements the {@link Builder}
  50. * interface) may modify the limit, but the general contract remains that
  51. * the position remain at zero, and that the limit be at least as large as
  52. * the object length.
  53. *
  54. * <p>Thus, very often the code will use <em>absolute</em> getters and setters
  55. * for primitive types, or it will use the {@link java.nio.ByteBuffer#duplicate()}
  56. * method, and sometimes the {@link java.nio.ByteBuffer#slice()} method, and
  57. * will change the position or limit of the duplicate buffer.
  58. */
  59. public interface Constructed
  60. {
  61. /**
  62. * Returns the total length, in bytes, of this structure.
  63. *
  64. * @return The length of this structure.
  65. */
  66. int length();
  67. /**
  68. * Returns a printable representation of this structure, with the
  69. * given prefix prepended to each line.
  70. *
  71. * @param prefix The prefix to prepend to each line of the
  72. * output. This value may be <code>null</code>.
  73. * @return A printable representation of this structure.
  74. */
  75. String toString(String prefix);
  76. }