Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../img/srcFileCovDistChart8.png 68% of files have more coverage
22   151   16   2.44
12   86   0.73   9
9     1.78  
1    
 
  Syntax       Line # 30 22 0% 16 9 79.1% 0.7906977
 
  (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    * Represents a wiki syntax that the user can use to enter wiki content. A syntax is made of two parts: a type
24    * (eg XWiki, Confluence, MediaWiki, etc) and a version (1.0, 2.0, etc).
25    * For example the XWiki 1.0 syntax, the XWiki 2.0 syntax, the Confluence 1.0 syntax, etc.
26    *
27    * @version $Id: 71082b968e0b797d53c263364245a744fce1772b $
28    * @since 2.0RC1
29    */
 
30    public class Syntax
31    {
32    public static final Syntax XHTML_1_0 = new Syntax(SyntaxType.XHTML, "1.0");
33    public static final Syntax HTML_4_01 = new Syntax(SyntaxType.HTML, "4.01");
34    public static final Syntax XWIKI_1_0 = new Syntax(SyntaxType.XWIKI, "1.0");
35    public static final Syntax XWIKI_2_0 = new Syntax(SyntaxType.XWIKI, "2.0");
36    public static final Syntax XWIKI_2_1 = new Syntax(SyntaxType.XWIKI, "2.1");
37    public static final Syntax PLAIN_1_0 = new Syntax(SyntaxType.PLAIN, "1.0");
38    public static final Syntax EVENT_1_0 = new Syntax(SyntaxType.EVENT, "1.0");
39    public static final Syntax TEX_1_0 = new Syntax(SyntaxType.TEX, "1.0");
40    public static final Syntax CREOLE_1_0 = new Syntax(SyntaxType.CREOLE, "1.0");
41    public static final Syntax JSPWIKI_1_0 = new Syntax(SyntaxType.JSPWIKI, "1.0");
42    public static final Syntax MEDIAWIKI_1_0 = new Syntax(SyntaxType.MEDIAWIKI, "1.0");
43    public static final Syntax CONFLUENCE_1_0 = new Syntax(SyntaxType.CONFLUENCE, "1.0");
44    public static final Syntax TWIKI_1_0 = new Syntax(SyntaxType.TWIKI, "1.0");
45    public static final Syntax DOCBOOK_4_4 = new Syntax(SyntaxType.DOCBOOK, "4.4");
46   
47    /**
48    * @since 3.3M1
49    */
50    public static final Syntax XDOMXML_CURRENT = new Syntax(SyntaxType.XDOMXML, "current");
51   
52    /**
53    * @since 3.3M1
54    */
55    public static final Syntax XDOMXML_1_0 = new Syntax(SyntaxType.XDOMXML, "1.0");
56   
57    /**
58    * @since 3.4M1
59    */
60    public static final Syntax MARKDOWN_1_0 = new Syntax(SyntaxType.MARKDOWN, "1.0");
61   
62    /**
63    * This is HTML with annotations (comments) in order to allow round tripping between for example the WYSIWYG editor
64    * and wiki syntax.
65    */
66    public static final Syntax ANNOTATED_XHTML_1_0 = new Syntax(SyntaxType.ANNOTATED_XHTML, "1.0");
67   
68    private SyntaxType type;
69   
70    private String version;
71   
72    /**
73    * Optional free form text that qualifies the version, eg "experimental".
74    */
75    private String qualifier;
76   
 
77  406 toggle public Syntax(SyntaxType type, String version)
78    {
79  406 this.type = type;
80  406 this.version = version;
81    }
82   
 
83  0 toggle public Syntax(SyntaxType type, String version, String qualifier)
84    {
85  0 this(type, version);
86  0 this.qualifier = qualifier;
87    }
88   
 
89  2665 toggle public SyntaxType getType()
90    {
91  2665 return this.type;
92    }
93   
 
94  2643 toggle public String getVersion()
95    {
96  2643 return this.version;
97    }
98   
 
99  32 toggle public String getQualifier()
100    {
101  32 return this.qualifier;
102    }
103   
 
104  2579 toggle public String toIdString()
105    {
106  2579 return getType().getId() + "/" + getVersion().toLowerCase();
107    }
108   
 
109  13 toggle @Override
110    public String toString()
111    {
112  13 return getType().toString() + " " + getVersion() + (getQualifier() != null ? " (" + getQualifier() + ")" : "");
113    }
114   
 
115  9 toggle @Override
116    public int hashCode()
117    {
118    // Random number. See http://www.technofundo.com/tech/java/equalhash.html for the detail of this
119    // algorithm.
120  9 int hash = 7;
121  9 hash = 31 * hash + (null == getType() ? 0 : getType().hashCode());
122  9 hash = 31 * hash + (null == getVersion() ? 0 : getVersion().hashCode());
123  9 hash = 31 * hash + (null == getQualifier() ? 0 : getQualifier().hashCode());
124  9 return hash;
125    }
126   
 
127  10 toggle @Override
128    public boolean equals(Object object)
129    {
130  10 boolean result;
131   
132    // See http://www.technofundo.com/tech/java/equalhash.html for the detail of this algorithm.
133  10 if (this == object) {
134  2 result = true;
135    } else {
136  8 if ((object == null) || (object.getClass() != this.getClass())) {
137  0 result = false;
138    } else {
139    // object must be Syntax at this point
140  8 Syntax syntax = (Syntax) object;
141  8 result =
142    (getType() == syntax.getType() || (getType() != null && getType().equals(syntax.getType())))
143    && (getVersion() == syntax.getVersion() || (getVersion() != null && getVersion().equals(
144    syntax.getVersion())))
145    && (getQualifier() == syntax.getQualifier() || (getQualifier() != null && getQualifier().equals(
146    syntax.getQualifier())));
147    }
148    }
149  10 return result;
150    }
151    }