Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangBinary


    }

    private String getValueString(final OtpErlangObject o, final boolean recordCheck)
            throws DebugException {
        if (o instanceof OtpErlangBinary) {
            final OtpErlangBinary b = (OtpErlangBinary) o;
            return getBinaryValueString(b);
        } else if (o instanceof OtpErlangTuple) {
            if (recordCheck) {
                final IErlRecordDef r = checkRecord(o);
                if (r != null) {
View Full Code Here


            return t.elementAt(index + ofs);
        } else if (value instanceof OtpErlangList) {
            final OtpErlangList l = (OtpErlangList) value;
            return l.elementAt(index);
        } else if (value instanceof OtpErlangBinary) {
            final OtpErlangBinary bs = (OtpErlangBinary) value;
            int j = bs.binaryValue()[index];
            if (j < 0) {
                j += 256;
            }
            return new OtpErlangLong(j);
        } else if (list != null) {
View Full Code Here

            return t.arity();
        } else if (value instanceof OtpErlangList) {
            final OtpErlangList l = (OtpErlangList) value;
            return l.arity();
        } else if (value instanceof OtpErlangBinary) {
            final OtpErlangBinary bs = (OtpErlangBinary) value;
            return bs.size();
        } else if (list != null) {
            return list.arity();
        } else {
            return -1;
        }
View Full Code Here

        final List<String> debuggerModules = getDebuggerModules();

        final List<OtpErlangTuple> modules = new ArrayList<OtpErlangTuple>(
                debuggerModules.size());
        for (final String module : debuggerModules) {
            final OtpErlangBinary b = getDebuggerBeam(module);
            if (b != null) {
                final OtpErlangString filename = new OtpErlangString(module + ".erl");
                final OtpErlangTuple t = OtpErlang.mkTuple(new OtpErlangAtom(module),
                        filename, b);
                modules.add(t);
View Full Code Here

    if (attributes.arity() != 0) throw new IllegalArgumentException("BinarySignature does not accept attributes");
  }
 
    @Override
  public OtpErlangObject instantiate() {
        return new OtpErlangBinary("<<\"wibble\">>");
    }
View Full Code Here

    byte[] testResult = mboxReference.sendArgs(testArg);
    assertEquals(testArg.length, testResult.length);
    for (int i = 0; i < testArg.length; i++) {
      assertEquals(testArg[i], testResult[i]);
    }
    OtpErlangBinary received = (OtpErlangBinary) mboxListener.getMsg();
    assertEquals(testArg.length, received.size());
    for (int i = 0; i < testArg.length; i++) {
      assertEquals(testArg[i], received.binaryValue()[i]);
    }
  }
View Full Code Here

* @version $Rev$ $Date$
*/
public class BinaryTypeHelper implements TypeHelper {

  public OtpErlangObject toErlang(Object object) {
    return new OtpErlangBinary((byte[])object);
  }
View Full Code Here

            } catch (final OtpErlangException e) {
                ErlLogger.error(e);
                return null;
            }
        } else if (o instanceof OtpErlangBinary) {
            final OtpErlangBinary b = (OtpErlangBinary) o;
            String result;
            result = decode(b.binaryValue(), Charsets.UTF_8);
            if (result == null) {
                result = decode(b.binaryValue(), Charsets.ISO_8859_1);
            }
            if (result == null) {
                ErlLogger.error("bad binary value in stringValue" + " (can't decode): "
                        + o);
            }
View Full Code Here

            }
            if (sb.length() < maxLength) {
                ioListToStringBuilder(l.getLastTail(), sb, maxLength);
            }
        } else if (o instanceof OtpErlangBinary) {
            final OtpErlangBinary b = (OtpErlangBinary) o;
            String s = decode(b.binaryValue(), Charsets.UTF_8);
            if (s == null) {
                s = new String(b.binaryValue(), Charsets.ISO_8859_1);
            }
            sb.append(s);
        } else if (o != null) {
            sb.append(o.toString());
        }
View Full Code Here

        if (obj != null && obj.getClass().isArray()) {
            final int len = Array.getLength(obj);
            // Class<?> component = obj.getClass().getComponentType();
            if (type.kind == 'b') {
                // TODO we can convert more things to binaries
                return new OtpErlangBinary(obj);
            }
            if (type.kind == 'l') {
                final OtpErlangObject[] vv = new OtpErlangObject[len];
                for (int i = 0; i < len; i++) {
                    vv[i] = java2erlang(Array.get(obj, i), type.content[0]);
                }
                return new OtpErlangList(vv);
            } else if (type.kind == 't') {
                final OtpErlangObject[] vv = new OtpErlangObject[len];
                for (int i = 0; i < len; i++) {
                    vv[i] = java2erlang(Array.get(obj, i), type.content[i]);
                }
                return new OtpErlangTuple(vv);
            } else {
                failConversion(obj, type);
            }
        }

        if (type.kind == 's' && obj != null) {
            return new OtpErlangString(obj.toString());
        }
        if (type.kind == 'b' && obj != null) {
            return new OtpErlangBinary(obj.toString().getBytes());
        }
        failConversion(obj, type);
        return null;
    }
View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpErlangBinary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.