use of nokogiri.internals.ReaderNode in project nokogiri by sparklemotion.
the class XmlReader method setAndRaiseErrorsIfAny.
private IRubyObject setAndRaiseErrorsIfAny(final Ruby runtime, final RaiseException ex) throws RaiseException {
final ReaderNode currentNode = currentNode();
if (currentNode == null) {
return runtime.getNil();
}
if (currentNode.isError()) {
RubyArray<?> errors = (RubyArray) getInstanceVariable("@errors");
IRubyObject error = currentNode.toSyntaxError();
errors.append(error);
setInstanceVariable("@errors", errors);
throw ex != null ? ex : ((XmlSyntaxError) error).toThrowable();
}
if (ex != null) {
throw ex;
}
return this;
}
use of nokogiri.internals.ReaderNode in project nokogiri by sparklemotion.
the class XmlReader method getOuterXml.
private String getOuterXml() {
ReaderNode current = currentNode();
if (current == null || current.depth < 0) {
return null;
}
if (current instanceof ClosingNode) {
return "<" + current.name + "/>";
}
StringBuilder sb = new StringBuilder();
for (int i = position; i <= current.endOffset; i++) {
sb.append(nodeQueue.get(i).getString());
}
return new String(sb);
}
use of nokogiri.internals.ReaderNode in project gocd by gocd.
the class XmlReader method getOuterXml.
private String getOuterXml() {
ReaderNode current = currentNode();
if (current.depth < 0)
return null;
if (current instanceof ClosingNode) {
return "<" + current.name + "/>";
}
StringBuffer sb = new StringBuffer();
for (int i = position; i <= current.endOffset; i++) {
sb.append(nodeQueue.get(i).getString());
}
return new String(sb);
}
use of nokogiri.internals.ReaderNode in project gocd by gocd.
the class XmlReader method empty_element_p.
@JRubyMethod(name = { "empty_element?", "self_closing?" })
public IRubyObject empty_element_p(ThreadContext context) {
ReaderNode readerNode = currentNode();
ensureNodeClosed(context);
if (readerNode == null)
return context.getRuntime().getNil();
if (!(readerNode instanceof ElementNode))
context.getRuntime().getFalse();
return RubyBoolean.newBoolean(context.getRuntime(), !readerNode.hasChildren);
}
use of nokogiri.internals.ReaderNode in project nokogiri by sparklemotion.
the class XmlReader method empty_element_p.
@JRubyMethod(name = { "empty_element?", "self_closing?" })
public IRubyObject empty_element_p(ThreadContext context) {
ReaderNode readerNode = currentNode();
ensureNodeClosed(context);
if (readerNode == null) {
return context.getRuntime().getNil();
}
if (!(readerNode instanceof ElementNode)) {
context.getRuntime().getFalse();
}
return RubyBoolean.newBoolean(context.getRuntime(), !readerNode.hasChildren);
}
Aggregations