    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 *     https://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 * <p>
    021 * A specialized lookup implementation that allows access to environment variables.
    022 * </p>
    023 * <p>
    024 * This implementation relies on {@link System#getenv()} to resolve environment variables. It can be used for
    025 * referencing environment variables in configuration files in an easy way, for instance:
    026 * </p>
    027 *
    028 * <pre>
    029 * java.home = ${env:JAVA_HOME}
    030 * </pre>
    031 *
    032 * <p>
    033 * {@code EnvironmentLookup} is one of the standard lookups that is registered per default for each configuration.
    034 * </p>
    035 *
    036 * @since 1.7
    037 * @deprecated Use {@link DefaultLookups#ENVIRONMENT}.
    038 */
    039@Deprecated
    040public class EnvironmentLookup implements Lookup {
    041
    042    /**
    043     * Constructs a new instance.
    044     */
    045    public EnvironmentLookup() {
    046        // empty
    047    }
    048
    049    /**
    050     * Performs a lookup for the specified variable. This implementation directly delegates to a {@code System.getenv()}.
    051     *
    052     * @param key the key to lookup
    053     * @return the value of this key or <strong>null</strong> if it cannot be resolved
    054     */
    055    @Override
    056    public String lookup(final String key) {
    057        return System.getenv(key);
    058    }
    059}