Examples of JAsciiMath


Examples of fi.celia.asciimath.JAsciiMath

      // to be sure, that browser execution will be successfulll:
      // " xxx " / " sddd " => will be changed into  (" xxx ") / (" sddd ")
      // " xxx " => (" xxx ") etc
      boolean bAddBrowserStrikes = true;
      // create asciimath variable
        JAsciiMath jAsciiMath = new JAsciiMath(jasciiMathPropertyFileName,
            bCheckStrikeErrors, p_bCorrectStrikeErrors, bAddBrowserStrikes);
 
      //CollectAsciiMathBlocks asciimathBlocks = new CollectAsciiMathBlocks(jAsciiMath);
      // dtbook = acutual input file
      File file = new File(dtbookFileName);
     
      String inputText = readFileData(file, charsetName);
     
      // skip possible error data of beginning of the input file (binary characters), like: ?>>
      int ind = inputText.indexOf("<?xml");
      if (ind > -1) // fix a possible bug: <?xml ....
        inputText = inputText.substring(ind);
     
      // tell which is input data
      m_strDtbookData = inputText;
      jAsciiMath.setInputData(inputText);
      jAsciiMath.replaceAsciiMathBlocks();
        // create collector of asciimath data blocks (calculus etc)
        CollectAsciiMathBlocks pamb = new CollectAsciiMathBlocks(jAsciiMath,
                                bCheckStrikeErrors,
                                p_bCorrectStrikeErrors);   
        //pamb.printAllAsciiMathBloks sb.toString();

        try {
          // collect asciimath data with the collector
          //AsciiMathBlockValue [] arrAMBlock = pamb.getAllAsciiMathBlocks();
          AsciiMathBlockValue [] arrAMBlock = jAsciiMath.getArrayOfAsciiMathBlocks();
          if (arrAMBlock == null)
            throw new DtbookAsciiMathException("Not founded any asciimath-blocks!");

          String inputAsciiMathText;
         
View Full Code Here

Examples of fi.celia.asciimath.JAsciiMath

       m.appendTail(sb);
       System.out.println(sb.toString());
       */
      boolean bCorrectStrikeErrors = false;
      boolean bCheckStrikeErrors = true;
      JAsciiMath jAsciiMath = new JAsciiMath("dtbookasciimath.properties",
          bCheckStrikeErrors, bCorrectStrikeErrors, false);
      jAsciiMath.setConvertHtmlChars(false);
     
      /*
           if (strModifiedMathData == null || markValue == null | start < 0 || end < 0)
      return -1; // = false
   
    int len = strModifiedMathData.length();
    if (len < 1)
      return -1; // = false

    if (start > len)
      return -1; // = false
    if (end > len)
      return -1; // = false

    int markLength = markValue.length();   
    int indStartMark = start - markLength;
    if (indStartMark < 0)
      indStartMark = 0;
    int indEndMark = end + markLength;
    if (indEndMark > len)
      indEndMark = len;
    String strPossibleMarkValue = strModifiedMathData.substring(indStartMark, indEndMark);
    if (strPossibleMarkValue == null || strPossibleMarkValue.trim().length() == 0)
      return -1;
    int indFoundMarkValue = strPossibleMarkValue.indexOf(markValue);
    if (indFoundMarkValue == -1)
      return -1;
   
    return (start +indFoundMarkValue);

       "x_JAsciiMath_DontModifyconst__begin";
       */
      /* String strModifiedMathData, String markValue, int start, int end */
      String strToken = null;
      String strModifiedMathData = "" +JAsciiMath.cnstDontModifyBegin;
      String markValue = "__";
      int start = strModifiedMathData.indexOf(JAsciiMath.cnstDontModifyBegin);
      int end = start + JAsciiMath.cnstDontModifyBegin.length();
      int ret = jAsciiMath.getMarkValueIndexNearOfFoundToken(strModifiedMathData,
                                  markValue,  start, end);
      if (ret != strModifiedMathData.indexOf(markValue))
      {
        System.err.println("Testi ajo 7 ei ok!!");
      }       
      else
        System.out.println("Testi ajo ok 7.");

      strModifiedMathData = "dffks kdfsdk_" +JAsciiMath.cnstDontModifyBegin;
      markValue = JAsciiMath.cnstDontModifyBegin;
      strToken = "_x_";
      start = strModifiedMathData.indexOf(JAsciiMath.cnstDontModifyBegin);
      end = start + JAsciiMath.cnstDontModifyBegin.length();
      ret = jAsciiMath.getMarkValueIndexNearOfFoundToken(strModifiedMathData,
                                  markValue,  start, end);
      if (ret != strModifiedMathData.indexOf(markValue))
      {
        System.err.println("Testi ajo 8 ei ok!!");
      }       
      else
        System.out.println("Testi ajo ok 8.");
     
      /*
       String markValue,
      String strToken, String strModifiedMathData, int start, int end
       */
      boolean retBoolean = jAsciiMath.getPossibleModificationOfMarkWord(markValue, 
          strToken, strModifiedMathData, start, end);
      if (!retBoolean)
      {
        System.err.println("Testi ajo 9 ei ok!!");
      }       
      else
        System.out.println("Testi ajo ok 9.");
     
      boolean success = true;
      String strInputData = "<span class=\"asciimath2\">dataa</span>";
      jAsciiMath.setInputData(strInputData);
      boolean bConvertAsciiMathDataWithSpaceRules = true;
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(bConvertAsciiMathDataWithSpaceRules);
      jAsciiMath.replaceAsciiMathBlocks();
      String srtOutPut = jAsciiMath.getOutputData();
      if (srtOutPut != null && !jAsciiMath.getOutputData().equals(strInputData))
      {
        success = false;
        System.err.println("Testi ajo 0 ei ok!!");
      }       
      else
        System.out.println("Testi ajo ok 0.");
   
      strInputData = "<span class=\"asciimath\">`dataa �`</span>";
      jAsciiMath.setInputData(strInputData);
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(bConvertAsciiMathDataWithSpaceRules);
      jAsciiMath.replaceAsciiMathBlocks();
      if (!jAsciiMath.getOutputData().equals(strInputData))
      {
        success = false;
        System.err.println("Testi ajo 1 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("      output='" +jAsciiMath.getOutputData()+"'");
      }
      else
        System.out.println("Testi ajo ok 1.");

      System.out.flush();
      System.out.println("");
     
      strInputData =
      "<span class=\"asciimath\">`dataa �`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      jAsciiMath.setInputData(strInputData);
     
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(bConvertAsciiMathDataWithSpaceRules);
      jAsciiMath.replaceAsciiMathBlocks();
      if (!jAsciiMath.getOutputData().equals(strInputData))
      {
        success = false;
        System.err.println("Testi ajo 2 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("      output='" +jAsciiMath.getOutputData()+"'");
      }
      else
        System.out.println("Testi ajo ok 2.");

      System.out.flush();
      System.out.println("");
     
      String strInputDataAsciiMath = "|>|>|>|<|<|<=|<=|>=|>=|sin|cos|tan|cot|sec|int|int_|ln|test_substring()|test_substring|";
      strInputData = "<span class=\"asciimath\">`"
        + JAsciiMath.getChangeNormalCharactersIntoLTAndGTHtmlCharacters(strInputDataAsciiMath)
        + "`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      String alkup_input = "<span class=\"asciimath\">"
        + JAsciiMath.getChangeLTAndGTHtmlCharactersIntoNormalCharacters(JAsciiMath.getChangeNormalCharactersIntoLTAndGTHtmlCharacters(strInputDataAsciiMath))
        + "</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";

      jAsciiMath.setInputData(strInputData);     
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(bConvertAsciiMathDataWithSpaceRules);
      jAsciiMath.replaceAsciiMathBlocks();
      String strCompare = "<span class=\"asciimath\">`| > | > | > | < | < | <= | <= | >= | >= | sin | cos | tan | cot | sec | int |int_| ln | test_substring() |test_substring|`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";     
      if (!jAsciiMath.getOutputData().equals(strCompare))
      {
        success = false;
        System.err.println("Testi ajo 3 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("  strCompare='" +strCompare+"'");
        System.err.println("      output='" +jAsciiMath.getOutputData()+"'");
      }
      else
      {
        System.out.println("Testi ajo ok 3.");
        System.out.println("strInputData   ='" +strInputData+"'");
        System.out.println("looginen syöttö='" +alkup_input+"'");       
        System.out.println("  strCompare   ='" +strCompare+"'");
        System.out.println("      output   ='" +jAsciiMath.getOutputData()+"'");       
      }

      System.out.flush();
      System.out.println("");

      strInputData =
        "<span class=\"asciimath\">`|)|(|>|-|+|=|!=|~~|*|(|test_substring| # |`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      jAsciiMath.setInputData(strInputData);
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(bConvertAsciiMathDataWithSpaceRules);
      jAsciiMath.replaceAsciiMathBlocks();
      strCompare = "<span class=\"asciimath\">`| )|( | > | -| +| =| !=| ~~| *|( |test_substring|#|`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      if (!jAsciiMath.getOutputData().equals(strCompare))
      {
        success = false;
        System.err.println("Testi ajo 4 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("  strCompare='" +strCompare+"'");
        System.err.println("      output='" +jAsciiMath.getOutputData()+"'");
      }
      else
      {
        System.out.println("Testi ajo ok 4.");
        System.out.println("strInputData='" +strInputData+"'");
        System.out.println("  strCompare='" +strCompare+"'");
        System.out.println("      output='" +jAsciiMath.getOutputData()+"'");
      }   

      System.out.flush();
      System.out.println("");

      strInputData =
        "<span class=\"asciimath\">`test_substring| .202 |1.222/1..222 1999. 123.22 1000`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      jAsciiMath.setInputData(strInputData);
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(false);
      jAsciiMath.setConvertAsciiMathDataCommaRule(true);
      jAsciiMath.replaceAsciiMathBlocks();
      strCompare = "<span class=\"asciimath\">`test_substring| .202 |1,222/1..222 1999. 123,22 1000`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      if (!jAsciiMath.getOutputData().equals(strCompare))
      {
        success = false;
        System.err.println("Testi ajo 5 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("  strCompare='" +strCompare+"'");
        System.err.println("      output='" +jAsciiMath.getOutputData()+"'");
      }
      else
      {
        System.out.println("Testi ajo ok 5.");
        System.out.println("strInputData='" +strInputData+"'");
        System.out.println("  strCompare='" +strCompare+"'");
        System.out.println("      output='" +jAsciiMath.getOutputData()+"'");
      }

      System.out.flush();
      System.out.println("");

      strInputData =
        "<span class=\"asciimath\">`test_substring| Iraq 11 > Ira>q 12 ,2 0,22 1222,2 11111 1.222,2 333.1222,2 444.1222,2 111111 32.22.222.22.222222.2,0 > Irqa Qrai IraQ`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      jAsciiMath.setInputData(strInputData);
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(false);
      jAsciiMath.setConvertAsciiMathDataCommaRule(false);
      jAsciiMath.setConvertAsciiMathDataThousndNumberRule(true);
      jAsciiMath.replaceAsciiMathBlocks();
      strCompare = "<span class=\"asciimath\">`test_substring| Iraq 11 > Ira>q 12 ,2 0,22 1.222,2 11.111 1.222,2 3.331.222,2 4.441.222,2 111.111 3.222.222.222.222.222,0 > Irqa Qrai IraQ`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      if (!jAsciiMath.getOutputData().equals(strCompare))
      {
        success = false;
        System.err.println("Testi ajo 6 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("  strCompare='" +strCompare+"'");
        System.err.println("      output='" +jAsciiMath.getOutputData()+"'");
      }
      else
      {
        System.out.println("Testi ajo ok 6.");
        System.out.println("strInputData='" +strInputData+"'");
        System.out.println("  strCompare='" +strCompare+"'");
        System.out.println("      output='" +jAsciiMath.getOutputData()+"'");
      }

      System.out.flush();
      System.out.println("");

      strInputDataAsciiMath = "|\">\"|\">\"|\">\"|\"<\"|\"<\"|\"<=\"|\"<=\"|\">=\"|\">=\"|\"sin\"|\"cos\"|\"tan\"|\"cot\"|\"sec\"|\"int\"|\"int_\"|\"ln\"|\"test_substring()\"|\"test_substring\"|";
      strInputData = "<span class=\"asciimath\">`"
        + JAsciiMath.getChangeNormalCharactersIntoLTAndGTHtmlCharacters(strInputDataAsciiMath)
        + "`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      alkup_input = "<span class=\"asciimath\">`"
        + JAsciiMath.getChangeLTAndGTHtmlCharactersIntoNormalCharacters(JAsciiMath.getChangeNormalCharactersIntoLTAndGTHtmlCharacters(strInputDataAsciiMath))
        + "`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";

      jAsciiMath.setInputData(strInputData);     
      jAsciiMath.setConvertAsciiMathDataWithSpaceRules(bConvertAsciiMathDataWithSpaceRules);
      jAsciiMath.replaceAsciiMathBlocks();
      strCompare = "<span class=\"asciimath\">`|\">\"|\">\"|\">\"|\"<\"|\"<\"|\"<=\"|\"<=\"|\">=\"|\">=\"|\"sin\"|\"cos\"|\"tan\"|\"cot\"|\"sec\"|\"int\"|\"int_\"|\"ln\"|\"test_substring()\"|\"test_substring\"|`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";     
      if (!jAsciiMath.getOutputData().equals(strCompare))
      {
        success = false;
        System.err.println("Testi ajo 7.1 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("  strCompare='" +strCompare+"'");
        System.err.println("      output='" +jAsciiMath.getOutputData()+"'");
      }
      else
      {
        System.out.println("Testi ajo ok 7.1");
        System.out.println("strInputData   ='" +strInputData+"'");
        System.out.println("looginen syöttö='" +alkup_input+"'");       
        System.out.println("  strCompare   ='" +strCompare+"'");
        System.out.println("      output   ='" +jAsciiMath.getOutputData()+"'");       
      }

      System.out.flush();
      System.out.println("");

      JAsciiMath jAsciiMath2 = new JAsciiMath("dtbookasciimath.properties",
          bCheckStrikeErrors, bCorrectStrikeErrors, true);
      jAsciiMath2.setConvertHtmlChars(false);

      strInputData =
        "<span class=\"asciimath\">`|)|(\"|)|(\"|)|(\"|)|(\"`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      jAsciiMath2.setInputData(strInputData);
      jAsciiMath2.setConvertAsciiMathDataWithSpaceRules(true);
      jAsciiMath2.setConvertAsciiMathDataCommaRule(true);
      jAsciiMath2.replaceAsciiMathBlocks();
      strCompare = "<span class=\"asciimath\">`| )|( \"|)|(\"| )|( \"|)|(\" )`</span> <span class=\"asciimath2\">`dataa �2`</span> <span class=\"asciimath\">`dataa �3`</span> <b/>";
      if (!jAsciiMath2.getOutputData().equals(strCompare))
      {
        success = false;
        System.err.println("Testi ajo 8 ei ok!!");
        System.err.println("strInputData='" +strInputData+"'");
        System.err.println("  strCompare='" +strCompare+"'");
        System.err.println("      output='" +jAsciiMath2.getOutputData()+"'");
      }
      else
      {
        System.out.println("Testi ajo ok 8.");
        System.out.println("strInputData='" +strInputData+"'");
        System.out.println("  strCompare='" +strCompare+"'");
        System.out.println("      output='" +jAsciiMath2.getOutputData()+"'");
      }


      boolean bAddBrowserStrikes = false;
      System.out.println();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.