1 //
2 // ========================================================================
3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.maven.plugin;
20
21 /**
22 * SystemProperty
23 *
24 * Provides the ability to set System properties
25 * for the mojo execution. A value will only
26 * be set if it is not set already. That is, if
27 * it was set on the command line or by the system,
28 * it won't be overridden by settings in the
29 * plugin's configuration.
30 *
31 */
32 public class SystemProperty
33 {
34
35
36 private String name;
37 private String value;
38 private boolean isSet;
39
40 /**
41 * @return Returns the name.
42 */
43 public String getName()
44 {
45 return this.name;
46 }
47 /**
48 * @param name The name to set.
49 */
50 public void setName(String name)
51 {
52 this.name = name;
53 }
54
55 public String getKey()
56 {
57 return this.name;
58 }
59
60 public void setKey (String name)
61 {
62 this.name = name;
63 }
64 /**
65 * @return Returns the value.
66 */
67 public String getValue()
68 {
69 return this.value;
70 }
71 /**
72 * @param value The value to set.
73 */
74 public void setValue(String value)
75 {
76 this.value = value;
77 }
78
79
80 public boolean isSet ()
81 {
82 return isSet;
83 }
84
85 /** Set a System.property with this value
86 * if it is not already set.
87 */
88 void setIfNotSetAlready()
89 {
90 if (System.getProperty(getName()) == null)
91 {
92 System.setProperty(getName(), (getValue()==null?"":getValue()));
93 isSet=true;
94 }
95 }
96
97 void setAnyway()
98 {
99 System.setProperty(getName(), (getValue()==null?"":getValue()));
100 isSet=true;
101 }
102
103 }