use of org.jruby.RubyString in project jruby-openssl by jruby.
the class StringHelper method newStringFrozen.
static RubyString newStringFrozen(final Ruby runtime, final ByteList bytes) {
final RubyString str = RubyString.newStringShared(runtime, bytes);
str.setFrozen(true);
return str;
}
use of org.jruby.RubyString in project jruby-openssl by jruby.
the class X509StoreContext method chain.
@JRubyMethod
public IRubyObject chain(final ThreadContext context) {
final Ruby runtime = context.runtime;
final List<X509AuxCertificate> chain = storeContext.getChain();
if (chain == null)
return runtime.getNil();
final RubyArray result = runtime.newArray(chain.size());
final RubyClass _Certificate = _Certificate(runtime);
try {
for (X509AuxCertificate x509 : chain) {
RubyString encoded = StringHelper.newString(runtime, x509.getEncoded());
result.append(_Certificate.callMethod(context, "new", encoded));
}
} catch (CertificateEncodingException e) {
throw newStoreError(runtime, e.getMessage());
}
return result;
}
use of org.jruby.RubyString in project nokogiri by sparklemotion.
the class XsltStylesheet method getTemplatesFromStreamSource.
private Templates getTemplatesFromStreamSource() throws TransformerConfigurationException {
if (stylesheet instanceof RubyString) {
StringReader reader = new StringReader(stylesheet.asJavaString());
StreamSource xsltStreamSource = new StreamSource(reader);
return factory.newTemplates(xsltStreamSource);
}
return null;
}
use of org.jruby.RubyString in project nokogiri by sparklemotion.
the class XmlNode method native_write_to.
/**
* @param args {IRubyObject io,
* IRubyObject encoding,
* IRubyObject indentString,
* IRubyObject options}
*/
@JRubyMethod(required = 4, visibility = Visibility.PRIVATE)
public IRubyObject native_write_to(ThreadContext context, IRubyObject[] args) {
IRubyObject io = args[0];
IRubyObject encoding = args[1];
IRubyObject indentString = args[2];
IRubyObject options = args[3];
String encString = rubyStringToString(encoding);
SaveContextVisitor visitor = new SaveContextVisitor(RubyFixnum.fix2int(options), rubyStringToString(indentString), encString, isHtmlDoc(context), isFragment(), 0);
accept(context, visitor);
final IRubyObject rubyString;
if (NokogiriHelpers.isUTF8(encString)) {
rubyString = convertString(context.runtime, visitor.getInternalBuffer());
} else {
ByteBuffer bytes = convertEncoding(Charset.forName(encString), visitor.getInternalBuffer());
ByteList str = new ByteList(bytes.array(), bytes.arrayOffset(), bytes.remaining());
rubyString = RubyString.newString(context.runtime, str);
}
Helpers.invoke(context, io, "write", rubyString);
return io;
}
Aggregations