|
|
@@ -11,11 +11,7 @@ package net.ranides.assira.text;
|
|
|
|
|
|
import java.io.Reader;
|
|
|
import java.io.Writer;
|
|
|
-import java.lang.reflect.Constructor;
|
|
|
import java.util.Arrays;
|
|
|
-import net.ranides.assira.reflection.ClassInspector;
|
|
|
-import net.ranides.assira.reflection.InspectException;
|
|
|
-import net.ranides.assira.reflection.ObjectInspector;
|
|
|
|
|
|
@SuppressWarnings({
|
|
|
// "PMD.ExcessiveClassLength",
|
|
|
@@ -620,34 +616,6 @@ public abstract class AbstractStrBuilder<Self extends AbstractStrBuilder<Self>>
|
|
|
return new StringBuilder(size).append(buffer, 0, size);
|
|
|
}
|
|
|
|
|
|
- private static final class Li { //NOPMD - lazy init idiom
|
|
|
- static final Constructor<String> NEW_STRING = ClassInspector.getConstructor(String.class, int.class, int.class, char[].class);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns String with builder content without involving copy operation.
|
|
|
- * It calls internal constructor of String by reflection.
|
|
|
- * <p>
|
|
|
- * WARNING: You must not use the StrBuilder after calling this method
|
|
|
- * as the buffer is now shared with the String object. To ensure this,
|
|
|
- * the internal character array is set to null, so you will get
|
|
|
- * NullPointerExceptions on all method calls.
|
|
|
- *
|
|
|
- * @return the builder as a String
|
|
|
- */
|
|
|
- public final String moveToString() {
|
|
|
- try {
|
|
|
- char[] data = buffer;
|
|
|
- int isize = size;
|
|
|
- buffer = null;
|
|
|
- size = -1;
|
|
|
- nullText = null;
|
|
|
- return ObjectInspector.createInstance(Li.NEW_STRING, 0, isize, data);
|
|
|
- } catch (InspectException ex) {
|
|
|
- throw new UnsupportedOperationException("StrBuilder.toSharedString is unsupported: " + ex.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Gets the contents of this builder as a Reader.
|
|
|
* <p>
|