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
16   149   10   2.67
6   62   0.62   6
6     1.67  
1    
 
  SyntaxType       Line # 26 16 0% 10 5 82.1% 0.8214286
 
  (987)
 
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.syntax;
21   
22    /**
23    * @version $Id: f8eb49e64dcd9b325fdb754e45450e7b64fcfe7b $
24    * @since 2.0RC1
25    */
 
26    public class SyntaxType
27    {
28    public static final SyntaxType XWIKI = new SyntaxType("xwiki", "XWiki");
29   
30    public static final SyntaxType CONFLUENCE = new SyntaxType("confluence", "Confluence");
31   
32    public static final SyntaxType MEDIAWIKI = new SyntaxType("mediawiki", "MediaWiki");
33   
34    public static final SyntaxType CREOLE = new SyntaxType("creole", "Creole");
35   
36    public static final SyntaxType JSPWIKI = new SyntaxType("jspwiki", "JSPWiki");
37   
38    public static final SyntaxType TWIKI = new SyntaxType("twiki", "TWiki");
39   
40    public static final SyntaxType XHTML = new SyntaxType("xhtml", "XHTML");
41   
42    public static final SyntaxType ANNOTATED_XHTML = new SyntaxType("annotatedxhtml", "Annotated XHTML");
43   
44    public static final SyntaxType HTML = new SyntaxType("html", "HTML");
45   
46    public static final SyntaxType PLAIN = new SyntaxType("plain", "Plain");
47   
48    public static final SyntaxType EVENT = new SyntaxType("event", "Event");
49   
50    public static final SyntaxType TEX = new SyntaxType("tex", "TeX");
51   
52    public static final SyntaxType DOCBOOK = new SyntaxType("docbook", "DocBook");
53   
54    /**
55    * @since 3.3M1
56    */
57    public static final SyntaxType XDOMXML = new SyntaxType("xdom+xml", "XML based XDOM");
58   
59    /**
60    * @since 3.4M1
61    */
62    public static final SyntaxType MARKDOWN = new SyntaxType("markdown", "Markdown");
63   
64    /**
65    * @see #getName()
66    */
67    private String name;
68   
69    /**
70    * @see #getId()
71    */
72    private String id;
73   
74    /**
75    * @param id the technical id of the Syntax type (ex "annotatedxhtml")
76    * @param name the human readable name of the Syntax type (ex "Annotated XHTML")
77    * @since 2.0M3
78    */
 
79  350 toggle public SyntaxType(String id, String name)
80    {
81  350 this.name = name;
82  350 this.id = id;
83    }
84   
85    /**
86    * @return the technical id of the Syntax type (ex "annotatedxhtml")
87    * @since 2.0M3
88    */
 
89  2628 toggle public String getId()
90    {
91  2628 return this.id;
92    }
93   
94    /**
95    * @return the human readable name of the Syntax type (ex "Annotated XHTML")
96    * @since 2.0M3
97    */
 
98  2 toggle public String getName()
99    {
100  2 return this.name;
101    }
102   
103    /**
104    * {@inheritDoc}
105    * <p>
106    * Display a human readable name of the Syntax type.
107    *
108    * @see java.lang.Object#toString()
109    */
 
110  13 toggle @Override
111    public String toString()
112    {
113  13 return this.name;
114    }
115   
 
116  9 toggle @Override
117    public int hashCode()
118    {
119    // Random number. See http://www.technofundo.com/tech/java/equalhash.html for the detail of this
120    // algorithm.
121    // Note that the name isn't part of the hashCode computation since it's not part of the Syntax type's identity
122  9 int hash = 7;
123  9 hash = 31 * hash + (null == getId() ? 0 : getId().hashCode());
124  9 return hash;
125    }
126   
 
127  7 toggle @Override
128    public boolean equals(Object object)
129    {
130  7 boolean result;
131   
132    // See http://www.technofundo.com/tech/java/equalhash.html for the detail of this algorithm.
133  7 if (this == object) {
134  0 result = true;
135    } else {
136  7 if ((object == null) || (object.getClass() != this.getClass())) {
137  0 result = false;
138    } else {
139    // Object must be Syntax at this point.
140  7 SyntaxType syntaxType = (SyntaxType) object;
141    // Note that the name isn't part of the hashCode computation since it's not part of the Syntax type's
142    // identity.
143  7 result = (getId() == syntaxType.getId() || (getId() != null && getId().equals(syntaxType.getId())));
144    }
145    }
146   
147  7 return result;
148    }
149    }