use of org.mvel2.util.StringAppender in project mvel by mvel.
the class ASMAccessorOptimizer method buildInputs.
private void buildInputs() {
if (compiledInputs.size() == 0)
return;
assert debug("\n{SETTING UP MEMBERS...}\n");
StringAppender constSig = new StringAppender("(");
int size = compiledInputs.size();
for (int i = 0; i < size; i++) {
assert debug("ACC_PRIVATE p" + i);
cw.visitField(ACC_PRIVATE, "p" + i, "L" + NAMESPACE + "compiler/ExecutableStatement;", null, null).visitEnd();
constSig.append("L" + NAMESPACE + "compiler/ExecutableStatement;");
}
constSig.append(")V");
assert debug("\n{CREATING INJECTION CONSTRUCTOR}\n");
MethodVisitor cv = cw.visitMethod(ACC_PUBLIC, "<init>", constSig.toString(), null, null);
cv.visitCode();
assert debug("ALOAD 0");
cv.visitVarInsn(ALOAD, 0);
assert debug("INVOKESPECIAL java/lang/Object.<init>");
cv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
for (int i = 0; i < size; i++) {
assert debug("ALOAD 0");
cv.visitVarInsn(ALOAD, 0);
assert debug("ALOAD " + (i + 1));
cv.visitVarInsn(ALOAD, i + 1);
assert debug("PUTFIELD p" + i);
cv.visitFieldInsn(PUTFIELD, className, "p" + i, "L" + NAMESPACE + "compiler/ExecutableStatement;");
}
assert debug("RETURN");
cv.visitInsn(RETURN);
cv.visitMaxs(0, 0);
cv.visitEnd();
assert debug("}");
}
use of org.mvel2.util.StringAppender in project mvel by mvel.
the class ObjectInspector method renderClassHeirarchy.
private static String renderClassHeirarchy(Class cls) {
List<String> list = new LinkedList<String>();
list.add(cls.getName());
while ((cls = cls.getSuperclass()) != null) {
list.add(cls.getName());
}
StringAppender output = new StringAppender();
for (int i = list.size() - 1; i != -1; i--) {
output.append(list.get(i));
if ((i - 1) != -1)
output.append(" -> ");
}
return output.toString();
}
use of org.mvel2.util.StringAppender in project mvel by mvel.
the class StringAppenderTest method testToCharsUnsupportedEncoding.
@Test
public void testToCharsUnsupportedEncoding() {
final StringAppender stringAppender = new StringAppender(0, "invalid");
stringAppender.append("a".getBytes()[0]);
final char[] expected = new char[15];
expected[0] = 'a';
Assert.assertArrayEquals(expected, stringAppender.toChars());
}
use of org.mvel2.util.StringAppender in project mvel by mvel.
the class StringAppenderTest method testGetChars.
@Test
public void testGetChars() {
final StringAppender stringAppender = new StringAppender(new StringBuffer("abc"));
Assert.assertArrayEquals(new char[] { 'a', 'b', 'c' }, stringAppender.getChars(0, 3));
}
use of org.mvel2.util.StringAppender in project mvel by mvel.
the class StringAppenderTest method testAppendCharArrSubSequence.
@Test
public void testAppendCharArrSubSequence() {
final StringAppender stringAppender = new StringAppender(new char[] { 'a' });
stringAppender.append(new char[] { 'b', 'c', 'd' }, 1, 2);
stringAppender.append(new char[] { 'e' }, 1, 0);
Assert.assertEquals("acd", stringAppender.toString());
}
Aggregations