use of org.jruby.RubyClass in project nokogiri by sparklemotion.
the class XmlDomParserContext method parse.
/**
* Must call setInputSource() before this method.
*/
public XmlDocument parse(ThreadContext context, IRubyObject klazz, IRubyObject url) {
XmlDocument xmlDoc;
try {
Document doc = do_parse();
xmlDoc = wrapDocument(context, (RubyClass) klazz, doc);
xmlDoc.setUrl(url);
addErrorsIfNecessary(context, xmlDoc);
return xmlDoc;
} catch (SAXException e) {
return getDocumentWithErrorsOrRaiseException(context, (RubyClass) klazz, e);
} catch (IOException e) {
return getDocumentWithErrorsOrRaiseException(context, (RubyClass) klazz, e);
}
}
use of org.jruby.RubyClass in project nokogiri by sparklemotion.
the class NokogiriService method createSaxModule.
private void createSaxModule(Ruby ruby, RubyModule xmlSaxModule, RubyModule htmlSaxModule) {
RubyClass xmlSaxParserContext = xmlSaxModule.defineClassUnder("ParserContext", ruby.getObject(), XML_SAXPARSER_CONTEXT_ALLOCATOR);
xmlSaxParserContext.defineAnnotatedMethods(XmlSaxParserContext.class);
RubyClass xmlSaxPushParser = xmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), XML_SAXPUSHPARSER_ALLOCATOR);
xmlSaxPushParser.defineAnnotatedMethods(XmlSaxPushParser.class);
RubyClass htmlSaxPushParser = htmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), HTML_SAXPUSHPARSER_ALLOCATOR);
htmlSaxPushParser.defineAnnotatedMethods(HtmlSaxPushParser.class);
RubyClass htmlSaxParserContext = htmlSaxModule.defineClassUnder("ParserContext", xmlSaxParserContext, HTML_SAXPARSER_CONTEXT_ALLOCATOR);
htmlSaxParserContext.defineAnnotatedMethods(HtmlSaxParserContext.class);
}
use of org.jruby.RubyClass in project nokogiri by sparklemotion.
the class NokogiriService method init.
private void init(Ruby ruby) {
RubyModule nokogiri = ruby.defineModule("Nokogiri");
RubyModule xmlModule = nokogiri.defineModuleUnder("XML");
RubyModule xmlSaxModule = xmlModule.defineModuleUnder("SAX");
RubyModule htmlModule = nokogiri.defineModuleUnder("HTML");
RubyModule htmlSaxModule = htmlModule.defineModuleUnder("SAX");
RubyModule xsltModule = nokogiri.defineModuleUnder("XSLT");
createJavaLibraryVersionConstants(ruby, nokogiri);
createNokogiriModule(ruby, nokogiri);
createSyntaxErrors(ruby, nokogiri, xmlModule);
RubyClass xmlNode = createXmlModule(ruby, xmlModule);
createHtmlModule(ruby, htmlModule);
createDocuments(ruby, xmlModule, htmlModule, xmlNode);
createSaxModule(ruby, xmlSaxModule, htmlSaxModule);
createXsltModule(ruby, xsltModule);
nokogiri.setInternalVariable("cache", populateNokogiriClassCahce(ruby));
}
use of org.jruby.RubyClass in project nokogiri by sparklemotion.
the class NokogiriService method createXsltModule.
private void createXsltModule(Ruby ruby, RubyModule xsltModule) {
RubyClass stylesheet = xsltModule.defineClassUnder("Stylesheet", ruby.getObject(), XSLT_STYLESHEET_ALLOCATOR);
stylesheet.defineAnnotatedMethods(XsltStylesheet.class);
xsltModule.defineAnnotatedMethod(XsltStylesheet.class, "register");
}
use of org.jruby.RubyClass in project nokogiri by sparklemotion.
the class NokogiriService method createSyntaxErrors.
private void createSyntaxErrors(Ruby ruby, RubyModule nokogiri, RubyModule xmlModule) {
RubyClass syntaxError = nokogiri.defineClassUnder("SyntaxError", ruby.getStandardError(), ruby.getStandardError().getAllocator());
RubyClass xmlSyntaxError = xmlModule.defineClassUnder("SyntaxError", syntaxError, XML_SYNTAXERROR_ALLOCATOR);
xmlSyntaxError.defineAnnotatedMethods(XmlSyntaxError.class);
}
Aggregations