/xmlenc-0.52/src/main/org/znerd/xmlenc/LineBreak.java

# · Java · 89 lines · 16 code · 16 blank · 57 comment · 0 complexity · 46898aea86e0dd28a1089441ee503e7f MD5 · raw file

  1. /*
  2. * $Id: LineBreak.java,v 1.3 2005/09/12 08:40:02 znerd Exp $
  3. */
  4. package org.znerd.xmlenc;
  5. /**
  6. * Enumeration type for line breaks.
  7. *
  8. * @version $Revision: 1.3 $ $Date: 2005/09/12 08:40:02 $
  9. * @author Jochen Schwoerer (j.schwoerer [at] web.de)
  10. * @author Ernst de Haan (<a href="mailto:wfe.dehaan@gmail.com">wfe.dehaan@gmail.com</a>)
  11. *
  12. * @since xmlenc 0.35
  13. */
  14. public final class LineBreak {
  15. //-------------------------------------------------------------------------
  16. // Class fields
  17. //-------------------------------------------------------------------------
  18. //-------------------------------------------------------------------------
  19. // Class functions
  20. //-------------------------------------------------------------------------
  21. //-------------------------------------------------------------------------
  22. // Constructors
  23. //-------------------------------------------------------------------------
  24. /**
  25. * Constructs a new <code>LineBreak</code> that consists of the specified
  26. * characters.
  27. *
  28. * @param lineBreak
  29. * the characters the line break consists of.
  30. */
  31. private LineBreak(String lineBreak) {
  32. _lineBreak = lineBreak;
  33. _lineBreakChars = lineBreak.toCharArray();
  34. }
  35. //-------------------------------------------------------------------------
  36. // Fields
  37. //-------------------------------------------------------------------------
  38. /**
  39. * The characters this line break consists of. This field is initialized by
  40. * the constructor.
  41. */
  42. private final String _lineBreak;
  43. /**
  44. * A character array containing the characters this line break consists of.
  45. * This field is initialized by the constructor.
  46. */
  47. final char[] _lineBreakChars;
  48. //-------------------------------------------------------------------------
  49. // Methods
  50. //-------------------------------------------------------------------------
  51. /**
  52. * Empty line break. This is equivalent to using no line breaks.
  53. */
  54. public static final LineBreak NONE = new LineBreak("");
  55. /**
  56. * Unix and MacOS/X line break. This represents the string <code>"\n"</code>.
  57. */
  58. public static final LineBreak UNIX = new LineBreak("\n");
  59. /**
  60. * DOS and Windows line break. This represents the string <code>"\r\n"</code>.
  61. */
  62. public static final LineBreak DOS = new LineBreak("\r\n");
  63. /**
  64. * MacOS line break. This represents the string <code>"\r"</code>.
  65. *
  66. * <p>This applies to all MacOS versions before MacOS/X. Use
  67. * {@link #UNIX} as the MacOS/X line break.
  68. */
  69. public static final LineBreak MACOS = new LineBreak("\r");
  70. public String toString() {
  71. return _lineBreak;
  72. }
  73. };