001: //
002: // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.4-b18-fcs
003: // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
004: // Any modifications to this file will be lost upon recompilation of the source schema.
005: // Generated on: 2005.03.04 at 10:20:40 PST
006: //
007:
008: package com.nabhinc.portal.config.impl.runtime;
009:
010: import javax.xml.bind.DatatypeConverter;
011: import javax.xml.bind.JAXBContext;
012: import javax.xml.bind.JAXBException;
013: import javax.xml.bind.Marshaller;
014: import javax.xml.bind.PropertyException;
015: import javax.xml.bind.Unmarshaller;
016: import javax.xml.bind.Validator;
017:
018: import com.sun.xml.bind.Messages;
019: import com.sun.xml.bind.DatatypeConverterImpl;
020:
021: /**
022: * This class provides the default implementation of JAXBContext. It
023: * also creates the GrammarInfoFacade that unifies all of the grammar
024: * info from packages on the contextPath.
025: *
026: * @version $Revision: 1.1 $
027: */
028: public class DefaultJAXBContextImpl extends JAXBContext {
029:
030: /**
031: * This object keeps information about the grammar.
032: *
033: * When more than one package are specified,
034: * GrammarInfoFacade is used.
035: */
036: private GrammarInfo gi = null;
037:
038: /**
039: * This is the constructor used by javax.xml.bind.FactoryFinder which
040: * bootstraps the RI. It causes the construction of a JAXBContext that
041: * contains a GrammarInfoFacade which is the union of all the generated
042: * JAXBContextImpl objects on the contextPath.
043: */
044: public DefaultJAXBContextImpl(String contextPath,
045: ClassLoader classLoader) throws JAXBException {
046:
047: this (GrammarInfoFacade.createGrammarInfoFacade(contextPath,
048: classLoader));
049:
050: // initialize datatype converter with ours
051: DatatypeConverter
052: .setDatatypeConverter(DatatypeConverterImpl.theInstance);
053: }
054:
055: /**
056: * This constructor is used by the default no-arg constructor in the
057: * generated JAXBContextImpl objects. It is also used by the
058: * bootstrapping constructor in this class.
059: */
060: public DefaultJAXBContextImpl(GrammarInfo gi) {
061: this .gi = gi;
062: }
063:
064: public GrammarInfo getGrammarInfo() {
065: return gi;
066: }
067:
068: /**
069: * Once we load a grammar, we will cache the value here.
070: */
071: private com.sun.msv.grammar.Grammar grammar = null;
072:
073: /**
074: * Loads a grammar object for the unmarshal-time validation.
075: */
076: public com.sun.msv.grammar.Grammar getGrammar()
077: throws JAXBException {
078: if (grammar == null)
079: // since JAXBContext needs to be thread-safe,
080: // this check might allow more than one thread to
081: // load a grammar, but that's fine; it's just a loss of
082: // time, but by itself it doesn't cause any problem.
083: // by not synchronizing method, we can avoid its overhead.
084: grammar = gi.getGrammar();
085: return grammar;
086: }
087:
088: /**
089: * Create a <CODE>Marshaller</CODE> object that can be used to convert a
090: * java content-tree into XML data.
091: *
092: * @return a <CODE>Marshaller</CODE> object
093: * @throws JAXBException if an error was encountered while creating the
094: * <code>Marshaller</code> object
095: */
096: public Marshaller createMarshaller() throws JAXBException {
097: return new MarshallerImpl(this );
098: }
099:
100: /**
101: * Create an <CODE>Unmarshaller</CODE> object that can be used to convert XML
102: * data into a java content-tree.
103: *
104: * @return an <CODE>Unmarshaller</CODE> object
105: * @throws JAXBException if an error was encountered while creating the
106: * <code>Unmarshaller</code> object
107: */
108: public Unmarshaller createUnmarshaller() throws JAXBException {
109: return new UnmarshallerImpl(this , gi);
110: }
111:
112: /**
113: * Create a <CODE>Validator</CODE> object that can be used to validate a
114: * java content-tree.
115: *
116: * @return an <CODE>Unmarshaller</CODE> object
117: * @throws JAXBException if an error was encountered while creating the
118: * <code>Validator</code> object
119: */
120: public Validator createValidator() throws JAXBException {
121: return new ValidatorImpl(this );
122: }
123:
124: /**
125: * Create an instance of the specified Java content interface.
126: *
127: * @param javaContentInterface the Class object
128: * @return an instance of the Java content interface
129: * @exception JAXBException
130: */
131: public Object newInstance(Class javaContentInterface)
132: throws JAXBException {
133:
134: if (javaContentInterface == null) {
135: throw new JAXBException(Messages
136: .format(Messages.CI_NOT_NULL));
137: }
138:
139: try {
140: Class c = gi.getDefaultImplementation(javaContentInterface);
141: if (c == null)
142: throw new JAXBException(Messages.format(
143: Messages.MISSING_INTERFACE,
144: javaContentInterface));
145:
146: return c.newInstance();
147: } catch (Exception e) {
148: throw new JAXBException(e);
149: }
150: }
151:
152: /**
153: * There are no required properties, so simply throw an exception. Other
154: * providers may have support for properties on Validator, but the RI doesn't
155: */
156: public void setProperty(String name, Object value)
157: throws PropertyException {
158:
159: throw new PropertyException(name, value);
160: }
161:
162: /**
163: * There are no required properties, so simply throw an exception. Other
164: * providers may have support for properties on Validator, but the RI doesn't
165: */
166: public Object getProperty(String name) throws PropertyException {
167:
168: throw new PropertyException(name);
169: }
170:
171: }
|