Skip to content

Commit

Permalink
Fix 120-length warnings reported for 2.1-RC4 here: http://people.apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed May 2, 2005
1 parent a8a5bea commit bc218db
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 46 deletions.
48 changes: 32 additions & 16 deletions src/java/org/apache/commons/lang/CharEncoding.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@
import java.io.UnsupportedEncodingException;

/**
* <p>Character encoding names required of every implementation of the Java platform.</p>
* <p>
* Character encoding names required of every implementation of the Java platform.
* </p>
*
* <p>According to the Java documentation
* <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>:<br />
* <p>
* According to <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>:
* <p>
* <cite>Every implementation of the Java platform is required to support the following character encodings. Consult the
* release documentation for your implementation to see if any other encodings are supported. </cite>
* release documentation for your implementation to see if any other encodings are supported.</cite>
* </p>
* </p>
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding
* names</a>
* @author Apache Software Foundation
* @since 2.1
* @version $Id$
Expand All @@ -42,7 +48,8 @@ public class CharEncoding {
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>
*/
public static final String ISO_8859_1 = "ISO-8859-1";

Expand All @@ -54,7 +61,8 @@ public class CharEncoding {
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>
*/
public static final String US_ASCII = "US-ASCII";

Expand All @@ -67,7 +75,8 @@ public class CharEncoding {
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>
*/
public static final String UTF_16 = "UTF-16";

Expand All @@ -79,7 +88,8 @@ public class CharEncoding {
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>
*/
public static final String UTF_16BE = "UTF-16BE";

Expand All @@ -91,7 +101,8 @@ public class CharEncoding {
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>
*/
public static final String UTF_16LE = "UTF-16LE";

Expand All @@ -103,7 +114,8 @@ public class CharEncoding {
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>
*/
public static final String UTF_8 = "UTF-8";

Expand All @@ -112,14 +124,18 @@ public class CharEncoding {
* Returns whether the named charset is supported.
* </p>
* <p>
* This is similar to
* <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html#isSupported(java.lang.String)">java.nio.charset.Charset.isSupported(String)</a>
* This is similar to <a
* href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html#isSupported(java.lang.String)">
* java.nio.charset.Charset.isSupported(String)</a>
* </p>
*
* @param name the name of the requested charset; may be either a canonical name or an alias
* @return <code>true</code> if, and only if, support for the named charset is available in the current Java virtual machine
* @param name
* the name of the requested charset; may be either a canonical name or an alias
* @return <code>true</code> if, and only if, support for the named charset is available in the current Java
* virtual machine
*
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character encoding names</a>
* @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character
* encoding names</a>
*/
public static boolean isSupported(String name) {
if (name == null) {
Expand Down
7 changes: 6 additions & 1 deletion src/java/org/apache/commons/lang/StringEscapeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,12 @@ public static void unescapeJavaScript(Writer out, String str) throws IOException
* <p>Escapes the characters in a <code>String</code> using HTML entities.</p>
*
* <p>
* For example: <tt>"bread" & "butter"</tt> => <tt>&amp;quot;bread&amp;quot; &amp;amp; &amp;quot;butter&amp;quot;</tt>.
* For example:
* </p>
* <p><code>"bread" & "butter"</code></p>
* becomes:
* <p>
* <code>&amp;quot;bread&amp;quot; &amp;amp; &amp;quot;butter&amp;quot;</code>.
* </p>
*
* <p>Supports all known HTML 4.0 entities, including funky accents.</p>
Expand Down
3 changes: 2 additions & 1 deletion src/java/org/apache/commons/lang/SystemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ public class SystemUtils {
* @since 2.1
* @since Java 1.4
*/
public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = getSystemProperty("java.util.prefs.PreferencesFactory");
public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY =
getSystemProperty("java.util.prefs.PreferencesFactory");

/**
* <p>The <code>java.vendor</code> System Property. Java vendor-specific string.</p>
Expand Down
21 changes: 13 additions & 8 deletions src/java/org/apache/commons/lang/Validate.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,18 +518,23 @@ public static void allElementsOfType(Collection collection, Class clazz, String
}

/**
* <p>Validate an argument, throwing <code>IllegalArgumentException</code>
* if the argument collection is <code>null</code> or has elements that are not of
* type <code>clazz</code> or a subclass.</p>
*
* <p>
* Validate an argument, throwing <code>IllegalArgumentException</code> if the argument collection is
* <code>null</code> or has elements that are not of type <code>clazz</code> or a subclass.
* </p>
*
* <pre>
* Validate.allElementsOfType(collection, String.class);
* </pre>
*
* <p>The message in the exception is 'The validated collection contains an element not of type clazz at index: '.</p>
*
* @param collection the collection to check, not null
* @param clazz the <code>Class</code> which the collection's elements are expected to be, not null
* <p>
* The message in the exception is 'The validated collection contains an element not of type clazz at index: '.
* </p>
*
* @param collection
* the collection to check, not null
* @param clazz
* the <code>Class</code> which the collection's elements are expected to be, not null
* @since 2.1
*/
public static void allElementsOfType(Collection collection, Class clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ public static String toString(Object object, ToStringStyle style, boolean output
* if the Object is <code>null</code>
* @since 2.0
*/
public static String toString(Object object, ToStringStyle style, boolean outputTransients, Class reflectUpToClass) {
public static String toString(Object object, ToStringStyle style, boolean outputTransients,
Class reflectUpToClass) {
return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients).toString();
}

Expand Down
39 changes: 24 additions & 15 deletions src/java/org/apache/commons/lang/time/DurationFormatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static String formatDurationWords(
* @return the time as a String
*/
public static String formatPeriodISO(long startMillis, long endMillis) {
return formatPeriod(startMillis, endMillis, ISO_EXTENDED_FORMAT_PATTERN, false, TimeZone.getDefault() );
return formatPeriod(startMillis, endMillis, ISO_EXTENDED_FORMAT_PATTERN, false, TimeZone.getDefault());
}

/**
Expand Down Expand Up @@ -257,7 +257,8 @@ public static String formatPeriod(long startMillis, long endMillis, String forma
* @param timezone the millis are defined in
* @return the time as a String
*/
public static String formatPeriod(long startMillis, long endMillis, String format, boolean padWithZeros, TimeZone timezone) {
public static String formatPeriod(long startMillis, long endMillis, String format, boolean padWithZeros,
TimeZone timezone) {

long millis = endMillis - startMillis;
if (millis < 28 * DateUtils.MILLIS_PER_DAY) {
Expand Down Expand Up @@ -368,50 +369,58 @@ public static String formatPeriod(long startMillis, long endMillis, String forma
* @param padWithZeros whether to pad
* @return the formetted string
*/
static String format(Token[] tokens, int years, int months, int days, int hours,
int minutes, int seconds, int milliseconds, boolean padWithZeros)
{
static String format(Token[] tokens, int years, int months, int days, int hours, int minutes, int seconds,
int milliseconds, boolean padWithZeros) {
StringBuffer buffer = new StringBuffer();
boolean lastOutputSeconds = false;
int sz = tokens.length;
for (int i = 0; i < sz; i++) {
Token token = tokens[i];
Object value = token.getValue();
int count = token.getCount();
if(value instanceof StringBuffer) {
if (value instanceof StringBuffer) {
buffer.append(value.toString());
} else {
if (value == y) {
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(years), count, '0') : Integer.toString(years));
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(years), count, '0') : Integer
.toString(years));
lastOutputSeconds = false;
} else if (value == M) {
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(months), count, '0') : Integer.toString(months));
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(months), count, '0') : Integer
.toString(months));
lastOutputSeconds = false;
} else if (value == d) {
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(days), count, '0') : Integer.toString(days));
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(days), count, '0') : Integer
.toString(days));
lastOutputSeconds = false;
} else if (value == H) {
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(hours), count, '0') : Integer.toString(hours));
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(hours), count, '0') : Integer
.toString(hours));
lastOutputSeconds = false;
} else if (value == m) {
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(minutes), count, '0') : Integer.toString(minutes));
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(minutes), count, '0') : Integer
.toString(minutes));
lastOutputSeconds = false;
} else if (value == s) {
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(seconds), count, '0') : Integer.toString(seconds));
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(seconds), count, '0') : Integer
.toString(seconds));
lastOutputSeconds = true;
} else if (value == S) {
if (lastOutputSeconds) {
milliseconds += 1000;
String str = padWithZeros ? StringUtils.leftPad(Integer.toString(milliseconds), count, '0') : Integer.toString(milliseconds);
String str = padWithZeros
? StringUtils.leftPad(Integer.toString(milliseconds), count, '0')
: Integer.toString(milliseconds);
buffer.append(str.substring(1));
} else {
buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(milliseconds), count, '0') : Integer.toString(milliseconds));
buffer.append(padWithZeros
? StringUtils.leftPad(Integer.toString(milliseconds), count, '0')
: Integer.toString(milliseconds));
}
lastOutputSeconds = false;
}
}
}

return buffer.toString();
}

Expand Down
9 changes: 5 additions & 4 deletions src/java/org/apache/commons/lang/time/FastDateFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ public static FastDateFormat getDateTimeInstance(
* @throws IllegalArgumentException if the Locale has no date/time
* pattern defined
*/
public static synchronized FastDateFormat getDateTimeInstance(
int dateStyle, int timeStyle, TimeZone timeZone, Locale locale) {
public static synchronized FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone,
Locale locale) {

Object key = new Pair(new Integer(dateStyle), new Integer(timeStyle));
if (timeZone != null) {
Expand All @@ -463,11 +463,12 @@ public static synchronized FastDateFormat getDateTimeInstance(
}

try {
SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle, timeStyle,
locale);
String pattern = formatter.toPattern();
format = getInstance(pattern, timeZone, locale);
cDateTimeInstanceCache.put(key, format);

} catch (ClassCastException ex) {
throw new IllegalArgumentException("No date time pattern for locale: " + locale);
}
Expand Down

0 comments on commit bc218db

Please sign in to comment.