From ef8eeb973be9971fabfd7fe692137d64928f35ad Mon Sep 17 00:00:00 2001 From: bvosburgh Date: Fri, 8 Jul 2011 15:55:33 +0000 Subject: singleton toString()s --- .../src/org/eclipse/jpt/common/utility/Filter.java | 28 +- .../jpt/common/utility/internal/BidiFilter.java | 26 +- .../utility/internal/BidiStringConverter.java | 32 +- .../common/utility/internal/BidiTransformer.java | 20 +- .../common/utility/internal/ExceptionHandler.java | 15 +- .../eclipse/jpt/common/utility/internal/Queue.java | 11 +- .../eclipse/jpt/common/utility/internal/Stack.java | 11 +- .../common/utility/internal/StringConverter.java | 15 +- .../jpt/common/utility/internal/StringMatcher.java | 9 +- .../jpt/common/utility/internal/StringTools.java | 697 ++++++++++++++++----- .../jpt/common/utility/internal/Transformer.java | 15 +- .../utility/internal/model/AbstractModel.java | 4 +- .../common/utility/model/event/ChangeEvent.java | 4 +- .../synchronizers/CallbackSynchronizer.java | 10 +- .../common/utility/synchronizers/Synchronizer.java | 10 +- .../utility/tests/internal/StringToolsTests.java | 23 +- 16 files changed, 693 insertions(+), 237 deletions(-) (limited to 'common') diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java index 222185940e..30509f6c49 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 Oracle. All rights reserved. + * Copyright (c) 2005, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -10,6 +10,7 @@ package org.eclipse.jpt.common.utility; import java.io.Serializable; +import org.eclipse.jpt.common.utility.internal.StringTools; /** * Used by various "pluggable" classes to filter objects. @@ -33,10 +34,12 @@ public interface Filter { /** - * Singleton implemetation of the filter interface that accepts all the + * Singleton implementation of the filter interface that accepts all the * objects (i.e. it does no filtering). */ - final class Null implements Filter, Serializable { + final class Null + implements Filter, Serializable + { @SuppressWarnings("rawtypes") public static final Filter INSTANCE = new Null(); @SuppressWarnings("unchecked") @@ -53,7 +56,7 @@ public interface Filter { } @Override public String toString() { - return "Filter.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -63,10 +66,12 @@ public interface Filter { } /** - * Singleton implemetation of the filter interface that accepts none of the + * Singleton implementation of the filter interface that accepts none of the * objects (i.e. it filters out all the objects). */ - final class Opaque implements Filter, Serializable { + final class Opaque + implements Filter, Serializable + { @SuppressWarnings("rawtypes") public static final Filter INSTANCE = new Opaque(); @SuppressWarnings("unchecked") @@ -83,7 +88,7 @@ public interface Filter { } @Override public String toString() { - return "Filter.Opaque"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -93,10 +98,12 @@ public interface Filter { } /** - * Singleton implemetation of the filter interface that throws an exception + * Singleton implementation of the filter interface that throws an exception * if called. */ - final class Disabled implements Filter, Serializable { + final class Disabled + implements Filter, Serializable + { @SuppressWarnings("rawtypes") public static final Filter INSTANCE = new Disabled(); @SuppressWarnings("unchecked") @@ -113,7 +120,7 @@ public interface Filter { } @Override public String toString() { - return "Filter.Disabled"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -121,5 +128,4 @@ public interface Filter { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java index 2894793ffd..015dc8fecc 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -20,8 +20,9 @@ import org.eclipse.jpt.common.utility.Filter; * If anyone can come up with a better class name * and/or method name, I would love to hear it. ~bjv */ -public interface BidiFilter extends Filter { - +public interface BidiFilter + extends Filter +{ /** * Return whether the specified object is "accepted" by the * "reverse" filter. What that means is determined by the client. @@ -29,7 +30,9 @@ public interface BidiFilter extends Filter { boolean reverseAccept(T o); - final class Null implements BidiFilter, Serializable { + final class Null + implements BidiFilter, Serializable + { @SuppressWarnings("rawtypes") public static final BidiFilter INSTANCE = new Null(); @SuppressWarnings("unchecked") @@ -50,7 +53,7 @@ public interface BidiFilter extends Filter { } @Override public String toString() { - return "BidiFilter.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -59,7 +62,9 @@ public interface BidiFilter extends Filter { } } - final class Opaque implements BidiFilter, Serializable { + final class Opaque + implements BidiFilter, Serializable + { @SuppressWarnings("rawtypes") public static final BidiFilter INSTANCE = new Opaque(); @SuppressWarnings("unchecked") @@ -80,7 +85,7 @@ public interface BidiFilter extends Filter { } @Override public String toString() { - return "BidiFilter.Opaque"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -89,7 +94,9 @@ public interface BidiFilter extends Filter { } } - final class Disabled implements BidiFilter, Serializable { + final class Disabled + implements BidiFilter, Serializable + { @SuppressWarnings("rawtypes") public static final BidiFilter INSTANCE = new Disabled(); @SuppressWarnings("unchecked") @@ -110,7 +117,7 @@ public interface BidiFilter extends Filter { } @Override public String toString() { - return "BidiFilter.Disabled"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -118,5 +125,4 @@ public interface BidiFilter extends Filter { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java index 056b29ae9f..8c7ebda6d3 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -18,8 +18,9 @@ import java.io.Serializable; * If anyone can come up with a better class name * and/or method name, I would love to hear it. ~bjv */ -public interface BidiStringConverter extends StringConverter { - +public interface BidiStringConverter + extends StringConverter +{ /** * Convert the specified string into an object. * The semantics of "convert to object" is determined by the @@ -29,7 +30,9 @@ public interface BidiStringConverter extends StringConverter { T convertToObject(String s); - final class Default implements BidiStringConverter, Serializable { + final class Default + implements BidiStringConverter, Serializable + { @SuppressWarnings("rawtypes") public static final BidiStringConverter INSTANCE = new Default(); @SuppressWarnings("unchecked") @@ -51,7 +54,7 @@ public interface BidiStringConverter extends StringConverter { } @Override public String toString() { - return "BidiStringConverter.Default"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -60,7 +63,9 @@ public interface BidiStringConverter extends StringConverter { } } - final class Disabled implements BidiStringConverter, Serializable { + final class Disabled + implements BidiStringConverter, Serializable + { @SuppressWarnings("rawtypes") public static final BidiStringConverter INSTANCE = new Disabled(); @SuppressWarnings("unchecked") @@ -81,7 +86,7 @@ public interface BidiStringConverter extends StringConverter { } @Override public String toString() { - return "BidiStringConverter.Disabled"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -90,7 +95,9 @@ public interface BidiStringConverter extends StringConverter { } } - final class BooleanConverter implements BidiStringConverter, Serializable { + final class BooleanConverter + implements BidiStringConverter, Serializable + { public static final BidiStringConverter INSTANCE = new BooleanConverter(); public static BidiStringConverter instance() { return INSTANCE; @@ -109,7 +116,7 @@ public interface BidiStringConverter extends StringConverter { } @Override public String toString() { - return "BidiStringConverter.BooleanConverter"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -118,7 +125,9 @@ public interface BidiStringConverter extends StringConverter { } } - final class IntegerConverter implements BidiStringConverter, Serializable { + final class IntegerConverter + implements BidiStringConverter, Serializable + { public static final BidiStringConverter INSTANCE = new IntegerConverter(); public static BidiStringConverter instance() { return INSTANCE; @@ -137,7 +146,7 @@ public interface BidiStringConverter extends StringConverter { } @Override public String toString() { - return "BidiStringConverter.IntegerConverter"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -145,5 +154,4 @@ public interface BidiStringConverter extends StringConverter { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java index c105d9d50a..3916af450c 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -18,8 +18,9 @@ import java.io.Serializable; * If anyone can come up with a better class name * and/or method name, I would love to hear it. ~bjv */ -public interface BidiTransformer extends Transformer { - +public interface BidiTransformer + extends Transformer +{ /** * Return the "reverse-transformed" object. * The semantics of "reverse-transform" is determined by the @@ -28,7 +29,9 @@ public interface BidiTransformer extends Transformer { T1 reverseTransform(T2 o); - final class Null implements BidiTransformer, Serializable { + final class Null + implements BidiTransformer, Serializable + { @SuppressWarnings("rawtypes") public static final BidiTransformer INSTANCE = new Null(); @SuppressWarnings("unchecked") @@ -51,7 +54,7 @@ public interface BidiTransformer extends Transformer { } @Override public String toString() { - return "BidiTransformer.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -60,7 +63,9 @@ public interface BidiTransformer extends Transformer { } } - final class Disabled implements BidiTransformer, Serializable { + final class Disabled + implements BidiTransformer, Serializable + { @SuppressWarnings("rawtypes") public static final BidiTransformer INSTANCE = new Disabled(); @SuppressWarnings("unchecked") @@ -81,7 +86,7 @@ public interface BidiTransformer extends Transformer { } @Override public String toString() { - return "BidiTransformer.Disabled"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -89,5 +94,4 @@ public interface BidiTransformer extends Transformer { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ExceptionHandler.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ExceptionHandler.java index 9c32f555a9..549b38471a 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ExceptionHandler.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ExceptionHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -33,7 +33,9 @@ public interface ExceptionHandler { * Singleton implementation of the exception handler interface that does * nothing with the exception. */ - final class Null implements ExceptionHandler, Serializable { + final class Null + implements ExceptionHandler, Serializable + { public static final ExceptionHandler INSTANCE = new Null(); public static ExceptionHandler instance() { return INSTANCE; @@ -47,7 +49,7 @@ public interface ExceptionHandler { } @Override public String toString() { - return "ExceptionHandler.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -60,7 +62,9 @@ public interface ExceptionHandler { * Singleton implementation of the exception handler interface that * wraps the exception in a runtime exception and throws it. */ - final class Runtime implements ExceptionHandler, Serializable { + final class Runtime + implements ExceptionHandler, Serializable + { public static final ExceptionHandler INSTANCE = new Runtime(); public static ExceptionHandler instance() { return INSTANCE; @@ -75,7 +79,7 @@ public interface ExceptionHandler { } @Override public String toString() { - return "ExceptionHandler.Runtime"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -83,5 +87,4 @@ public interface ExceptionHandler { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java index 9cc4bc5ce3..4f46bbb4c4 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * Copyright (c) 2009, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -42,7 +42,9 @@ public interface Queue { boolean isEmpty(); - final class Empty implements Queue, Serializable { + final class Empty + implements Queue, Serializable + { @SuppressWarnings("rawtypes") public static final Queue INSTANCE = new Empty(); @SuppressWarnings("unchecked") @@ -65,11 +67,14 @@ public interface Queue { public boolean isEmpty() { return true; } + @Override + public String toString() { + return StringTools.buildSingletonToString(this); + } private static final long serialVersionUID = 1L; private Object readResolve() { // replace this object with the singleton return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java index 88186bffe3..bf9c34c88e 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -42,7 +42,9 @@ public interface Stack { boolean isEmpty(); - final class Empty implements Stack, Serializable { + final class Empty + implements Stack, Serializable + { @SuppressWarnings("rawtypes") public static final Stack INSTANCE = new Empty(); @SuppressWarnings("unchecked") @@ -65,11 +67,14 @@ public interface Stack { public boolean isEmpty() { return true; } + @Override + public String toString() { + return StringTools.buildSingletonToString(this); + } private static final long serialVersionUID = 1L; private Object readResolve() { // replace this object with the singleton return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java index 412c9c199f..437b41e4ee 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -25,7 +25,9 @@ public interface StringConverter { String convertToString(T o); - final class Default implements StringConverter, Serializable { + final class Default + implements StringConverter, Serializable + { @SuppressWarnings("rawtypes") public static final StringConverter INSTANCE = new Default(); @SuppressWarnings("unchecked") @@ -42,7 +44,7 @@ public interface StringConverter { } @Override public String toString() { - return "StringConverter.Default"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -51,7 +53,9 @@ public interface StringConverter { } } - final class Disabled implements StringConverter, Serializable { + final class Disabled + implements StringConverter, Serializable + { @SuppressWarnings("rawtypes") public static final StringConverter INSTANCE = new Disabled(); @SuppressWarnings("unchecked") @@ -68,7 +72,7 @@ public interface StringConverter { } @Override public String toString() { - return "StringConverter.Disabled"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -76,5 +80,4 @@ public interface StringConverter { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java index c66900e3cb..ceab04044c 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -35,7 +35,9 @@ public interface StringMatcher { boolean matches(String string); - final class Null implements StringMatcher, Serializable { + final class Null + implements StringMatcher, Serializable + { public static final StringMatcher INSTANCE = new Null(); public static StringMatcher instance() { return INSTANCE; @@ -53,7 +55,7 @@ public interface StringMatcher { } @Override public String toString() { - return "StringMatcher.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -61,5 +63,4 @@ public interface StringMatcher { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java index 0eab3b6e26..ec458be12b 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 Oracle. All rights reserved. + * Copyright (c) 2005, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -68,7 +68,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#pad(int) + *

+ * + * String.pad(int) + * */ public static String pad(String string, int length) { return pad(string, length, ' '); @@ -79,7 +82,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOn(int, Writer) + *

+ * + * String.padOn(int, Writer) + * */ public static void padOn(String string, int length, Writer writer) { padOn(string, length, ' ', writer); @@ -90,7 +96,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOn(int, StringBuffer) + *

+ * + * String.padOn(int, StringBuffer) + * */ public static void padOn(String string, int length, StringBuffer sb) { padOn(string, length, ' ', sb); @@ -101,7 +110,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOn(int, StringBuilder) + *

+ * + * String.padOn(int, StringBuilder) + * */ public static void padOn(String string, int length, StringBuilder sb) { padOn(string, length, ' ', sb); @@ -113,7 +125,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#pad(int, char) + *

+ * + * String.pad(int, char) + * */ public static String pad(String string, int length, char c) { int stringLength = string.length(); @@ -132,7 +147,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOn(int, char, Writer) + *

+ * + * String.padOn(int, char, Writer) + * */ public static void padOn(String string, int length, char c, Writer writer) { int stringLength = string.length(); @@ -152,7 +170,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOn(int, char, StringBuffer) + *

+ * + * String.padOn(int, char, StringBuffer) + * */ public static void padOn(String string, int length, char c, StringBuffer sb) { int stringLength = string.length(); @@ -172,7 +193,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOn(int, char, StringBuilder) + *

+ * + * String.padOn(int, char, StringBuilder) + * */ public static void padOn(String string, int length, char c, StringBuilder sb) { int stringLength = string.length(); @@ -191,7 +215,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#pad(int) + *

+ * + * String.pad(int) + * */ public static char[] pad(char[] string, int length) { return pad(string, length, ' '); @@ -202,7 +229,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOn(int, writer) + *

+ * + * String.padOn(int, writer) + * */ public static void padOn(char[] string, int length, Writer writer) { padOn(string, length, ' ', writer); @@ -213,7 +243,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOn(int, StringBuffer) + *

+ * + * String.padOn(int, StringBuffer) + * */ public static void padOn(char[] string, int length, StringBuffer sb) { padOn(string, length, ' ', sb); @@ -224,7 +257,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOn(int, StringBuilder) + *

+ * + * String.padOn(int, StringBuilder) + * */ public static void padOn(char[] string, int length, StringBuilder sb) { padOn(string, length, ' ', sb); @@ -236,7 +272,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#pad(int, char) + *

+ * + * String.pad(int, char) + * */ public static char[] pad(char[] string, int length, char c) { int stringLength = string.length; @@ -255,7 +294,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOn(int, char, Writer) + *

+ * + * String.padOn(int, char, Writer) + * */ public static void padOn(char[] string, int length, char c, Writer writer) { int stringLength = string.length; @@ -275,7 +317,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOn(int, char, StringBuffer) + *

+ * + * String.padOn(int, char, StringBuffer) + * */ public static void padOn(char[] string, int length, char c, StringBuffer sb) { int stringLength = string.length; @@ -295,7 +340,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOn(int, char, StringBuilder) + *

+ * + * String.padOn(int, char, StringBuilder) + * */ public static void padOn(char[] string, int length, char c, StringBuilder sb) { int stringLength = string.length; @@ -314,7 +362,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncate(int) + *

+ * + * String.padOrTruncate(int) + * */ public static String padOrTruncate(String string, int length) { return padOrTruncate(string, length, ' '); @@ -325,7 +376,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncateOn(int, Writer) + *

+ * + * String.padOrTruncateOn(int, Writer) + * */ public static void padOrTruncateOn(String string, int length, Writer writer) { padOrTruncateOn(string, length, ' ', writer); @@ -336,7 +390,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncateOn(int, StringBuffer) + *

+ * + * String.padOrTruncateOn(int, StringBuffer) + * */ public static void padOrTruncateOn(String string, int length, StringBuffer sb) { padOrTruncateOn(string, length, ' ', sb); @@ -347,7 +404,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncateOn(int, StringBuilder) + *

+ * + * String.padOrTruncateOn(int, StringBuilder) + * */ public static void padOrTruncateOn(String string, int length, StringBuilder sb) { padOrTruncateOn(string, length, ' ', sb); @@ -359,7 +419,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncate(int, char) + *

+ * + * String.padOrTruncate(int, char) + * */ public static String padOrTruncate(String string, int length, char c) { int stringLength = string.length(); @@ -378,7 +441,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncateOn(int, char, Writer) + *

+ * + * String.padOrTruncateOn(int, char, Writer) + * */ public static void padOrTruncateOn(String string, int length, char c, Writer writer) { int stringLength = string.length(); @@ -397,7 +463,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncateOn(int, char, StringBuffer) + *

+ * + * String.padOrTruncateOn(int, char, StringBuffer) + * */ public static void padOrTruncateOn(String string, int length, char c, StringBuffer sb) { int stringLength = string.length(); @@ -416,7 +485,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncateOn(int, char, StringBuilder) + *

+ * + * String.padOrTruncateOn(int, char, StringBuilder) + * */ public static void padOrTruncateOn(String string, int length, char c, StringBuilder sb) { int stringLength = string.length(); @@ -434,7 +506,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncate(int) + *

+ * + * String.padOrTruncate(int) + * */ public static char[] padOrTruncate(char[] string, int length) { return padOrTruncate(string, length, ' '); @@ -445,7 +520,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncateOn(int, Writer) + *

+ * + * String.padOrTruncateOn(int, Writer) + * */ public static void padOrTruncateOn(char[] string, int length, Writer writer) { padOrTruncateOn(string, length, ' ', writer); @@ -456,7 +534,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncateOn(int, StringBuffer) + *

+ * + * String.padOrTruncateOn(int, StringBuffer) + * */ public static void padOrTruncate(char[] string, int length, StringBuffer sb) { padOrTruncateOn(string, length, ' ', sb); @@ -467,7 +548,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with spaces at the end. - * String#padOrTruncateOn(int, StringBuilder) + *

+ * + * String.padOrTruncateOn(int, StringBuilder) + * */ public static void padOrTruncate(char[] string, int length, StringBuilder sb) { padOrTruncateOn(string, length, ' ', sb); @@ -479,7 +563,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncate(int, char) + *

+ * + * String.padOrTruncate(int, char) + * */ public static char[] padOrTruncate(char[] string, int length, char c) { int stringLength = string.length; @@ -500,7 +587,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncateOn(int, char, Writer) + *

+ * + * String.padOrTruncateOn(int, char, Writer) + * */ public static void padOrTruncateOn(char[] string, int length, char c, Writer writer) { int stringLength = string.length; @@ -519,7 +609,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncateOn(int, char, StringBuffer) + *

+ * + * String.padOrTruncateOn(int, char, StringBuffer) + * */ public static void padOrTruncateOn(char[] string, int length, char c, StringBuffer sb) { int stringLength = string.length; @@ -538,7 +631,10 @@ public final class StringTools { * If it is longer than the specified length, it is truncated. * If it is shorter than the specified length, it is padded with the * specified character at the end. - * String#padOrTruncateOn(int, char, StringBuilder) + *

+ * + * String.padOrTruncateOn(int, char, StringBuilder) + * */ public static void padOrTruncateOn(char[] string, int length, char c, StringBuilder sb) { int stringLength = string.length; @@ -694,7 +790,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPad(int) + *

+ * + * String.zeroPad(int) + * */ public static String zeroPad(String string, int length) { return frontPad(string, length, '0'); @@ -705,7 +804,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOn(int, Writer) + *

+ * + * String.zeroPadOn(int, Writer) + * */ public static void zeroPadOn(String string, int length, Writer writer) { frontPadOn(string, length, '0', writer); @@ -716,7 +818,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOn(int, StringBuffer) + *

+ * + * String.zeroPadOn(int, StringBuffer) + * */ public static void zeroPadOn(String string, int length, StringBuffer sb) { frontPadOn(string, length, '0', sb); @@ -727,7 +832,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOn(int, StringBuilder) + *

+ * + * String.zeroPadOn(int, StringBuilder) + * */ public static void zeroPadOn(String string, int length, StringBuilder sb) { frontPadOn(string, length, '0', sb); @@ -739,7 +847,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPad(int, char) + *

+ * + * String.frontPad(int, char) + * */ public static String frontPad(String string, int length, char c) { int stringLength = string.length(); @@ -758,7 +869,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOn(int, char, Writer) + *

+ * + * String.frontPadOn(int, char, Writer) + * */ public static void frontPadOn(String string, int length, char c, Writer writer) { int stringLength = string.length(); @@ -778,7 +892,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOn(int, char, StringBuffer) + *

+ * + * String.frontPadOn(int, char, StringBuffer) + * */ public static void frontPadOn(String string, int length, char c, StringBuffer sb) { int stringLength = string.length(); @@ -798,7 +915,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOn(int, char, StringBuilder) + *

+ * + * String.frontPadOn(int, char, StringBuilder) + * */ public static void frontPadOn(String string, int length, char c, StringBuilder sb) { int stringLength = string.length(); @@ -817,7 +937,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPad(int) + *

+ * + * String.zeroPad(int) + * */ public static char[] zeroPad(char[] string, int length) { return frontPad(string, length, '0'); @@ -828,7 +951,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOn(int, Writer) + *

+ * + * String.zeroPadOn(int, Writer) + * */ public static void zeroPadOn(char[] string, int length, Writer writer) { frontPadOn(string, length, '0', writer); @@ -839,7 +965,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOn(int, StringBuffer) + *

+ * + * String.zeroPadOn(int, StringBuffer) + * */ public static void zeroPadOn(char[] string, int length, StringBuffer sb) { frontPadOn(string, length, '0', sb); @@ -850,7 +979,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOn(int, StringBuilder) + *

+ * + * String.zeroPadOn(int, StringBuilder) + * */ public static void zeroPadOn(char[] string, int length, StringBuilder sb) { frontPadOn(string, length, '0', sb); @@ -862,7 +994,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPad(int, char) + *

+ * + * String.frontPad(int, char) + * */ public static char[] frontPad(char[] string, int length, char c) { int stringLength = string.length; @@ -881,7 +1016,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOn(int, char, Writer) + *

+ * + * String.frontPadOn(int, char, Writer) + * */ public static void frontPadOn(char[] string, int length, char c, Writer writer) { int stringLength = string.length; @@ -901,7 +1039,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOn(int, char, StringBuffer) + *

+ * + * String.frontPadOn(int, char, StringBuffer) + * */ public static void frontPadOn(char[] string, int length, char c, StringBuffer sb) { int stringLength = string.length; @@ -921,7 +1062,10 @@ public final class StringTools { * If it is longer than the specified length, an IllegalArgumentException is thrown. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOn(int, char, StringBuilder) + *

+ * + * String.frontPadOn(int, char, StringBuilder) + * */ public static void frontPadOn(char[] string, int length, char c, StringBuilder sb) { int stringLength = string.length; @@ -940,7 +1084,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncate(int) + *

+ * + * String.zeroPadOrTruncate(int) + * */ public static String zeroPadOrTruncate(String string, int length) { return frontPadOrTruncate(string, length, '0'); @@ -951,7 +1098,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncateOn(int, Writer) + *

+ * + * String.zeroPadOrTruncateOn(int, Writer) + * */ public static void zeroPadOrTruncateOn(String string, int length, Writer writer) { frontPadOrTruncateOn(string, length, '0', writer); @@ -962,7 +1112,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncateOn(int, StringBuffer) + *

+ * + * String.zeroPadOrTruncateOn(int, StringBuffer) + * */ public static void zeroPadOrTruncateOn(String string, int length, StringBuffer sb) { frontPadOrTruncateOn(string, length, '0', sb); @@ -973,7 +1126,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncateOn(int, StringBuilder) + *

+ * + * String.zeroPadOrTruncateOn(int, StringBuilder) + * */ public static void zeroPadOrTruncateOn(String string, int length, StringBuilder sb) { frontPadOrTruncateOn(string, length, '0', sb); @@ -985,7 +1141,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncate(int, char) + *

+ * + * String.frontPadOrTruncate(int, char) + * */ public static String frontPadOrTruncate(String string, int length, char c) { int stringLength = string.length(); @@ -1004,7 +1163,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncateOn(int, char, Writer) + *

+ * + * String.frontPadOrTruncateOn(int, char, Writer) + * */ public static void frontPadOrTruncateOn(String string, int length, char c, Writer writer) { int stringLength = string.length(); @@ -1023,7 +1185,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncateOn(int, char, StringBuffer) + *

+ * + * String.frontPadOrTruncateOn(int, char, StringBuffer) + * */ public static void frontPadOrTruncateOn(String string, int length, char c, StringBuffer sb) { int stringLength = string.length(); @@ -1042,7 +1207,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncateOn(int, char, StringBuilder) + *

+ * + * String.frontPadOrTruncateOn(int, char, StringBuilder) + * */ public static void frontPadOrTruncateOn(String string, int length, char c, StringBuilder sb) { int stringLength = string.length(); @@ -1060,7 +1228,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncate(int) + *

+ * + * String.zeroPadOrTruncate(int) + * */ public static char[] zeroPadOrTruncate(char[] string, int length) { return frontPadOrTruncate(string, length, '0'); @@ -1071,7 +1242,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncateOn(int, Writer) + *

+ * + * String.zeroPadOrTruncateOn(int, Writer) + * */ public static void zeroPadOrTruncateOn(char[] string, int length, Writer writer) { frontPadOrTruncateOn(string, length, '0', writer); @@ -1082,7 +1256,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncateOn(int, StringBuffer) + *

+ * + * String.zeroPadOrTruncateOn(int, StringBuffer) + * */ public static void zeroPadOrTruncateOn(char[] string, int length, StringBuffer sb) { frontPadOrTruncateOn(string, length, '0', sb); @@ -1093,7 +1270,10 @@ public final class StringTools { * If the string is already the specified length, it is returned unchanged. * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with zeros at the front. - * String#zeroPadOrTruncateOn(int, StringBuilder) + *

+ * + * String.zeroPadOrTruncateOn(int, StringBuilder) + * */ public static void zeroPadOrTruncateOn(char[] string, int length, StringBuilder sb) { frontPadOrTruncateOn(string, length, '0', sb); @@ -1105,7 +1285,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncate(int, char) + *

+ * + * String.frontPadOrTruncate(int, char) + * */ public static char[] frontPadOrTruncate(char[] string, int length, char c) { int stringLength = string.length; @@ -1126,7 +1309,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncateOn(int, char, Writer) + *

+ * + * String.frontPadOrTruncateOn(int, char, Writer) + * */ public static void frontPadOrTruncateOn(char[] string, int length, char c, Writer writer) { int stringLength = string.length; @@ -1145,7 +1331,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncateOn(int, char, StringBuffer) + *

+ * + * String.frontPadOrTruncateOn(int, char, StringBuffer) + * */ public static void frontPadOrTruncateOn(char[] string, int length, char c, StringBuffer sb) { int stringLength = string.length; @@ -1164,7 +1353,10 @@ public final class StringTools { * If it is longer than the specified length, only the last part of the string is returned. * If it is shorter than the specified length, it is padded with the * specified character at the front. - * String#frontPadOrTruncateOn(int, char, StringBuilder) + *

+ * + * String.frontPadOrTruncateOn(int, char, StringBuilder) + * */ public static void frontPadOrTruncateOn(char[] string, int length, char c, StringBuilder sb) { int stringLength = string.length; @@ -2342,7 +2534,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and return the result. - * String#removeFirstOccurrence(char) + *

+ * + * String.removeFirstOccurrence(char) + * */ public static String removeFirstOccurrence(String string, char c) { int index = string.indexOf(c); @@ -2366,7 +2561,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, Writer) + *

+ * + * String.removeFirstOccurrenceOn(char, Writer) + * */ public static void removeFirstOccurrenceOn(String string, char c, Writer writer) { int index = string.indexOf(c); @@ -2380,7 +2578,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, StringBuffer) + *

+ * + * String.removeFirstOccurrenceOn(char, StringBuffer) + * */ public static void removeFirstOccurrenceOn(String string, char c, StringBuffer sb) { int index = string.indexOf(c); @@ -2394,7 +2595,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, StringBuilder) + *

+ * + * String.removeFirstOccurrenceOn(char, StringBuilder) + * */ public static void removeFirstOccurrenceOn(String string, char c, StringBuilder sb) { int index = string.indexOf(c); @@ -2408,7 +2612,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and return the result. - * String#removeFirstOccurrence(char) + *

+ * + * String.removeFirstOccurrence(char) + * */ public static char[] removeFirstOccurrence(char[] string, char c) { int index = ArrayTools.indexOf(string, c); @@ -2435,7 +2642,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, Writer) + *

+ * + * String.removeFirstOccurrenceOn(char, Writer) + * */ public static void removeFirstOccurrenceOn(char[] string, char c, Writer writer) { int index = ArrayTools.indexOf(string, c); @@ -2464,7 +2674,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, StringBuffer) + *

+ * + * String.removeFirstOccurrenceOn(char, StringBuffer) + * */ public static void removeFirstOccurrenceOn(char[] string, char c, StringBuffer sb) { int index = ArrayTools.indexOf(string, c); @@ -2493,7 +2706,10 @@ public final class StringTools { /** * Remove the first occurrence of the specified character * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, StringBuilder) + *

+ * + * String.removeFirstOccurrenceOn(char, StringBuilder) + * */ public static void removeFirstOccurrenceOn(char[] string, char c, StringBuilder sb) { int index = ArrayTools.indexOf(string, c); @@ -2522,7 +2738,10 @@ public final class StringTools { /** * Remove all occurrences of the specified character * from the specified string and return the result. - * String#removeAllOccurrences(char) + *

+ * + * String.removeAllOccurrences(char) + * */ public static String removeAllOccurrences(String string, char c) { int first = string.indexOf(c); @@ -2532,7 +2751,10 @@ public final class StringTools { /** * Remove all occurrences of the specified character * from the specified string and write the result to the specified stream. - * String#removeAllOccurrencesOn(char, Writer) + *

+ * + * String.removeAllOccurrencesOn(char, Writer) + * */ public static void removeAllOccurrencesOn(String string, char c, Writer writer) { int first = string.indexOf(c); @@ -2546,7 +2768,10 @@ public final class StringTools { /** * Remove all occurrences of the specified character * from the specified string and write the result to the specified stream. - * String#removeAllOccurrencesOn(char, StringBuffer) + *

+ * + * String.removeAllOccurrencesOn(char, StringBuffer) + * */ public static void removeAllOccurrencesOn(String string, char c, StringBuffer sb) { int first = string.indexOf(c); @@ -2560,7 +2785,10 @@ public final class StringTools { /** * Remove all occurrences of the specified character * from the specified string and write the result to the specified stream. - * String#removeAllOccurrencesOn(char, StringBuilder) + *

+ * + * String.removeAllOccurrencesOn(char, StringBuilder) + * */ public static void removeAllOccurrencesOn(String string, char c, StringBuilder sb) { int first = string.indexOf(c); @@ -2574,7 +2802,10 @@ public final class StringTools { /** * Remove all occurrences of the specified character * from the specified string and return the result. - * String#removeAllOccurrences(char) + *

+ * + * String.removeAllOccurrences(char) + * */ public static char[] removeAllOccurrences(char[] string, char c) { int first = ArrayTools.indexOf(string, c); @@ -2594,7 +2825,10 @@ public final class StringTools { * Remove all occurrences of the specified character * from the specified string and write the result to the * specified writer. - * String#removeAllOccurrencesOn(char, Writer) + *

+ * + * String.removeAllOccurrencesOn(char, Writer) + * */ public static void removeAllOccurrencesOn(char[] string, char c, Writer writer) { int first = ArrayTools.indexOf(string, c); @@ -2623,7 +2857,10 @@ public final class StringTools { * Remove all occurrences of the specified character * from the specified string and append the result to the * specified string buffer. - * String#removeAllOccurrencesOn(char, StringBuffer) + *

+ * + * String.removeAllOccurrencesOn(char, StringBuffer) + * */ public static void removeAllOccurrencesOn(char[] string, char c, StringBuffer sb) { int first = ArrayTools.indexOf(string, c); @@ -2652,7 +2889,10 @@ public final class StringTools { * Remove all occurrences of the specified character * from the specified string and append the result to the * specified string builder. - * String#removeAllOccurrencesOn(char, StringBuilder) + *

+ * + * String.removeAllOccurrencesOn(char, StringBuilder) + * */ public static void removeAllOccurrencesOn(char[] string, char c, StringBuilder sb) { int first = ArrayTools.indexOf(string, c); @@ -2679,7 +2919,10 @@ public final class StringTools { /** * Remove all the spaces from the specified string and return the result. - * String#removeAllSpaces() + *

+ * + * String.removeAllSpaces() + * */ public static String removeAllSpaces(String string) { return removeAllOccurrences(string, ' '); @@ -2688,7 +2931,10 @@ public final class StringTools { /** * Remove all the spaces * from the specified string and write the result to the specified writer. - * String#removeAllSpacesOn(Writer) + *

+ * + * String.removeAllSpacesOn(Writer) + * */ public static void removeAllSpacesOn(String string, Writer writer) { removeAllOccurrencesOn(string, ' ', writer); @@ -2698,7 +2944,10 @@ public final class StringTools { * Remove all the spaces * from the specified string and write the result to the specified * string buffer. - * String#removeAllSpacesOn(StringBuffer) + *

+ * + * String.removeAllSpacesOn(StringBuffer) + * */ public static void removeAllSpacesOn(String string, StringBuffer sb) { removeAllOccurrencesOn(string, ' ', sb); @@ -2708,7 +2957,10 @@ public final class StringTools { * Remove all the spaces * from the specified string and write the result to the specified * string builder. - * String#removeAllSpacesOn(StringBuilder) + *

+ * + * String.removeAllSpacesOn(StringBuilder) + * */ public static void removeAllSpacesOn(String string, StringBuilder sb) { removeAllOccurrencesOn(string, ' ', sb); @@ -2716,7 +2968,10 @@ public final class StringTools { /** * Remove all the spaces from the specified string and return the result. - * String#removeAllSpaces() + *

+ * + * String.removeAllSpaces() + * */ public static char[] removeAllSpaces(char[] string) { return removeAllOccurrences(string, ' '); @@ -2726,7 +2981,10 @@ public final class StringTools { * Remove all the spaces * from the specified string and write the result to the * specified writer. - * String#removeAllSpacesOn(Writer) + *

+ * + * String.removeAllSpacesOn(Writer) + * */ public static void removeAllSpacesOn(char[] string, Writer writer) { removeAllOccurrencesOn(string, ' ', writer); @@ -2736,7 +2994,10 @@ public final class StringTools { * Remove all the spaces * from the specified string and append the result to the * specified string buffer. - * String#removeAllSpacesOn(StringBuffer) + *

+ * + * String.removeAllSpacesOn(StringBuffer) + * */ public static void removeAllSpacesOn(char[] string, StringBuffer sb) { removeAllOccurrencesOn(string, ' ', sb); @@ -2746,7 +3007,10 @@ public final class StringTools { * Remove all the spaces * from the specified string and append the result to the * specified string builder. - * String#removeAllSpacesOn(StringBuilder) + *

+ * + * String.removeAllSpacesOn(StringBuilder) + * */ public static void removeAllSpacesOn(char[] string, StringBuilder sb) { removeAllOccurrencesOn(string, ' ', sb); @@ -2754,7 +3018,10 @@ public final class StringTools { /** * Remove all the whitespace from the specified string and return the result. - * String#removeAllWhitespace() + *

+ * + * String.removeAllWhitespace() + * */ public static String removeAllWhitespace(String string) { char[] string2 = string.toCharArray(); @@ -2766,7 +3033,10 @@ public final class StringTools { * Remove all the whitespace * from the specified string and append the result to the * specified writer. - * String#removeAllWhitespaceOn(Writer) + *

+ * + * String.removeAllWhitespaceOn(Writer) + * */ public static void removeAllWhitespaceOn(String string, Writer writer) { char[] string2 = string.toCharArray(); @@ -2782,7 +3052,10 @@ public final class StringTools { * Remove all the whitespace * from the specified string and append the result to the * specified string buffer. - * String#removeAllWhitespaceOn(StringBuffer) + *

+ * + * String.removeAllWhitespaceOn(StringBuffer) + * */ public static void removeAllWhitespaceOn(String string, StringBuffer sb) { char[] string2 = string.toCharArray(); @@ -2798,7 +3071,10 @@ public final class StringTools { * Remove all the whitespace * from the specified string and append the result to the * specified string builder. - * String#removeAllWhitespaceOn(StringBuilder) + *

+ * + * String.removeAllWhitespaceOn(StringBuilder) + * */ public static void removeAllWhitespaceOn(String string, StringBuilder sb) { char[] string2 = string.toCharArray(); @@ -2812,7 +3088,10 @@ public final class StringTools { /** * Remove all the whitespace from the specified string and return the result. - * String#removeAllWhitespace() + *

+ * + * String.removeAllWhitespace() + * */ public static char[] removeAllWhitespace(char[] string) { int first = indexOfWhitespace_(string); @@ -2842,7 +3121,10 @@ public final class StringTools { * Remove all the whitespace * from the specified string and append the result to the * specified writer. - * String#removeAllWhitespaceOn(Writer) + *

+ * + * String.removeAllWhitespaceOn(Writer) + * */ public static void removeAllWhitespaceOn(char[] string, Writer writer) { int first = indexOfWhitespace_(string); @@ -2871,7 +3153,10 @@ public final class StringTools { * Remove all the whitespace * from the specified string and append the result to the * specified string buffer. - * String#removeAllWhitespaceOn(StringBuffer) + *

+ * + * String.removeAllWhitespaceOn(StringBuffer) + * */ public static void removeAllWhitespaceOn(char[] string, StringBuffer sb) { int first = indexOfWhitespace_(string); @@ -2900,7 +3185,10 @@ public final class StringTools { * Remove all the whitespace * from the specified string and append the result to the * specified string builder. - * String#removeAllWhitespaceOn(StringBuilder) + *

+ * + * String.removeAllWhitespaceOn(StringBuilder) + * */ public static void removeAllWhitespaceOn(char[] string, StringBuilder sb) { int first = indexOfWhitespace_(string); @@ -2929,7 +3217,10 @@ public final class StringTools { * Compress the whitespace in the specified string and return the result. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespace() + *

+ * + * String.compressWhitespace() + * */ public static String compressWhitespace(String string) { char[] string2 = string.toCharArray(); @@ -2943,7 +3234,10 @@ public final class StringTools { * specified writer. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespaceOn(Writer) + *

+ * + * String.compressWhitespaceOn(Writer) + * */ public static void compressWhitespaceOn(String string, Writer writer) { char[] string2 = string.toCharArray(); @@ -2961,7 +3255,10 @@ public final class StringTools { * specified string buffer. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespaceOn(StringBuffer) + *

+ * + * String.compressWhitespaceOn(StringBuffer) + * */ public static void compressWhitespaceOn(String string, StringBuffer sb) { char[] string2 = string.toCharArray(); @@ -2979,7 +3276,10 @@ public final class StringTools { * specified string builder. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespaceOn(StringBuilder) + *

+ * + * String.compressWhitespaceOn(StringBuilder) + * */ public static void compressWhitespaceOn(String string, StringBuilder sb) { char[] string2 = string.toCharArray(); @@ -2995,7 +3295,10 @@ public final class StringTools { * Compress the whitespace in the specified string and return the result. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespace() + *

+ * + * String.compressWhitespace() + * */ public static char[] compressWhitespace(char[] string) { int first = indexOfWhitespace_(string); @@ -3017,7 +3320,10 @@ public final class StringTools { * specified writer. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespaceOn(Writer) + *

+ * + * String.compressWhitespaceOn(Writer) + * */ public static void compressWhitespaceOn(char[] string, Writer writer) { int first = indexOfWhitespace_(string); @@ -3058,7 +3364,10 @@ public final class StringTools { * specified string buffer. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespaceOn(StringBuffer) + *

+ * + * String.compressWhitespaceOn(StringBuffer) + * */ public static void compressWhitespaceOn(char[] string, StringBuffer sb) { int first = indexOfWhitespace_(string); @@ -3099,7 +3408,10 @@ public final class StringTools { * specified string builder. * The whitespace is compressed by replacing any occurrence of one or more * whitespace characters with a single space. - * String#compressWhitespaceOn(StringBuilder) + *

+ * + * String.compressWhitespaceOn(StringBuilder) + * */ public static void compressWhitespaceOn(char[] string, StringBuilder sb) { int first = indexOfWhitespace_(string); @@ -3139,7 +3451,10 @@ public final class StringTools { /** * Return the length of the common prefix shared by the specified strings. - * String#commonPrefixLength(String) + *

+ * + * String.commonPrefixLength(String) + * */ public static int commonPrefixLength(String s1, String s2) { return commonPrefixLength(s1.toCharArray(), s2.toCharArray()); @@ -3155,7 +3470,10 @@ public final class StringTools { /** * Return the length of the common prefix shared by the specified strings; * but limit the length to the specified maximum. - * String#commonPrefixLength(String, int) + *

+ * + * String.commonPrefixLength(String, int) + * */ public static int commonPrefixLength(String s1, String s2, int max) { return commonPrefixLength(s1.toCharArray(), s2.toCharArray(), max); @@ -3207,7 +3525,10 @@ public final class StringTools { /** * Return the specified string with its first letter capitalized. - * String#capitalize() + *

+ * + * String.capitalize() + * */ public static String capitalize(String string) { if ((string.length() == 0) || Character.isUpperCase(string.charAt(0))) { @@ -3288,7 +3609,10 @@ public final class StringTools { /** * Append the specified string to the specified string buffer * with its first letter capitalized. - * String#capitalizeOn(StringBuffer) + *

+ * + * String.capitalizeOn(StringBuffer) + * */ public static void capitalizeOn(String string, StringBuffer sb) { if (string.length() == 0) { @@ -3327,7 +3651,10 @@ public final class StringTools { /** * Append the specified string to the specified string builder * with its first letter capitalized. - * String#capitalizeOn(StringBuffer) + *

+ * + * String.capitalizeOn(StringBuffer) + * */ public static void capitalizeOn(String string, StringBuilder sb) { if (string.length() == 0) { @@ -3366,7 +3693,10 @@ public final class StringTools { /** * Append the specified string to the specified string buffer * with its first letter capitalized. - * String#capitalizeOn(Writer) + *

+ * + * String.capitalizeOn(Writer) + * */ public static void capitalizeOn(String string, Writer writer) { if (string.length() == 0) { @@ -3438,7 +3768,10 @@ public final class StringTools { * Return the specified string with its first letter converted to lower case. * (Unless both the first and second letters are upper case, * in which case the string is returned unchanged.) - * String#uncapitalize() + *

+ * + * String.uncapitalize() + * */ public static String uncapitalize(String string) { if (stringNeedNotBeUncapitalized_(string)) { @@ -3474,7 +3807,10 @@ public final class StringTools { * with its first letter converted to lower case. * (Unless both the first and second letters are upper case, * in which case the string is returned unchanged.) - * String#uncapitalizeOn(StringBuffer) + *

+ * + * String.uncapitalizeOn(StringBuffer) + * */ public static void uncapitalizeOn(String string, StringBuffer sb) { if (stringNeedNotBeUncapitalized_(string)) { @@ -3511,7 +3847,10 @@ public final class StringTools { * with its first letter converted to lower case. * (Unless both the first and second letters are upper case, * in which case the string is returned unchanged.) - * String#uncapitalizeOn(StringBuffer) + *

+ * + * String.uncapitalizeOn(StringBuffer) + * */ public static void uncapitalizeOn(String string, StringBuilder sb) { if (stringNeedNotBeUncapitalized_(string)) { @@ -3548,7 +3887,10 @@ public final class StringTools { * with its first letter converted to lower case. * (Unless both the first and second letters are upper case, * in which case the string is returned unchanged.) - * String#uncapitalizeOn(Writer) + *

+ * + * String.uncapitalizeOn(Writer) + * */ public static void uncapitalizeOn(String string, Writer writer) { if (stringNeedNotBeUncapitalized_(string)) { @@ -3559,17 +3901,17 @@ public final class StringTools { } - // ********** #toString() helper methods ********** + // ********** toString() helper methods ********** /** - * Build a "standard" {@link Object#toString() toString()} result for the - * specified object and additional information:

+	 * Build a "Dali standard" {@link Object#toString() toString()} result for
+	 * the specified object and additional information:
 	 *     ClassName[00-F3-EE-42](add'l info)
 	 * 
*/ public static String buildToStringFor(Object o, Object additionalInfo) { StringBuilder sb = new StringBuilder(); - buildSimpleToStringOn(o, sb); + appendSimpleToString(sb, o); sb.append('('); sb.append(additionalInfo); sb.append(')'); @@ -3577,59 +3919,92 @@ public final class StringTools { } /** - * Build a "standard" {@link Object#toString() toString()} result for the - * specified object:
+	 * Build a "Dali standard" {@link Object#toString() toString()} result for
+	 * the specified object:
 	 *     ClassName[00-F3-EE-42]
 	 * 
*/ public static String buildToStringFor(Object o) { StringBuilder sb = new StringBuilder(); - buildSimpleToStringOn(o, sb); + appendSimpleToString(sb, o); return sb.toString(); } /** - * Append a "standard" {@link Object#toString() toString()} result for the - * specified object to the specified buffer:
+	 * Append a "Dali standard" {@link Object#toString() toString()} result for
+	 * the specified object to the specified string builder:
 	 *     ClassName[00-F3-EE-42]
-	 * 
*/ - public static void buildSimpleToStringOn(Object o, StringBuffer sb) { - sb.append(buildToStringClassName(o.getClass())); + public static void appendSimpleToString(StringBuilder sb, Object o) { + appendToStringClassName(sb, o.getClass()); sb.append('['); separateOn(buildHashCode(o), '-', 2, sb); sb.append(']'); } private static String buildHashCode(Object o) { - // use System#identityHashCode(Object), since Object#hashCode() may be overridden + // use System.identityHashCode(Object), since Object.hashCode() may be overridden return zeroPad(Integer.toHexString(System.identityHashCode(o)).toUpperCase(), 8); } /** - * Append a "standard" {@link Object#toString() toString()} result for the - * specified object to the specified string builder:
-	 *     ClassName[00-F3-EE-42]
-	 * 
+ * Return a name suitable for a "Dali standard" + * {@link Object#toString() toString()} implementation. + * {@link Class#getSimpleName()} isn't quite useful enough:
    + *
  • An anonymous class's simple name is an empty string. + * Return the "Dali standard" name of the anonymous class's super class + * instead, which is a bit more helpful. + *
  • A member or local class's simple name does not + * include its context. Prefix the class's simple name with its + * enclosing class's "Dali standard" name. + *
*/ - public static void buildSimpleToStringOn(Object o, StringBuilder sb) { - sb.append(buildToStringClassName(o.getClass())); - sb.append('['); - separateOn(buildHashCode(o), '-', 2, sb); - sb.append(']'); + public static String buildToStringClassName(Class javaClass) { + StringBuilder sb = new StringBuilder(); + appendToStringClassName(sb, javaClass); + return sb.toString(); } /** - * Return a name suitable for a {@link Object#toString() toString()} implementation. - * {@link Class#getSimpleName()} isn't quite good enough for anonymous - * classes; since it returns an empty string. This method will return the - * name of the anonymous class's super class, which is a bit more helpful. + * Return a string suitable for a singleton; which is the simple + * name of the object's class, since there should only be one. */ - public static String buildToStringClassName(Class javaClass) { - String simpleName = javaClass.getSimpleName(); - return simpleName.equals("") ? //$NON-NLS-1$ - buildToStringClassName(javaClass.getSuperclass()) : // recurse - simpleName; + public static String buildSingletonToString(Object o) { + return buildToStringClassName(o.getClass()); + } + + /** + * Append a name suitable for a "Dali standard" + * {@link Object#toString() toString()} implementation to the specified + * string builder. + * @see #buildToStringClassName(Class) + */ + public static void appendToStringClassName(StringBuilder sb, Class javaClass) { + if (javaClass.isAnonymousClass()) { + appendToStringClassName(sb, javaClass.getSuperclass()); // recurse + } else { + Class enclosingClass = javaClass.getEnclosingClass(); + if (enclosingClass == null) { + appendToStringClassName_(sb, javaClass); // top-level class + } else { + appendToStringClassName(sb, enclosingClass); // recurse + sb.append('.'); + sb.append(javaClass.getSimpleName()); + } + } + } + + /** + * pre-condition: the specified class is a top-level class + */ + private static void appendToStringClassName_(StringBuilder sb, Class javaClass) { + String fullName = javaClass.getName(); + int dot = fullName.lastIndexOf('.'); + if (dot == -1) { + sb.append(fullName); // "default" package + } else { + sb.append(fullName, dot + 1, fullName.length()); + } } /** @@ -3637,6 +4012,10 @@ public final class StringTools { * to the specified string builder:
 	 *     ["foo", "bar", "baz"]
 	 * 
+ *

+ * + * StringBuilder.append(Object[]) + * */ public static String append(StringBuilder sb, T[] array) { return append(sb, new ArrayListIterator(array)); @@ -3647,6 +4026,10 @@ public final class StringTools { * to the specified string builder:

 	 *     ["foo", "bar", "baz"]
 	 * 
+ *

+ * + * StringBuilder.append(Iterable) + * */ public static String append(StringBuilder sb, Iterable iterable) { return append(sb, iterable.iterator()); @@ -3657,6 +4040,10 @@ public final class StringTools { * to the specified string builder:

 	 *     ["foo", "bar", "baz"]
 	 * 
+ *

+ * + * StringBuilder.append(Iterator) + * */ public static String append(StringBuilder sb, Iterator iterator) { sb.append('['); @@ -3674,8 +4061,8 @@ public final class StringTools { // ********** queries ********** /** - * Return whether the specified string is null, empty, or contains - * only whitespace characters. + * Return whether the specified string is null, empty, or + * contains only whitespace characters. */ public static boolean stringIsEmpty(String string) { if (string == null) { @@ -3689,8 +4076,8 @@ public final class StringTools { } /** - * Return whether the specified string is null, empty, or contains - * only whitespace characters. + * Return whether the specified string is null, empty, or + * contains only whitespace characters. */ public static boolean stringIsEmpty(char[] string) { if (string == null) { @@ -3713,16 +4100,16 @@ public final class StringTools { } /** - * Return whether the specified string is non-null, non-empty, and does - * not contain only whitespace characters. + * Return whether the specified string is non-null, non-empty, + * and does not contain only whitespace characters. */ public static boolean stringIsNotEmpty(String string) { return ! stringIsEmpty(string); } /** - * Return whether the specified string is non-null, non-empty, and does - * not contain only whitespace characters. + * Return whether the specified string is non-null, non-empty, + * and does not contain only whitespace characters. */ public static boolean stringIsNotEmpty(char[] string) { return ! stringIsEmpty(string); @@ -3825,7 +4212,7 @@ public final class StringTools { /** * Return whether the specified characters are are equal, ignoring case. - * @see java.lang.String#regionMatches(boolean, int, String, int, int) + * @see String#regionMatches(boolean, int, String, int, int) */ public static boolean charactersAreEqualIgnoreCase(char c1, char c2) { // something about the Georgian alphabet requires us to check lower case also diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java index d95534e737..38430f5ce1 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 Oracle. All rights reserved. + * Copyright (c) 2005, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -33,7 +33,9 @@ public interface Transformer { * A "null" transformer will perform no transformation at all; * it will simply return the object "untransformed". */ - final class Null implements Transformer, Serializable { + final class Null + implements Transformer, Serializable + { @SuppressWarnings("rawtypes") public static final Transformer INSTANCE = new Null(); @SuppressWarnings("unchecked") @@ -51,7 +53,7 @@ public interface Transformer { } @Override public String toString() { - return "Transformer.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -66,7 +68,9 @@ public interface Transformer { * where a transformer is optional and the default transformer should * not be used. */ - final class Disabled implements Transformer, Serializable { + final class Disabled + implements Transformer, Serializable + { @SuppressWarnings("rawtypes") public static final Transformer INSTANCE = new Disabled(); @SuppressWarnings("unchecked") @@ -83,7 +87,7 @@ public interface Transformer { } @Override public String toString() { - return "Transformer.Disabled"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -91,5 +95,4 @@ public interface Transformer { return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java index e880beb71f..c8d1dc690b 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -985,7 +985,7 @@ public abstract class AbstractModel @Override public String toString() { StringBuilder sb = new StringBuilder(); - StringTools.buildSimpleToStringOn(this, sb); + StringTools.appendSimpleToString(sb, this); sb.append('('); int len = sb.length(); this.toString(sb); diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java index 9d702bac6c..22247ecfdc 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -47,7 +47,7 @@ public abstract class ChangeEvent extends EventObject { @Override public String toString() { StringBuilder sb = new StringBuilder(); - StringTools.buildSimpleToStringOn(this, sb); + StringTools.appendSimpleToString(sb, this); sb.append('('); int len = sb.length(); this.toString(sb); diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java index 029227a8c7..af1662a4bb 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * Copyright (c) 2009, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,6 +11,7 @@ package org.eclipse.jpt.common.utility.synchronizers; import java.io.Serializable; import java.util.EventListener; +import org.eclipse.jpt.common.utility.internal.StringTools; /** * Extend {@link Synchronizer} to notify listeners @@ -54,7 +55,9 @@ public interface CallbackSynchronizer * Singleton implementation of the {@link CallbackSynchronizer} interface that will do * nothing. */ - final class Null implements CallbackSynchronizer, Serializable { + final class Null + implements CallbackSynchronizer, Serializable + { public static final CallbackSynchronizer INSTANCE = new Null(); public static CallbackSynchronizer instance() { return INSTANCE; @@ -80,7 +83,7 @@ public interface CallbackSynchronizer } @Override public String toString() { - return "CallbackSynchronizer.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -88,5 +91,4 @@ public interface CallbackSynchronizer return INSTANCE; } } - } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java index 230fb86eb3..df45d78230 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * Copyright (c) 2008, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -10,6 +10,7 @@ package org.eclipse.jpt.common.utility.synchronizers; import java.io.Serializable; +import org.eclipse.jpt.common.utility.internal.StringTools; /** * This interface defines the protocol for starting, stopping, and executing a @@ -51,7 +52,9 @@ public interface Synchronizer { * Singleton implementation of the {@link Synchronizer} interface that will do * nothing. */ - final class Null implements Synchronizer, Serializable { + final class Null + implements Synchronizer, Serializable + { public static final Synchronizer INSTANCE = new Null(); public static Synchronizer instance() { return INSTANCE; @@ -71,7 +74,7 @@ public interface Synchronizer { } @Override public String toString() { - return "Synchronizer.Null"; //$NON-NLS-1$ + return StringTools.buildSingletonToString(this); } private static final long serialVersionUID = 1L; private Object readResolve() { @@ -79,5 +82,4 @@ public interface Synchronizer { return INSTANCE; } } - } diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java index 137b55249a..b34bab2474 100644 --- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java +++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 Oracle. All rights reserved. + * Copyright (c) 2005, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -1045,6 +1045,27 @@ public class StringToolsTests extends TestCase { assertEquals("Object", StringTools.buildToStringClassName(o.getClass())); } + public void testBuildToStringClassName_member() { + assertEquals("Map.Entry", StringTools.buildToStringClassName(java.util.Map.Entry.class)); + } + + public void testBuildToStringClassName_local() { + class Foo { + Bar bar = new Bar(); + class Bar { + Bar() { + super(); + } + } + Foo() { + super(); + } + } + Foo foo = new Foo(); + assertEquals("StringToolsTests.Foo", StringTools.buildToStringClassName(foo.getClass())); + assertEquals("StringToolsTests.Foo.Bar", StringTools.buildToStringClassName(foo.bar.getClass())); + } + // ********** queries ********** public void testStringIsEmptyString() { -- cgit v1.2.3