001//========================================================================
002//$Id$
003//Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
004//------------------------------------------------------------------------
005//Licensed under the Apache License, Version 2.0 (the "License");
006//you may not use this file except in compliance with the License.
007//You may obtain a copy of the License at 
008//http://www.apache.org/licenses/LICENSE-2.0
009//Unless required by applicable law or agreed to in writing, software
010//distributed under the License is distributed on an "AS IS" BASIS,
011//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012//See the License for the specific language governing permissions and
013//limitations under the License.
014//========================================================================
015
016package org.jszip.jetty;
017
018/**
019 * SystemProperty
020 * 
021 * Provides the ability to set System properties
022 * for the mojo execution. A value will only 
023 * be set if it is not set already. That is, if
024 * it was set on the command line or by the system,
025 * it won't be overridden by settings in the 
026 * plugin's configuration.
027 *
028 */
029public class SystemProperty
030{
031
032
033    private String name;
034    private String value;
035    private boolean isSet;
036    
037    /**
038     * @return Returns the name.
039     */
040    public String getName()
041    {
042        return this.name;
043    }
044    /**
045     * @param name The name to set.
046     */
047    public void setName(String name)
048    {
049        this.name = name;
050    }
051
052    public String getKey()
053    {
054        return this.name;
055    }
056
057    public void setKey (String name)
058    {
059        this.name = name;
060    }
061    /**
062     * @return Returns the value.
063     */
064    public String getValue()
065    {
066        return this.value;
067    }
068    /**
069     * @param value The value to set.
070     */
071    public void setValue(String value)
072    {
073        this.value = value;
074    }
075
076    
077    public boolean isSet ()
078    {
079        return isSet;
080    }
081    
082    /** Set a System.property with this value
083     * if it is not already set.
084     */
085    void setIfNotSetAlready()
086    {
087        if (System.getProperty(getName()) == null)
088        {
089            System.setProperty(getName(), (getValue()==null?"":getValue()));
090            isSet=true;
091        }
092    }
093
094}