use of org.jruby.anno.JRubyMethod in project nokogiri by sparklemotion.
the class XmlNode method create_internal_subset.
@JRubyMethod
public IRubyObject create_internal_subset(ThreadContext context, IRubyObject name, IRubyObject external_id, IRubyObject system_id) {
IRubyObject subset = internal_subset(context);
if (!subset.isNil()) {
throw context.getRuntime().newRuntimeError("Document already has internal subset");
}
Document document = getOwnerDocument();
if (document == null) {
return context.getRuntime().getNil();
}
XmlDocument xdoc = (XmlDocument) getCachedNodeOrCreate(context.getRuntime(), document);
IRubyObject xdtd = xdoc.createInternalSubset(context, name, external_id, system_id);
return xdtd;
}
use of org.jruby.anno.JRubyMethod in project nokogiri by sparklemotion.
the class HtmlEntityLookup method get.
/**
* Looks up an HTML entity <code>key</code>.
*
* The description is a bit lacking.
*/
@JRubyMethod()
public IRubyObject get(ThreadContext context, IRubyObject key) {
Ruby ruby = context.getRuntime();
String name = key.toString();
int val = HTMLEntities.get(name);
if (val == -1)
return ruby.getNil();
IRubyObject edClass = ruby.getClassFromPath("Nokogiri::HTML::EntityDescription");
IRubyObject edObj = invoke(context, edClass, "new", ruby.newFixnum(val), ruby.newString(name), ruby.newString(name + " entity"));
return edObj;
}
use of org.jruby.anno.JRubyMethod in project nokogiri by sparklemotion.
the class HtmlSaxParserContext method parse_file.
@JRubyMethod(name = "file", meta = true)
public static IRubyObject parse_file(ThreadContext context, IRubyObject klazz, IRubyObject data, IRubyObject encoding) {
HtmlSaxParserContext ctx = (HtmlSaxParserContext) NokogiriService.HTML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass) klazz);
ctx.initialize(context.getRuntime());
ctx.setInputSourceFile(context, data);
String javaEncoding = findEncoding(context, encoding);
if (javaEncoding != null) {
ctx.getInputSource().setEncoding(javaEncoding);
}
return ctx;
}
use of org.jruby.anno.JRubyMethod in project nokogiri by sparklemotion.
the class HtmlSaxParserContext method parse_io.
@JRubyMethod(name = "io", meta = true)
public static IRubyObject parse_io(ThreadContext context, IRubyObject klazz, IRubyObject data, IRubyObject encoding) {
HtmlSaxParserContext ctx = (HtmlSaxParserContext) NokogiriService.HTML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass) klazz);
ctx.initialize(context.getRuntime());
ctx.setInputSource(context, data, context.getRuntime().getNil());
String javaEncoding = findEncoding(context, encoding);
if (javaEncoding != null) {
ctx.getInputSource().setEncoding(javaEncoding);
}
return ctx;
}
use of org.jruby.anno.JRubyMethod in project gocd by gocd.
the class HtmlEntityLookup method get.
/**
* Looks up an HTML entity <code>key</code>.
*
* The description is a bit lacking.
*/
@JRubyMethod()
public IRubyObject get(ThreadContext context, IRubyObject key) {
Ruby ruby = context.getRuntime();
String name = key.toString();
int val = HTMLEntities.get(name);
if (val == -1)
return ruby.getNil();
IRubyObject edClass = ruby.getClassFromPath("Nokogiri::HTML::EntityDescription");
IRubyObject edObj = invoke(context, edClass, "new", ruby.newFixnum(val), ruby.newString(name), ruby.newString(name + " entity"));
return edObj;
}
Aggregations