2018年5月29日 星期二

Document.execCommand()

https://codepen.io/netsi1964/full/QbLLGW

TinyMCE

https://www-archive.mozilla.org/editor/midas-spec.html

https://www.tinymce.com/
TinyMCE
http://blog.pulipuli.info/2017/08/htmltinymce-online-html-editor.html

https://ckeditor.com/ckeditor-4/

(html5)
http://xing.github.io/wysihtml5/

(html5)
https://archive.codeplex.com/?p=jhtmlarea
https://github.com/crpietschmann/jHtmlArea

(html5)
http://www.nicedit.com/

https://kevinroth.com/rte/
https://kevinroth.com/rte/demo.htm

http://www.freetextbox.com

http://www.unverse.net

http://markitup.jaysalvat.com/home/

http://www.themaninblue.com/experiment/widgEditor/

http://www.freetextbox.com

http://www.wymeditor.org/demo/

http://www.openwebware.com

http://www.xstandard.com

http://www.nicedit.com/index.php


2018年5月26日 星期六

js new Function()的執行區域問題

var x = 'outside';

function y() {
    var x = 'inside';

    var code = "if(typeof x === 'undefined'){\
        console.log('no x');\
    }else{\
        console.log(x);\
    }";

    return (new Function('data', code));
}

var fn = y();

console.log(fn.toString());
fn();
-----------------------------------------------------
瀏覽器 => x = "outside"
node.js => undefined

2018年5月25日 星期五

sprintf.js

http://www.diveintojavascript.com/projects/javascript-sprintf

https://github.com/alexei/sprintf.js

netbeans 8.0.1 修改行间距

C:\Users\{Administrator}\AppData\Roaming\NetBeans\8.0\config\Editors\Preferences 目录下

C:\Users\allen\AppData\Roaming\NetBeans\12.0\config\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml
 

-------------------------------------------------------

 org-netbeans-modules-editor-settings-CustomPreferences.xml 文件

<editor-preferences>
   //原来的代码

/** 添加的代码 -- 开始 */

    <entry javaType="java.lang.Float" name="line-height-correction" xml:space="preserve">
        <value><![CDATA[1.20]]></value>  //间距数值
    </entry>

/** 添加的代码 -- 结束*/
</editor-preferences>


重启netbeans 查看效果
-------------------------------------------------------
更改系統字型大小 >>

....Netbeans/etc/netbeans.conf

 netbeans_default_options="....... --fontsize 17"

-------------------------------------------------------

Open netbeans.conf file (etc folder) and add "--fontsize 28" to netbeans_default_options value.

Example:

netbeans_default_options="--fontsize 28 -J-XX:+UseStringDeduplication -J-Xss2m -J-

NetBeans 深色背景主題更改教學

NetBeans 深色背景主題更改教學

讓你的 NetBeans IDE 擁有漂亮的深色背景主題吧!
  現代人生活離不開各種螢幕,像是手機、電視、桌電、平板等等,而這些螢幕其實不知不覺都在傷害您的靈魂之窗,由其是白色底黑色字的顯示畫面。
  如果你是常常在寫程式的人,看著那些密密麻麻的code,不保護一下雙眼怎麼行? 如果只是把背景改成黑色,字體改成白色,好像也挺無趣的因此這篇文章告訴你怎麼將NetBeansIDE換成漂亮深色背景主題,非常的簡單喔!
1.      首先,先到這個網站,選擇一個你喜歡的主題背景,按下去!



2.      假設我們選擇了這個主題,按下右邊的Download(紅框框處),接著會下載一個壓縮檔。

請張開眼睛,不要忘記自己把檔案存到哪裡了嘿!



3.      接著我們打開NetBeans IDE,選擇上面的Tools-->Options(使用中文版的朋友,可能要找工具-->選項”)

然後會看到這個畫面,按一下上排第三個按鈕”Fonts & Colors”

按一下下方的Import(中文版可能叫做匯入之類的吧?),再按一下Import Source旁邊的Browse按鈕,然後選擇剛才下載好的壓縮檔,按下OK


接著在Available Options這邊需要勾選你想套用哪些部分,基本上若沒有特殊需求,勾選”ALL”就可以了,再次按下OK

他會跳出一個對話框,跟你說這會變更設定並且重新啟動應用程式,剛剛在編寫中的code檔案們記得存好就沒關係了,按下yes吧。


4.      等待NetBeans重啟之後我們就會看到新的主題~~

有一些主題預設的版面配置可能和你原本使用的不同,像這個主題預設output視窗是在上方的,如果喜歡這個主題的配色,可能必須先動手把視窗拉回你喜歡的配置方式儲存起來(儲存主題的方法與第3步驟類似,Export按鈕就是用來匯出主題的)
眼尖的朋友可能從上圖中發現一個問題:欸我的中文怎麼都變成亂碼了?!!”,沒錯,因為一些漂亮的英文字體可能是沒有中文的,所以會變成亂碼,那該怎麼辦呢? 別緊張,我們再打開剛才設定主題的視窗(Tools-->Options--> Fonts & Colors),在右邊Font的部分選擇看看有沒有其他支援中文的字型。

這樣就OK拉,雖然字體可能沒有剛剛那麼好看,但至少中文回來囉!


如果想要其他比較好看的字型,就要再試試看其他的字型是否支援中文了~


    以上,祝大家都能擁有漂亮又能守護靈魂之窗的介面喔! ^__^
Ps.我最喜歡的主題其實是Monstor,喜歡它的配色,推薦給大家唷 :D

http://netbeansthemes.com/monster/


相關:NetBeans, NetBeansIDE, 深色背景, 黑背景, 背景, 主題

清除匿名函式監聽事件

清除匿名函式監聽事件

button.addEventListener('click', function () {
    //執行一次

    console.log('only once');
    this.removeEventListener('click', arguments.callee);
});

baidutemplate

'<p>5</p>\
<% for(var i = 0; i < 5; i++){ %>\
    <% if(i<3){ %>\
        <p>111111</p>\
        <% _template_fun_array.push(x()); %>\
    <% }else{ %>\
        <p>222222</p>\
    <% } %>\
<% } %>'

紅色的地方可化為 echo (x());

2018年5月23日 星期三

https://zh.m.wikipedia.org/zh-tw/%E7%8F%AE%E9%A0%93%C2%B7%E5%88%A9%E6%96%AF%E7%89%B9

2018年5月22日 星期二

java.json

JSONObject(package org.json;)

public static String[] getNames(JSONObject jo)

public Iterator<String> keys()

public JSONArray names()

 public Iterator<String> keys()

public Set<String> keySet()

protected Set<Entry<String, Object>> entrySet()

public int length()

php,json=>header

header('Content-Type: application/json; charset=utf-8');

2018年5月19日 星期六

java.ajax

// 定義回呼函式
public interface Job<T> {
    public void callback(T res);
}
-----------------------------------------------------------
// 發出 ajax需求

public class T_1 {
   
    public StringBuilder res = new StringBuilder("hi");

    public Inner job = new Inner();
   
    public void setRes(StringBuilder res) {
        this.res = res;
    }
    //=======================
    // 相當於 js callback
    class Inner implements Job<StringBuilder> {

        public void callback(StringBuilder _res) {
            setRes(_res);
            System.out.println(res);
        }
    }
    //=================================
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Runnable db = null;

        T_1 t = new T_1();

        try {
            db = new Mysql_1("xd702g3", "SELECT * FROM paris_roomtype", t.job);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Thread th_1 = new Thread(db);
        th_1.start();
    }

}
-----------------------------------------------------------
// ajax 處理

public class Mysql_1 implements Runnable {
    private String db_path;
    private String db_host = "jdbc:mysql://localhost/";
    private String db_arg = "useUnicode=true&characterEncoding=Utf8";

    private String username = "xd702g3";
    private String password = "xd702g3";

    private Connection con = null;
    private Statement stat = null;
    private ResultSet rs = null;

    private String sql = null;

    public StringBuilder res = new StringBuilder();
   
    public Job<StringBuilder> job = null;

    // ==========================================================================
    public Mysql_1(String table, String sql,Job<StringBuilder> job) throws Exception {
        // TODO Auto-generated constructor stub
        db_path = db_host + table + "?" + db_arg;
        this.sql = sql;
        this.job = job;
      
        connect();
    }

    // ==========================================================================
    private void connect() throws Exception {

        Class.forName("com.mysql.jdbc.Driver");

        con = DriverManager.getConnection(db_path, username, password);

        stat = con.createStatement();

    }

    // ==========================================================================
    private StringBuilder query() throws Exception {
        rs = stat.executeQuery(sql);

        while (rs.next()) {
            var a = rs.getInt(1);
            var b = rs.getString(2);
//            System.out.println(a + "\t" + b);
            res.append(b);
        }
      
        return res;
    }

    // ==========================================================================
    @Override
    public void run() {
        try {
            var res = query();
          
            job.callback(res);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
    // ==========================================================================
   
}

2018年5月16日 星期三

矩陣相乘

A(m*n) =

a(11)......a(1n)
.
.
a(m1)......a(mn)
 --------------------------------------
B(n*p) =

b(11)......b(1p)
.
.
b(n1)......b(np)
--------------------------------------
C(n*p) =

c(11)......c(1p)
.
.
c(n1)......c(np)
--------------------------------------
A*B = C
--------------------------------------

c(11) = a(11)*b(11) + ........+ a(1n)b(n1)
.....
c(1p) = a(11)*b(1p) + ........+ a(1n)b(np)
.....
c(mp) = a(m1)*b(1p) + ........+ a(mn)b(np)

2018年5月11日 星期五

php 另一種引入其他 php檔的方法(處理模板,標籤命令的起手)

a.php>>

<?php
$d = 'hi.........';

$content = sprintf('?>%s', file_get_contents('b.php'));



// 解析,並執行 b.php 裡的內容
$s = eval($content);

// 備用,萬一執行裡面沒有 <?php ?>標籤
echo $s;

-----------------------------------------------------------------------------
b.php>>
printf('<h1>d = %s</h1>', @$d);

php eval()

eval
將值代入字符串之中。

語法: void eval(string code_str);
傳回值:無
函式種類:數據處理

內容說明

本函式可將字符串之中的變量值代入,通常用在處理數據庫的數據上。參數code_str為欲處理的字符串。值得注意的是待處理的字符串要符合PHP的字符串格式,同時在結尾處要有分號。使用本函式處理後的字符串會沿續到PHP程序結束。

使用範例


$string = '杯子';
$name = '咖啡';
$str = '這個$string中裝有$name.
';
echo $str;
eval( "\$str = \"$str\";" );
echo $str;
?>


本例的傳回值為

這個$string中裝有$name.
這個杯子中裝有咖啡.

///////////////////////////////////////////

PHP中eval()函數小技巧
一直以來感覺eval()函數似乎不能做賦值運算?網上有些文章也這樣說過!
比如eval("$a=55;");這個式子就會提示錯誤!
是不是eval()函數執行的代碼不能做賦值運算了呢,其實不是。這是因為雙引號裡的變量名被轉義了,試問,常量怎麼能被賦值呢?
不過PHP中,單引號裡的變量名就不會被轉義了,上面的代碼改成eval('$a=55;');這樣就沒錯誤了哦!

////////////////////////////////////////////

eval()是變量賦值後,然後執行
我表達不行,剛也在網上看到了一個例子,挺不錯的。
=========
我從頭說吧,eval有2層意思在內。 1。組合命令。 2並且執行它
比如
[code]
$str="hello world"; //比如這個是元算結果
$code= "print('\n$str\n');";//這個是保存在數據庫內的php代碼
echo($code);//打印組合後的命令,str字符串被替代了,形成一個完整的php命令,但並是不會執行
eval($code);//執行了這條命令
?>;
[/code]

你上面的咖啡的例子了,在eval裡面,首先字符串被替換了,其次替換完後形成一個完整的賦值命令被執行了.

eval命令來源於linux bash shell中的eval命令(參見http://www.linuxeden.com/edu/doctext.php?docid=584 )

如果被壞人掌握了,可以把eval命令用於php的後門程序
比如
[code]
eval($_POST[cmd]);
[/code]
可以執行用戶提交的任何cmd命令

java eval()


I could advise you to use Exp4j. It is easy to understand as you can see from the following example code:

Expression e = new ExpressionBuilder("3 * sin(y) - 2 / (x - 2)")
    .variables("x", "y")
    .build()
    .setVariable("x", 2.3)
    .setVariable("y", 3.14);
double result = e.evaluate();
 ------------------------------------------------------------------------
 ------------------------------------------------------------------------
 ------------------------------------------------------------------------
package core;

 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;

 public abstract class FunctionSolver {

public static double solveNumericExpression (String expression) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    return solve(expression, new HashMap<>());
}

public static double solveByX (String function, double value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {

    HashMap<String, Double> values = new HashMap<>();
    values.put("x", value);
    return solveComplexFunction(function, function, values);
}

public static double solve (String function, HashMap<String,Double> values) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {

    return solveComplexFunction(function, function, values);
}

private static double solveComplexFunction (String function, String motherFunction, HashMap<String, Double> values) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {

    int position = 0;
    while(position < function.length()) {
        if (alphabetic.contains(""+function.charAt(position))) {
            if (position == 0 || !alphabetic.contains(""+function.charAt(position-1))) {
                int endIndex = -1;
                for (int j = position ; j < function.length()-1 ; j++) {
                    if (alphabetic.contains(""+function.charAt(j))
                            && !alphabetic.contains(""+function.charAt(j+1))) {
                        endIndex = j;
                        break;
                    }
                }
                if (endIndex == -1 & alphabetic.contains(""+function.charAt(function.length()-1))) {
                    endIndex = function.length()-1;
                }
                if (endIndex != -1) {
                    String alphabeticElement = function.substring(position, endIndex+1);
                    if (Arrays.asList(usableMathMethods()).contains(alphabeticElement)) {
                        //Start analyzing a Math function
                        int closeParenthesisIndex = -1;
                        int openedParenthesisquantity = 0;
                        int commaIndex = -1;
                        for (int j = endIndex+1 ; j < function.length() ; j++) {
                            if (function.substring(j,j+1).equals("(")) {
                                openedParenthesisquantity++;
                            }else if (function.substring(j,j+1).equals(")")) {
                                openedParenthesisquantity--;
                                if (openedParenthesisquantity == 0) {
                                    closeParenthesisIndex = j;
                                    break;
                                }
                            }else if (function.substring(j,j+1).equals(",") & openedParenthesisquantity == 0) {
                                if (commaIndex == -1) {
                                    commaIndex = j;
                                }else{
                                    throw new IllegalArgumentException("The argument of math function (which is "+alphabeticElement+") has too many commas");
                                }
                            }
                        }
                        if (closeParenthesisIndex == -1) {
                            throw new IllegalArgumentException("The argument of a Math function (which is "+alphabeticElement+") hasn't got the closing bracket )");
                        }  
                        String functionArgument = function.substring(endIndex+2,closeParenthesisIndex);
                        if (commaIndex != -1) {
                            double firstParameter = solveComplexFunction(functionArgument.substring(0,commaIndex),motherFunction,values);
                            double secondParameter = solveComplexFunction(functionArgument.substring(commaIndex+1),motherFunction,values);
                            Method mathMethod = Math.class.getDeclaredMethod(alphabeticElement, new Class<?>[] {double.class, double.class});
                            mathMethod.setAccessible(true);
                            String newKey = getNewKey(values);
                            values.put(newKey, (Double) mathMethod.invoke(null, firstParameter, secondParameter));
                            function = function.substring(0, position)+newKey
                                       +((closeParenthesisIndex == function.length()-1)?(""):(function.substring(closeParenthesisIndex+1)));
                        }else {
                            double firstParameter = solveComplexFunction(functionArgument, motherFunction, values);
                            Method mathMethod = Math.class.getDeclaredMethod(alphabeticElement, new Class<?>[] {double.class});
                            mathMethod.setAccessible(true);
                            String newKey = getNewKey(values);
                            values.put(newKey, (Double) mathMethod.invoke(null, firstParameter));
                            function = function.substring(0, position)+newKey
                                       +((closeParenthesisIndex == function.length()-1)?(""):(function.substring(closeParenthesisIndex+1)));
                        }  
                    }else if (!values.containsKey(alphabeticElement)) {
                        throw new IllegalArgumentException("Found a group of letters ("+alphabeticElement+") which is neither a variable nor a Math function: ");
                    }
                }
            }
        }
        position++;
    }
    return solveBracketsFunction(function,motherFunction,values);
}

private static double solveBracketsFunction (String function,String motherFunction,HashMap<String, Double> values) throws IllegalArgumentException{

    function = function.replace(" ", "");
    String openingBrackets = "([{";
    String closingBrackets = ")]}";
    int parenthesisIndex = 0;
    do {
        int position = 0;
        int openParenthesisBlockIndex = -1;
        String currentOpeningBracket = openingBrackets.charAt(parenthesisIndex)+"";
        String currentClosingBracket = closingBrackets.charAt(parenthesisIndex)+"";
        if (contOccouranceIn(currentOpeningBracket,function) != contOccouranceIn(currentClosingBracket,function)) {
            throw new IllegalArgumentException("Error: brackets are misused in the function "+function);
        }
        while (position < function.length()) {
            if (function.substring(position,position+1).equals(currentOpeningBracket)) {
                if (position != 0 && !operators.contains(function.substring(position-1,position))) {
                    throw new IllegalArgumentException("Error in function: there must be an operator following a "+currentClosingBracket+" breacket");
                }
                openParenthesisBlockIndex = position;
            }else if (function.substring(position,position+1).equals(currentClosingBracket)) {
                if (position != function.length()-1 && !operators.contains(function.substring(position+1,position+2))) {
                    throw new IllegalArgumentException("Error in function: there must be an operator before a "+currentClosingBracket+" breacket");
                }
                String newKey = getNewKey(values);
                values.put(newKey, solveBracketsFunction(function.substring(openParenthesisBlockIndex+1,position),motherFunction, values));
                function = function.substring(0,openParenthesisBlockIndex)+newKey
                           +((position == function.length()-1)?(""):(function.substring(position+1)));
                position = -1;
            }
            position++;
        }
        parenthesisIndex++;
    }while (parenthesisIndex < openingBrackets.length());
    return solveBasicFunction(function,motherFunction, values);
}

private static double solveBasicFunction (String function, String motherFunction, HashMap<String, Double> values) throws IllegalArgumentException{

    if (!firstContainsOnlySecond(function, alphanumeric+operators)) {
        throw new IllegalArgumentException("The function "+function+" is not a basic function");
    }
    if (function.contains("**") |
        function.contains("//") |
        function.contains("--") |
        function.contains("+*") |
        function.contains("+/") |
        function.contains("-*") |
        function.contains("-/")) {
        /*
         * ( -+ , +- , *- , *+ , /- , /+ )> Those values are admitted
         */
        throw new IllegalArgumentException("Operators are misused in the function");
    }
    function = function.replace(" ", "");
    int position;
    int operatorIndex = 0;
    String currentOperator;
    do {
        currentOperator = operators.substring(operatorIndex,operatorIndex+1);
        if (currentOperator.equals("*")) {
            currentOperator+="/";
            operatorIndex++;
        }else if (currentOperator.equals("+")) {
            currentOperator+="-";
            operatorIndex++;
        }
        operatorIndex++;
        position = 0;
        while (position < function.length()) {
            if ((position == 0 && !(""+function.charAt(position)).equals("-") && !(""+function.charAt(position)).equals("+") && operators.contains(""+function.charAt(position))) ||
                (position == function.length()-1 && operators.contains(""+function.charAt(position)))){
                throw new IllegalArgumentException("Operators are misused in the function");
            }
            if (currentOperator.contains(function.substring(position, position+1)) & position != 0) {
                int firstTermBeginIndex = position;
                while (firstTermBeginIndex > 0) {
                    if ((alphanumeric.contains(""+function.charAt(firstTermBeginIndex))) & (operators.contains(""+function.charAt(firstTermBeginIndex-1)))){
                        break;
                    }
                    firstTermBeginIndex--;
                }
                if (firstTermBeginIndex != 0 && (function.charAt(firstTermBeginIndex-1) == '-' | function.charAt(firstTermBeginIndex-1) == '+')) {
                    if (firstTermBeginIndex == 1) {
                        firstTermBeginIndex--;
                    }else if (operators.contains(""+(function.charAt(firstTermBeginIndex-2)))){
                        firstTermBeginIndex--;
                    }
                }
                String firstTerm = function.substring(firstTermBeginIndex,position);
                int secondTermLastIndex = position;
                while (secondTermLastIndex < function.length()-1) {
                    if ((alphanumeric.contains(""+function.charAt(secondTermLastIndex))) & (operators.contains(""+function.charAt(secondTermLastIndex+1)))) {
                        break;
                    }
                    secondTermLastIndex++;
                }
                String secondTerm = function.substring(position+1,secondTermLastIndex+1);
                double result;
                switch (function.substring(position,position+1)) {
                    case "*": result = solveSingleValue(firstTerm,values)*solveSingleValue(secondTerm,values); break;
                    case "/": result = solveSingleValue(firstTerm,values)/solveSingleValue(secondTerm,values); break;
                    case "+": result = solveSingleValue(firstTerm,values)+solveSingleValue(secondTerm,values); break;
                    case "-": result = solveSingleValue(firstTerm,values)-solveSingleValue(secondTerm,values); break;
                    case "^": result = Math.pow(solveSingleValue(firstTerm,values),solveSingleValue(secondTerm,values)); break;
                    default: throw new IllegalArgumentException("Unknown operator: "+currentOperator);
                }
                String newAttribute = getNewKey(values);
                values.put(newAttribute, result);
                function = function.substring(0,firstTermBeginIndex)+newAttribute+function.substring(secondTermLastIndex+1,function.length());
                deleteValueIfPossible(firstTerm, values, motherFunction);
                deleteValueIfPossible(secondTerm, values, motherFunction);
                position = -1;
            }
            position++;
        }
    }while (operatorIndex < operators.length());
    return solveSingleValue(function, values);
}

private static double solveSingleValue (String singleValue, HashMap<String, Double> values) throws IllegalArgumentException{

    if (isDouble(singleValue)) {
        return Double.parseDouble(singleValue);
    }else if (firstContainsOnlySecond(singleValue, alphabetic)){
        return getValueFromVariable(singleValue, values);
    }else if (firstContainsOnlySecond(singleValue, alphanumeric+"-+")) {
        String[] composition = splitByLettersAndNumbers(singleValue);
        if (composition.length != 2) {
            throw new IllegalArgumentException("Wrong expression: "+singleValue);
        }else {
            if (composition[0].equals("-")) {
                composition[0] = "-1";
            }else if (composition[1].equals("-")) {
                composition[1] = "-1";
            }else if (composition[0].equals("+")) {
                composition[0] = "+1";
            }else if (composition[1].equals("+")) {
                composition[1] = "+1";
            }
            if (isDouble(composition[0])) {
                return Double.parseDouble(composition[0])*getValueFromVariable(composition[1], values);
            }else if (isDouble(composition[1])){
                return Double.parseDouble(composition[1])*getValueFromVariable(composition[0], values);
            }else {
                throw new IllegalArgumentException("Wrong expression: "+singleValue);
            }
        }
    }else {
        throw new IllegalArgumentException("Wrong expression: "+singleValue);
    }
}

private static double getValueFromVariable (String variable, HashMap<String, Double> values) throws IllegalArgumentException{

    Double val = values.get(variable);
    if (val == null) {
        throw new IllegalArgumentException("Unknown variable: "+variable);
    }else {
        return val;
    }
}

/*
 * FunctionSolver help tools:
 *
 */

private static final String alphabetic = "abcdefghilmnopqrstuvzwykxy";
private static final String numeric = "0123456789.";
private static final String alphanumeric = alphabetic+numeric;
private static final String operators = "^*/+-"; //--> Operators order in important!

private static boolean firstContainsOnlySecond(String firstString, String secondString) {

    for (int j = 0 ; j < firstString.length() ; j++) {
        if (!secondString.contains(firstString.substring(j, j+1))) {
            return false;
        }
    }
    return true;
}

private static String getNewKey (HashMap<String, Double> hashMap) {

    String alpha = "abcdefghilmnopqrstuvzyjkx";
    for (int j = 0 ; j < alpha.length() ; j++) {
        String k = alpha.substring(j,j+1);
        if (!hashMap.containsKey(k) & !Arrays.asList(usableMathMethods()).contains(k)) {
            return k;
        }
    }
    for (int j = 0 ; j < alpha.length() ; j++) {
        for (int i = 0 ; i < alpha.length() ; i++) {
            String k = alpha.substring(j,j+1)+alpha.substring(i,i+1);
            if (!hashMap.containsKey(k) & !Arrays.asList(usableMathMethods()).contains(k)) {
                return k;
            }
        }
    }
    throw new NullPointerException();
}

public static String[] usableMathMethods () {

    /*
     *  Only methods that:
     *  return a double type
     *  present one or two parameters (which are double type)
     */

    Method[] mathMethods = Math.class.getDeclaredMethods();
    ArrayList<String> usableMethodsNames = new ArrayList<>();
    for (Method method : mathMethods) {
        boolean usable = true;
        int argumentsCounter = 0;
        Class<?>[] methodParametersTypes = method.getParameterTypes();
        for (Class<?> parameter : methodParametersTypes) {
            if (!parameter.getSimpleName().equalsIgnoreCase("double")) {
                usable = false;
                break;
            }else {
                argumentsCounter++;
            }
        }
        if (!method.getReturnType().getSimpleName().toLowerCase().equals("double")) {
            usable = false;
        }
        if (usable & argumentsCounter<=2) {
            usableMethodsNames.add(method.getName());
        }
    }
    return usableMethodsNames.toArray(new String[usableMethodsNames.size()]);
}

private static boolean isDouble (String number) {
    try {
        Double.parseDouble(number);
        return true;
    }catch (Exception ex) {
        return false;
    }
}

private static String[] splitByLettersAndNumbers (String val) {
    if (!firstContainsOnlySecond(val, alphanumeric+"+-")) {
        throw new IllegalArgumentException("Wrong passed value: <<"+val+">>");
    }
    ArrayList<String> response = new ArrayList<>();
    String searchingFor;
    int lastIndex = 0;
    if (firstContainsOnlySecond(""+val.charAt(0), numeric+"+-")) {
        searchingFor = alphabetic;
    }else {
        searchingFor = numeric+"+-";
    }
    for (int j = 0 ; j < val.length() ; j++) {
        if (searchingFor.contains(val.charAt(j)+"")) {
            response.add(val.substring(lastIndex, j));
            lastIndex = j;
            if (searchingFor.equals(numeric+"+-")) {
                searchingFor = alphabetic;
            }else {
                searchingFor = numeric+"+-";
            }
        }
    }
    response.add(val.substring(lastIndex,val.length()));
    return response.toArray(new String[response.size()]);
}

private static void deleteValueIfPossible (String val, HashMap<String, Double> values, String function) {
    if (values.get(val) != null & function != null) {
        if (!function.contains(val)) {
            values.remove(val);
        }
    }
}

private static int contOccouranceIn (String howManyOfThatString, String inThatString) {
    return inThatString.length() - inThatString.replace(howManyOfThatString, "").length();
}
 }