samples/conditionaluseofapi/src/conditionaluseofapi/StringBuilderAdd15.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 20:46:27 +0100
changeset 408 9a439a79c6d0
permissions -rw-r--r--
Use scala 2.10.4 to compile on JDK8
jtulach@6
     1
package conditionaluseofapi;
jtulach@6
     2
jtulach@6
     3
/** Implementation for string concatention using Java 5 only.
jtulach@6
     4
 * 
jtulach@6
     5
 * StringBuilder is supposed to be faster than StringBuffer as it
jtulach@6
     6
 * is not synchronized and as such it is does not waste time with
jtulach@6
     7
 * synchronization when its methods are called. 
jtulach@6
     8
 *
jtulach@6
     9
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jtulach@6
    10
 */
jtulach@6
    11
final class StringBuilderAdd15 implements AddString {
jtulach@6
    12
    
jtulach@6
    13
    private StringBuilder sb = new StringBuilder();
jtulach@6
    14
jtulach@6
    15
    public void addString(String msg) {
jtulach@6
    16
        sb.append(msg);
jtulach@6
    17
    }
jtulach@6
    18
jtulach@6
    19
    public String getMessage() {
jtulach@6
    20
        return sb.toString();
jtulach@6
    21
    }
jtulach@6
    22
jtulach@6
    23
    public String toString() {
jtulach@6
    24
        return "New Shiny and Fast Java 5 Implementation";
jtulach@6
    25
    }
jtulach@6
    26
}