MCPcopy Create free account
hub / github.com/beanshell/beanshell / stringSetup

Method stringSetup

src/bsh/BSHLiteral.java:97–137  ·  view source on GitHub ↗
(String str)

Source from the content-addressed store, hash-verified

95 }
96
97 void stringSetup(String str)
98 {
99 StringBuilder buffer = new StringBuilder();
100 int len = str.length();
101 for(int i = 0; i < len; i++)
102 {
103 char ch = str.charAt(i);
104 if(ch == '\\')
105 {
106 // get next character
107 ch = str.charAt(++i);
108
109 if(Character.isDigit(ch))
110 {
111 int endPos = i;
112
113 // check the next two characters
114 int max = Math.min( i + 2, len - 1 );
115 while(endPos < max)
116 {
117 if(Character.isDigit(str.charAt(endPos + 1)))
118 endPos++;
119 else
120 break;
121 }
122
123 ch = (char)Integer.parseInt(str.substring(i, endPos + 1), 8);
124 i = endPos;
125 }
126 else
127 ch = getEscapeChar(ch);
128 }
129
130 buffer.append(ch);
131 }
132
133 String s = buffer.toString();
134 if( internStrings )
135 s = s.intern();
136 value = s;
137 }
138}

Callers 1

LiteralMethod · 0.95

Calls 4

getEscapeCharMethod · 0.95
parseIntMethod · 0.80
appendMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected