Ver código fonte

Merge branch 'master' of http://repo1.mydevil.net/git/priv/ranides/assira

Conflicts:
	assira/pom.xml
Ranides Atterwim 10 anos atrás
pai
commit
f70e636046

+ 2 - 1
.gitignore

@@ -7,4 +7,5 @@
 /assira.junit/nbproject/
 /assira.drafts/target/
 /assira/pom.xml.versionsBackup
-/assira.test/target/
+/assira.test/target/
+/assira.drafts/nbproject/

+ 3 - 2
assira.rules/src/main/java/net/ranides/assira/rules/utils/ASTUtils.java

@@ -6,8 +6,6 @@
  */
 package net.ranides.assira.rules.utils;
 
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
 import java.util.List;
 import net.sourceforge.pmd.lang.ast.Node;
 import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
@@ -24,6 +22,9 @@ import net.sourceforge.pmd.lang.java.ast.ASTType;
  */
 public final class ASTUtils {
     
+    // @todo (assira.rules #1) return array[0] should be allowed!
+    // napisać własną wersję, która wykrywa tablice odrobinę mądrzej
+    
     private ASTUtils() {
         /* utility class */
     }

+ 20 - 5
assira/pom.xml

@@ -29,15 +29,18 @@
                             <includes>
                                 <include>net/ranides/assira/annotations/Meta*</include>
                                 <include>net/ranides/assira/annotations/javac/**</include>
+                                
                                 <include>net/ranides/assira/awt/ImageLoader*</include>
                                 <include>net/ranides/assira/awt/AWTInvoker*</include>
-                                <include>net/ranides/assira/generic/SerializationUtils*</include>
-                                <include>net/ranides/assira/generic/TypeToken*</include>
+                                
                                 <include>net/ranides/assira/collection/arrays/NativeArrayUtils</include>
                                 <include>net/ranides/assira/collection/arrays/ArrayUtils</include>
+                                <include>net/ranides/assira/collection/iterators/ForwardIterator*</include>
                                 <include>net/ranides/assira/collection/iterators/IteratorUtils*</include>
+                                <include>net/ranides/assira/collection/iterators/IntIteratorUtils*</include>
                                 <include>net/ranides/assira/collection/lists/ListUtils</include>
                                 <include>net/ranides/assira/collection/sets/Bitmask*</include>
+                                
                                 <include>net/ranides/assira/lexer/**</include>
                                 
                                 <include>net/ranides/assira/reflection/IAnnotations.class</include>
@@ -52,14 +55,26 @@
                                 <include>net/ranides/assira/reflection/IHints.class</include>
                                 <include>net/ranides/assira/reflection/IMethod.class</include>
                                 <include>net/ranides/assira/reflection/IMethods.class</include>
+                                <include>net/ranides/assira/generic/SerializationUtils*</include>
+                                <include>net/ranides/assira/generic/TypeToken*</include>
+                                <include>net/ranides/assira/generic/Wrapper*</include>
+                                
+                                <include>net/ranides/assira/io/IOStreams*</include>
+                                <include>net/ranides/assira/io/IOEvents*</include>
+                                <include>net/ranides/assira/io/StringInput</include>
+                                <include>net/ranides/assira/io/StringOutput*</include>
+                                
+                                <include>net/ranides/assira/math/LSFR*</include>
+                                <include>net/ranides/assira/math/MathUtils*</include>
+                                
                                 <include>net/ranides/assira/reflection/IVariable.class</include>
                                 <include>net/ranides/assira/reflection/IVariables.class</include>
                                 
                                 <include>net/ranides/assira/reflection/impl/*</include>
                                 <include>net/ranides/assira/reflection/util/ReflectUtils*</include>
-                                <include>net/ranides/assira/io/*</include>
-                                <include>net/ranides/assira/math/LSFR*</include>
-                                <include>net/ranides/assira/math/MathUtils*</include>
+                                
+                                <include>net/ranides/assira/text/StrBuffer*</include>
+                                <include>net/ranides/assira/text/StrBuffer*</include>
                             </includes>
 						</configuration>
 					</plugin>

+ 1 - 1
assira/src/main/java/net/ranides/assira/reflection/impl/AClass.java

@@ -153,7 +153,7 @@ public class AClass implements IClass {
         if(params.isEmpty()) {
             return name();
         }
-        return StrBuilder.alloc().append(name()).open("<",">",", ").append(params).close().toString();
+        return new StrBuilder().append(name()).open("<",">",", ").append(params).close().toString();
     }
     
 }

+ 1 - 1
assira/src/main/java/net/ranides/assira/reflection/impl/AMethod.java

@@ -78,7 +78,7 @@ public abstract class AMethod implements IMethod {
     
     @Override
     public String toString() {
-        return StrBuilder.alloc()
+        return new StrBuilder()
             .append(returns()).append(" ")
             .append(parent())
             .append(".")

+ 541 - 0
assira/src/main/java/net/ranides/assira/text/StrBuffer.java

@@ -0,0 +1,541 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+
+package net.ranides.assira.text;
+
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.function.Function;
+import java.util.function.IntFunction;
+import net.ranides.assira.collection.arrays.ArrayUtils;
+import net.ranides.assira.collection.arrays.NativeArray;
+import net.ranides.assira.collection.arrays.NativeArrayUtils;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+@SuppressWarnings({
+    "PMD.TooManyPublicMethods",
+    "PMD.TooManyDifferentMethods"
+})
+public class StrBuffer implements Appendable, CharSequence, Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    protected static final char[] EMPTY = new char[0];
+
+    protected char[] buffer;
+
+    protected int size;
+
+    private final BuilderState options = new BuilderState();
+
+    public StrBuffer(int capacity) {
+        this.buffer = new char[capacity];
+    }
+
+    public StrBuilderOptions options() {
+        return options;
+    }
+    
+    @Override
+    public int length() {
+        return size;
+    }
+    
+    public int capacity() {
+        return buffer.length;
+    }
+    
+    public StrBuffer resize(int length, char c) {
+        if (length < 0) {
+            throw new IllegalArgumentException("negative size: " + length);
+        }
+        if (length > size) {
+            throw new IllegalArgumentException(length + " is greater than " + capacity());
+        }
+        size = length;
+        return this;
+    }
+    
+    public StrBuffer clear() {
+        size = 0;
+        return this;
+    }
+    
+    @Override
+    public char charAt(int index) {
+        return buffer[index];
+    }
+    
+    public StrBuffer setCharAt(int index, char value) {
+        buffer[index] = value;
+        return this;
+    }
+
+    @Override
+    public CharSequence subSequence(int begin, int end) {
+        return StringUtils.wrap(buffer, begin, end);
+    }
+    
+    public char[] getChars() {
+        return getChars(0, size);
+    }
+    
+    public char[] getChars(int begin, int end) {
+        if (end == begin) {
+            return StrBuffer.EMPTY;
+        }
+        return ArrayUtils.slice(buffer, begin, end);
+    }
+    
+    public char[] getChars(char[] target) {
+        return getChars(0, size, target, 0);
+    }
+    
+    public char[] getChars(int begin, int end, char target[], int offset) {
+        System.arraycopy(buffer, begin, target, offset, end - begin);
+        return target;
+    }
+    
+    public String getRightFragment(int length) {
+        return new String(buffer, size - length, length);
+    }
+
+    public String getLeftFragment(int length) {
+        return new String(buffer, 0, length);
+    }
+
+    public StrBuffer reverse() {
+        NativeArrayUtils.reverse(NativeArray.wrap(buffer), size);
+        return this;
+    }
+    
+    public StrBuffer open() {
+        return StrBuffer.this.append(options.reset().open());
+    }
+
+    public StrBuffer open(String open) {
+        options.open(open);
+        return open();
+    }
+
+    public StrBuffer open(String open, String close) {
+        options.open(open).close(close);
+        return open();
+    }
+
+    public StrBuffer open(String open, String close, String separator) {
+        options.open(open).close(close).separator(separator);
+        return open();
+    }
+    
+    public StrBuffer close() {
+        return StrBuffer.this.append(options.close());
+    }
+
+    public StrBuffer item() {
+        if(0 != options.counter++) {
+            StrBuffer.this.append(options.separator());
+        }
+        return this;
+    }
+    
+    public StrBuffer endl() {
+        return StrBuffer.this.append(options.endl());
+    }
+    
+    public StrBuffer append() {
+        return this;
+    }
+    
+    @Override
+    public StrBuffer append(CharSequence value) {
+        return append(value, 0, value.length());
+    }
+
+    @Override
+    public StrBuffer append(CharSequence value, int begin, int end) {
+        for(int i=begin; i<end; i++) {
+            buffer[size++] = value.charAt(i);
+        }
+        return this;
+    }
+    
+    public StrBuffer append(String value) {
+        return append(value, 0, value.length());
+    }
+    
+    public StrBuffer append(String value, int begin, int end) {
+        int n = end - begin;
+        value.getChars(begin, end, buffer, size);
+        size += n;
+        return this;
+    }
+    
+    public StrBuffer append(StringBuffer value) {
+        return append(value, 0, value.length());
+    }
+    
+    public StrBuffer append(StringBuffer value, int begin, int end) {
+        int n = end - begin;
+        value.getChars(begin, end, buffer, size);
+        size += n;
+        return this;
+    }
+    
+    public StrBuffer append(StringBuilder value) {
+        return append(value, 0, value.length());
+    }
+    
+    public StrBuffer append(StringBuilder value, int begin, int end) {
+        int n = end - begin;
+        value.getChars(begin, end, buffer, size);
+        size += n;
+        return this;
+    }
+    
+    public StrBuffer append(char[] value) {
+        return append(value, 0, value.length);
+    }
+    
+    public StrBuffer append(char[] value, int begin, int end) {
+        int n = end - begin;
+        System.arraycopy(value, begin, buffer, size, n);
+        size += n;
+        return this;
+    }
+
+    @Override
+    public StrBuffer append(char c) {
+        buffer[size++] = c;
+        return this;
+    }
+    
+    public StrBuffer append(Object value) {
+        return append(value.toString());        
+    }
+    
+    public StrBuffer append(boolean value) {
+        return append(value ? "true" : "false");
+    }
+    
+    public StrBuffer append(int value) {
+        return append(String.valueOf(value));
+    }
+    
+    public StrBuffer append(long value) {
+        return append(String.valueOf(value));
+    }
+
+    public StrBuffer append(float value) {
+        return append(String.valueOf(value));
+    }
+
+    public StrBuffer append(double value) {
+        return append(String.valueOf(value));
+    }
+    
+    public StrBuffer append(Iterable<?> values) {
+        return append(values.iterator(), Object::toString);
+    }
+    
+    public <T> StrBuffer append(Iterable<? extends T> values, Function<T,String> function) {
+        return append(values.iterator(), function);
+    }
+    
+    public <T> StrBuffer append(Iterator<? extends T> values) {
+        return append(values, Object::toString);
+    }
+    
+    public <T> StrBuffer append(Iterator<? extends T> values, Function<T,String> function) {
+        if ( !values.hasNext() ) {
+            return this;
+        }
+        String separator = options().separator();
+        for (;;) {
+            T item = values.next();
+            append(function.apply(item));
+            if ( !values.hasNext() ) {
+                return this;
+            }
+            append(separator);
+        }
+    }
+    
+    public <T> StrBuffer append(T[] values) {
+        return append(values, Object::toString);
+    }
+    
+    public <T> StrBuffer append(T[] values, Function<T,String> function) {
+        if ( 0==values.length ) {
+            return this;
+        }
+        String separator = options().separator();
+        append(function.apply(values[0]));
+        for (int i=1; i<values.length; i++) {
+            append(separator).append(function.apply(values[i]));
+        }
+        return this;
+    }
+    
+    public <T> StrBuffer append(NativeArray values) {
+        return append(values.size(), i -> String.valueOf(values.get(i)));
+    }
+    
+    public <T> StrBuffer append(int size, IntFunction<String> function) {
+        if ( 0==size ) {
+            return this;
+        }
+        String separator = options().separator();
+        append(function.apply(0));
+        for (int i=1; i<size; i++) {
+            append(separator).append(function.apply(i));
+        }
+        return this;
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+        if (object instanceof StrBuffer) {
+            return equalsSB((StrBuffer)object);
+        }
+        if (object instanceof CharSequence) {
+            return equalsCS((CharSequence)object);
+        }
+        return false;
+    }
+
+    private boolean equalsSB(StrBuffer other) {
+        if (this.size != other.size) {
+            return false;
+        }
+        for(int i=0; i<size; i++) {
+            if(this.buffer[i] != other.buffer[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private boolean equalsCS(CharSequence other) {
+        if (this.size != other.length()) {
+            return false;
+        }
+        for(int i=0; i<size; i++) {
+            if(this.buffer[i] != other.charAt(i)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return NativeArray.wrap(buffer).hashCode(0, size);
+    }
+
+    
+    @Override
+    public String toString() {
+        return new String(buffer, 0, size);
+    }
+
+    public StringBuilder toBuilder() {
+        return new StringBuilder(size).append(buffer, 0, size);
+    }
+
+    public Writer asWriter() {
+        return new SWriter();
+    }
+
+    public Reader asReader() {
+        return new SReader();
+    }
+
+    private final class SReader extends Reader {
+
+        private int pos;
+        private int mark;
+
+        @Override
+        public void close() {
+            // do nothing
+        }
+
+        @Override
+        public int read() {
+            if (!ready()) {
+                return -1;
+            }
+            return buffer[pos++];
+        }
+
+        @Override
+        public int read(char target[], int offset, int length) {
+            if (pos >= length()) {
+                return -1;
+            }
+            if (pos + length > length()) {
+                length = length() - pos;
+            }
+            getChars(pos, pos + length, target, offset);
+            pos += length;
+            return length;
+        }
+
+        @Override
+        public long skip(long n) {
+            if (pos + n > size) {
+                n = size - pos;
+            }
+            if (n < 0) {
+                return 0;
+            }
+            pos += n;
+            return n;
+        }
+
+        @Override
+        public boolean ready() {
+            return pos < size;
+        }
+
+        @Override
+        public boolean markSupported() {
+            return true;
+        }
+
+        @Override
+        public void mark(int readAheadLimit) {
+            mark = pos;
+        }
+
+        @Override
+        public void reset() {
+            pos = mark;
+        }
+
+    }
+
+    private final class SWriter extends Writer {
+
+        @Override
+        public void close() {
+            // do nothing
+        }
+
+        @Override
+        public void flush() {
+            // do nothing
+        }
+
+        @Override
+        public void write(int c) {
+            StrBuffer.this.append((char) c);
+        }
+
+        @Override
+        public void write(char[] buffer) {
+            StrBuffer.this.append(buffer);
+        }
+
+        @Override
+        public void write(char[] buffer, int offset, int length) {
+            StrBuffer.this.append(buffer, offset, length);
+        }
+
+        @Override
+        public void write(String str) {
+            StrBuffer.this.append(str);
+        }
+
+        @Override
+        public void write(String str, int offset, int length) {
+            StrBuffer.this.append(str, offset, length);
+        }
+
+    }
+
+    private static final class BuilderState extends StrBuilderOptions {
+
+        private static final long serialVersionUID = 1L;
+
+        protected int counter;
+
+        private String endl;
+
+        private String separator;
+
+        private String open;
+
+        private String close;
+
+        @Override
+        public StrBuilder builder() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public String endl() {
+            return endl;
+        }
+
+        @Override
+        public BuilderState endl(String value) {
+            this.endl = value;
+            return this;
+        }
+
+        @Override
+        public String separator() {
+            return separator;
+        }
+
+        @Override
+        public BuilderState separator(String value) {
+            this.separator = value;
+            return this;
+        }
+
+        @Override
+        public String open() {
+            return open;
+        }
+
+        @Override
+        public BuilderState open(String value) {
+            this.open = value;
+            return this;
+        }
+
+        @Override
+        public String close() {
+            return close;
+        }
+
+        @Override
+        public BuilderState close(String value) {
+            this.close = value;
+            return this;
+        }
+
+        protected BuilderState reset() {
+            this.counter = 0;
+            return this;
+        }
+
+    }
+
+}
+

Diferenças do arquivo suprimidas por serem muito extensas
+ 480 - 935
assira/src/main/java/net/ranides/assira/text/StrBuilder.java


+ 1 - 1
assira/src/test/java/net/ranides/assira/collection/maps/CacheTest.java

@@ -257,7 +257,7 @@ public class CacheTest {
     }
 	
 	private static String text(Random rand, int size) {
-		StrBuilder sb = StrBuilder.alloc(size);
+		StrBuilder sb = new StrBuilder(size);
 		for(int i=0; i<size; i++) {
 			sb.append( (char)(' '+rand.nextInt(128)) );
 		}

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

@@ -33,7 +33,7 @@ public class StrBuilderTest {
         List<Integer> list2 = Arrays.asList(10,11,12,13);
         List<Integer> list3 = Arrays.asList(3,4,5);
         
-        StrBuilder sb = StrBuilder.alloc();
+        StrBuilder sb = new StrBuilder();
         sb
             .options()
                 .open("{ ").close(" }").separator(",")
@@ -66,7 +66,7 @@ public class StrBuilderTest {
     
     @Test
     public void testOpenClose() {
-        StrBuilder sb = StrBuilder.alloc();
+        StrBuilder sb = new StrBuilder();
         
         assertThrows(IllegalStateException.class, sb::close);
         
@@ -89,7 +89,7 @@ public class StrBuilderTest {
     
     @Test
     public void testOptions() {
-        StrBuilder sb = StrBuilder.alloc();
+        StrBuilder sb = new StrBuilder();
         
         sb
             .options().blank("b1").endl("o1").separator("c1").builder()
@@ -120,7 +120,7 @@ public class StrBuilderTest {
     
     @Test
     public void testAppend_String() {
-        StrBuilder builder = StrBuilder.alloc();
+        StrBuilder builder = new StrBuilder();
         builder.options().blank("-");
         
         // String
@@ -162,7 +162,7 @@ public class StrBuilderTest {
     
     @Test
     public void testAppend_Chars() {
-        StrBuilder builder = StrBuilder.alloc();
+        StrBuilder builder = new StrBuilder();
         builder.options().blank("-");
         
         // char[]
@@ -182,7 +182,7 @@ public class StrBuilderTest {
     
     @Test
     public void testAppend_Primitive() {
-        StrBuilder builder = StrBuilder.alloc();
+        StrBuilder builder = new StrBuilder();
 
         // boolean
         builder
@@ -202,7 +202,7 @@ public class StrBuilderTest {
     
     @Test
     public void testAppend_Iterable() {
-        StrBuilder builder = StrBuilder.alloc();
+        StrBuilder builder = new StrBuilder();
         builder.options()
             .separator(",")
             .blank("-")
@@ -239,7 +239,7 @@ public class StrBuilderTest {
     
     @Test
     public void testAppend_Array() {
-        StrBuilder builder = StrBuilder.alloc();
+        StrBuilder builder = new StrBuilder();
         builder.options()
             .separator(",")
             .blank("-")
@@ -277,7 +277,7 @@ public class StrBuilderTest {
     
     @Test
     public void testReserve() {
-        StrBuilder sb = StrBuilder.alloc(128);
+        StrBuilder sb = new StrBuilder(128);
         sb.append("Hello world");
         assertEquals(128, sb.capacity());
         assertEquals(11, sb.length());
@@ -292,7 +292,7 @@ public class StrBuilderTest {
     
     @Test
     public void testTrim() {
-        StrBuilder sb = StrBuilder.alloc(128);
+        StrBuilder sb = new StrBuilder(128);
         sb.append("Hello world");
         assertEquals(128, sb.capacity());
         assertEquals(11, sb.length());
@@ -310,7 +310,7 @@ public class StrBuilderTest {
     
     @Test
     public void testResize() {
-        StrBuilder sb = StrBuilder.alloc(128);
+        StrBuilder sb = new StrBuilder(128);
         sb.append("Hello world");
 
         sb.resize(8, '.');
@@ -329,7 +329,7 @@ public class StrBuilderTest {
     
     @Test
     public void testClear() {
-        StrBuilder sb = StrBuilder.alloc(8);
+        StrBuilder sb = new StrBuilder(8);
         sb.append("Hello world");
         assertEquals(16, sb.capacity());
         assertEquals(11, sb.length());
@@ -342,7 +342,7 @@ public class StrBuilderTest {
     
     @Test
     public void testSequence() {
-        StrBuilder sb = StrBuilder.alloc().append("Hello world");
+        StrBuilder sb = new StrBuilder().append("Hello world");
         
         StringTester.assertString("Hello world", sb);
         StringTester.assertString("ello wo", sb.subSequence(1, 8));
@@ -361,7 +361,7 @@ public class StrBuilderTest {
     
     @Test
     public void testGetChars() {
-        StrBuilder sb = StrBuilder.alloc(32).append("Hello world");
+        StrBuilder sb = new StrBuilder(32).append("Hello world");
         
         assertArrayEquals("Hello world".toCharArray(), sb.getChars());
         
@@ -388,7 +388,7 @@ public class StrBuilderTest {
     
     @Test
     public void testFragmet() {
-        StrBuilder sb = StrBuilder.alloc(32).append("Hello world");
+        StrBuilder sb = new StrBuilder(32).append("Hello world");
         
         assertEquals("", sb.getLeftFragment(0));
         assertEquals("Hell", sb.getLeftFragment(4));
@@ -401,7 +401,7 @@ public class StrBuilderTest {
     
     @Test
     public void testReverse() {
-        StrBuilder sb = StrBuilder.alloc(32).append("Hello world");
+        StrBuilder sb = new StrBuilder(32).append("Hello world");
         
         sb.reverse();
         assertEquals("dlrow olleH", sb.toString());
@@ -414,7 +414,7 @@ public class StrBuilderTest {
     
     @Test
     public void testToBuilder() {
-        StrBuilder sb = StrBuilder.alloc(32).append("Hello world");
+        StrBuilder sb = new StrBuilder(32).append("Hello world");
         assertEquals("Hello world!", sb.toBuilder().append("!").toString());
         assertEquals("Hello world", sb.toString());
     }
@@ -422,17 +422,17 @@ public class StrBuilderTest {
     @Test
     @SuppressFBWarnings("EC_UNRELATED_TYPES")
     public void testEquals() {
-        StrBuilder a = StrBuilder.alloc(16).append("Hello");
-        StrBuilder b = StrBuilder.alloc(160).append("He").append("llo");
-        StrBuilder c = StrBuilder.alloc(160).append("He").append("ll!");
+        StrBuilder a = new StrBuilder(16).append("Hello");
+        StrBuilder b = new StrBuilder(160).append("He").append("llo");
+        StrBuilder c = new StrBuilder(160).append("He").append("ll!");
         
         assertTrue(a.equals(a));
         
         assertFalse(a.equals(null));
         assertFalse(a.equals(new Object()));
         
-        assertFalse(a.equals(StrBuilder.alloc(160).append("Hallo")));
-        assertFalse(a.equals(StrBuilder.alloc(160).append("Hello!")));
+        assertFalse(a.equals(new StrBuilder(160).append("Hallo")));
+        assertFalse(a.equals(new StrBuilder(160).append("Hello!")));
         
         assertFalse(a.equals("Hello!"));
         assertFalse(a.equals("Hella"));
@@ -445,7 +445,7 @@ public class StrBuilderTest {
     
     @Test
     public void testWriter() throws IOException {
-        StrBuilder sb = StrBuilder.alloc();
+        StrBuilder sb = new StrBuilder();
         Writer writer = sb.asWriter();
         sb.append("Hello ");
         
@@ -468,7 +468,7 @@ public class StrBuilderTest {
         TAdapter<Reader, StrBuilder> map = new TAdapter<>();
         
         Function<String, Reader> rf = map.map(
-            (String text) -> StrBuilder.alloc().append(text), builder -> builder.asReader()
+            (String text) -> new StrBuilder().append(text), builder -> builder.asReader()
         );
         BiConsumer<Reader, String> ra = (reader, text) -> {
             map.get(reader).append(text);
@@ -482,7 +482,7 @@ public class StrBuilderTest {
     
     @Test
     public void testHashcode() {
-        assertEquals(Arrays.hashCode("Hello".toCharArray()), StrBuilder.alloc(32).append("Hello").hashCode());
+        assertEquals(Arrays.hashCode("Hello".toCharArray()), new StrBuilder(32).append("Hello").hashCode());
     }
 
     

+ 2 - 2
assira/src/test/java/net/ranides/assira/text/StringUtilsBenchmark.java

@@ -310,7 +310,7 @@ public class StringUtilsBenchmark extends SimpleBenchmark {
             prv = Character.toLowerCase(prv);
         }
         
-        StrBuilder builder = StrBuilder.alloc(2*max);
+        StrBuilder builder = new StrBuilder(2*max);
         
         for(int i=1; i<max; i++) {
             char c = value.charAt(i);
@@ -356,7 +356,7 @@ public class StringUtilsBenchmark extends SimpleBenchmark {
             prv = Character.toLowerCase(prv);
         }
         
-        StrBuilder builder = StrBuilder.unsafe(2*max);
+        StrBuffer builder = new StrBuffer(2*max);
         
         for(int i=1; i<max; i++) {
             char c = value.charAt(i);