<commit_before>/**!
 * hessian.js - lib/object.js
 * Copyright(c) 2014
 * MIT Licensed
 *
 * Authors:
 *   dead_horse <<EMAIL>> (http://deadhorse.me)
 *   fengmk2 <<EMAIL>> (http://fengmk2.github.com)
 */

'use strict';

var util = require('util');

exports.DEFAULT_CLASSNAME = {
  boolean: 'boolean',
  int: 'int',
  long: 'long',
  double: 'double',
  date: 'java.util.Date',
  string: 'java.lang.String',
  byteArray: '[B',
  list: 'java.util.ArrayList',
  map: 'java.util.HashMap',
  exception: 'java.lang.RuntimeException'
};

exports.Object = 'java.lang.Object';

var SERIALIZER_MAP = exports.SERIALIZER_MAP = {};

[
  'boolean',
  'java.lang.Boolean',
  'bool',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Bool';
});

[
  'double',
  'java.lang.Double',
  'float',
  'java.lang.Float',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Double';
});

[
  'java.lang.Long',
  'long',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Long';
});

[
  'short',
  'java.lang.Short',
  'int',
  'java.lang.Integer',
  'byte',
  'java.lang.Byte',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Int';
});

[
  'java.lang.String',
  'String',
  'string',
  'char',
  'char[]',
  'java.lang.Character',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'String';
});

[
  'java.util.Date'
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Date';
});

// http://www.devthought.com/2011/12/22/a-string-is-not-an-error/
function JavaExceptionError(obj) {
  Error.call(this);
  // Error.captureStackTrace(this, arguments.callee);

  // $: { detailMessage: 'this is a java IOException instance',
  // cause: [Circular],
  // stackTrace:
  //  [ { declaringClass: 'hessian.Main',
  //      methodName: 'main',
  //      fileName: 'Main.java',
  //      lineNumber: 1282 } ] }

  if (obj.$.undeclaredThrowable instanceof Error) {
    if (!obj.$.detailMessage) {
      return obj.$.undeclaredThrowable;
    }
    this.name = obj.$.undeclaredThrowable.name;
    this.message = obj.$.detailMessage + '; ' + obj.$.undeclaredThrowable.message;
  } else {
    this.message = obj.$.detailMessage;
    this.name = obj.$class;
  }

  var stack = this.name + ': ' + this.message;
  var stackTraces = obj.$.stackTrace || [];
  for (var i = 0; i < stackTraces.length; i++) {
    var trace = stackTraces[i];
    stack += '\n    at ' + trace.declaringClass + '.' + trace.methodName
      + ' (' + trace.fileName + ':' + trace.lineNumber + ')';
  }

  this.stack = stack;
}

util.inherits(JavaExceptionError, Error);

exports.JavaExceptionError = JavaExceptionError;<commit_msg>handle xxxx.HSFException<commit_after>/**!
 * hessian.js - lib/object.js
 * Copyright(c) 2014
 * MIT Licensed
 *
 * Authors:
 *   dead_horse <<EMAIL>> (http://deadhorse.me)
 *   fengmk2 <<EMAIL>> (http://fengmk2.github.com)
 */

'use strict';

var util = require('util');

exports.DEFAULT_CLASSNAME = {
  boolean: 'boolean',
  int: 'int',
  long: 'long',
  double: 'double',
  date: 'java.util.Date',
  string: 'java.lang.String',
  byteArray: '[B',
  list: 'java.util.ArrayList',
  map: 'java.util.HashMap',
  exception: 'java.lang.RuntimeException'
};

exports.Object = 'java.lang.Object';

var SERIALIZER_MAP = exports.SERIALIZER_MAP = {};

[
  'boolean',
  'java.lang.Boolean',
  'bool',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Bool';
});

[
  'double',
  'java.lang.Double',
  'float',
  'java.lang.Float',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Double';
});

[
  'java.lang.Long',
  'long',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Long';
});

[
  'short',
  'java.lang.Short',
  'int',
  'java.lang.Integer',
  'byte',
  'java.lang.Byte',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Int';
});

[
  'java.lang.String',
  'String',
  'string',
  'char',
  'char[]',
  'java.lang.Character',
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'String';
});

[
  'java.util.Date'
].forEach(function (t) {
  SERIALIZER_MAP[t] = 'Date';
});

// http://www.devthought.com/2011/12/22/a-string-is-not-an-error/
function JavaExceptionError(obj) {
  Error.call(this);
  // Error.captureStackTrace(this, arguments.callee);

  // $: { detailMessage: 'this is a java IOException instance',
  // cause: [Circular],
  // stackTrace:
  //  [ { declaringClass: 'hessian.Main',
  //      methodName: 'main',
  //      fileName: 'Main.java',
  //      lineNumber: 1282 } ] }

  if (obj.$.undeclaredThrowable instanceof Error) {
    if (!obj.$.detailMessage) {
      return obj.$.undeclaredThrowable;
    }
    this.name = obj.$.undeclaredThrowable.name;
    this.message = obj.$.detailMessage + '; ' + obj.$.undeclaredThrowable.message;
  } else if (!obj.$.detailMessage) {
  //   xxx.HSFException { '$class': 'xxxx.HSFException',
  // '$':
  //  { reasonAndSolution: '',
  //    hsfExceptionDesc: null,
  //    detailMessage: null,
  //    cause:
  //     { [xxxx.RemotingException:
    return obj.$.cause;
  } else {
    this.message = obj.$.detailMessage;
    if (obj.$.reasonAndSolution) {
      this.message += '; reasonAndSolution: ' + obj.$.reasonAndSolution;
    }
    this.name = obj.$class;
  }

  var stack = this.name + ': ' + this.message;
  var stackTraces = obj.$.stackTrace || [];
  for (var i = 0; i < stackTraces.length; i++) {
    var trace = stackTraces[i];
    stack += '\n    at ' + trace.declaringClass + '.' + trace.methodName
      + ' (' + trace.fileName + ':' + trace.lineNumber + ')';
  }

  this.stack = stack;
}

util.inherits(JavaExceptionError, Error);

exports.JavaExceptionError = JavaExceptionError;
{'fraction_non_alphanumeric': 0.19949035311248633, 'fraction_numerical': 0.00691663633054241, 'mean_word_length': 3.204284621270084, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7005924', 'n_tokens_mistral': 2111, 'n_tokens_neox': 2065, 'n_words': 346}