Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PropertyUtils |
|
| 5.0;5 |
1 | package org.apache.maven.model.converter.plugins; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | /** | |
23 | * Utility class which features various methods for converting String-based property values. | |
24 | * | |
25 | * @author Dennis Lundberg | |
26 | * @version $Id: PropertyUtils.java 661727 2008-05-30 14:21:49Z bentmann $ | |
27 | */ | |
28 | 0 | public class PropertyUtils |
29 | { | |
30 | static String convertOnOffToBoolean( String value ) | |
31 | { | |
32 | 8 | if ( value != null ) |
33 | { | |
34 | 7 | if ( "on".equalsIgnoreCase( value ) ) |
35 | { | |
36 | 3 | return Boolean.TRUE.toString(); |
37 | } | |
38 | 4 | if ( "off".equalsIgnoreCase( value ) ) |
39 | { | |
40 | 3 | return Boolean.FALSE.toString(); |
41 | } | |
42 | } | |
43 | 2 | return null; |
44 | } | |
45 | ||
46 | static String convertYesNoToBoolean( String value ) | |
47 | { | |
48 | 8 | if ( value != null ) |
49 | { | |
50 | 7 | if ( "yes".equalsIgnoreCase( value ) ) |
51 | { | |
52 | 4 | return Boolean.TRUE.toString(); |
53 | } | |
54 | 3 | if ( "no".equalsIgnoreCase( value ) ) |
55 | { | |
56 | 2 | return Boolean.FALSE.toString(); |
57 | } | |
58 | } | |
59 | 2 | return null; |
60 | } | |
61 | ||
62 | static String invertBoolean( String stringValue ) | |
63 | { | |
64 | 7 | if ( stringValue != null ) |
65 | { | |
66 | 6 | boolean booleanValue = Boolean.valueOf( stringValue ).booleanValue(); |
67 | 6 | boolean invertedBooleanValue = !booleanValue; |
68 | 6 | return new Boolean( invertedBooleanValue ).toString(); |
69 | } | |
70 | 1 | return null; |
71 | } | |
72 | } |