| Method from com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl Detail: |
public JAXBModelImpl bind() {
// this has been problematic. turn it off.
// if(!forest.checkSchemaCorrectness(this))
// return null;
// internalization
forest.transform();
if(!NO_CORRECTNESS_CHECK) {
// correctness check
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
sf.setErrorHandler(new DowngradingErrorHandler(this));
forest.weakSchemaCorrectnessCheck(sf);
if(hadError)
return null; // error in the correctness check. abort now
}
JCodeModel codeModel = new JCodeModel();
ModelLoader gl = new ModelLoader(opts,codeModel,this);
try {
XSSchemaSet result = gl.createXSOM(forest);
if(result==null)
return null;
// we need info about each field, so we go ahead and generate the
// skeleton at this point.
// REVISIT: we should separate FieldRenderer and FieldAccessor
// so that accessors can be used before we build the code.
Model model = gl.annotateXMLSchema(result);
if(model==null) return null;
if(hadError) return null; // if we have any error by now, abort
Outline context = model.generateCode(opts,this);
if(context==null) return null;
if(hadError) return null;
return new JAXBModelImpl(context);
} catch( SAXException e ) {
// since XSOM uses our parser that scans DOM,
// no parser error is possible.
// all the other errors will be directed to ErrorReceiver
// before it's thrown, so when the exception is thrown
// the error should have already been reported.
// thus ignore.
return null;
}
}
|
public void error(SAXParseException exception) {
hadError = true;
if(errorListener!=null)
errorListener.error(exception);
}
|
public void fatalError(SAXParseException exception) {
hadError = true;
if(errorListener!=null)
errorListener.fatalError(exception);
}
|
public void forcePackageName(String packageName) {
opts.defaultPackage = packageName;
}
|
public Options getOptions() {
return opts;
}
|
public ContentHandler getParserHandler(String systemId) {
return forest.getParserHandler(systemId,true);
}
|
public void info(SAXParseException exception) {
if(errorListener!=null)
errorListener.info(exception);
}
|
public void parseSchema(InputSource source) {
checkAbsoluteness(source.getSystemId());
try {
forest.parse(source,true);
} catch (SAXException e) {
// parsers are required to report an error to ErrorHandler,
// so we should never see this error.
e.printStackTrace();
}
}
|
public void parseSchema(String systemId,
Element element) {
checkAbsoluteness(systemId);
try {
DOMScanner scanner = new DOMScanner();
// use a locator that sets the system ID correctly
// so that we can resolve relative URLs in most of the case.
// it still doesn't handle xml:base and XInclude and all those things
// correctly. There's just no way to make all those things work with DOM!
LocatorImpl loc = new LocatorImpl();
loc.setSystemId(systemId);
scanner.setLocator(loc);
scanner.setContentHandler(getParserHandler(systemId));
scanner.scan(element);
} catch (SAXException e) {
// since parsing DOM shouldn't cause a SAX exception
// and our handler will never throw it, it's not clear
// if this will ever happen.
fatalError(new SAXParseException2(
e.getMessage(), null, systemId,-1,-1, e));
}
}
|
public void parseSchema(String systemId,
XMLStreamReader reader) throws XMLStreamException {
checkAbsoluteness(systemId);
forest.parse(systemId,reader,true);
}
|
public void setClassNameAllocator(ClassNameAllocator allocator) {
opts.classNameAllocator = allocator;
}
|
public void setDefaultPackageName(String packageName) {
opts.defaultPackage2 = packageName;
}
|
public void setEntityResolver(EntityResolver entityResolver) {
forest.setEntityResolver(entityResolver);
opts.entityResolver = entityResolver;
}
|
public void setErrorListener(ErrorListener errorListener) {
this.errorListener = errorListener;
}
|
public void warning(SAXParseException exception) {
if(errorListener!=null)
errorListener.warning(exception);
}
|