From 82214ae9ccf71a869b4b22a171de7815dbbaa03e Mon Sep 17 00:00:00 2001 From: Robert Schuster Date: Fri, 18 Feb 2005 07:44:59 +0000 Subject: [PATCH] Charset.java (forName): Throws IllegalArgumentException when argument is null and added documentation. 2005-02-18 Robert Schuster * java/nio/charset/Charset.java (forName): Throws IllegalArgumentException when argument is null and added documentation. From-SVN: r95218 --- libjava/ChangeLog | 6 ++++++ libjava/java/nio/charset/Charset.java | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index cb0e02463e2..d6c781ea634 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2005-02-18 Robert Schuster + + * java/nio/charset/Charset.java (forName): Throws + IllegalArgumentException when argument is null + and added documentation. + 2005-02-17 Ito Kazumitsu * gnu/java/nio/channels/FileChannelImpl.java (write(ByteBuffer)): diff --git a/libjava/java/nio/charset/Charset.java b/libjava/java/nio/charset/Charset.java index 5bb78f63ca9..67e4fb146ff 100644 --- a/libjava/java/nio/charset/Charset.java +++ b/libjava/java/nio/charset/Charset.java @@ -117,9 +117,24 @@ public abstract class Charset implements Comparable { return charsetForName (charsetName) != null; } - + + /** + * Returns the Charset instance for the charset of the given name. + * + * @param charsetName + * @return + * @throws UnsupportedCharsetException if this VM does not support + * the charset of the given name. + * @throws IllegalCharsetNameException if the given charset name is + * legal. + * @throws IllegalArgumentException if charsetName is null. + */ public static Charset forName (String charsetName) { + // Throws IllegalArgumentException as the JDK does. + if(charsetName == null) + throw new IllegalArgumentException("Charset name must not be null."); + Charset cs = charsetForName (charsetName); if (cs == null) throw new UnsupportedCharsetException (charsetName); -- 2.30.2