use of com.sun.tools.xjc.reader.Ring in project jaxb-ri by eclipse-ee4j.
the class BGMBuilder method build.
/**
* Entry point.
*/
public static Model build(XSSchemaSet _schemas, JCodeModel codeModel, ErrorReceiver _errorReceiver, Options opts) {
// set up a ring
final Ring old = Ring.begin();
try {
ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);
Ring.add(XSSchemaSet.class, _schemas);
Ring.add(codeModel);
Model model = new Model(opts, codeModel, null, /*set later*/
opts.classNameAllocator, _schemas);
Ring.add(model);
Ring.add(ErrorReceiver.class, ef);
Ring.add(CodeModelClassFactory.class, new CodeModelClassFactory(ef));
BGMBuilder builder = new BGMBuilder(opts.defaultPackage, opts.defaultPackage2, opts.isExtensionMode(), opts.getFieldRendererFactory(), opts.activePlugins);
builder._build();
if (ef.hadError())
return null;
else
return model;
} finally {
Ring.end(old);
}
}
use of com.sun.tools.xjc.reader.Ring in project jaxb-ri by eclipse-ee4j.
the class TDTDReader method parse.
/**
* Parses DTD grammar and a binding information into BGM.
*
* <p>
* This method is just a utility method that covers 80% of the use
* cases.
*
* @param bindingInfo
* binding information file, if any. Can be null.
*/
public static Model parse(InputSource dtd, InputSource bindingInfo, ErrorReceiver errorReceiver, Options opts) {
try {
// set up a ring
final Ring old = Ring.begin();
try {
ErrorReceiverFilter ef = new ErrorReceiverFilter(errorReceiver);
JCodeModel cm = new JCodeModel();
Model model = new Model(opts, cm, NameConverter.standard, opts.classNameAllocator, null);
Ring.add(cm);
Ring.add(model);
Ring.add(ErrorReceiver.class, ef);
TDTDReader reader = new TDTDReader(ef, opts, bindingInfo);
DTDParser parser = new DTDParser();
parser.setDtdHandler(reader);
if (opts.entityResolver != null)
parser.setEntityResolver(opts.entityResolver);
try {
parser.parse(dtd);
} catch (SAXParseException e) {
// this error was already handled by GrammarReaderController
return null;
}
Ring.get(ModelChecker.class).check();
if (ef.hadError())
return null;
else
return model;
} finally {
Ring.end(old);
}
} catch (IOException | SAXException e) {
errorReceiver.error(new SAXParseException2(e.getMessage(), null, e));
return null;
} catch (AbortException e) {
// parsing was aborted but the error was already reported
return null;
}
}
Aggregations