/*
 * $Id$
 * $Revision$ $Date$
 * 
 * ==============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package wicket.util.resource;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

import wicket.WicketRuntimeException;
import wicket.util.io.Streams;

/**
 * @see wicket.util.resource.IResource
 * 
 * @author Jonathan Locke
 */
public abstract class AbstractResource implements IStringResource
{
	/** Charset for resource */
	private Charset charset = Charset.defaultCharset();

	/**
	 * Sets the character set used for reading this resource.
	 * 
	 * @param charset
	 *            Charset for component
	 */
	public void setCharset(final Charset charset)
	{
		this.charset = charset;
	}

	/**
	 * @return This resource as a String.
	 */
	public String asString()
	{
		try
		{
			return Streams.readString(new InputStreamReader(getInputStream(), charset));
		}
		catch (IOException e)
		{
			throw new WicketRuntimeException("Unable to read resource as String", e);
		}
		catch (ResourceNotFoundException e)
		{
			throw new WicketRuntimeException("Unable to read resource as String", e);
		}
	}

	/**
	 * @return Charset for resource
	 */
	protected Charset getCharset()
	{
		return charset;
	}
}

@@ -1067,35 +1067,8 @@
 rset
- = Charset.defaultCharset()
 ;%0A%0A%09
@@ -1364,16 +1364,136 @@
 try%0A%09%09%7B%0A
+%09%09%09if (charset == null)%0A%09%09%09%7B%0A%09%09%09%09return Streams.readString(new InputStreamReader(getInputStream()));%0A%09%09%09%7D%0A%09%09%09else%0A%09%09%09%7B%0A%09
 %09%09%09retur
@@ -1564,16 +1564,21 @@
 rset));%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09ca

Fix for 1.4 JDK and before.