MCPcopy
hub / github.com/alibaba/druid / scanString2

Method scanString2

core/src/main/java/com/alibaba/druid/sql/parser/Lexer.java:1800–1901  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1798 }
1799
1800 protected final void scanString2() {
1801 {
1802 boolean hasSpecial = false;
1803 int startIndex = pos + 1;
1804 int endIndex = -1; // text.indexOf('\'', startIndex);
1805 for (int i = startIndex; i < text.length(); ++i) {
1806 final char ch = text.charAt(i);
1807 if (ch == '\\') {
1808 hasSpecial = true;
1809 continue;
1810 }
1811 if (ch == '\'') {
1812 endIndex = i;
1813 break;
1814 }
1815 }
1816
1817 if (endIndex == -1) {
1818 throw new ParserException("unclosed str. " + info());
1819 }
1820
1821 String stringVal;
1822 if (token == Token.AS) {
1823 stringVal = text.substring(pos, endIndex + 1);
1824 } else {
1825 if (startIndex == endIndex) {
1826 stringVal = "";
1827 } else {
1828 stringVal = text.substring(startIndex, endIndex);
1829 }
1830 }
1831 // hasSpecial = stringVal.indexOf('\\') != -1;
1832
1833 if (!hasSpecial) {
1834 this.stringVal = stringVal;
1835 int pos = endIndex + 1;
1836 char ch = charAt(pos);
1837 if (ch != '\'') {
1838 this.pos = pos;
1839 this.ch = ch;
1840 token = LITERAL_CHARS;
1841 return;
1842 }
1843 }
1844 }
1845
1846 mark = pos;
1847 boolean hasSpecial = false;
1848 for (; ; ) {
1849 if (isEOF()) {
1850 lexError("unclosed.str.lit");
1851 return;
1852 }
1853
1854 ch = charAt(++pos);
1855
1856 if (ch == '\\') {
1857 scanChar();

Callers 1

scanSingleQuoteModeMethod · 0.80

Calls 12

charAtMethod · 0.95
infoMethod · 0.95
isEOFMethod · 0.95
lexErrorMethod · 0.95
scanCharMethod · 0.95
initBuffMethod · 0.95
arraycopyMethod · 0.95
putCharMethod · 0.95
subStringMethod · 0.95
substringMethod · 0.80
lengthMethod · 0.45

Tested by 1

scanSingleQuoteModeMethod · 0.64