Java tutorial
/* * Copyright 2010 the original author or authors. * * 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 org.openehealth.ipf.commons.map.config; import java.util.ArrayList; import java.util.Collection; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.core.io.Resource; /** * This class should be used to define the custom mappings * in the spring context definition. * * <pre class="code"> * <!-- either as a list of mapping definitions --> * <bean id="customMapping3" * class="org.openehealth.ipf.commons.map.config.CustomMappings"> * <property name="mappingScripts"> * <list> * <value>classpath:configurer1.map</value> * <value>classpath:configurer2.map</value> * </list> * </property> * </bean> * * <!-- or as a single mapping definition --> * <bean id="customMappingSingle" * class="org.openehealth.ipf.commons.map.config.CustomMappings"> * <property name="mappingScript" value="classpath:configurer3.map" /> * </bean></pre> * * @see CustomMappingsConfigurer * @author Christian Ohr * @author Boris Stanojevic * */ public class CustomMappings { private Collection<Resource> mappingScripts; private Resource mappingScript; private static final Log LOG = LogFactory.getLog(CustomMappings.class); public Collection<Resource> getMappingScripts() { return mappingScripts; } public void setMappingScripts(Collection<Resource> mappingScripts) { this.mappingScripts = new ArrayList<Resource>(mappingScripts.size()); for (Resource mappingScript : mappingScripts) { if (mappingScript.exists() && mappingScript.isReadable()) { this.mappingScripts.add(mappingScript); } else { LOG.warn("Could not read mapping script " + mappingScript.getFilename()); } } this.mappingScripts = mappingScripts; } public Resource getMappingScript() { return mappingScript; } public void setMappingScript(Resource mappingScript) { if (mappingScript.exists() && mappingScript.isReadable()) { this.mappingScript = mappingScript; } else { LOG.warn("Could not read mapping script " + mappingScript.getFilename()); } } }