Examples of DtbookAsciiMathException


Examples of fi.celia.asciimath.DtbookAsciiMathException

    private void
    copyDirIntoTargetHome(String copyPath, String dirName, String intoDir)
    throws DtbookAsciiMathException, FileNotFoundException, IOException
    {
      if (copyPath == null)
        throw new DtbookAsciiMathException("copyPath is null!");
      if (dirName == null)
        throw new DtbookAsciiMathException("dirName is null!");
      if (intoDir == null)
        throw new DtbookAsciiMathException("intoDir is null!");
     
      File fromDirFile = new File(copyPath +File.separator + dirName);
      if (!fromDirFile.exists())
        throw new DtbookAsciiMathException(fromDirFile.getAbsolutePath() +" does not exist!");
      if (!fromDirFile.isDirectory())
        throw new DtbookAsciiMathException(fromDirFile.getAbsolutePath() +" is not a directory!");
      File intoDirFile = new File(intoDir);
      if (!intoDirFile.exists())
        throw new DtbookAsciiMathException(intoDirFile.getAbsolutePath() +" does not exist!");
      if (!intoDirFile.isDirectory())
        throw new DtbookAsciiMathException(intoDirFile.getAbsolutePath() +" is not a directory!");
     
      File targetFile = new File(intoDir  +File.separator +dirName);
      if (!targetFile.exists())
      {
        if (!targetFile.mkdir())
          throw new DtbookAsciiMathException(targetFile.getAbsolutePath() +" cannot create a new directory!");
      }
     
      File [] arrFiles = fromDirFile.listFiles();
      int max = arrFiles.length;
      if(max == 0)
        throw new DtbookAsciiMathException(fromDirFile.getAbsolutePath() +" nothing to copy!");
     
      for(int i = 0; i < max; i++)
      {
        copyFile(arrFiles[i], targetFile.getAbsolutePath() +File.separator +arrFiles[i].getName());
      }
View Full Code Here

Examples of fi.celia.asciimath.DtbookAsciiMathException

      int available = fis.available();
      byte [] bytes = new byte[available];
      int read = fis.read(bytes);
      fis.close();
      if (available != read)
        throw new DtbookAsciiMathException("All data (" +available
            +") has not read (" +read +")!");
      FileOutputStream fos = new FileOutputStream(intoFileName);
      fos.write(bytes);
      fos.close();
    }
View Full Code Here

Examples of fi.celia.asciimath.DtbookAsciiMathException

        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;
         
          StringBuffer sb = new StringBuffer();
          int iCount = 0, max = arrAMBlock.length;
          AsciiMathBlockValue amValue;
         
          // collect all asciimath calculus data into one stringbuffer
          // and mark every asciimath blocks with special mark string,
          // that is possible to find these special labeled asciimath
          // positions later. At later time, generated asciimath-xml
          // blocks will replaced <asciimath> and </asciimath> blocks.
          for(int i = 0; i < max; i++)
          {
            amValue = arrAMBlock[i];
            // to much strings: class="asciimath">
            inputAsciiMathText = amValue.getAsciiMathValue();
            //inputAsciiMathText = inputAsciiMathText.substring("class=\"asciimath\">".length());
            sb.append("x_" + iCount + cnstMarkBegin + inputAsciiMathText + "x_" + iCount +cnstMarkEnd +"\n");
            iCount++;         
          }
         
        inputAsciiMathText = sb.toString();
        // replace inputText_here with template data
        // (template data is just little modifyed ascimath editor data)
        String strChanged = strTemplate.replace("inputText_here",
            new String(inputAsciiMathText.getBytes(charsetName)));
         
        //System.out.println( "strMuutettu");
        //System.out.println( strMuutettu);
        //System.out.println();
       
        // write modified template data into a file and run it later within
        // the asciimath browser:
        FileWriter fw = new FileWriter(outputFile);
        fw.write(strChanged.toCharArray());
        fw.close();
 
        // take timestamp just writen file:
        File tmp_file = outputFile ;
        //outputFile = null;
        outputFile = new File(tmp_file.getAbsolutePath());
        tmp_file = null;
        long outputFile_lastModified = outputFile.lastModified();
        long outputFile_size = outputFile.length();
       
        File exe_asciimath = outputFile.getAbsoluteFile();
       
        // A string can be executed in the standard java way:
        // Create the String
        outputFile = null;
        outputFile = new File(exeXmlFileName);
        if (outputFile == null)
          throw new DtbookAsciiMathException("outputFile is null: " + exeXmlFileName +"!");
        long outputFileSize = exe_asciimath.length();
        exe_asciimath = null;
        String command = "\"" + asciiMathWWWBrowserApplication  +"\""// -chrome
       
        // see if this application is executed under unix
View Full Code Here

Examples of fi.celia.asciimath.DtbookAsciiMathException

      //System.out.println( strMuutettuFileData);
      System.out.println();
     
      long modifiedFile_length = modifiedFile.length();
      if (modifiedFile_length == outputFileSize)
        throw new DtbookAsciiMathException("Unmodified file! The size of file is same: " +outputFileSize
            +"\nUser has not saved a generated asciimath editor file by the browser!");
     
      System.out.println( "Reading and handling just saved file....");       
      String strMuutettuFileData = readFileData(modifiedFile, charsetName);
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.