Beispiel #1
0
  /**
   * Copies a source file to a destination file, optionally preserving the source's last
   * modification time. We already have an input stream to read the source file, but we know nothing
   * about the destination file yet. Note that this method <em>never</em> closes the given input
   * stream!
   *
   * @throws FileNotFoundException If either the source or the destination cannot get accessed.
   * @throws InputIOException If copying the data fails because of an IOException in the source.
   * @throws IOException If copying the data fails because of an IOException in the destination.
   */
  private static void cp0(
      final boolean preserve, final java.io.File src, final InputStream in, final java.io.File dst)
      throws IOException {
    try {
      if (dst instanceof File) {
        final File dstFile = (File) dst;
        dstFile.ensureNotVirtualRoot("cannot write");
        final String dstEntryName = dstFile.getEnclEntryName();
        if (dstEntryName != null) {
          cp0(preserve, src, in, dstFile.getEnclArchive().getArchiveController(), dstEntryName);
          return;
        }
      }
    } catch (RfsEntryFalsePositiveException dstIsNotArchive) {
    }

    // Treat the destination like a regular file.
    final OutputStream out = new java.io.FileOutputStream(dst);
    try {
      Streams.cat(in, out);
    } finally {
      out.close();
    }
    if (preserve && !dst.setLastModified(src.lastModified()))
      throw new IOException(dst.getPath() + " (cannot preserve last modification time)");
  }
Beispiel #2
0
 /**
  * Removes any <code>&quot;.&quot;</code> and <code>&quot;..&quot;</code> directories from the
  * path wherever possible.
  *
  * @param file The file instance which's path is to be normalized.
  * @return <code>file</code> if it was already in normalized form. Otherwise, an object which's
  *     runtime class is guaranteed to be <code>java.io.File</code>.
  */
 public static java.io.File normalize(final java.io.File file) {
   final String path = file.getPath();
   final String newPath = Paths.normalize(path, File.separatorChar);
   return newPath != path // mind contract of Paths.normalize!
       ? new java.io.File(newPath)
       : file;
 }
Beispiel #3
0
 void open(java.lang.String name) {
   final java.lang.String textString;
   if (name == null || name.length() == 0) {
     return;
   }
   java.io.File file = new java.io.File(name);
   if (!file.exists()) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_file_no_exist"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   try {
     java.io.FileInputStream stream = new java.io.FileInputStream(file.getPath());
     try {
       java.io.Reader in = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
       char[] readBuffer = new char[2048];
       java.lang.StringBuffer buffer = new java.lang.StringBuffer((int) file.length());
       int n;
       while ((n = in.read(readBuffer)) > 0) {
         buffer.append(readBuffer, 0, (-n));
       }
       textString = buffer.toString();
       stream.close();
     } catch (java.io.IOException e) {
       java.lang.String message =
           MessageFormat.format(
               resources.getString("Err_file_io"), new java.lang.String[] {file.getName()});
       displayError(message);
       return;
     }
   } catch (java.io.FileNotFoundException e) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_not_found"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   org.eclipse.swt.widgets.Display display = text.getDisplay();
   display.asyncExec(
       new java.lang.Runnable() {
         public void run() {
           text.setText(textString);
         }
       });
   lineStyler.parseBlockComments(textString);
 }
  public static void processBrRequisitionFile(
      java.io.File filePortrait2Process,
      biz.systempartners.claims.ClaimsViewer claimsViewer,
      java.util.Vector invoiceVector,
      java.util.Vector filesVector) {

    biz.systempartners.claims.XMLClaimFile xmlClaimFile =
        new biz.systempartners.claims.XMLClaimFile();

    xmlClaimFile.processFile(filePortrait2Process);

    javax.swing.JTable tempInvoiceTable;

    java.util.Vector headerInvoiceVector = new java.util.Vector(1, 1);

    headerInvoiceVector.addElement("Invoice No.");

    //     claimsTable = new javax.swing.JTable(5,4);
    // claimsTable = claimsViewer.getInvoiceTable();
    claimsTable = xmlClaimFile.xmlClaim.getInvoiceTable();
    invoiceTable = claimsViewer.getInvoiceListTable();

    javax.swing.JPanel claimsViewerPanel = claimsViewer.getClaimsViewerPanel();

    javax.swing.JScrollPane jScrollPane11 = claimsViewer.getScrollPane();

    javax.swing.JScrollPane invoiceScrollPane = claimsViewer.getInvoiceListScrollPane();

    invoiceVector = claimsViewer.getInvoiceVector();

    java.util.Vector invoiceChildVector = new java.util.Vector(1, 1);
    javax.swing.JTextField patientNo = claimsViewer.getPatientNo();
    javax.swing.JTextField patientName = claimsViewer.getPatientName();
    javax.swing.JTextField schemeMemberNo = claimsViewer.getSchemeMemberNo();
    javax.swing.JTextField schemeName = claimsViewer.getSchemeName();
    javax.swing.JTextField schemePayer = claimsViewer.getSchemePayer();
    javax.swing.JTextField accountNo = claimsViewer.getAccountNo();
    javax.swing.JTextField invoiceNo = claimsViewer.getInvoiceNo();
    javax.swing.JTextField healthCareProvider = claimsViewer.getHealthCareProvider();

    jScrollPane11.setViewportView(claimsTable);
    if (claimsViewer.isShowing()) {
      claimsViewer.validate();
    } else {
      claimsViewer.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
      claimsViewer.setVisible(true);
    }

    claimsViewer.invalidate();

    // try {

    //     try {

    //   java.io.FileInputStream requisFileIOStream = new
    // java.io.FileInputStream(filePortrait2Process);

    //   java.io.ObjectInputStream requisObjInStream = new
    // java.io.ObjectInputStream(requisFileIOStream);

    //                javax.swing.table.JTableHeader claimsTableHeader =
    // (javax.swing.table.JTableHeader)requisObjInStream.readObject();

    //  requisTable = (javax.swing.JTable)requisObjInStream.readObject();

    //  String invoiceNoString = (java.lang.String)requisObjInStream.readObject();
    String invoiceNoString = xmlClaimFile.xmlClaim.getInvoiceNumber();
    invoiceNo.setText(invoiceNoString);

    //  patientNo.setText((java.lang.String)requisObjInStream.readObject());
    patientNo.setText(xmlClaimFile.xmlClaim.getPatientNumber());
    System.out.println(
        "PATIENT NUMBER : "
            + xmlClaimFile.xmlClaim.getPatientNumber()
            + "   "
            + xmlClaimFile.xmlClaim.getPatientName()
            + "  "
            + xmlClaimFile.xmlClaim.getSchemeName());
    // patientName.setText((java.lang.String)requisObjInStream.readObject());
    patientName.setText(xmlClaimFile.xmlClaim.getPatientName());
    //   schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject());
    schemeMemberNo.setText(xmlClaimFile.xmlClaim.getSchemeMemberNumber());
    //   schemeName.setText((java.lang.String)requisObjInStream.readObject());
    schemeName.setText(xmlClaimFile.xmlClaim.getSchemeName());
    //  schemePayer.setText((java.lang.String)requisObjInStream.readObject());
    schemePayer.setText(xmlClaimFile.xmlClaim.getSchemePayer());
    //  accountNo.setText((java.lang.String)requisObjInStream.readObject());
    accountNo.setText(xmlClaimFile.xmlClaim.getAccountNumber());
    healthCareProvider.setText(xmlClaimFile.xmlClaim.getHealthCareProvider());

    tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector);
    invoiceChildVector.add(invoiceNoString);
    invoiceChildVector.add(filePortrait2Process.getPath());
    if (filesVector == null) {
      filesVector = new java.util.Vector(1, 1);
    }

    filesVector.add(filePortrait2Process.getAbsolutePath());
    claimsViewer.filesVector = filesVector;
    if (invoiceVector == null) {
      invoiceVector = new java.util.Vector(1, 1);
    }
    invoiceVector.add(invoiceChildVector);
    /*
    invoiceNo.setText(invoiceNoString);
    invoiceChildVector.add(invoiceNoString);
    invoiceChildVector.add(filePortrait2Process.getPath());
    filesVector.add(filePortrait2Process.getAbsolutePath());
    //                System.out.println("Child Cector Size ="+invoiceChildVector.size());
    //                System.out.println("File saved in child vector ="+filePortrait2Process.getPath());
    invoiceVector.add(invoiceChildVector);
    //                            for (int j = 0; j < invoiceChildVector.capacity(); j++) {
    //                System.out.println("Child entry ["+invoiceChildVector.elementAt(j)+"]");
    //            }
    patientNo.setText((java.lang.String)requisObjInStream.readObject());

    patientName.setText((java.lang.String)requisObjInStream.readObject());

    schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject());

    schemeName.setText((java.lang.String)requisObjInStream.readObject());

    schemePayer.setText((java.lang.String)requisObjInStream.readObject());

    accountNo.setText((java.lang.String)requisObjInStream.readObject());
    */
    tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector);

    System.out.println("Starting to populate tables ...");
    /**
     * for (int i = 0; i < requisTable.getModel().getRowCount(); i++) {
     *
     * <p>for (int j = 0; j < requisTable.getModel().getColumnCount(); j++){
     *
     * <p>if (requisTable.getValueAt(i,0) != null) {
     *
     * <p>claimsTable.setValueAt(requisTable.getValueAt(i,j), i, j);
     *
     * <p>System.out.println(requisTable.getValueAt(i,j)); } } }
     */
    for (int i = 0; i < tempInvoiceTable.getModel().getRowCount(); i++) {

      for (int j = 0; j < tempInvoiceTable.getModel().getColumnCount(); j++) {

        if (tempInvoiceTable.getValueAt(i, 0) != null) {

          invoiceTable.setValueAt(tempInvoiceTable.getValueAt(i, j), i, j);
          System.out.println("Invoices : " + tempInvoiceTable.getValueAt(i, j));
          System.out.println(tempInvoiceTable.getValueAt(i, j));
        }
      }
    }

    //        claimsTable.setModel(requisTable.getModel());

    gridBagConstraints = new java.awt.GridBagConstraints();

    gridBagConstraints.gridx = 0;

    gridBagConstraints.gridy = 0;

    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;

    gridBagConstraints.weightx = 1.0;

    gridBagConstraints.weighty = 100.0;

    claimsViewerPanel.removeAll();

    claimsViewerPanel.add(jScrollPane11, gridBagConstraints);

    invoiceScrollPane.setViewportView(invoiceTable);

    jScrollPane11.setViewportView(claimsTable);

    claimsViewerPanel.validate();

    for (int i = 0; i < invoiceVector.size(); i++) {

      java.util.Vector childVector = (java.util.Vector) invoiceVector.elementAt(i);

      for (int j = 0; j < childVector.size(); j++) {

        //               System.out.println("Child entry at ---- !!! ["+j+"] is
        // ["+childVector.elementAt(j)+"]");

        File file2SelectedInvoice;

        file2SelectedInvoice = new java.io.File(childVector.elementAt(j).toString());

        System.out.println("Selected File ---- !!!!! [" + file2SelectedInvoice.getPath() + "]");
      }

      //           for (int j = 0; j < childVector.size(); j++) {

      //            if  (childVector.elementAt(0).toString().equalsIgnoreCase(invoiceNo)) {

      //           }
      //        }

    }

    //   } catch(java.lang.ClassNotFoundException cnfExec) {

    //       javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), cnfExec.getMessage());

    //    }

    // } catch(java.io.IOException ioExec) {

    //    javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), ioExec.getMessage());

    //  }
  }
Beispiel #5
0
 /** @see File#contains */
 public static boolean contains(java.io.File a, java.io.File b) {
   a = getCanOrAbsFile(a);
   b = getCanOrAbsFile(b);
   return contains(a.getPath(), b.getPath());
 }
Beispiel #6
0
  /**
   * Copies a source file to a destination file, optionally preserving the source's last
   * modification time. We know that the source file appears to be an entry in an archive file, but
   * we know nothing about the destination file yet.
   *
   * <p>Note that this method synchronizes on the class object in order to prevent dead locks by two
   * threads copying archive entries to the other's source archive concurrently!
   *
   * @throws FalsePositiveException If the source or the destination is a false positive and the
   *     exception cannot get resolved within this method.
   * @throws InputIOException If copying the data fails because of an IOException in the source.
   * @throws IOException If copying the data fails because of an IOException in the destination.
   */
  private static void cp0(
      final boolean preserve,
      final ArchiveController srcController,
      final String srcEntryName,
      final java.io.File dst)
      throws IOException {
    // Do not assume anything about the lock status of the controller:
    // This method may be called from a subclass while a lock is acquired!
    // assert !srcController.readLock().isLocked();
    // assert !srcController.writeLock().isLocked();

    try {
      try {
        if (dst instanceof File) {
          final File dstFile = (File) dst;
          dstFile.ensureNotVirtualRoot("cannot write");
          final String dstEntryName = dstFile.getEnclEntryName();
          if (dstEntryName != null) {
            cp0(
                preserve,
                srcController,
                srcEntryName,
                dstFile.getEnclArchive().getArchiveController(),
                dstEntryName);
            return;
          }
        }
      } catch (RfsEntryFalsePositiveException isNotArchive) {
        // Both the source and/or the destination may be false positives,
        // so we need to use the exception's additional information to
        // find out which controller actually detected the false positive.
        if (isNotArchive.getController() == srcController)
          throw isNotArchive; // not my job - pass on!
      }

      final InputStream in;
      final long time;
      srcController.readLock().lock();
      try {
        in = srcController.createInputStream0(srcEntryName); // detects false positives!
        time = srcController.lastModified(srcEntryName);
      } finally {
        srcController.readLock().unlock();
      }

      // Treat the destination like a regular file.
      final OutputStream out;
      try {
        out = new java.io.FileOutputStream(dst);
      } catch (IOException ex) {
        try {
          in.close();
        } catch (IOException inFailure) {
          throw new InputIOException(inFailure);
        }
        throw ex;
      }

      cp(in, out);
      if (preserve && !dst.setLastModified(time))
        throw new IOException(dst.getPath() + " (cannot preserve last modification time)");
    } catch (ArchiveEntryFalsePositiveException ex) {
      assert srcController == ex.getController();
      // Reroute call to the source's enclosing archive controller.
      cp0(
          preserve,
          srcController.getEnclController(),
          srcController.enclEntryName(srcEntryName),
          dst);
    }
  }