Refactor: introduce Constant class to share String constants
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c541012..f46e69e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -8,6 +8,9 @@
 	<body>

 	    <release version="1.6-SNAPSHOT" date="in Mercurial" description="development">

 	    	<action dev="py4fun" type="update">

+                Refactor: introduce Constant class to share String constants (2010-01-12)

+            </action>

+            <action dev="py4fun" type="update">

                 Keep Tag.equals(String) to simplify transition to Tag class (2010-01-08)

             </action>

             <action dev="py4fun" type="update">

diff --git a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
index e0d0b71..1ebfcf8 100644
--- a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
+++ b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
@@ -44,7 +44,7 @@
 import org.yaml.snakeyaml.events.StreamEndEvent;
 import org.yaml.snakeyaml.events.StreamStartEvent;
 import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.reader.Reader;
+import org.yaml.snakeyaml.scanner.Constant;
 import org.yaml.snakeyaml.util.ArrayStack;
 
 /**
@@ -913,8 +913,8 @@
         }
         // First character or preceded by a whitespace.
         boolean preceededByWhitespace = true;
-        boolean followedByWhitespace = (scalar.length() == 1 || "\0 \t\r\n\u0085\u2029\u2029"
-                .indexOf(scalar.charAt(1)) != -1);
+        boolean followedByWhitespace = (scalar.length() == 1 || Constant.NULL_BL_T_LINEBR
+                .has(scalar.charAt(1)));
         // The previous character is a space.
         boolean previousSpace = false;
 
@@ -959,7 +959,7 @@
                 }
             }
             // Check for line breaks, special, and unicode characters.
-            if (Reader.LINEBR.indexOf(ch) != -1) {
+            if (Constant.LINEBR.has(ch)) {
                 lineBreaks = true;
             }
             if (!(ch == '\n' || ('\u0020' <= ch && ch <= '\u007E'))) {
@@ -986,7 +986,7 @@
                 }
                 previousSpace = true;
                 previousBreak = false;
-            } else if (Reader.LINEBR.indexOf(ch) != -1) {
+            } else if (Constant.LINEBR.has(ch)) {
                 if (index == 0) {
                     leadingBreak = true;
                 }
@@ -1005,9 +1005,9 @@
 
             // Prepare for the next character.
             index++;
-            preceededByWhitespace = ("\0 \t\r" + Reader.LINEBR).indexOf(ch) != -1;
-            followedByWhitespace = (index + 1 >= scalar.length() || ("\0 \t\r" + Reader.LINEBR)
-                    .indexOf(scalar.charAt(index + 1)) != -1);
+            preceededByWhitespace = Constant.NULL_BL_T_LINEBR.has(ch);
+            followedByWhitespace = (index + 1 >= scalar.length() || Constant.NULL_BL_T_LINEBR
+                    .has(scalar.charAt(index + 1)));
         }
         // Let's decide what styles are allowed.
         boolean allowFlowPlain = true;
@@ -1148,7 +1148,7 @@
                     start = end;
                 }
             } else if (breaks) {
-                if (ch == 0 || Reader.LINEBR.indexOf(ch) == -1) {
+                if (ch == 0 || !Constant.LINEBR.has(ch)) {
                     if (text.charAt(start) == '\n') {
                         writeLineBreak(null);
                     }
@@ -1164,7 +1164,7 @@
                     start = end;
                 }
             } else {
-                if (ch == 0 || (" " + Reader.LINEBR).indexOf(ch) != -1 || ch == '\'') {
+                if (Constant.LINEBR.has("\0 \'", ch)) {
                     if (start < end) {
                         String data = text.substring(start, end);
                         this.column += data.length();
@@ -1181,7 +1181,7 @@
             }
             if (ch != 0) {
                 spaces = ch == ' ';
-                breaks = Reader.LINEBR.indexOf(ch) != -1;
+                breaks = Constant.LINEBR.has(ch);
             }
             end++;
         }
@@ -1251,14 +1251,13 @@
     private String determineBlockHints(String text) {
         StringBuffer hints = new StringBuffer();
         if (text != null && text.length() > 0) {
-            if ((" " + Reader.LINEBR).indexOf(text.charAt(0)) != -1) {
+            if (Constant.LINEBR.has(" ", text.charAt(0))) {
                 hints.append(bestIndent);
             }
             char ch1 = text.charAt(text.length() - 1);
-            if (Reader.LINEBR.indexOf(ch1) == -1) {
+            if (!Constant.LINEBR.has(ch1)) {
                 hints.append("-");
-            } else if (text.length() == 1
-                    || (Reader.LINEBR.indexOf(text.charAt(text.length() - 2)) != -1)) {
+            } else if (text.length() == 1 || Constant.LINEBR.has(text.charAt(text.length() - 2))) {
                 hints.append("+");
             }
         }
@@ -1282,7 +1281,7 @@
                 ch = text.charAt(end);
             }
             if (breaks) {
-                if (ch == 0 || (Reader.LINEBR.indexOf(ch) == -1)) {
+                if (ch == 0 || !Constant.LINEBR.has(ch)) {
                     if (!leadingSpace && ch != 0 && ch != ' ' && text.charAt(start) == '\n') {
                         writeLineBreak(null);
                     }
@@ -1312,7 +1311,7 @@
                     start = end;
                 }
             } else {
-                if (ch == 0 || (" " + Reader.LINEBR).indexOf(ch) != -1) {
+                if (Constant.LINEBR.has("\0 ", ch)) {
                     String data = text.substring(start, end);
                     this.column += data.length();
                     stream.write(data);
@@ -1323,7 +1322,7 @@
                 }
             }
             if (ch != 0) {
-                breaks = (Reader.LINEBR.indexOf(ch) != -1);
+                breaks = Constant.LINEBR.has(ch);
                 spaces = (ch == ' ');
             }
             end++;
@@ -1345,7 +1344,7 @@
                 ch = text.charAt(end);
             }
             if (breaks) {
-                if (ch == 0 || Reader.LINEBR.indexOf(ch) == -1) {
+                if (ch == 0 || !Constant.LINEBR.has(ch)) {
                     String data = text.substring(start, end);
                     for (char br : data.toCharArray()) {
                         if (br == '\n') {
@@ -1360,7 +1359,7 @@
                     start = end;
                 }
             } else {
-                if (ch == 0 || Reader.LINEBR.indexOf(ch) != -1) {
+                if (ch == 0 || Constant.LINEBR.has(ch)) {
                     String data = text.substring(start, end);
                     stream.write(data);
                     if (ch == 0) {
@@ -1370,7 +1369,7 @@
                 }
             }
             if (ch != 0) {
-                breaks = (Reader.LINEBR.indexOf(ch) != -1);
+                breaks = (Constant.LINEBR.has(ch));
             }
             end++;
         }
@@ -1412,7 +1411,7 @@
                     start = end;
                 }
             } else if (breaks) {
-                if (Reader.LINEBR.indexOf(ch) == -1) {
+                if (!Constant.LINEBR.has(ch)) {
                     if (text.charAt(start) == '\n') {
                         writeLineBreak(null);
                     }
@@ -1430,7 +1429,7 @@
                     start = end;
                 }
             } else {
-                if (ch == 0 || Reader.LINEBR.indexOf(ch) != -1) {
+                if (ch == 0 || Constant.LINEBR.has(ch)) {
                     String data = text.substring(start, end);
                     this.column += data.length();
                     stream.write(data);
@@ -1439,7 +1438,7 @@
             }
             if (ch != 0) {
                 spaces = (ch == ' ');
-                breaks = (Reader.LINEBR.indexOf(ch) != -1);
+                breaks = (Constant.LINEBR.has(ch));
             }
             end++;
         }
diff --git a/src/main/java/org/yaml/snakeyaml/error/Mark.java b/src/main/java/org/yaml/snakeyaml/error/Mark.java
index f9c3f87..e421185 100644
--- a/src/main/java/org/yaml/snakeyaml/error/Mark.java
+++ b/src/main/java/org/yaml/snakeyaml/error/Mark.java
@@ -15,7 +15,7 @@
  */

 package org.yaml.snakeyaml.error;

 

-import org.yaml.snakeyaml.scanner.ScannerImpl;

+import org.yaml.snakeyaml.scanner.Constant;

 

 /**

  * It's just a record and its only use is producing nice error messages. Parser

@@ -40,7 +40,7 @@
     }

 

     private boolean isLineBreak(char ch) {

-        return ScannerImpl.NULL_OR_LINEBR.indexOf(ch) != -1;

+        return Constant.NULL_OR_LINEBR.has(ch);

     }

 

     public String get_snippet(int indent, int max_length) {

diff --git a/src/main/java/org/yaml/snakeyaml/reader/Reader.java b/src/main/java/org/yaml/snakeyaml/reader/Reader.java
index 27dcf63..abb0607 100644
--- a/src/main/java/org/yaml/snakeyaml/reader/Reader.java
+++ b/src/main/java/org/yaml/snakeyaml/reader/Reader.java
@@ -22,6 +22,7 @@
 

 import org.yaml.snakeyaml.error.Mark;

 import org.yaml.snakeyaml.error.YAMLException;

+import org.yaml.snakeyaml.scanner.Constant;

 

 /**

  * Reader: determines the data encoding and converts it to unicode, checks if

@@ -34,8 +35,6 @@
     // it in case of data corruption

     final static Pattern NON_PRINTABLE = Pattern

             .compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");

-    public final static String LINEBR = "\n\u0085\u2028\u2029";

-

     private String name;

     private final java.io.Reader stream;

     private int pointer = 0;

@@ -93,8 +92,7 @@
             ch = this.buffer.charAt(this.pointer);

             this.pointer++;

             this.index++;

-            if (LINEBR.indexOf(ch) != -1

-                    || (ch == '\r' && this.buffer.charAt(this.pointer) != '\n')) {

+            if (Constant.LINEBR.has(ch) || (ch == '\r' && buffer.charAt(pointer) != '\n')) {

                 this.line++;

                 this.column = 0;

             } else if (ch != '\uFEFF') {

diff --git a/src/main/java/org/yaml/snakeyaml/scanner/Constant.java b/src/main/java/org/yaml/snakeyaml/scanner/Constant.java
new file mode 100644
index 0000000..2067bd2
--- /dev/null
+++ b/src/main/java/org/yaml/snakeyaml/scanner/Constant.java
@@ -0,0 +1,45 @@
+/**

+ * Copyright (c) 2008-2010 Andrey Somov

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.scanner;

+

+public final class Constant {

+    private final static String LINEBR_S = "\n\u0085\u2028\u2029";

+    private final static String FULL_LINEBR_S = "\r" + LINEBR_S;

+    private final static String NULL_OR_LINEBR_S = "\0" + FULL_LINEBR_S;

+    private final static String NULL_BL_LINEBR_S = " " + NULL_OR_LINEBR_S;

+    private final static String NULL_BL_T_LINEBR_S = "\t" + NULL_BL_LINEBR_S;

+

+    public final static Constant LINEBR = new Constant(LINEBR_S);

+    public final static Constant FULL_LINEBR = new Constant(FULL_LINEBR_S);

+    public final static Constant NULL_OR_LINEBR = new Constant(NULL_OR_LINEBR_S);

+    public final static Constant NULL_BL_LINEBR = new Constant(NULL_BL_LINEBR_S);

+    public final static Constant NULL_BL_T_LINEBR = new Constant(NULL_BL_T_LINEBR_S);

+

+    private String content;

+

+    private Constant(String content) {

+        this.content = content;

+    }

+

+    public boolean has(char ch) {

+        return content.indexOf(ch) != -1;

+    }

+

+    public boolean has(String additional, char ch) {

+        return additional.indexOf(ch) != -1 || content.indexOf(ch) != -1;

+    }

+}

diff --git a/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java b/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
index 0d517ea..b142ea8 100644
--- a/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
+++ b/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
@@ -27,7 +27,6 @@
 
 import org.yaml.snakeyaml.error.Mark;
 import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.reader.Reader;
 import org.yaml.snakeyaml.tokens.AliasToken;
 import org.yaml.snakeyaml.tokens.AnchorToken;
 import org.yaml.snakeyaml.tokens.BlockEndToken;
@@ -81,10 +80,6 @@
  * @see <a href="http://pyyaml.org/wiki/PyYAML">PyYAML</a> for more information
  */
 public final class ScannerImpl implements Scanner {
-    private final static String NULL_BL_LINEBR = "\0 \r" + Reader.LINEBR;
-    private final static String NULL_BL_T_LINEBR = "\0 \t\r" + Reader.LINEBR;
-    public final static String NULL_OR_LINEBR = "\0\r" + Reader.LINEBR;
-    private final static String FULL_LINEBR = "\r" + Reader.LINEBR;
     private final static String ALPHA = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
     private final static Pattern NOT_HEXA = Pattern.compile("[^0-9A-Fa-f]");
     public final static Map<Character, String> ESCAPE_REPLACEMENTS = new HashMap<Character, String>();
@@ -881,12 +876,10 @@
         return reader.getColumn() == 0;
     }
 
-    private static final String SPACES = "\0 \t\r" + Reader.LINEBR;
-
     private boolean checkDocumentStart() {
         // DOCUMENT-START: ^ '---' (' '|'\n')
         if (reader.getColumn() == 0) {
-            if ("---".equals(reader.prefix(3)) && SPACES.indexOf(reader.peek(3)) != -1) {
+            if ("---".equals(reader.prefix(3)) && Constant.NULL_BL_T_LINEBR.has(reader.peek(3))) {
                 return true;
             }
         }
@@ -896,7 +889,7 @@
     private boolean checkDocumentEnd() {
         // DOCUMENT-END: ^ '...' (' '|'\n')
         if (reader.getColumn() == 0) {
-            if ("...".equals(reader.prefix(3)) && SPACES.indexOf(reader.peek(3)) != -1) {
+            if ("...".equals(reader.prefix(3)) && Constant.NULL_BL_T_LINEBR.has(reader.peek(3))) {
                 return true;
             }
         }
@@ -905,7 +898,7 @@
 
     private boolean checkBlockEntry() {
         // BLOCK-ENTRY: '-' (' '|'\n')
-        return SPACES.indexOf(reader.peek(1)) != -1;
+        return Constant.NULL_BL_T_LINEBR.has(reader.peek(1));
     }
 
     private boolean checkKey() {
@@ -914,7 +907,7 @@
             return true;
         } else {
             // KEY(block context): '?' (' '|'\n')
-            return SPACES.indexOf(reader.peek(1)) != -1;
+            return Constant.NULL_BL_T_LINEBR.has(reader.peek(1));
         }
     }
 
@@ -924,7 +917,7 @@
             return true;
         } else {
             // VALUE(block context): ':' (' '|'\n')
-            return (SPACES.indexOf(reader.peek(1)) != -1);
+            return Constant.NULL_BL_T_LINEBR.has(reader.peek(1));
         }
     }
 
@@ -946,9 +939,9 @@
          * </pre>
          */
         char ch = reader.peek();
-        return (("\0 \t\r-?:,[]{}#&*!|>\'\"%@`" + Reader.LINEBR).indexOf(ch) == -1 || (("\0 \t\r" + Reader.LINEBR)
-                .indexOf(reader.peek(1)) == -1 && (ch == '-' || (this.flowLevel == 0 && "?:"
-                .indexOf(ch) != -1))));
+        return (!Constant.NULL_BL_T_LINEBR.has("-?:,[]{}#&*!|>\'\"%@`", ch) || !Constant.NULL_BL_T_LINEBR
+                .has(reader.peek(1))
+                && (ch == '-' || (this.flowLevel == 0 && "?:".indexOf(ch) != -1)));
     }
 
     // Scanners.
@@ -984,7 +977,7 @@
                 reader.forward();
             }
             if (reader.peek() == '#') {
-                while (("\0\r" + Reader.LINEBR).indexOf(reader.peek()) == -1) {
+                while (!Constant.NULL_OR_LINEBR.has(reader.peek())) {
                     reader.forward();
                 }
             }
@@ -1013,7 +1006,7 @@
             endMark = reader.getMark();
         } else {
             endMark = reader.getMark();
-            while (("\0\r" + Reader.LINEBR).indexOf(reader.peek()) == -1) {
+            while (!Constant.NULL_OR_LINEBR.has(reader.peek())) {
                 reader.forward();
             }
         }
@@ -1037,7 +1030,7 @@
         String value = reader.prefix(length);
         reader.forward(length);
         ch = reader.peek();
-        if (NULL_BL_LINEBR.indexOf(ch) == -1) {
+        if (!Constant.NULL_BL_LINEBR.has(ch)) {
             throw new ScannerException("while scanning a directive", startMark,
                     "expected alphabetic or numeric character, but found " + ch + "(" + ((int) ch)
                             + ")", reader.getMark());
@@ -1058,7 +1051,7 @@
         }
         reader.forward();
         Integer minor = scanYamlDirectiveNumber(startMark);
-        if (NULL_BL_LINEBR.indexOf(reader.peek()) == -1) {
+        if (!Constant.NULL_BL_LINEBR.has(reader.peek())) {
             throw new ScannerException("while scanning a directive", startMark,
                     "expected a digit or ' ', but found " + reader.peek() + "("
                             + ((int) reader.peek()) + ")", reader.getMark());
@@ -1115,7 +1108,7 @@
     private String scanTagDirectivePrefix(Mark startMark) {
         // See the specification for details.
         String value = scanTagUri("directive", startMark);
-        if (NULL_BL_LINEBR.indexOf(reader.peek()) == -1) {
+        if (!Constant.NULL_BL_LINEBR.has(reader.peek())) {
             throw new ScannerException("while scanning a directive", startMark,
                     "expected ' ', but found " + reader.peek() + "(" + ((int) reader.peek()) + ")",
                     reader.getMark());
@@ -1129,12 +1122,12 @@
             reader.forward();
         }
         if (reader.peek() == '#') {
-            while (NULL_OR_LINEBR.indexOf(reader.peek()) == -1) {
+            while (!Constant.NULL_OR_LINEBR.has(reader.peek())) {
                 reader.forward();
             }
         }
         char ch = reader.peek();
-        if (NULL_OR_LINEBR.indexOf(ch) == -1) {
+        if (!Constant.NULL_OR_LINEBR.has(ch)) {
             throw new ScannerException("while scanning a directive", startMark,
                     "expected a comment or a line break, but found " + ch + "(" + ((int) ch) + ")",
                     reader.getMark());
@@ -1173,7 +1166,7 @@
         String value = reader.prefix(length);
         reader.forward(length);
         ch = reader.peek();
-        if (("\0 \t\r?:,]}%@`" + Reader.LINEBR).indexOf(ch) == -1) {
+        if (!Constant.NULL_BL_T_LINEBR.has("?:,]}%@`", ch)) {
             throw new ScannerException("while scanning an " + name, startMark,
                     "expected alphabetic or numeric character, but found " + ch + "("
                             + ((int) reader.peek()) + ")", reader.getMark());
@@ -1203,13 +1196,13 @@
                                 + ")", reader.getMark());
             }
             reader.forward();
-        } else if (NULL_BL_T_LINEBR.indexOf(ch) != -1) {
+        } else if (Constant.NULL_BL_T_LINEBR.has(ch)) {
             suffix = "!";
             reader.forward();
         } else {
             int length = 1;
             boolean useHandle = false;
-            while (("\0 \r" + Reader.LINEBR).indexOf(ch) == -1) {
+            while (!Constant.NULL_BL_LINEBR.has(ch)) {
                 if (ch == '!') {
                     useHandle = true;
                     break;
@@ -1227,7 +1220,7 @@
             suffix = scanTagUri("tag", startMark);
         }
         ch = reader.peek();
-        if (NULL_BL_LINEBR.indexOf(ch) == -1) {
+        if (!Constant.NULL_BL_LINEBR.has(ch)) {
             throw new ScannerException("while scanning a tag", startMark,
                     "expected ' ', but found '" + ch + "' (" + ((int) ch) + ")", reader.getMark());
         }
@@ -1282,7 +1275,7 @@
             chunks.append(breaks);
             boolean leadingNonSpace = " \t".indexOf(reader.peek()) == -1;
             int length = 0;
-            while (NULL_OR_LINEBR.indexOf(reader.peek(length)) == -1) {
+            while (!Constant.NULL_OR_LINEBR.has(reader.peek(length))) {
                 length++;
             }
             chunks.append(reader.prefix(length));
@@ -1362,7 +1355,7 @@
             }
         }
         ch = reader.peek();
-        if (NULL_BL_LINEBR.indexOf(ch) == -1) {
+        if (!Constant.NULL_BL_LINEBR.has(ch)) {
             throw new ScannerException("while scanning a block scalar", startMark,
                     "expected chomping or indentation indicators, but found " + ch, reader
                             .getMark());
@@ -1376,12 +1369,12 @@
             reader.forward();
         }
         if (reader.peek() == '#') {
-            while (NULL_OR_LINEBR.indexOf(reader.peek()) == -1) {
+            while (!Constant.NULL_OR_LINEBR.has(reader.peek())) {
                 reader.forward();
             }
         }
         char ch = reader.peek();
-        if (NULL_OR_LINEBR.indexOf(ch) == -1) {
+        if (!Constant.NULL_OR_LINEBR.has(ch)) {
             throw new ScannerException("while scanning a block scalar", startMark,
                     "expected a comment or a line break, but found " + ch, reader.getMark());
         }
@@ -1393,7 +1386,7 @@
         StringBuffer chunks = new StringBuffer();
         int maxIndent = 0;
         Mark endMark = reader.getMark();
-        while ((" \r" + Reader.LINEBR).indexOf(reader.peek()) != -1) {
+        while (Constant.LINEBR.has(" \r", reader.peek())) {
             if (reader.peek() != ' ') {
                 chunks.append(scanLineBreak());
                 endMark = reader.getMark();
@@ -1414,7 +1407,7 @@
         while (this.reader.getColumn() < indent && reader.peek() == ' ') {
             reader.forward();
         }
-        while (FULL_LINEBR.indexOf(reader.peek()) != -1) {
+        while (Constant.FULL_LINEBR.has(reader.peek())) {
             chunks.append(scanLineBreak());
             endMark = reader.getMark();
             while (this.reader.getColumn() < indent && reader.peek() == ' ') {
@@ -1460,7 +1453,7 @@
         StringBuffer chunks = new StringBuffer();
         while (true) {
             int length = 0;
-            while (("\'\"\\\0 \t\r" + Reader.LINEBR).indexOf(reader.peek(length)) == -1) {
+            while (!Constant.NULL_BL_T_LINEBR.has("\'\"\\", reader.peek(length))) {
                 length++;
             }
             if (length != 0) {
@@ -1493,7 +1486,7 @@
                     char unicode = (char) Integer.parseInt(val, 16);
                     chunks.append(unicode);
                     reader.forward(length);
-                } else if (FULL_LINEBR.indexOf(ch) != -1) {
+                } else if (Constant.FULL_LINEBR.has(ch)) {
                     scanLineBreak();
                     chunks.append(scanFlowScalarBreaks(startMark));
                 } else {
@@ -1520,7 +1513,7 @@
         if (ch == '\0') {
             throw new ScannerException("while scanning a quoted scalar", startMark,
                     "found unexpected end of stream", reader.getMark());
-        } else if (FULL_LINEBR.indexOf(ch) != -1) {
+        } else if (Constant.FULL_LINEBR.has(ch)) {
             String lineBreak = scanLineBreak();
             String breaks = scanFlowScalarBreaks(startMark);
             if (!"\n".equals(lineBreak)) {
@@ -1543,14 +1536,14 @@
             // separators.
             String prefix = reader.prefix(3);
             if (("---".equals(prefix) || "...".equals(prefix))
-                    && NULL_BL_T_LINEBR.indexOf(reader.peek(3)) != -1) {
+                    && Constant.NULL_BL_T_LINEBR.has(reader.peek(3))) {
                 throw new ScannerException("while scanning a quoted scalar", startMark,
                         "found unexpected document separator", reader.getMark());
             }
             while (" \t".indexOf(reader.peek()) != -1) {
                 reader.forward();
             }
-            if (FULL_LINEBR.indexOf(reader.peek()) != -1) {
+            if (Constant.FULL_LINEBR.has(reader.peek())) {
                 chunks.append(scanLineBreak());
             } else {
                 return chunks.toString();
@@ -1581,9 +1574,9 @@
             }
             while (true) {
                 ch = reader.peek(length);
-                if (("\0 \t\r" + Reader.LINEBR).indexOf(ch) != -1
-                        || (this.flowLevel == 0 && ch == ':' && ("\0 \t\r" + Reader.LINEBR)
-                                .indexOf(reader.peek(length + 1)) != -1)
+                if (Constant.NULL_BL_T_LINEBR.has(ch)
+                        || (this.flowLevel == 0 && ch == ':' && Constant.NULL_BL_T_LINEBR
+                                .has(reader.peek(length + 1)))
                         || (this.flowLevel != 0 && ",:?[]{}".indexOf(ch) != -1)) {
                     break;
                 }
@@ -1591,7 +1584,7 @@
             }
             // It's not clear what we should do with ':' in the flow context.
             if (this.flowLevel != 0 && ch == ':'
-                    && ("\0 \t\r,[]{}" + Reader.LINEBR).indexOf(reader.peek(length + 1)) == -1) {
+                    && !Constant.NULL_BL_T_LINEBR.has(",[]{}", reader.peek(length + 1))) {
                 reader.forward(length);
                 throw new ScannerException("while scanning a plain scalar", startMark,
                         "found unexpected ':'", reader.getMark(),
@@ -1630,23 +1623,23 @@
         String whitespaces = reader.prefix(length);
         reader.forward(length);
         char ch = reader.peek();
-        if (FULL_LINEBR.indexOf(ch) != -1) {
+        if (Constant.FULL_LINEBR.has(ch)) {
             String lineBreak = scanLineBreak();
             this.allowSimpleKey = true;
             String prefix = reader.prefix(3);
             if ("---".equals(prefix) || "...".equals(prefix)
-                    && NULL_BL_T_LINEBR.indexOf(reader.peek(3)) != -1) {
+                    && Constant.NULL_BL_T_LINEBR.has(reader.peek(3))) {
                 return "";
             }
             StringBuffer breaks = new StringBuffer();
-            while ((" \r" + Reader.LINEBR).indexOf(reader.peek()) != -1) {
+            while (Constant.LINEBR.has(" \r", reader.peek())) {
                 if (reader.peek() == ' ') {
                     reader.forward();
                 } else {
                     breaks.append(scanLineBreak());
                     prefix = reader.prefix(3);
                     if ("---".equals(prefix) || "...".equals(prefix)
-                            && NULL_BL_T_LINEBR.indexOf(reader.peek(3)) != -1) {
+                            && Constant.NULL_BL_T_LINEBR.has(reader.peek(3))) {
                         return "";
                     }
                 }
diff --git a/src/test/java/org/yaml/snakeyaml/scanner/ConstantTest.java b/src/test/java/org/yaml/snakeyaml/scanner/ConstantTest.java
new file mode 100644
index 0000000..44c2dbf
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/scanner/ConstantTest.java
@@ -0,0 +1,37 @@
+/**

+ * Copyright (c) 2008-2010 Andrey Somov

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.scanner;

+

+import junit.framework.TestCase;

+

+public class ConstantTest extends TestCase {

+

+    public void testHasChar() {

+        assertTrue(Constant.LINEBR.has('\n'));

+        assertTrue(Constant.LINEBR.has('\u0085'));

+        assertFalse(Constant.LINEBR.has(' '));

+    }

+

+    public void testHasStringChar() {

+        assertTrue(Constant.LINEBR.has(" ", ' '));

+    }

+

+    public void testHas0() {

+        assertTrue(Constant.LINEBR.has("\0", (char) 0));

+    }

+

+}