001: //
002: // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.5-b16-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.12.17 at 09:43:27 AM GMT+07:00
006: //
007:
008: package com.mvnforum.jaxb.db.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.3 $
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: * <p>
077: * getGrammar is normally very expensive, so it's worth
078: * synchronizing to avoid unnecessary invocation.
079: */
080: public synchronized com.sun.msv.grammar.Grammar getGrammar()
081: throws JAXBException {
082: if (grammar == null)
083: grammar = gi.getGrammar();
084: return grammar;
085: }
086:
087: /**
088: * Create a <CODE>Marshaller</CODE> object that can be used to convert a
089: * java content-tree into XML data.
090: *
091: * @return a <CODE>Marshaller</CODE> object
092: * @throws JAXBException if an error was encountered while creating the
093: * <code>Marshaller</code> object
094: */
095: public Marshaller createMarshaller() throws JAXBException {
096: return new MarshallerImpl(this );
097: }
098:
099: /**
100: * Create an <CODE>Unmarshaller</CODE> object that can be used to convert XML
101: * data into a java content-tree.
102: *
103: * @return an <CODE>Unmarshaller</CODE> object
104: * @throws JAXBException if an error was encountered while creating the
105: * <code>Unmarshaller</code> object
106: */
107: public Unmarshaller createUnmarshaller() throws JAXBException {
108: return new UnmarshallerImpl(this , gi);
109: }
110:
111: /**
112: * Create a <CODE>Validator</CODE> object that can be used to validate a
113: * java content-tree.
114: *
115: * @return an <CODE>Unmarshaller</CODE> object
116: * @throws JAXBException if an error was encountered while creating the
117: * <code>Validator</code> object
118: */
119: public Validator createValidator() throws JAXBException {
120: return new ValidatorImpl(this );
121: }
122:
123: /**
124: * Create an instance of the specified Java content interface.
125: *
126: * @param javaContentInterface the Class object
127: * @return an instance of the Java content interface
128: * @exception JAXBException
129: */
130: public Object newInstance(Class javaContentInterface)
131: throws JAXBException {
132:
133: if (javaContentInterface == null) {
134: throw new JAXBException(Messages
135: .format(Messages.CI_NOT_NULL));
136: }
137:
138: try {
139: Class c = gi.getDefaultImplementation(javaContentInterface);
140: if (c == null)
141: throw new JAXBException(Messages.format(
142: Messages.MISSING_INTERFACE,
143: javaContentInterface));
144:
145: return c.newInstance();
146: } catch (Exception e) {
147: throw new JAXBException(e);
148: }
149: }
150:
151: /**
152: * There are no required properties, so simply throw an exception. Other
153: * providers may have support for properties on Validator, but the RI doesn't
154: */
155: public void setProperty(String name, Object value)
156: throws PropertyException {
157:
158: throw new PropertyException(name, value);
159: }
160:
161: /**
162: * There are no required properties, so simply throw an exception. Other
163: * providers may have support for properties on Validator, but the RI doesn't
164: */
165: public Object getProperty(String name) throws PropertyException {
166:
167: throw new PropertyException(name);
168: }
169:
170: }
|