test_class.declarator: escapeHandler
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected HerdCharacterEscapeHandler escapeHandler;
test_class.type: HerdCharacterEscapeHandler
test_class.var_name: escapeHandler
test_class.declarator: TEST_BUFFER = "A<>&\"'\u0001\t"
test_class.modifier: private static final
test_class.original_string: private static final String TEST_BUFFER = "A<>&\"'\u0001\t";
test_class.type: String
test_class.var_name: TEST_BUFFER
test_class.file: herd-code/herd-dao/src/test/java/org/finra/herd/dao/helper/HerdCharacterEscapeHandlerTest.java
test_class.identifier: HerdCharacterEscapeHandlerTest
test_class.superclass: extends AbstractDaoTest
test_case.body: @Test
      public void testEscapeNoAttribute() throws Exception
      {
          // "No attribute" doesn't escape double and single quotes.
          StringWriter writer = new StringWriter();
          escapeHandler.escape(TEST_BUFFER.toCharArray(), 0, TEST_BUFFER.length(), false, writer);
          assertEquals("A&lt;&gt;&amp;\"'&#x1;\t", writer.toString());
      }
test_case.class_method_signature: HerdCharacterEscapeHandlerTest.testEscapeNoAttribute()
test_case.full_signature: @Test public void testEscapeNoAttribute()
test_case.identifier: testEscapeNoAttribute
test_case.invocations: escape toCharArray length assertEquals toString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEscapeNoAttribute()
focal_class.file: herd-code/herd-dao/src/main/java/org/finra/herd/dao/helper/HerdCharacterEscapeHandler.java
focal_class.identifier: HerdCharacterEscapeHandler
focal_class.interfaces: implements CharacterEscapeHandler
focal_class.class_method_signature: HerdCharacterEscapeHandler.escape(char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)
focal_class.full_signature: @Override public void escape(char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)
focal_class.identifier: escape
focal_class.modifiers: @Override public
focal_class.parameters: (char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)
focal_class.return: void
focal_class.signature: void escape(char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)
focal_class.class_method_signature: HerdCharacterEscapeHandler.isXml11RestrictedCharacter(char ch)
focal_class.full_signature: public static boolean isXml11RestrictedCharacter(char ch)
focal_class.identifier: isXml11RestrictedCharacter
focal_class.modifiers: public static
focal_class.parameters: (char ch)
focal_class.return: boolean
focal_class.signature: boolean isXml11RestrictedCharacter(char ch)
focal_method.body: @Override
      public void escape(char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter) throws IOException
      {
          // Loop through all characters in the buffer starting at "start" and going until the length has been reached.
          for (int i = start; i < start + length; i++)
          {
              // Grab a character in the buffer.
              char ch = buffer[i];
  
              // Handle the standard XML tag escaping.
              if (ch == '&')
              {
                  outputWriter.write("&amp;");
                  continue;
              }
              if (ch == '<')
              {
                  outputWriter.write("&lt;");
                  continue;
              }
              if (ch == '>')
              {
                  outputWriter.write("&gt;");
                  continue;
              }
  
              // Handle the single and double quote characters when attributes are present.
              if (ch == '"' && isAttributeValue)
              {
                  outputWriter.write("&quot;");
                  continue;
              }
              if (ch == '\'' && isAttributeValue)
              {
                  outputWriter.write("&apos;");
                  continue;
              }
  
              // Escape the character if it's XML 1.1 restricted.
              if (isXml11RestrictedCharacter(ch))
              {
                  outputWriter.write("&#x");
                  outputWriter.write(Integer.toHexString(ch));
                  outputWriter.write(";");
                  continue;
              }
  
              // In all other cases, output the character as is.
              outputWriter.write(ch);
          }
      }
focal_method.class_method_signature: HerdCharacterEscapeHandler.escape(char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)
focal_method.full_signature: @Override public void escape(char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)
focal_method.identifier: escape
focal_method.invocations: write write write write write isXml11RestrictedCharacter write write toHexString write write
focal_method.modifiers: @Override public
focal_method.parameters: (char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)
focal_method.return: void
focal_method.signature: void escape(char[] buffer, int start, int length, boolean isAttributeValue, Writer outputWriter)