001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.resource; 018 019import java.io.IOException; 020import java.io.InputStream; 021import java.io.InputStreamReader; 022import java.io.Reader; 023 024import org.apache.wicket.util.value.ValueMap; 025 026/** 027 * Load properties from properties file via a Reader, which allows to provide the charset and thus 028 * the encoding can be different than ISO 8859-1. 029 * 030 * @author Juergen Donnerstag 031 */ 032public class UtfPropertiesFilePropertiesLoader implements IPropertiesLoader 033{ 034 private final String fileExtension; 035 036 private final String encoding; 037 038 /** 039 * Construct. 040 * 041 * @param fileExtension 042 * @param encoding 043 */ 044 public UtfPropertiesFilePropertiesLoader(final String fileExtension, final String encoding) 045 { 046 this.fileExtension = fileExtension; 047 this.encoding = encoding; 048 } 049 050 /** 051 * @see org.apache.wicket.resource.IPropertiesLoader#getFileExtension() 052 */ 053 @Override 054 public final String getFileExtension() 055 { 056 return fileExtension; 057 } 058 059 /** 060 * @see org.apache.wicket.resource.IPropertiesLoader#loadJavaProperties(java.io.InputStream) 061 */ 062 @Override 063 public java.util.Properties loadJavaProperties(final InputStream in) throws IOException 064 { 065 java.util.Properties properties = new java.util.Properties(); 066 Reader reader = new InputStreamReader(in, encoding); 067 068 properties.load(reader); 069 070 return properties; 071 } 072 073 /** 074 * @see org.apache.wicket.resource.IPropertiesLoader#loadWicketProperties(java.io.InputStream) 075 */ 076 @Override 077 public ValueMap loadWicketProperties(InputStream inputStream) 078 { 079 return null; 080 } 081}