KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > xb > binding > sunday > unmarshalling > SchemaResolverConfig


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.xb.binding.sunday.unmarshalling;
23
24 import java.util.Iterator JavaDoc;
25 import java.util.Map JavaDoc;
26 import java.util.Properties JavaDoc;
27
28 import org.jboss.logging.Logger;
29 import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
30
31 /**
32  * SchemaResolverConfig.
33  *
34  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
35  * @version $Revision: 1958 $
36  */

37 public class SchemaResolverConfig implements SchemaResolverConfigMBean
38 {
39    /** The log */
40    private static final Logger log = Logger.getLogger(SchemaResolverConfig.class);
41    
42    /** The singleton schema resolver */
43    protected static DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
44    
45    /** The initializers by namespace */
46    protected Properties JavaDoc schemaInitializers;
47
48    /** The locations by namespace */
49    protected Properties JavaDoc schemaLocations;
50
51    /** The parse annotations by namespace */
52    protected Properties JavaDoc parseAnnotations;
53
54    public Properties JavaDoc getSchemaInitializers()
55    {
56       return schemaInitializers;
57    }
58
59    public void setSchemaInitializers(Properties JavaDoc schemaInitializers)
60    {
61       this.schemaInitializers = schemaInitializers;
62       if (schemaInitializers != null && schemaInitializers.size() != 0)
63       {
64          for (Iterator JavaDoc i = schemaInitializers.entrySet().iterator(); i.hasNext();)
65          {
66             Map.Entry JavaDoc entry = (Map.Entry JavaDoc) i.next();
67             String JavaDoc namespace = (String JavaDoc) entry.getKey();
68             String JavaDoc initializer = (String JavaDoc) entry.getValue();
69             try
70             {
71                resolver.addSchemaInitializer(namespace, initializer);
72             }
73             catch (Exception JavaDoc ignored)
74             {
75                log.debug("Ignored: ", ignored);
76             }
77          }
78       }
79    }
80
81    public Properties JavaDoc getSchemaLocations()
82    {
83       return schemaLocations;
84    }
85
86    public void setSchemaLocations(Properties JavaDoc schemaLocations)
87    {
88       this.schemaLocations = schemaLocations;
89       if (schemaLocations != null && schemaLocations.size() != 0)
90       {
91          for (Iterator JavaDoc i = schemaLocations.entrySet().iterator(); i.hasNext();)
92          {
93             Map.Entry JavaDoc entry = (Map.Entry JavaDoc) i.next();
94             String JavaDoc namespace = (String JavaDoc) entry.getKey();
95             String JavaDoc location = (String JavaDoc) entry.getValue();
96             resolver.addSchemaLocation(namespace, location);
97          }
98       }
99    }
100
101    public Properties JavaDoc getParseAnnotations()
102    {
103       return parseAnnotations;
104    }
105
106    public void setParseAnnotations(Properties JavaDoc parseAnnotations)
107    {
108       this.parseAnnotations = parseAnnotations;
109       if (parseAnnotations != null && parseAnnotations.size() != 0)
110       {
111          for (Iterator JavaDoc i = parseAnnotations.entrySet().iterator(); i.hasNext();)
112          {
113             Map.Entry JavaDoc entry = (Map.Entry JavaDoc) i.next();
114             String JavaDoc namespace = (String JavaDoc) entry.getKey();
115             String JavaDoc value = (String JavaDoc) entry.getValue();
116             Boolean JavaDoc booleanValue = Boolean.valueOf(value);
117             resolver.addSchemaParseAnnotations(namespace, booleanValue);
118          }
119       }
120    }
121 }
122
Popular Tags