EMMA Coverage Report (generated Tue Jan 19 17:53:40 UTC 2010)
[all classes][org.jomc.model]

COVERAGE SUMMARY FOR SOURCE FILE [DefaultModelContext.java]

nameclass, %method, %block, %line, %
DefaultModelContext.java100% (4/4)100% (35/35)71%  (939/1322)72%  (142.6/199)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DefaultModelContext$2100% (1/1)100% (2/2)40%  (61/154)49%  (10.3/21)
resolveResource (String, String, String, String, String): LSInput 100% (1/1)37%  (55/148)47%  (9.3/20)
DefaultModelContext$2 (DefaultModelContext): void 100% (1/1)100% (6/6)100% (1/1)
     
class DefaultModelContext$1100% (1/1)100% (2/2)43%  (137/318)55%  (27.3/50)
resolveEntity (String, String): InputSource 100% (1/1)42%  (131/312)54%  (26.3/49)
DefaultModelContext$1 (DefaultModelContext): void 100% (1/1)100% (6/6)100% (1/1)
     
class DefaultModelContext100% (1/1)100% (14/14)81%  (462/571)78%  (80/103)
createUnmarshaller (): Unmarshaller 100% (1/1)40%  (4/10)33%  (1/3)
createSchema (): Schema 100% (1/1)70%  (60/86)63%  (12/19)
createContext (): JAXBContext 100% (1/1)74%  (56/76)69%  (11/16)
createMarshaller (): Marshaller 100% (1/1)78%  (73/93)75%  (15/20)
getSchemaResources (): Set 100% (1/1)79%  (142/179)86%  (24/28)
<static initializer> 100% (1/1)100% (8/8)100% (1/1)
DefaultModelContext (ClassLoader): void 100% (1/1)100% (16/16)100% (4/4)
access$000 (DefaultModelContext): Schemas 100% (1/1)100% (3/3)100% (1/1)
access$100 (DefaultModelContext, String, Object): String 100% (1/1)100% (5/5)100% (1/1)
access$200 (DefaultModelContext): Set 100% (1/1)100% (3/3)100% (1/1)
createEntityResolver (): EntityResolver 100% (1/1)100% (5/5)100% (1/1)
createResourceResolver (): LSResourceResolver 100% (1/1)100% (5/5)100% (1/1)
getMessage (String, Object): String 100% (1/1)100% (15/15)100% (1/1)
getSchemas (): Schemas 100% (1/1)100% (67/67)100% (8/8)
     
class DefaultModelContext$2$1100% (1/1)100% (17/17)100% (279/279)100% (25/25)
DefaultModelContext$2$1 (DefaultModelContext$2, InputSource, String): void 100% (1/1)100% (12/12)100% (1/1)
getBaseURI (): String 100% (1/1)100% (3/3)100% (1/1)
getByteStream (): InputStream 100% (1/1)100% (4/4)100% (1/1)
getCertifiedText (): boolean 100% (1/1)100% (2/2)100% (1/1)
getCharacterStream (): Reader 100% (1/1)100% (4/4)100% (1/1)
getEncoding (): String 100% (1/1)100% (4/4)100% (1/1)
getPublicId (): String 100% (1/1)100% (4/4)100% (1/1)
getStringData (): String 100% (1/1)100% (2/2)100% (1/1)
getSystemId (): String 100% (1/1)100% (4/4)100% (1/1)
setBaseURI (String): void 100% (1/1)100% (30/30)100% (2/2)
setByteStream (InputStream): void 100% (1/1)100% (30/30)100% (2/2)
setCertifiedText (boolean): void 100% (1/1)100% (30/30)100% (2/2)
setCharacterStream (Reader): void 100% (1/1)100% (30/30)100% (2/2)
setEncoding (String): void 100% (1/1)100% (30/30)100% (2/2)
setPublicId (String): void 100% (1/1)100% (30/30)100% (2/2)
setStringData (String): void 100% (1/1)100% (30/30)100% (2/2)
setSystemId (String): void 100% (1/1)100% (30/30)100% (2/2)

1/*
2 *   Copyright (c) 2009 The JOMC Project
3 *   Copyright (c) 2005 Christian Schulte <cs@jomc.org>
4 *   All rights reserved.
5 *
6 *   Redistribution and use in source and binary forms, with or without
7 *   modification, are permitted provided that the following conditions
8 *   are met:
9 *
10 *     o Redistributions of source code must retain the above copyright
11 *       notice, this list of conditions and the following disclaimer.
12 *
13 *     o Redistributions in binary form must reproduce the above copyright
14 *       notice, this list of conditions and the following disclaimer in
15 *       the documentation and/or other materials provided with the
16 *       distribution.
17 *
18 *   THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
19 *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
22 *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 *   $Id: DefaultModelContext.java 1331 2010-01-18 00:18:28Z schulte2005 $
31 *
32 */
33package org.jomc.model;
34 
35import java.io.IOException;
36import java.io.InputStream;
37import java.io.Reader;
38import java.lang.ref.Reference;
39import java.lang.ref.SoftReference;
40import java.net.URI;
41import java.net.URISyntaxException;
42import java.net.URL;
43import java.text.MessageFormat;
44import java.util.ArrayList;
45import java.util.Enumeration;
46import java.util.HashSet;
47import java.util.Iterator;
48import java.util.List;
49import java.util.Locale;
50import java.util.Map;
51import java.util.ResourceBundle;
52import java.util.Set;
53import java.util.jar.Attributes;
54import java.util.jar.Manifest;
55import java.util.logging.Level;
56import javax.xml.XMLConstants;
57import javax.xml.bind.JAXBContext;
58import javax.xml.bind.JAXBException;
59import javax.xml.bind.Marshaller;
60import javax.xml.bind.Unmarshaller;
61import javax.xml.transform.Source;
62import javax.xml.transform.sax.SAXSource;
63import javax.xml.validation.Schema;
64import javax.xml.validation.SchemaFactory;
65import org.jomc.model.bootstrap.BootstrapContext;
66import org.jomc.model.bootstrap.BootstrapException;
67import org.jomc.model.bootstrap.Schemas;
68import org.w3c.dom.ls.LSInput;
69import org.w3c.dom.ls.LSResourceResolver;
70import org.xml.sax.EntityResolver;
71import org.xml.sax.InputSource;
72import org.xml.sax.SAXException;
73import org.xml.sax.helpers.DefaultHandler;
74 
75/**
76 * Default {@code ModelContext} implementation.
77 *
78 * @author <a href="mailto:cs@jomc.org">Christian Schulte</a>
79 * @version $Id: DefaultModelContext.java 1331 2010-01-18 00:18:28Z schulte2005 $
80 * @see ModelContext#createModelContext(java.lang.ClassLoader)
81 */
82public class DefaultModelContext extends ModelContext
83{
84 
85    /** Supported schema name extensions. */
86    private static final String[] SCHEMA_EXTENSIONS = new String[]
87    {
88        "xsd"
89    };
90 
91    /** Cached {@code Schemas}. */
92    private Reference<Schemas> cachedSchemas = new SoftReference<Schemas>( null );
93 
94    /** Cached schema resources. */
95    private Reference<Set<URI>> cachedSchemaResources = new SoftReference<Set<URI>>( null );
96 
97    /**
98     * Creates a new {@code DefaultModelContext} instance taking a class loader.
99     *
100     * @param classLoader The class loader of the context.
101     */
102    public DefaultModelContext( final ClassLoader classLoader )
103    {
104        super( classLoader );
105    }
106 
107    @Override
108    public EntityResolver createEntityResolver() throws ModelException
109    {
110        return new DefaultHandler()
111        {
112 
113            @Override
114            public InputSource resolveEntity( final String publicId, final String systemId )
115                throws SAXException, IOException
116            {
117                if ( systemId == null )
118                {
119                    throw new NullPointerException( "systemId" );
120                }
121 
122                InputSource schemaSource = null;
123 
124                try
125                {
126                    org.jomc.model.bootstrap.Schema s = null;
127                    final Schemas classpathSchemas = getSchemas();
128 
129                    if ( publicId != null )
130                    {
131                        s = classpathSchemas.getSchemaByPublicId( publicId );
132                    }
133                    if ( s == null )
134                    {
135                        s = classpathSchemas.getSchemaBySystemId( systemId );
136                    }
137 
138                    if ( s != null )
139                    {
140                        schemaSource = new InputSource();
141                        schemaSource.setPublicId( s.getPublicId() != null ? s.getPublicId() : publicId );
142                        schemaSource.setSystemId( s.getSystemId() );
143 
144                        if ( s.getClasspathId() != null )
145                        {
146                            final URL resource = findResource( s.getClasspathId() );
147 
148                            if ( resource != null )
149                            {
150                                schemaSource.setSystemId( resource.toExternalForm() );
151                            }
152                            else
153                            {
154                                if ( isLoggable( Level.WARNING ) )
155                                {
156                                    log( Level.WARNING, getMessage( "resourceNotFound", new Object[]
157                                        {
158                                            s.getClasspathId()
159                                        } ), null );
160 
161                                }
162                            }
163                        }
164 
165                        if ( isLoggable( Level.FINE ) )
166                        {
167                            log( Level.FINE, getMessage( "resolutionInfo", new Object[]
168                                {
169                                    publicId + ", " + systemId,
170                                    schemaSource.getPublicId() + ", " + schemaSource.getSystemId()
171                                } ), null );
172 
173                        }
174                    }
175 
176                    if ( schemaSource == null )
177                    {
178                        final URI systemUri = new URI( systemId );
179                        String schemaName = systemUri.getPath();
180                        if ( schemaName != null )
181                        {
182                            final int lastIndexOfSlash = schemaName.lastIndexOf( '/' );
183                            if ( lastIndexOfSlash != -1 && lastIndexOfSlash < schemaName.length() )
184                            {
185                                schemaName = schemaName.substring( lastIndexOfSlash + 1 );
186                            }
187 
188                            for ( URI uri : getSchemaResources() )
189                            {
190                                if ( uri.getPath().endsWith( schemaName ) )
191                                {
192                                    schemaSource = new InputSource();
193                                    schemaSource.setPublicId( publicId );
194                                    schemaSource.setSystemId( uri.toASCIIString() );
195 
196                                    if ( isLoggable( Level.FINE ) )
197                                    {
198                                        log( Level.FINE, getMessage( "resolutionInfo", new Object[]
199                                            {
200                                                systemUri.toASCIIString(),
201                                                schemaSource.getSystemId()
202                                            } ), null );
203 
204                                    }
205 
206                                    break;
207                                }
208                            }
209                        }
210                        else
211                        {
212                            if ( isLoggable( Level.WARNING ) )
213                            {
214                                log( Level.WARNING, getMessage( "unsupportedSystemIdUri", new Object[]
215                                    {
216                                        systemId, systemUri.toASCIIString()
217                                    } ), null );
218 
219                            }
220 
221                            schemaSource = null;
222                        }
223                    }
224                }
225                catch ( final URISyntaxException e )
226                {
227                    if ( isLoggable( Level.WARNING ) )
228                    {
229                        log( Level.WARNING, getMessage( "unsupportedSystemIdUri", new Object[]
230                            {
231                                systemId, e.getMessage()
232                            } ), null );
233 
234                    }
235 
236                    schemaSource = null;
237                }
238                catch ( final BootstrapException e )
239                {
240                    throw (IOException) new IOException( getMessage( "failedResolvingSchemas", null ) ).initCause( e );
241                }
242                catch ( final ModelException e )
243                {
244                    throw (IOException) new IOException( getMessage( "failedResolving", new Object[]
245                        {
246                            publicId, systemId, e.getMessage()
247                        } ) ).initCause( e );
248 
249                }
250 
251                return schemaSource;
252            }
253 
254        };
255    }
256 
257    @Override
258    public LSResourceResolver createResourceResolver() throws ModelException
259    {
260        return new LSResourceResolver()
261        {
262 
263            public LSInput resolveResource( final String type, final String namespaceURI, final String publicId,
264                                            final String systemId, final String baseURI )
265            {
266                final String resolvePublicId = namespaceURI == null ? publicId : namespaceURI;
267                final String resolveSystemId = systemId == null ? "" : systemId;
268 
269                try
270                {
271                    if ( XMLConstants.W3C_XML_SCHEMA_NS_URI.equals( type ) )
272                    {
273                        final InputSource schemaSource =
274                            createEntityResolver().resolveEntity( resolvePublicId, resolveSystemId );
275 
276                        if ( schemaSource != null )
277                        {
278                            return new LSInput()
279                            {
280 
281                                public Reader getCharacterStream()
282                                {
283                                    return schemaSource.getCharacterStream();
284                                }
285 
286                                public void setCharacterStream( final Reader characterStream )
287                                {
288                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
289                                        {
290                                            "setCharacterStream",
291                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
292                                        } ), null );
293 
294                                }
295 
296                                public InputStream getByteStream()
297                                {
298                                    return schemaSource.getByteStream();
299                                }
300 
301                                public void setByteStream( final InputStream byteStream )
302                                {
303                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
304                                        {
305                                            "setByteStream",
306                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
307                                        } ), null );
308 
309                                }
310 
311                                public String getStringData()
312                                {
313                                    return null;
314                                }
315 
316                                public void setStringData( final String stringData )
317                                {
318                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
319                                        {
320                                            "setStringData",
321                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
322                                        } ), null );
323 
324                                }
325 
326                                public String getSystemId()
327                                {
328                                    return schemaSource.getSystemId();
329                                }
330 
331                                public void setSystemId( final String systemId )
332                                {
333                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
334                                        {
335                                            "setSystemId",
336                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
337                                        } ), null );
338 
339                                }
340 
341                                public String getPublicId()
342                                {
343                                    return schemaSource.getPublicId();
344                                }
345 
346                                public void setPublicId( final String publicId )
347                                {
348                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
349                                        {
350                                            "setPublicId",
351                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
352                                        } ), null );
353 
354                                }
355 
356                                public String getBaseURI()
357                                {
358                                    return baseURI;
359                                }
360 
361                                public void setBaseURI( final String baseURI )
362                                {
363                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
364                                        {
365                                            "setBaseURI",
366                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
367                                        } ), null );
368 
369                                }
370 
371                                public String getEncoding()
372                                {
373                                    return schemaSource.getEncoding();
374                                }
375 
376                                public void setEncoding( final String encoding )
377                                {
378                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
379                                        {
380                                            "setEncoding",
381                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
382                                        } ), null );
383 
384                                }
385 
386                                public boolean getCertifiedText()
387                                {
388                                    return false;
389                                }
390 
391                                public void setCertifiedText( final boolean certifiedText )
392                                {
393                                    log( Level.WARNING, getMessage( "unsupportedOperation", new Object[]
394                                        {
395                                            "setCertifiedText",
396                                            DefaultModelContext.class.getName() + ".LSResourceResolver"
397                                        } ), null );
398 
399                                }
400 
401                            };
402                        }
403 
404                    }
405                    else if ( isLoggable( Level.WARNING ) )
406                    {
407                        log( Level.WARNING, getMessage( "unsupportedResourceType", new Object[]
408                            {
409                                type
410                            } ), null );
411 
412                    }
413                }
414                catch ( final SAXException e )
415                {
416                    if ( isLoggable( Level.SEVERE ) )
417                    {
418                        log( Level.SEVERE, getMessage( "failedResolving", new Object[]
419                            {
420                                resolvePublicId, resolveSystemId, e.getMessage()
421                            } ), e );
422 
423                    }
424                }
425                catch ( final IOException e )
426                {
427                    if ( isLoggable( Level.SEVERE ) )
428                    {
429                        log( Level.SEVERE, getMessage( "failedResolving", new Object[]
430                            {
431                                resolvePublicId, resolveSystemId, e.getMessage()
432                            } ), e );
433 
434                    }
435                }
436                catch ( final ModelException e )
437                {
438                    if ( isLoggable( Level.SEVERE ) )
439                    {
440                        log( Level.SEVERE, getMessage( "failedResolving", new Object[]
441                            {
442                                resolvePublicId, resolveSystemId, e.getMessage()
443                            } ), e );
444 
445                    }
446                }
447 
448                return null;
449            }
450 
451        };
452 
453    }
454 
455    @Override
456    public Schema createSchema() throws ModelException
457    {
458        try
459        {
460            final SchemaFactory f = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
461            final Schemas schemas = this.getSchemas();
462            final List<Source> sources = new ArrayList<Source>( schemas.getSchema().size() );
463            final EntityResolver entityResolver = this.createEntityResolver();
464 
465            for ( org.jomc.model.bootstrap.Schema s : schemas.getSchema() )
466            {
467                final InputSource inputSource = entityResolver.resolveEntity( s.getPublicId(), s.getSystemId() );
468 
469                if ( inputSource != null )
470                {
471                    sources.add( new SAXSource( inputSource ) );
472                }
473            }
474 
475            if ( sources.isEmpty() )
476            {
477                throw new ModelException( this.getMessage( "missingSchemas", null ) );
478            }
479 
480            f.setResourceResolver( this.createResourceResolver() );
481            return f.newSchema( sources.toArray( new Source[ sources.size() ] ) );
482        }
483        catch ( final BootstrapException e )
484        {
485            throw new ModelException( e );
486        }
487        catch ( final IOException e )
488        {
489            throw new ModelException( e );
490        }
491        catch ( final SAXException e )
492        {
493            throw new ModelException( e );
494        }
495    }
496 
497    @Override
498    public JAXBContext createContext() throws ModelException
499    {
500        try
501        {
502            final StringBuilder packageNames = new StringBuilder();
503 
504            for ( final Iterator<org.jomc.model.bootstrap.Schema> s = this.getSchemas().getSchema().iterator();
505                  s.hasNext(); )
506            {
507                final org.jomc.model.bootstrap.Schema schema = s.next();
508                if ( schema.getContextId() != null )
509                {
510                    packageNames.append( ':' ).append( schema.getContextId() );
511                    if ( this.isLoggable( Level.CONFIG ) )
512                    {
513                        this.log( Level.CONFIG, this.getMessage( "foundContext", new Object[]
514                            {
515                                schema.getContextId()
516                            } ), null );
517 
518                    }
519                }
520            }
521 
522            if ( packageNames.length() == 0 )
523            {
524                throw new ModelException( this.getMessage( "missingSchemas", null ) );
525            }
526 
527            return JAXBContext.newInstance( packageNames.toString().substring( 1 ), this.getClassLoader() );
528        }
529        catch ( final BootstrapException e )
530        {
531            throw new ModelException( e );
532        }
533        catch ( final JAXBException e )
534        {
535            throw new ModelException( e );
536        }
537    }
538 
539    @Override
540    public Marshaller createMarshaller() throws ModelException
541    {
542        try
543        {
544            final StringBuilder packageNames = new StringBuilder();
545            final StringBuilder schemaLocation = new StringBuilder();
546 
547            for ( final Iterator<org.jomc.model.bootstrap.Schema> s = this.getSchemas().getSchema().iterator();
548                  s.hasNext(); )
549            {
550                final org.jomc.model.bootstrap.Schema schema = s.next();
551                if ( schema.getContextId() != null )
552                {
553                    packageNames.append( ':' ).append( schema.getContextId() );
554                }
555                if ( schema.getPublicId() != null && schema.getSystemId() != null )
556                {
557                    schemaLocation.append( ' ' ).append( schema.getPublicId() ).append( ' ' ).
558                        append( schema.getSystemId() );
559 
560                }
561            }
562 
563            if ( packageNames.length() == 0 )
564            {
565                throw new ModelException( this.getMessage( "missingSchemas", null ) );
566            }
567 
568            final Marshaller m =
569                JAXBContext.newInstance( packageNames.toString().substring( 1 ), this.getClassLoader() ).
570                createMarshaller();
571 
572            if ( schemaLocation.length() != 0 )
573            {
574                m.setProperty( Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation.toString().substring( 1 ) );
575            }
576 
577            return m;
578        }
579        catch ( final BootstrapException e )
580        {
581            throw new ModelException( e );
582        }
583        catch ( final JAXBException e )
584        {
585            throw new ModelException( e );
586        }
587    }
588 
589    @Override
590    public Unmarshaller createUnmarshaller() throws ModelException
591    {
592        try
593        {
594            return this.createContext().createUnmarshaller();
595        }
596        catch ( final JAXBException e )
597        {
598            throw new ModelException( e );
599        }
600    }
601 
602    /**
603     * Gets the schemas of the instance.
604     *
605     * @return The schemas of the instance.
606     *
607     * @throws BootstrapException if getting the schemas fails.
608     */
609    private Schemas getSchemas() throws BootstrapException
610    {
611        Schemas schemas = this.cachedSchemas.get();
612 
613        if ( schemas == null )
614        {
615            schemas = BootstrapContext.createBootstrapContext( this.getClassLoader() ).findSchemas();
616 
617            if ( schemas != null && this.isLoggable( Level.CONFIG ) )
618            {
619                for ( org.jomc.model.bootstrap.Schema s : schemas.getSchema() )
620                {
621                    this.log( Level.CONFIG, this.getMessage( "foundSchema", new Object[]
622                        {
623                            s.getPublicId(), s.getSystemId(), s.getContextId(), s.getClasspathId()
624                        } ), null );
625 
626                }
627            }
628 
629            this.cachedSchemas = new SoftReference( schemas );
630        }
631 
632        return schemas;
633    }
634 
635    /**
636     * Searches the context for {@code META-INF/MANIFEST.MF} resources and returns a set of URIs of entries whose name
637     * end with a known schema extension.
638     *
639     * @return Set of URIs of any matching entries.
640     *
641     * @throws IOException if reading fails.
642     * @throws URISyntaxException if parsing fails.
643     */
644    private Set<URI> getSchemaResources() throws IOException, URISyntaxException
645    {
646        Set<URI> resources = this.cachedSchemaResources.get();
647 
648        if ( resources == null )
649        {
650            resources = new HashSet<URI>();
651            final long t0 = System.currentTimeMillis();
652            int count = 0;
653 
654            for ( final Enumeration<URL> e = this.getClassLoader().getResources( "META-INF/MANIFEST.MF" );
655                  e.hasMoreElements(); )
656            {
657                count++;
658                final URL manifestUrl = e.nextElement();
659                final String externalForm = manifestUrl.toExternalForm();
660                final String baseUrl = externalForm.substring( 0, externalForm.indexOf( "META-INF" ) );
661                final InputStream manifestStream = manifestUrl.openStream();
662                final Manifest mf = new Manifest( manifestStream );
663                manifestStream.close();
664 
665                if ( this.isLoggable( Level.FINE ) )
666                {
667                    this.log( Level.FINE, this.getMessage( "processing", new Object[]
668                        {
669                            externalForm
670                        } ), null );
671 
672                }
673 
674                for ( Map.Entry<String, Attributes> entry : mf.getEntries().entrySet() )
675                {
676                    for ( int i = SCHEMA_EXTENSIONS.length - 1; i >= 0; i-- )
677                    {
678                        if ( entry.getKey().toLowerCase().endsWith( '.' + SCHEMA_EXTENSIONS[i].toLowerCase() ) )
679                        {
680                            final URL schemaUrl = new URL( baseUrl + entry.getKey() );
681                            resources.add( schemaUrl.toURI() );
682 
683                            if ( this.isLoggable( Level.FINE ) )
684                            {
685                                this.log( Level.FINE, this.getMessage( "foundSchemaCandidate", new Object[]
686                                    {
687                                        schemaUrl.toExternalForm()
688                                    } ), null );
689 
690                            }
691                        }
692                    }
693                }
694            }
695 
696            if ( this.isLoggable( Level.FINE ) )
697            {
698                this.log( Level.FINE, this.getMessage( "contextReport", new Object[]
699                    {
700                        count, "META-INF/MANIFEST.MF", Long.valueOf( System.currentTimeMillis() - t0 )
701                    } ), null );
702 
703            }
704 
705            this.cachedSchemaResources = new SoftReference( resources );
706        }
707 
708        return resources;
709    }
710 
711    private String getMessage( final String key, final Object args )
712    {
713        return new MessageFormat( ResourceBundle.getBundle( DefaultModelContext.class.getName().replace( '.', '/' ),
714                                                            Locale.getDefault() ).getString( key ) ).format( args );
715 
716    }
717 
718}

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