Kaynağa Gözat

AbstractStrBuilder#moveToString - removed, its incompatible with JDK8 and newer.that was terrible hack anyway

ranides atterwim 11 yıl önce
ebeveyn
işleme
798c182d08

+ 1 - 1
pom.xml

@@ -5,7 +5,7 @@
 
     <groupId>net.ranides</groupId>
     <artifactId>assira</artifactId>
-    <version>0.68.5</version>
+    <version>0.70.1</version>
     <packaging>jar</packaging>
 
     <name>assira</name>

+ 0 - 32
src/main/java/net/ranides/assira/text/AbstractStrBuilder.java

@@ -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>

+ 1 - 2
src/main/java/net/ranides/assira/text/format/AnsiCharSequence.java

@@ -12,7 +12,6 @@ import java.awt.Font;
 import java.io.Serializable;
 import java.util.Iterator;
 import net.ranides.assira.math.Bitwise;
-import net.ranides.assira.text.StrBuilder;
 
 /**
  * Klasa reprezentująca ciąg znaków razem z przypisanymi do nich atrybutami 
@@ -246,7 +245,7 @@ public abstract class AnsiCharSequence implements CharSequence, Serializable {
 
     @Override
     public final String toString() {
-        return new StrBuilder(length()).append(this).moveToString();
+        return new StringBuilder(length()).append(this).toString();
     }
     
     

+ 0 - 31
src/test/java/net/ranides/assira/text/StrBuilderTest.java

@@ -1,31 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text;
-
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class StrBuilderTest {
-    
-    public StrBuilderTest() {
-    }
-
-    @Test
-    public void testMoveToString() {
-        StrBuilder b1 = new StrBuilder();
-        b1.append("Hello");
-        assertEquals("Hello", b1.moveToString());
-        
-        CharSequence s1 = "Hello world";
-        assertEquals("Hello world", new StrBuilder(s1.length()).append(s1).toString());
-    }
-    
-}