Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../img/srcFileCovDistChart9.png 55% of files have more coverage
30   134   20   3.75
20   71   0.67   8
8     2.5  
1    
 
  WikiParameter       Line # 28 30 0% 20 11 81% 0.8103448
 
  (341)
 
1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.wikimodel;
21   
22    /**
23    * A wiki parameter object.
24    *
25    * @version $Id: ed808805370ef607f217453883e9a6365f70271b $
26    * @since 4.0M1
27    */
 
28    public class WikiParameter
29    {
30    private String fKey;
31   
32    private String fStr;
33   
34    private Boolean fValid;
35   
36    private String fValue;
37   
38    /**
39    * @param key
40    * @param value
41    */
 
42  1366 toggle public WikiParameter(String key, String value)
43    {
44  1366 fKey = key;
45  1366 fValue = value;
46    }
47   
48    /**
49    * @param pair
50    */
 
51  0 toggle public WikiParameter(WikiParameter pair)
52    {
53  0 fKey = pair.getKey();
54  0 fValue = pair.getValue();
55    }
56   
57    /**
58    * @see java.lang.Object#equals(java.lang.Object)
59    */
 
60  132 toggle public boolean equals(Object obj)
61    {
62  132 if (obj == this) {
63  115 return true;
64    }
65  17 if (!(obj instanceof WikiParameter)) {
66  0 return false;
67    }
68  17 WikiParameter pair = (WikiParameter) obj;
69  17 return fKey.equals(pair.fKey)
70    && (fValue == pair.fValue || (fValue != null && fValue
71    .equals(pair.fValue)));
72    }
73   
74    /**
75    * @return the key
76    */
 
77  1587 toggle public String getKey()
78    {
79  1587 return fKey;
80    }
81   
82    /**
83    * @return the value
84    */
 
85  1470 toggle public String getValue()
86    {
87  1470 return fValue;
88    }
89   
90    /**
91    * @see java.lang.Object#hashCode()
92    */
 
93  208 toggle public int hashCode()
94    {
95  208 return fKey.hashCode() ^ (fValue != null ? fValue.hashCode() : 0);
96    }
97   
98    /**
99    * @return <code>true</code> if this key/value pair is valid
100    */
 
101  374 toggle public boolean isValid()
102    {
103  374 if (fValid == null) {
104  374 int len = (fKey != null) ? fKey.length() : 0;
105  374 boolean result = len > 0;
106  374 boolean delimiter = false;
107  1772 for (int i = 0; result && i < len; i++) {
108  1398 char ch = fKey.charAt(i);
109  1398 if (ch == ':') {
110  10 result = !delimiter && i > 0 && i < len - 1;
111  10 delimiter = true;
112  1388 } else if (ch == '.' || ch == '-') {
113  0 result = i > 0 && i < len - 1;
114    } else {
115  1388 result &= (i == 0 && Character.isLetter(ch))
116    || Character.isLetterOrDigit(ch);
117    }
118    }
119  374 fValid = result ? Boolean.TRUE : Boolean.FALSE;
120    }
121  374 return fValid == Boolean.TRUE;
122    }
123   
124    /**
125    * @see java.lang.Object#toString()
126    */
 
127  407 toggle public String toString()
128    {
129  407 if (fStr == null) {
130  401 fStr = fKey + "='" + WikiPageUtil.escapeXmlAttribute(fValue) + "'";
131    }
132  407 return fStr;
133    }
134    }