public org.mozilla.javascript.Scriptable generateJStype(final String textString,final boolean returnAsString){
  if (returnAsString) {
    return cx.newObject(scope,"String",new Object[]{textString});
  }
 else {
    if (textString != null && !textString.isEmpty() && StringUtils.isNumber(textString) && !(textString.length() == 1 && textString.indexOf('.') != -1)) {
      final Double retNum=Double.valueOf(textString);
      return cx.newObject(scope,"Number",new Object[]{retNum});
    }
 else {
      return cx.newObject(scope,"String",new Object[]{textString});
    }
  }
}

public org . mozilla . javascript . Scriptable generateJStype ( final String textString , final boolean returnAsString ) { if ( returnAsString ) { return cx . newObject ( scope , "String" , new Object [ ] { textString } ) ; } else { if ( textString != null && ! textString . isEmpty ( ) && StringUtils . isNumber ( textString ) && ! ( textString . length ( ) == 1 && textString . indexOf ( '.' ) != - 1 ) ) { final Double retNum = Double . valueOf ( textString ) ; return cx . newObject ( scope , "Number" , new Object [ ] { retNum } ) ; } else { return cx . newObject ( scope , "String" , new Object [ ] { textString } ) ; } } }
typetoreturn 0 = string , 1 = double , - 1 = guess
