@NotNull private static String toString(@NotNull OtpErlangObject quoted) { String string; if (quoted instanceof OtpErlangBoolean || quoted instanceof OtpErlangAtom || quoted instanceof OtpErlangByte || quoted instanceof OtpErlangChar || quoted instanceof OtpErlangFloat || quoted instanceof OtpErlangDouble || quoted instanceof OtpErlangExternalFun || quoted instanceof OtpErlangFun || quoted instanceof OtpErlangInt || quoted instanceof OtpErlangLong || quoted instanceof OtpErlangMap || quoted instanceof OtpErlangPid || quoted instanceof OtpErlangString) { string = quoted.toString(); } else if (quoted instanceof OtpErlangBitstr) { string = toString((OtpErlangBitstr) quoted); } else if (quoted instanceof OtpErlangList) { string = toString((OtpErlangList) quoted); } else if (quoted instanceof OtpErlangTuple) { string = toString((OtpErlangTuple) quoted); } else { throw new IllegalArgumentException("Don't know how to convert " + quoted.getClass() + " to string"); } return string; }
/** * Create an OtpErlangExit exception with the given reason. * * @param reason * the reason this exit signal has been sent. */ public OtpErlangExit(final OtpErlangObject reason) { super(reason.toString()); this.reason = reason; }
/** * Create an OtpErlangExit exception with the given reason and sender pid. * * @param reason * the reason this exit signal has been sent. * * @param pid * the pid that sent this exit. */ public OtpErlangExit(final OtpErlangObject reason, final OtpErlangPid pid) { super(reason.toString()); this.reason = reason; this.pid = pid; }
protected String toString(final int start) { final StringBuffer s = new StringBuffer(); s.append("["); for (int i = start; i < arity(); i++) { if (i > start) { s.append(","); } s.append(elems[i].toString()); } if (lastTail != null) { s.append("|").append(lastTail.toString()); } s.append("]"); return s.toString(); }
/** * Get the string representation of the tuple. * * @return the string representation of the tuple. */ @Override public String toString() { int i; final StringBuffer s = new StringBuffer(); final int arity = elems.length; s.append("{"); for (i = 0; i < arity; i++) { if (i > 0) { s.append(","); } s.append(elems[i].toString()); } s.append("}"); return s.toString(); }
/** * Get the string representation of the map. * * @return the string representation of the map. */ @Override public String toString() { final StringBuffer s = new StringBuffer(); s.append("#{"); boolean first = true; for (final Map.Entry<OtpErlangObject, OtpErlangObject> e : entrySet()) { if (first) { first = false; } else { s.append(","); } s.append(e.getKey().toString()); s.append(" => "); s.append(e.getValue().toString()); } s.append("}"); return s.toString(); }
public OtpErlangObject doInConnection(Connection connection) throws Exception { logger.debug("Sending RPC for module [" + module + "] function [" + function + "] args [" + args); connection.sendRPC(module, function, args); //TODO consider dedicated response object. OtpErlangObject response = connection.receiveRPC(); logger.debug("Response received = " + response.toString()); handleResponseError(module, function, response); return response; } });
public void handleResponseError(String module, String function, OtpErlangObject result) { //{badrpc,{'EXIT',{undef,[{rabbit_access_control,list_users,[[]]},{rpc,'-handle_call/3-fun-0-',5}]}}} if (result instanceof OtpErlangTuple) { OtpErlangTuple msg = (OtpErlangTuple)result; if (msg.elementAt(0) instanceof OtpErlangAtom) { OtpErlangAtom responseAtom = (OtpErlangAtom)msg.elementAt(0); //TODO consider error handler strategy. if (responseAtom.atomValue().equals("badrpc")) { if (msg.elementAt(1) instanceof OtpErlangTuple) { throw new ErlangBadRpcException( (OtpErlangTuple)msg.elementAt(1)); } else { throw new ErlangBadRpcException( msg.elementAt(1).toString()); } } else if (responseAtom.atomValue().equals("error")) { if (msg.elementAt(1) instanceof OtpErlangTuple) { throw new ErlangErrorRpcException( (OtpErlangTuple)msg.elementAt(1)); } else { throw new ErlangErrorRpcException( msg.elementAt(1).toString()); } } } } }
throw new InvalidTermToBinaryException("Unknown cell type encountered: " + cell.toString() + ", unable to continue parsing.");