blob: f827b3f1a322ceee2bc6561e4cac5ade96afbdba [file] [log] [blame]
<HTML><HEAD><META CONTENT="text/html; charset=UTF-8" HTTP-EQUIV="Content-Type"/><TITLE>EMMA Coverage Report</TITLE><STYLE TYPE="text/css"> TABLE,TD,TH {border-style:solid; border-color:black;} TD,TH {background:white;margin:0;line-height:100%;padding-left:0.5em;padding-right:0.5em;} TD {border-width:0 1px 0 0;} TH {border-width:1px 1px 1px 0;} TR TD.h {color:red;} TABLE {border-spacing:0; border-collapse:collapse;border-width:0 0 1px 1px;} P,H1,H2,H3,TH {font-family:verdana,arial,sans-serif;font-size:10pt;} TD {font-family:courier,monospace;font-size:10pt;} TABLE.hdft {border-spacing:0;border-collapse:collapse;border-style:none;} TABLE.hdft TH,TABLE.hdft TD {border-style:none;line-height:normal;} TABLE.hdft TH.tl,TABLE.hdft TD.tl {background:#6699CC;color:white;} TABLE.hdft TD.nv {background:#6633DD;color:white;} .nv A:link {color:white;} .nv A:visited {color:white;} .nv A:active {color:yellow;} TABLE.hdft A:link {color:white;} TABLE.hdft A:visited {color:white;} TABLE.hdft A:active {color:yellow;} .in {color:#356085;} TABLE.s TD {padding-left:0.25em;padding-right:0.25em;} TABLE.s TD.l {padding-left:0.25em;padding-right:0.25em;text-align:right;background:#F0F0F0;} TABLE.s TR.z TD {background:#FF9999;} TABLE.s TR.p TD {background:#FFFF88;} TABLE.s TR.c TD {background:#CCFFCC;} A:link {color:#0000EE;text-decoration:none;} A:visited {color:#0000EE;text-decoration:none;} A:hover {color:#0000EE;text-decoration:underline;} TABLE.cn {border-width:0 0 1px 0;} TABLE.s {border-width:1px 0 1px 1px;} TD.h {color:red;border-width:0 1px 0 0;} TD.f {border-width:0 1px 0 1px;} TD.hf {color:red;border-width:0 1px 0 1px;} TH.f {border-width:1px 1px 1px 1px;} TR.cis TD {background:#F0F0F0;} TR.cis TD {border-width:1px 1px 1px 0;} TR.cis TD.h {color:red;border-width:1px 1px 1px 0;} TR.cis TD.f {border-width:1px 1px 1px 1px;} TR.cis TD.hf {color:red;border-width:1px 1px 1px 1px;} TD.b {border-style:none;background:transparent;line-height:50%;} TD.bt {border-width:1px 0 0 0;background:transparent;line-height:50%;} TR.o TD {background:#F0F0F0;}TABLE.it {border-style:none;}TABLE.it TD,TABLE.it TH {border-style:none;}</STYLE></HEAD><BODY><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="tl"><A HREF="http://www.eclemma.org/">EMMA</A> Coverage Report (generated Fri Feb 20 18:44:54 GMT 2009)</TH></TR><TR><TD CLASS="nv">[<A HREF="../xslUnitTestCoverage.html">all classes</A>][<A HREF="4.html">org.eclipse.wst.sse.core.internal.propertytester</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">StructuredFilePropertyTester.java</SPAN>]</H2><TABLE CELLSPACING="0" WIDTH="100%"><TR><TH>name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD>StructuredFilePropertyTester.java</TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/3)</TD><TD CLASS="h">0%   (0/57)</TD><TD CLASS="h">0%   (0/16)</TD></TR></TABLE><H3>COVERAGE BREAKDOWN BY CLASS AND METHOD</H3><TABLE CLASS="cn" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="f">name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD></TR><TR CLASS="cis"><TD CLASS="f">class <A HREF="#0">StructuredFilePropertyTester</A></TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/3)</TD><TD CLASS="h">0%   (0/57)</TD><TD CLASS="h">0%   (0/16)</TD></TR><TR><TD CLASS="f"><A HREF="#0">StructuredFilePropertyTester (): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/3)</TD><TD CLASS="h">0%   (0/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">test (Object, String, Object [], Object): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/22)</TD><TD CLASS="h">0%   (0/3)</TD></TR><TR><TD CLASS="f"><A HREF="#3">testContentType (IFile, String): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/32)</TD><TD CLASS="h">0%   (0/12)</TD></TR></TABLE><P></P><TABLE CLASS="s" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="l">1</TD><TD>/******************************************************************************</TD></TR><TR><TD CLASS="l">2</TD><TD> * Copyright (c) 2008 IBM Corporation and others.</TD></TR><TR><TD CLASS="l">3</TD><TD> * All rights reserved. This program and the accompanying materials</TD></TR><TR><TD CLASS="l">4</TD><TD> * are made available under the terms of the Eclipse Public License v1.0</TD></TR><TR><TD CLASS="l">5</TD><TD> * which accompanies this distribution, and is available at</TD></TR><TR><TD CLASS="l">6</TD><TD> * http://www.eclipse.org/legal/epl-v10.html</TD></TR><TR><TD CLASS="l">7</TD><TD> *</TD></TR><TR><TD CLASS="l">8</TD><TD> * Contributors:</TD></TR><TR><TD CLASS="l">9</TD><TD> *     IBM Corporation - initial API and implementation</TD></TR><TR><TD CLASS="l">10</TD><TD> ******************************************************************************/</TD></TR><TR><TD CLASS="l">11</TD><TD>package org.eclipse.wst.sse.core.internal.propertytester;</TD></TR><TR><TD CLASS="l">12</TD><TD> </TD></TR><TR><TD CLASS="l">13</TD><TD>import org.eclipse.core.expressions.PropertyTester;</TD></TR><TR><TD CLASS="l">14</TD><TD>import org.eclipse.core.resources.IFile;</TD></TR><TR><TD CLASS="l">15</TD><TD>import org.eclipse.core.runtime.content.IContentDescription;</TD></TR><TR><TD CLASS="l">16</TD><TD>import org.eclipse.core.runtime.content.IContentType;</TD></TR><TR><TD CLASS="l">17</TD><TD>import org.eclipse.wst.sse.core.internal.Logger;</TD></TR><TR><TD CLASS="l">18</TD><TD> </TD></TR><TR><TD CLASS="l">19</TD><TD>/**</TD></TR><TR><TD CLASS="l">20</TD><TD> * A Property Tester that operates on IFiles and validates</TD></TR><TR><TD CLASS="l">21</TD><TD> * that the expected content type id matches that of the content</TD></TR><TR><TD CLASS="l">22</TD><TD> * type of the file, or any of the base content types.</TD></TR><TR><TD CLASS="l"><A NAME="0">23</A></TD><TD> * </TD></TR><TR><TD CLASS="l">24</TD><TD> * Based on org.eclipse.core.internal.propertytester.FilePropertyTester</TD></TR><TR><TD CLASS="l">25</TD><TD> * </TD></TR><TR><TD CLASS="l">26</TD><TD> */</TD></TR><TR CLASS="z"><TD CLASS="l">27</TD><TD>public class StructuredFilePropertyTester extends PropertyTester {</TD></TR><TR><TD CLASS="l">28</TD><TD> </TD></TR><TR><TD CLASS="l">29</TD><TD>        /**</TD></TR><TR><TD CLASS="l">30</TD><TD>         * A property indicating that we are looking to verify that the file matches</TD></TR><TR><TD CLASS="l">31</TD><TD>         * the content type matching the given identifier. The identifier is</TD></TR><TR><TD CLASS="l">32</TD><TD>         * provided as the expected value.</TD></TR><TR><TD CLASS="l">33</TD><TD>         */</TD></TR><TR><TD CLASS="l">34</TD><TD>        private static final String PROPERTY_CONTENT_TYPE_ID = &#34;contentTypeId&#34;; //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">35</TD><TD>        </TD></TR><TR><TD CLASS="l">36</TD><TD>        /*</TD></TR><TR><TD CLASS="l"><A NAME="2">37</A></TD><TD>         * (non-Javadoc)</TD></TR><TR><TD CLASS="l">38</TD><TD>         * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)</TD></TR><TR><TD CLASS="l">39</TD><TD>         */</TD></TR><TR><TD CLASS="l">40</TD><TD>        public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {</TD></TR><TR CLASS="z"><TD CLASS="l">41</TD><TD>                if(PROPERTY_CONTENT_TYPE_ID.equals(property) &amp;&amp; (expectedValue != null) &amp;&amp; (receiver instanceof IFile) &amp;&amp; ((IFile) receiver).exists())</TD></TR><TR CLASS="z"><TD CLASS="l">42</TD><TD>                        return testContentType((IFile) receiver, expectedValue.toString());</TD></TR><TR CLASS="z"><TD CLASS="l">43</TD><TD>                return false;</TD></TR><TR><TD CLASS="l">44</TD><TD>        }</TD></TR><TR><TD CLASS="l">45</TD><TD>        </TD></TR><TR><TD CLASS="l">46</TD><TD>        /**</TD></TR><TR><TD CLASS="l">47</TD><TD>         * Tests whether the content type for &lt;code&gt;file&lt;/code&gt; (or any base content types) </TD></TR><TR><TD CLASS="l">48</TD><TD>         * matches the &lt;code&gt;contentTypeId&lt;/code&gt;. It is possible that this method call could</TD></TR><TR><TD CLASS="l">49</TD><TD>         * cause the file to be read. It is also possible (through poor plug-in</TD></TR><TR><TD CLASS="l">50</TD><TD>         * design) for this method to load plug-ins.</TD></TR><TR><TD CLASS="l">51</TD><TD>         * </TD></TR><TR><TD CLASS="l">52</TD><TD>         * @param file</TD></TR><TR><TD CLASS="l">53</TD><TD>         *            The file for which the content type should be determined; must</TD></TR><TR><TD CLASS="l">54</TD><TD>         *            not be &lt;code&gt;null&lt;/code&gt;.</TD></TR><TR><TD CLASS="l">55</TD><TD>         * @param contentTypeId</TD></TR><TR><TD CLASS="l">56</TD><TD>         *            The expected content type; must not be &lt;code&gt;null&lt;/code&gt;.</TD></TR><TR><TD CLASS="l">57</TD><TD>         * @return &lt;code&gt;true&lt;/code&gt; if the file's content type (or base content types) </TD></TR><TR><TD CLASS="l"><A NAME="3">58</A></TD><TD>         *         has an identifier that matches &lt;code&gt;contentTypeId&lt;/code&gt;;</TD></TR><TR><TD CLASS="l">59</TD><TD>         *         &lt;code&gt;false&lt;/code&gt; otherwise.</TD></TR><TR><TD CLASS="l">60</TD><TD>         */</TD></TR><TR><TD CLASS="l">61</TD><TD>        private boolean testContentType(final IFile file, String contentTypeId) {</TD></TR><TR CLASS="z"><TD CLASS="l">62</TD><TD>                final String expectedValue = contentTypeId.trim();</TD></TR><TR><TD CLASS="l">63</TD><TD> </TD></TR><TR><TD CLASS="l">64</TD><TD>                try {</TD></TR><TR CLASS="z"><TD CLASS="l">65</TD><TD>                        IContentDescription contentDescription = file.getContentDescription();</TD></TR><TR CLASS="z"><TD CLASS="l">66</TD><TD>                        if (contentDescription != null) {</TD></TR><TR CLASS="z"><TD CLASS="l">67</TD><TD>                                IContentType contentType = contentDescription.getContentType();</TD></TR><TR CLASS="z"><TD CLASS="l">68</TD><TD>                                while (contentType != null) {</TD></TR><TR CLASS="z"><TD CLASS="l">69</TD><TD>                                        if (expectedValue.equals(contentType.getId()))</TD></TR><TR CLASS="z"><TD CLASS="l">70</TD><TD>                                                return true;</TD></TR><TR CLASS="z"><TD CLASS="l">71</TD><TD>                                        contentType = contentType.getBaseType();</TD></TR><TR><TD CLASS="l">72</TD><TD>                                }</TD></TR><TR><TD CLASS="l">73</TD><TD>                        }</TD></TR><TR><TD CLASS="l">74</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">75</TD><TD>                catch (Exception e) {</TD></TR><TR><TD CLASS="l">76</TD><TD>                        // [232831] - Log messages only when debugging</TD></TR><TR CLASS="z"><TD CLASS="l">77</TD><TD>                        if(Logger.DEBUG)</TD></TR><TR CLASS="z"><TD CLASS="l">78</TD><TD>                                Logger.logException(e);</TD></TR><TR><TD CLASS="l">79</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">80</TD><TD>                return false;</TD></TR><TR><TD CLASS="l">81</TD><TD>        }</TD></TR><TR><TD CLASS="l">82</TD><TD>}</TD></TR></TABLE><P></P><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="nv">[<A HREF="../xslUnitTestCoverage.html">all classes</A>][<A HREF="4.html">org.eclipse.wst.sse.core.internal.propertytester</A>]</TD></TR><TR><TD CLASS="tl"><A HREF="http://www.eclemma.org/support.html">EMMA 2.0.5312 EclEmma Fix 1</A> (C) Vladimir Roubtsov</TD></TR></TABLE></BODY></HTML>