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
14   144   9   2.8
6   50   0.64   5
5     1.8  
1    
 
  ResourceType       Line # 37 14 0% 9 3 88% 0.88
 
  (229)
 
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.listener.reference;
21   
22    /**
23    * The Resource type. It can be one of:
24    * <ul>
25    * <li>document ("doc")</li>
26    * <li>URL ("url")</li>
27    * <li>document in another wiki (interwiki) ("interwiki")</li>
28    * <li>relative URL ("path")</li>
29    * <li>mail ("mailto")</li>
30    * <li>attachment ("attach")</li>
31    * <li>UNC path ("unc")</li>
32    * </ul>
33    *
34    * @version $Id: 8b0e88f2b1917261db65d34a8a4daa8ac0cc59ae $
35    * @since 2.5RC1
36    */
 
37    public class ResourceType
38    {
39    /**
40    * Special type to be used when the type of the resource is not known.
41    */
42    public static final ResourceType UNKNOWN = new ResourceType("unknown");
43   
44    /**
45    * Represents a Document.
46    */
47    public static final ResourceType DOCUMENT = new ResourceType("doc");
48   
49    /**
50    * Represents an URL.
51    */
52    public static final ResourceType URL = new ResourceType("url");
53   
54    /**
55    * Represents a document in another wiki.
56    */
57    public static final ResourceType INTERWIKI = new ResourceType("interwiki");
58   
59    /**
60    * Represents a relative URL in the current wiki.
61    */
62    public static final ResourceType PATH = new ResourceType("path");
63   
64    /**
65    * Represents a mail.
66    */
67    public static final ResourceType MAILTO = new ResourceType("mailto");
68   
69    /**
70    * Represents an attachment.
71    */
72    public static final ResourceType ATTACHMENT = new ResourceType("attach");
73   
74    /**
75    * Represents an icon.
76    */
77    public static final ResourceType ICON = new ResourceType("icon");
78   
79    /**
80    * Represents a UNC (Universal Naming Convention) (eg "\\myserver\myshare\mydoc.txt").
81    * @since 2.7M1
82    */
83    public static final ResourceType UNC = new ResourceType("unc");
84   
85    /**
86    * @see #getScheme()
87    */
88    private String scheme;
89   
90    /**
91    * @param scheme see {@link #getScheme()}
92    */
 
93  170 toggle public ResourceType(String scheme)
94    {
95  170 setScheme(scheme);
96    }
97   
98    /**
99    * @return the type of the link (eg "doc" for links to documents, etc)
100    */
 
101  1570 toggle public String getScheme()
102    {
103  1570 return this.scheme;
104    }
105   
106    /**
107    * @param scheme see {@link #getScheme()}
108    */
 
109  170 toggle public void setScheme(String scheme)
110    {
111  170 this.scheme = scheme;
112    }
113   
 
114  4 toggle @Override
115    public int hashCode()
116    {
117    // Random number. See http://www.technofundo.com/tech/java/equalhash.html for the detail of this
118    // algorithm.
119  4 int hash = 8;
120  4 hash = 31 * hash + (null == getScheme() ? 0 : getScheme().hashCode());
121  4 return hash;
122    }
123   
 
124  281 toggle @Override
125    public boolean equals(Object object)
126    {
127  281 boolean result;
128   
129    // See http://www.technofundo.com/tech/java/equalhash.html for the detail of this algorithm.
130  281 if (this == object) {
131  140 result = true;
132    } else {
133  141 if ((object == null) || (object.getClass() != this.getClass())) {
134  0 result = false;
135    } else {
136    // object must be ResourceType at this point
137  141 ResourceType type = (ResourceType) object;
138  141 result = (getScheme() == type.getScheme() || (getScheme() != null
139    && getScheme().equals(type.getScheme())));
140    }
141    }
142  281 return result;
143    }
144    }