jtulach@6: package conditionaluseofapi; jtulach@6: jtulach@6: /** Implementation for string concatention using Java 5 only. jtulach@6: * jtulach@6: * StringBuilder is supposed to be faster than StringBuffer as it jtulach@6: * is not synchronized and as such it is does not waste time with jtulach@6: * synchronization when its methods are called. jtulach@6: * jtulach@6: * @author Jaroslav Tulach jtulach@6: */ jtulach@6: final class StringBuilderAdd15 implements AddString { jtulach@6: jtulach@6: private StringBuilder sb = new StringBuilder(); jtulach@6: jtulach@6: public void addString(String msg) { jtulach@6: sb.append(msg); jtulach@6: } jtulach@6: jtulach@6: public String getMessage() { jtulach@6: return sb.toString(); jtulach@6: } jtulach@6: jtulach@6: public String toString() { jtulach@6: return "New Shiny and Fast Java 5 Implementation"; jtulach@6: } jtulach@6: }