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.commons.configuration2.interpol;
018
019
020/**
021 * <p>
022 * A specialized lookup implementation that allows access to environment
023 * variables.
024 * </p>
025 * <p>
026 * This implementation relies on {@link System#getenv()} to resolve
027 * environment variables. It can be used for referencing environment variables
028 * in configuration files in an easy way, for instance:
029 * </p>
030 *
031 * <pre>
032 * java.home = ${env:JAVA_HOME}
033 * </pre>
034 *
035 * <p>
036 * {@code EnvironmentLookup} is one of the standard lookups that is
037 * registered per default for each configuration.
038 * </p>
039 *
040 * @author <a
041 *         href="http://commons.apache.org/configuration/team-list.html">Commons
042 *         Configuration team</a>
043 * @since 1.7
044 * @version $Id: EnvironmentLookup.java 1843310 2018-10-09 16:43:53Z ggregory $
045 * @deprecated Use {@link DefaultLookups#ENVIRONMENT}.
046 */
047@Deprecated
048public class EnvironmentLookup implements Lookup
049{
050    /**
051     * Performs a lookup for the specified variable. This implementation
052     * directly delegates to a {@code System.getenv()}.
053     *
054     * @param key the key to lookup
055     * @return the value of this key or <b>null</b> if it cannot be resolved
056     */
057    @Override
058    public String lookup(final String key)
059    {
060        return System.getenv(key);
061    }
062}