EMMA Coverage Report (generated Tue Jun 29 17:42:06 CEST 2010)
[all classes][org.jomc.sdk.model.support]

COVERAGE SUMMARY FOR SOURCE FILE [JaxpResourceResolverFactory.java]

nameclass, %method, %block, %line, %
JaxpResourceResolverFactory.java50%  (1/2)9%   (2/22)6%   (9/160)6%   (2.8/50)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SchemaTypeInput0%   (0/1)0%   (0/18)0%   (0/86)0%   (0/31)
SchemaTypeInput (SchemaType): void 0%   (0/1)0%   (0/6)0%   (0/3)
getBaseURI (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getByteStream (): InputStream 0%   (0/1)0%   (0/13)0%   (0/6)
getCertifiedText (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
getCharacterStream (): Reader 0%   (0/1)0%   (0/2)0%   (0/1)
getEncoding (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getJavaResource (): URL 0%   (0/1)0%   (0/33)0%   (0/6)
getPublicId (): String 0%   (0/1)0%   (0/4)0%   (0/1)
getStringData (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getSystemId (): String 0%   (0/1)0%   (0/12)0%   (0/2)
setBaseURI (String): void 0%   (0/1)0%   (0/1)0%   (0/1)
setByteStream (InputStream): void 0%   (0/1)0%   (0/1)0%   (0/1)
setCertifiedText (boolean): void 0%   (0/1)0%   (0/1)0%   (0/1)
setCharacterStream (Reader): void 0%   (0/1)0%   (0/1)0%   (0/1)
setEncoding (String): void 0%   (0/1)0%   (0/1)0%   (0/1)
setPublicId (String): void 0%   (0/1)0%   (0/1)0%   (0/1)
setStringData (String): void 0%   (0/1)0%   (0/1)0%   (0/1)
setSystemId (String): void 0%   (0/1)0%   (0/1)0%   (0/1)
     
class JaxpResourceResolverFactory100% (1/1)50%  (2/4)12%  (9/74)14%  (2.8/19)
getSchemas (): SchemasType 0%   (0/1)0%   (0/20)0%   (0/3)
resolveResource (String, String, String, String, String): LSInput 0%   (0/1)0%   (0/43)0%   (0/13)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
JaxpResourceResolverFactory (): void 100% (1/1)100% (3/3)100% (2/2)

1// SECTION-START[License Header]
2// <editor-fold defaultstate="collapsed" desc=" Generated License ">
3/*
4 *   Copyright (c) 2010 The JOMC Project
5 *   Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net>
6 *   All rights reserved.
7 *
8 *   Redistribution and use in source and binary forms, with or without
9 *   modification, are permitted provided that the following conditions
10 *   are met:
11 *
12 *     o Redistributions of source code must retain the above copyright
13 *       notice, this list of conditions and the following disclaimer.
14 *
15 *     o Redistributions in binary form must reproduce the above copyright
16 *       notice, this list of conditions and the following disclaimer in
17 *       the documentation and/or other materials provided with the
18 *       distribution.
19 *
20 *   THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
21 *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
24 *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *   $Id: JaxpResourceResolverFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $
33 *
34 */
35// </editor-fold>
36// SECTION-END
37package org.jomc.sdk.model.support;
38 
39import org.w3c.dom.ls.LSResourceResolver;
40import java.io.IOException;
41import java.io.InputStream;
42import java.io.Reader;
43import java.net.URL;
44import org.jomc.sdk.model.SchemaType;
45import org.jomc.sdk.model.SchemasType;
46import org.w3c.dom.ls.LSInput;
47import static org.jomc.sdk.model.modlet.SdkModelProvider.XML_SCHEMA_JAVA_CLASSPATH_ID_ATTRIBUTE;
48 
49// SECTION-START[Documentation]
50// <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
51/**
52 * XML Schema Set JAXP 'LSResourceResolver' factory implementation.
53 * <p><b>Specifications</b><ul>
54 * <li>{@code 'org.w3c.dom.ls.LSResourceResolver'} {@code (org.w3c.dom.ls.LSResourceResolver)} {@code Multiton}</li>
55 * </ul></p>
56 * <p><b>Properties</b><ul>
57 * <li>"{@link #getSchemas schemas}"
58 * <blockquote>Property of type {@code org.jomc.sdk.model.SchemasType}.
59 * <p>List of XML schemas ('schemas' element from XML namespace 'http://jomc.org/sdk/model).</p>
60 * </blockquote></li>
61 * </ul></p>
62 *
63 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
64 * @version $Id: JaxpResourceResolverFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $
65 */
66// </editor-fold>
67// SECTION-END
68// SECTION-START[Annotations]
69// <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
70@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
71// </editor-fold>
72// SECTION-END
73public final class JaxpResourceResolverFactory implements LSResourceResolver
74{
75    // SECTION-START[LSResourceResolver]
76 
77    public LSInput resolveResource( final String type, final String namespaceURI, final String publicId,
78                                    final String systemId, final String baseURI )
79    {
80        LSInput input = null;
81        final SchemasType schemas = this.getSchemas();
82 
83        if ( schemas.getLanguageId().equals( type ) )
84        {
85            SchemaType schema = null;
86 
87            if ( namespaceURI != null )
88            {
89                schema = schemas.getSchemaByPublicId( namespaceURI );
90            }
91            if ( schema == null && publicId != null )
92            {
93                schema = schemas.getSchemaByPublicId( publicId );
94            }
95            if ( schema == null && systemId != null )
96            {
97                schema = schemas.getSchemaBySystemId( systemId );
98            }
99 
100            if ( schema != null )
101            {
102                input = new SchemaTypeInput( schema );
103            }
104        }
105 
106        return input;
107    }
108 
109    // SECTION-END
110    // SECTION-START[JaxpResourceResolverFactory]
111    // SECTION-END
112    // SECTION-START[Constructors]
113    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
114 
115    /** Creates a new {@code JaxpResourceResolverFactory} instance. */
116    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
117    public JaxpResourceResolverFactory()
118    {
119        // SECTION-START[Default Constructor]
120        super();
121        // SECTION-END
122    }
123    // </editor-fold>
124    // SECTION-END
125    // SECTION-START[Dependencies]
126    // SECTION-END
127    // SECTION-START[Properties]
128    // <editor-fold defaultstate="collapsed" desc=" Generated Properties ">
129 
130    /**
131     * Gets the value of the {@code schemas} property.
132     * @return List of XML schemas ('schemas' element from XML namespace 'http://jomc.org/sdk/model).
133     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
134     */
135    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
136    private org.jomc.sdk.model.SchemasType getSchemas()
137    {
138        final org.jomc.sdk.model.SchemasType _p = (org.jomc.sdk.model.SchemasType) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "schemas" );
139        assert _p != null : "'schemas' property not found.";
140        return _p;
141    }
142    // </editor-fold>
143    // SECTION-END
144    // SECTION-START[Messages]
145    // SECTION-END
146}
147 
148/**
149 * {@code LSInput} implementation backed by {@code SchemaType} instance.
150 *
151 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
152 * @version $Id: JaxpResourceResolverFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $
153 */
154class SchemaTypeInput implements LSInput
155{
156 
157    /** The schema backing the input. */
158    private final SchemaType schemaType;
159 
160    /**
161     * Creates a new {@code SchemaTypeInput} instance taking a {@code SchemaType} instance.
162     *
163     * @param schemaType The schema backing the input.
164     */
165    SchemaTypeInput( final SchemaType schemaType )
166    {
167        this.schemaType = schemaType;
168    }
169 
170    public Reader getCharacterStream()
171    {
172        return null;
173    }
174 
175    public void setCharacterStream( final Reader characterStream )
176    {
177    }
178 
179    public InputStream getByteStream()
180    {
181        try
182        {
183            final URL javaResource = this.getJavaResource();
184            if ( javaResource != null )
185            {
186                return javaResource.openStream();
187            }
188 
189            return null;
190        }
191        catch ( final IOException e )
192        {
193            return null;
194        }
195    }
196 
197    public void setByteStream( final InputStream byteStream )
198    {
199    }
200 
201    public String getStringData()
202    {
203        return null;
204    }
205 
206    public void setStringData( final String stringData )
207    {
208    }
209 
210    public String getSystemId()
211    {
212        final URL javaResource = this.getJavaResource();
213        return javaResource != null ? javaResource.toExternalForm() : this.schemaType.getSystemId();
214    }
215 
216    public void setSystemId( final String systemId )
217    {
218    }
219 
220    public String getPublicId()
221    {
222        return this.schemaType.getPublicId();
223    }
224 
225    public void setPublicId( final String publicId )
226    {
227    }
228 
229    public String getBaseURI()
230    {
231        return null;
232    }
233 
234    public void setBaseURI( final String baseURI )
235    {
236    }
237 
238    public String getEncoding()
239    {
240        return null;
241    }
242 
243    public void setEncoding( final String encoding )
244    {
245    }
246 
247    public boolean getCertifiedText()
248    {
249        return false;
250    }
251 
252    public void setCertifiedText( final boolean certifiedText )
253    {
254    }
255 
256    private URL getJavaResource()
257    {
258        if ( this.schemaType.getOtherAttributes().containsKey( XML_SCHEMA_JAVA_CLASSPATH_ID_ATTRIBUTE ) )
259        {
260            String absoluteLocation =
261                this.schemaType.getOtherAttributes().get( XML_SCHEMA_JAVA_CLASSPATH_ID_ATTRIBUTE );
262 
263            if ( !absoluteLocation.startsWith( "/" ) )
264            {
265                absoluteLocation = '/' + absoluteLocation;
266            }
267 
268            return this.getClass().getResource( absoluteLocation );
269        }
270 
271        return null;
272    }
273 
274}

[all classes][org.jomc.sdk.model.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov