Skip to content

leopiccionia/easyprint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easyprint

This documentation is provisional, and should be replaced by Javadoc.

EasyPrint

java.lang.String concatenation in Java is slow and bad practice, due to String immutability. Don't get me wrong: I dig immutability, but it's not for all tasks.

java.lang.StringBuilder looks too low-level and, for some tasks, too verbose -- like almost everything Java.

This package contains a wrapper for StringBuilder as easy, or easier, to use than String concatenation, with some batteries.

Methods

public EasyString(String string)

Creates a EasyString from a String.

public EasyString(StringBuilder builder)

Creates a EasyString from a StringBuilder.

public EasyString(Object... args)

Creates a EasyString from Object[] or Object varargs.

public EasyString append(Object... args)

Appends Object[] or Object varargs to an EasyString instance. Returns this, so can be chained.

Not recommended for appending constant values; use EasyString() instead.

public static EasyString concat(String separator, Object... args)

Inspired by Lua's table.concat(). Interpolates each elements of args (Object[] or Object varargs) with separator.

Not recommended for "" separator; use EasyString() instead.

public static void print(Object... args)

Wrapper for System.out.print(new EasyString(Object... args)).

public static void println(Object... args)

Wrapper for System.out.println(new EasyString(Object... args)).

public static EasyString repeat(String string, int times)

Repeats string times times. For example, repeat("*", 5) returns *****.

from java.lang.CharSequence

public char charArt(int index)

Returns the index-th char from CharSequence built.

public int length()

Returns the length of CharSequence built.

public CharSequence subSequence(int start, int end)

Returns the subsquence [start,end - 1] from CharSequence built.

public String toString()

Returns String built.

TODO

  • Tests
  • More tests
  • File writing, similarly to print() and println()
  • StringBuffer wrapper
  • Implementing useful interfaces
    • CharSequence
  • Javadoc
  • Benchmark against other alternatives

About

StringBuilder wrapper, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages