text:
package sat;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Random;
import java.util.regex.Pattern;
import javax.swing.*;
import javax.swing.event.InternalFrameEvent;
import si300.SI300;

/**
 *
 * @author Wellington Felix Martins
 */
public class TelaSAT extends javax.swing.JFrame {

    Texto envia;
    Vender enviar;

    /**
     * Creates new form TelaSAT
     */
    public TelaSAT() {
        initComponents();

    }
    public String codigo = "";

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel4 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel33 = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel49 = new javax.swing.JLabel();
        jPasswordField1 = new javax.swing.JPasswordField();
        jPanel6 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel50 = new javax.swing.JLabel();
        jLabel51 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        jLabel44 = new javax.swing.JLabel();
        jLabel45 = new javax.swing.JLabel();
        jLabel46 = new javax.swing.JLabel();
        jLabel47 = new javax.swing.JLabel();
        jLabel48 = new javax.swing.JLabel();

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(153, 204, 255));
        setLocationByPlatform(true);
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel2.setBackground(new java.awt.Color(153, 204, 255));
        jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel2.setForeground(new java.awt.Color(153, 204, 255));
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jButton4.setBackground(new java.awt.Color(255, 204, 102));
        jButton4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton4.setForeground(new java.awt.Color(255, 255, 255));
        jButton4.setText("Extrair Logs");
        jButton4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, 110, 40));

        jButton3.setBackground(new java.awt.Color(153, 153, 255));
        jButton3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton3.setForeground(new java.awt.Color(255, 255, 255));
        jButton3.setText("Teste SAT");
        jButton3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 60, 110, 40));

        jButton2.setBackground(new java.awt.Color(153, 153, 255));
        jButton2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton2.setForeground(new java.awt.Color(255, 255, 255));
        jButton2.setText("Status SAT");
        jButton2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 60, 110, 40));

        jButton1.setBackground(new java.awt.Color(153, 153, 255));
        jButton1.setFont(new java.awt.Font("Century Gothic", 1, 11)); // NOI18N
        jButton1.setForeground(new java.awt.Color(255, 255, 255));
        jButton1.setText("Consulta-S@T");
        jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 60, 111, 40));

        jButton5.setBackground(new java.awt.Color(0, 204, 102));
        jButton5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jButton5.setForeground(new java.awt.Color(255, 255, 255));
        jButton5.setText("Limpar");
        jButton5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 100, 110, 40));

        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        jPanel2.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(3, 76, 364, -1));

        jTextArea1.setColumns(20);
        jTextArea1.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        jTextArea1.setRows(5);
        jTextArea1.setToolTipText("Copie e insira aqui o seu XML!");
        jTextArea1.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jTextArea1);

        jPanel2.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 260, 350, 190));

        jLabel33.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel33.setForeground(new java.awt.Color(255, 255, 255));
        jLabel33.setText("S@T SWEDA");
        jPanel2.add(jLabel33, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 20, -1, -1));

        jButton6.setBackground(new java.awt.Color(255, 102, 102));
        jButton6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton6.setForeground(new java.awt.Color(255, 255, 255));
        jButton6.setText("SAIR");
        jButton6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 140, 110, 40));

        jButton7.setBackground(new java.awt.Color(0, 204, 102));
        jButton7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton7.setForeground(new java.awt.Color(255, 255, 255));
        jButton7.setText("Vender");
        jButton7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, 110, 40));

        jPanel5.setBackground(new java.awt.Color(153, 153, 255));
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel49.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel49.setText("Digite o Código de Ativação:");
        jPanel5.add(jLabel49, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));

        jPasswordField1.setToolTipText("Digite o código");
        jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField1ActionPerformed(evt);
            }
        });
        jPanel5.add(jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 3, 140, 25));

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 30, Short.MAX_VALUE)
        );

        jPanel5.add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, -30, 110, 30));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 20, Short.MAX_VALUE)
        );

        jPanel5.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, -30, -1, 20));

        jPanel2.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 220, 350, 30));

        jButton8.setBackground(new java.awt.Color(255, 102, 102));
        jButton8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton8.setForeground(new java.awt.Color(255, 255, 255));
        jButton8.setText("Cancela CF-e");
        jButton8.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton8, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 140, 110, 40));

        jButton9.setBackground(new java.awt.Color(0, 204, 102));
        jButton9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton9.setForeground(new java.awt.Color(255, 255, 255));
        jButton9.setText("Enviar Dados Venda XML String");
        jButton9.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 460, 350, 40));

        jButton10.setBackground(new java.awt.Color(255, 204, 102));
        jButton10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton10.setForeground(new java.awt.Color(255, 255, 255));
        jButton10.setText("ConsultaSessão");
        jButton10.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton10, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 100, 110, 40));

        jPanel8.setBackground(new java.awt.Color(255, 204, 102));

        jLabel50.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel50.setText("ULTIMA SESSÃO");

        jLabel51.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel51.setText(":  ");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel50, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel51, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel50, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                .addComponent(jLabel51, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel2.add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, 350, -1));

        getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 370, 510));

        jPanel1.setBackground(new java.awt.Color(153, 153, 255));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Status Rede:");
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, -1, -1));

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("---- STATUS SAT ----");
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 10, -1, -1));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("IP Rede");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1));

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Numero SAT");
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 33, -1, -1));

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Tipo de Rede");
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1));

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("MAC");
        jPanel1.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, -1));

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Mask");
        jPanel1.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, -1, -1));

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Getway");
        jPanel1.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, -1, -1));

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("DNS 1");
        jPanel1.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, -1, -1));

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("DNS 2");
        jPanel1.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 170, -1, -1));

        jLabel11.setBackground(new java.awt.Color(0, 0, 0));
        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel11.setText(":");
        jPanel1.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 30, -1, 20));

        jLabel12.setBackground(new java.awt.Color(0, 0, 0));
        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel12.setText(":");
        jPanel1.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 50, -1, -1));

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel13.setText(":");
        jPanel1.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 70, -1, -1));

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel14.setText(":");
        jPanel1.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 90, -1, -1));

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel15.setText(":");
        jPanel1.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 110, -1, -1));

        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel16.setText(":");
        jPanel1.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 130, -1, -1));

        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel17.setText(":");
        jPanel1.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 150, -1, -1));

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel18.setText(":");
        jPanel1.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 170, -1, -1));

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel19.setText(":");
        jPanel1.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 190, -1, -1));

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel20.setForeground(new java.awt.Color(255, 255, 255));
        jLabel20.setText("Nilvel Bateria");
        jPanel1.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 210, -1, -1));

        jLabel21.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel21.setForeground(new java.awt.Color(255, 255, 255));
        jLabel21.setText("Memória Total");
        jPanel1.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 230, -1, -1));

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel22.setForeground(new java.awt.Color(255, 255, 255));
        jLabel22.setText("Memória Usada");
        jPanel1.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 250, -1, -1));

        jLabel23.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel23.setForeground(new java.awt.Color(255, 255, 255));
        jLabel23.setText("Data e Hora");
        jPanel1.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 270, -1, -1));

        jLabel24.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel24.setForeground(new java.awt.Color(255, 255, 255));
        jLabel24.setText("Versão Software Básico");
        jPanel1.add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 290, -1, -1));

        jLabel25.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel25.setForeground(new java.awt.Color(255, 255, 255));
        jLabel25.setText("Versão Layout");
        jPanel1.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 310, -1, -1));

        jLabel26.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel26.setForeground(new java.awt.Color(255, 255, 255));
        jLabel26.setText("Ultimo CF-e SAT");
        jPanel1.add(jLabel26, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 330, -1, -1));

        jLabel27.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel27.setForeground(new java.awt.Color(255, 255, 255));
        jLabel27.setText("CF-e Inicial");
        jPanel1.add(jLabel27, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 350, -1, -1));

        jLabel28.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel28.setForeground(new java.awt.Color(255, 255, 255));
        jLabel28.setText("CF-e Final");
        jPanel1.add(jLabel28, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 370, -1, -1));

        jLabel29.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel29.setForeground(new java.awt.Color(255, 255, 255));
        jLabel29.setText("Data/Hora ultima Transmissão");
        jPanel1.add(jLabel29, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 390, -1, -1));

        jLabel30.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel30.setForeground(new java.awt.Color(255, 255, 255));
        jLabel30.setText("Data Emissão Certificado");
        jPanel1.add(jLabel30, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 430, -1, -1));

        jLabel31.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel31.setForeground(new java.awt.Color(255, 255, 255));
        jLabel31.setText("Data Vencimento Certificado");
        jPanel1.add(jLabel31, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 450, -1, -1));

        jLabel32.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel32.setForeground(new java.awt.Color(255, 255, 255));
        jLabel32.setText("Estado SAT");
        jPanel1.add(jLabel32, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 470, -1, -1));

        jLabel34.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel34.setText(":");
        jPanel1.add(jLabel34, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 210, -1, -1));

        jLabel35.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel35.setText(":");
        jPanel1.add(jLabel35, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 230, -1, -1));

        jLabel36.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel36.setText(":");
        jPanel1.add(jLabel36, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 250, -1, -1));

        jLabel37.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel37.setText(":");
        jPanel1.add(jLabel37, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 270, -1, -1));

        jLabel38.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel38.setText(":");
        jPanel1.add(jLabel38, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 290, -1, -1));

        jLabel39.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel39.setText(":");
        jPanel1.add(jLabel39, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 310, -1, -1));

        jLabel40.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel40.setText(":");
        jPanel1.add(jLabel40, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 330, -1, -1));

        jLabel41.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel41.setText(":");
        jPanel1.add(jLabel41, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 350, -1, -1));

        jLabel42.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel42.setText(":");
        jPanel1.add(jLabel42, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 370, -1, -1));

        jLabel43.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel43.setText(":");
        jPanel1.add(jLabel43, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 390, -1, -1));

        jLabel44.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel44.setText(":");
        jPanel1.add(jLabel44, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 430, -1, -1));

        jLabel45.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel45.setText(":");
        jPanel1.add(jLabel45, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 450, -1, -1));

        jLabel46.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel46.setText(":");
        jPanel1.add(jLabel46, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 470, -1, -1));

        jLabel47.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jLabel47.setForeground(new java.awt.Color(255, 255, 255));
        jLabel47.setText("Data/Hora Comunicação Sefaz");
        jPanel1.add(jLabel47, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 410, -1, -1));

        jLabel48.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel48.setText(":");
        jPanel1.add(jLabel48, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 410, -1, -1));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 0, 350, 510));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        Random gerador = new Random();
        int numero = gerador.nextInt(999999);
        String ret = SAT.INSTANCE.ConsultarSAT(numero);
        String[] reto = ret.split(Pattern.quote("|"));
        JOptionPane.showMessageDialog(null,reto[2]);

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        Random gerador = new Random();
        jTextArea1.setText(null);
        codigo = jPasswordField1.getText();

        int numero = gerador.nextInt(999999);
        String ret = SAT.INSTANCE.ConsultarStatusOperacional(numero, codigo);

        String[] reto = ret.split(Pattern.quote("|"));
    JOptionPane.showMessageDialog(null, reto[2]);
    String rec = new String(reto[27]);// Converte um vetor para uma string comum

    Integer reca = new Integer(rec);

    String estado = "";

    if(reca == 0){
    estado = "DESBLOQUEADO";
    }else if(reca == 1){
    estado = "BLOQUEIO SEFAZ";
    }else if(reca == 2){
    estado = "BLOQUEIO CONTRIBUINTE";
    }else if(reca == 3){
    estado = "BLOQUEIO AUTÔNOMO";
    }else if(reca == 4){
    estado = "BLOQUEIO PARA DESATIVAÇÃO";
    }

        jLabel11.setText(": "+reto[5]);// numero de serie sat
        jLabel12.setText(": "+reto[6]);// tipo de rede
        jLabel13.setText(": "+reto[7]);// ip da rede
        jLabel14.setText(": "+reto[8]);//
        jLabel15.setText(": "+reto[9]);//
        jLabel16.setText(": "+reto[10]);//
        jLabel17.setText(": "+reto[11]);//
        jLabel18.setText(": "+reto[12]);//
        jLabel19.setText(": "+reto[13]);//
        jLabel34.setText(": "+reto[14]);//
        jLabel35.setText(": "+reto[15]);//
        jLabel36.setText(": "+reto[16]);//
        jLabel37.setText(": "+reto[17]);//
        jLabel38.setText(": "+reto[18]);//
        jLabel39.setText(": "+reto[19]);//
        jLabel40.setText(": "+reto[20]);//
        jLabel41.setText(": "+reto[21]);//
        jLabel42.setText(": "+reto[22]);//
        jLabel43.setText(": "+reto[23]);//
        jLabel48.setText(": "+reto[24]);//
        jLabel44.setText(": "+reto[25]);//
        jLabel45.setText(": "+reto[26]);//

        jLabel46.setText(": "+estado);//

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        Random gerador = new Random();
        String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<CFe>\n" +
"	<infCFe versaoDadosEnt=\"0.06\">\n" +
"		<ide>\n" +
"			<CNPJ>10615281000140</CNPJ>\n" +
"			<signAC>SGR-SAT SISTEMA DE GESTAO E RETAGUARDA DO SAT</signAC>\n" +
"			<numeroCaixa>233</numeroCaixa>\n" +
"		</ide>\n" +
"		<emit>\n" +
"			<CNPJ>53485215000106</CNPJ>\n" +
"			<IE>111072115110</IE>\n" +
"			<cRegTribISSQN>3</cRegTribISSQN>\n" +
"			<indRatISSQN>S</indRatISSQN>\n" +
"		</emit>\n" +
"		<dest>\n" +
"			<CNPJ>53485215000106</CNPJ>\n" +
"			<xNome>Sweda Informatica Ltda.</xNome>\n" +
"		</dest>\n" +
"		<entrega>\n" +
"			<xLgr>Rua Dona Brigida</xLgr>\n" +
"			<nro>713</nro>\n" +
"			<xCpl>A</xCpl>\n" +
"			<xBairro>Vila Mariana</xBairro>\n" +
"			<xMun>São Paulo</xMun>\n" +
"			<UF>SP</UF>\n" +
"		</entrega>\n" +
"		<det nItem=\"1\">\n" +
"			<prod>\n" +
"				<cProd>7899264308001</cProd>\n" +
"				<xProd>Pao Forma Integral Light</xProd>\n" +
"				<NCM>85447030</NCM>\n" +
"				<CFOP>5401</CFOP>\n" +
"				<uCom>un</uCom>\n" +
"				<qCom>2.0000</qCom>\n" +
"				<vUnCom>1.00</vUnCom>\n" +
"				<indRegra>T</indRegra>\n" +
"				<vDesc>0.00</vDesc>\n" +
"				<vOutro>0.00</vOutro>\n" +
"			</prod>\n" +
"			<imposto>\n" +
"				<ICMS>\n" +
"					<ICMS00>\n" +
"						<Orig>1</Orig>\n" +
"						<CST>00</CST>\n" +
"						<pICMS>07.00</pICMS>\n" +
"					</ICMS00>\n" +
"				</ICMS>\n" +
"				<PIS>\n" +
"					<PISSN>\n" +
"						<CST>49</CST>\n" +
"					</PISSN>\n" +
"				</PIS>\n" +
"				<COFINS>\n" +
"					<COFINSAliq>\n" +
"						<CST>01</CST>\n" +
"						<vBC>1.00</vBC>\n" +
"						<pCOFINS>5.0000</pCOFINS>\n" +
"					</COFINSAliq>\n" +
"				</COFINS>\n" +
"			</imposto>\n" +
"		</det>\n" +
"		<total/>\n" +
"		<pgto>\n" +
"			<MP><cMP>01</cMP>\n" +
"				<vMP>10.00</vMP>\n" +
"				<cAdmC>025</cAdmC>\n" +
"			</MP>\n" +
"		</pgto>\n" +
"	</infCFe>\n" +
"</CFe>";
        String xm=null;
        xm=xml;
        jTextArea1.setText(xml);
        String venda = jTextArea1.getText();
        codigo = jPasswordField1.getText();

            int numero = gerador.nextInt(999999);
            String ret = SAT.INSTANCE.TesteFimAFim(numero,codigo, venda);
        String[] reto = ret.split(Pattern.quote("|"));
        JOptionPane.showMessageDialog(null, reto[2]);

    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:

       jTextArea1.setText("");
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        Random gerador = new Random();
        int numero = gerador.nextInt(999999);
        codigo = jPasswordField1.getText();

        String ret = SAT.INSTANCE.ExtrairLogs(numero, codigo);
        String[] reto = ret.split(Pattern.quote("|"));
        JOptionPane.showMessageDialog(null, reto[2]);

        String a = new String(reto[5]); // string "a" recebe vetor com a base64
        byte[] byteArray = Base64.decode(a.toString());// byteArray descodifica "a"
        String decodedString = new String(byteArray);// String decodedString recebe byteArray.
        envia = new Texto();
        envia.setVisible(true);
        envia.receber(decodedString);// envia para tela de texto.

    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        enviar = new Vender();
        enviar.setVisible(true);
        enviar.receber(codigo);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPasswordField1ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
         Random gerador = new Random();
        jTextArea1.setText(null);
        codigo = jPasswordField1.getText();

        String ret ="", ass="";

        String[] reto = ret.split(Pattern.quote("|"));
   String nn = "";
   nn = JOptionPane.showInputDialog("Digite a chave para cancelamento");
  ass = JOptionPane.showInputDialog("Insira a Assinatura Digital de 344 caracteres ");
        String canc = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<CFeCanc>\n" +
"<infCFe chCanc=\""+"CFe"+nn+"\">\n" +
"<ide>\n" +
"<CNPJ>14934661000107</CNPJ>\n" +
"<signAC>"+ass+"</signAC>\n" +
"<numeroCaixa>233</numeroCaixa>\n" +
"</ide>\n" +
"<emit />\n" +
"<dest />\n" +
"<total />\n" +
"<infAdic />\n" +
"</infCFe>\n" +
"</CFeCanc>";
         String b ="CFe",c="";
         c=b+nn;

         Random gera = new Random();

        int cupon = gerador.nextInt(999999);
          ret = SAT.INSTANCE.CancelarUltimaVenda(cupon, codigo, c, canc);
        String[] retoa = ret.split(Pattern.quote("|"));
        JOptionPane.showMessageDialog(null, retoa[3]);

        String ab = retoa[6]; // string "a" recebe vetor com a base64
        byte[] byteArray = Base64.decode(ab);// byteArray descodifica "a"
        String decodedString = new String(byteArray);// String decodedString recebe byteArray.

          Integer.toString(cupon);
        String gv = "C:/Teste/cfecancelado";
                try{
                    FileWriter nf = new FileWriter(gv+"/Cancelado_CF-e_" + cupon + ".xml");
                       PrintWriter arq = new PrintWriter(nf);
                       arq.print(decodedString);
                       nf.close();
                    }catch(Exception erro){
                        JOptionPane.showMessageDialog(null,"Falha ao gerar arquivo");

                    }
        /*envia = new Texto();
        envia.setVisible(true);
        envia.receber(decodedString);// envia para tela de texto.*/
       si300.SI300.INSTANCE.SI300_eBuscarPortaVelocidade();
       si300.SI300.INSTANCE.SI300_iImprimirImagem("C:\\Documents and Settings\\wfelix\\Desktop\\download.bmp");
        SI300.INSTANCE.SI300_iImprimirXMLString(decodedString, null, null, 0, null, null,0, true);

    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        Random gerador = new Random();
        int cupon = gerador.nextInt(999999);

        String cf_e="";

        cf_e=jTextArea1.getText();
        String ret = SAT.INSTANCE.EnviarDadosVenda(cupon,jPasswordField1.getText(), cf_e);
        String[] reto = ret.split(Pattern.quote("|"));
       JOptionPane.showMessageDialog(null, reto[3]);

        String a = reto[6]; // string "a" recebe vetor com a base64
        byte[] byteArray = Base64.decode(a);// byteArray descodifica "a"
        String decodedString = new String(byteArray);// String decodedString recebe byteArray.
        jTextArea1.setText(decodedString);

         /* Integer.toString(cupon);
         String gv = jTextArea1.getText();
                try{
                    FileWriter nf = new FileWriter(gv+"/CF-e_" + cupon + ".xml");
                       PrintWriter arq = new PrintWriter(nf);
                       arq.print(decodedString);
                       nf.close();
                    }catch(Exception erro){
                        JOptionPane.showMessageDialog(null,"Falha ao gerar arquivo");

                    }
        /*envia = new Texto();
        envia.setVisible(true);
        envia.receber(decodedString);// envia para tela de texto.*/
                int tipo = 0;
                tipo = Integer.parseInt(JOptionPane.showInputDialog("Escolha a opção desejada:\n\n0 = Cupom completo\n1 = Cupom Resumido"));
       si300.SI300.INSTANCE.SI300_eBuscarPortaVelocidade();
       //si300.SI300.INSTANCE.SI300_iImprimirImagem("C:\\Documents and Settings\\wfelix\\Desktop\\download.bmp");
        SI300.INSTANCE.SI300_iImprimirXMLString(decodedString, null, null, tipo, null, null,0, true);
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed

// TODO add your handling code here:
        Random gerador = new Random();
        int numero = gerador.nextInt(999999);
        codigo = jPasswordField1.getText();
        int nn ;
        nn = Integer.parseInt(JOptionPane.showInputDialog("Digite a Sessão"));
        String ret ="";
        ret = SAT.INSTANCE.ConsultarNumeroSessao(numero, codigo, nn);
        jTextArea1.setText(ret);

        String[] reto = ret.split(Pattern.quote("|"));
        JOptionPane.showMessageDialog(null, reto[2]);
        jLabel51.setText(reto[0]+" Comando Consultar Sessão");
        //JOptionPane.showMessageDialog(null, reto[3]);
        String a = reto[6]; // string "a" recebe vetor com a base64
        byte[] byteArray = Base64.decode(a);// byteArray descodifica "a"
        String decodedString = new String(byteArray);// String decodedString recebe byteArray.

    }//GEN-LAST:event_jButton10ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables

 public void internalFrameClosing(InternalFrameEvent evt) {
               fecharJanela();
            }

    public void fecharJanela() {
        throw new UnsupportedOperationException(""); //To change body of generated methods, choose Tools | Templates.
    }

}


text:
FNC_UI_PREFIX(dialogs,manageHQ,menu);
FNC_UI_PREFIX(dialogs,manageHQ,move);
FNC_UI_PREFIX(dialogs,manageHQ,rebuild);
FNC_UI_PREFIX(dialogs,manageHQ,takeMoney);
FNC_UI_PREFIX(dialogs,manageHQ,upgrade);

redpajama_set_name: RedPajamaGithub


text:
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**partnerId** | **string** |  |
**pricingRequestId** | **string** |  |
**price** | **double** |  |
**currency** | **string** |  |
**segment** | **string** |  | [optional]
**pricingRule** | **string** |  | [optional]
**group** | **string** |  | [optional]
**modifier** | **float** |  | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


text:
package com.ansorgit.plugins.bash.lang.psi.impl.expression;

import com.ansorgit.plugins.bash.lang.psi.BashVisitor;
import com.ansorgit.plugins.bash.lang.psi.api.expression.BashRedirectExpr;
import com.ansorgit.plugins.bash.lang.psi.impl.BashBaseStubElementImpl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.stubs.StubElement;
import javax.annotation.Nonnull;

/**
 * User: jansorg
 * Date: Oct 29, 2009
 * Time: 8:44:28 PM
 */
public class BashRedirectExprImpl extends BashBaseStubElementImpl<StubElement> implements BashRedirectExpr {
    public BashRedirectExprImpl(final ASTNode astNode) {
        super(astNode, "BashRedirectExpr");
    }

    @Override
    public void accept(@Nonnull PsiElementVisitor visitor) {
        if (visitor instanceof BashVisitor) {
            ((BashVisitor) visitor).visitRedirectExpression(this);
        } else {
            visitor.visitElement(this);
        }
    }
}


text:
package com.heliosapm.opentsdb.server;

import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;

/**
 *
Title: PipelineModifier

 *
Description: Defines a class that modifies a pipeline for a specific purpose

 *
Company: Helios Development Group LLC

 * @author Whitehead (nwhitehead AT heliosdev DOT org)
 *
com.heliosapm.opentsdb.server.PipelineModifier

 */

public interface PipelineModifier {
	/**
	 * Modifies the passed pipeline to provide specific functionality
	 * @param pipeline The pipeline to modify
	 */
	public void modifyPipeline(ChannelPipeline pipeline);

	/**
	 * Returns the name of this modifier
	 * @return the name of this modifier
	 */
	public String getName();

	/**
	 * Returns the channel handler to insert into the pipeline
	 * @return the channel handler to insert into the pipeline
	 */
	public ChannelHandler getChannelHandler();
}


text:
class DynamicFormsMailer < ActionMailer::Base
  include DynamicForms::Models::DynamicFormsMailer
end


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<meta name="generator" content="JDiff v1.1.0">

<meta name="description" content="JDiff is a Javadoc doclet which generates an HTML report of all the packages, classes, constructors, methods, and fields which have been removed, added or changed in any way, including their documentation, when two APIs are compared.">
<meta name="keywords" content="diff, jdiff, javadiff, java diff, java difference, API difference, difference between two APIs, API diff, Javadoc, doclet">
<TITLE>
API Change Statistics
</TITLE>
<link href="../../../../assets/android-developer-docs.css" rel="stylesheet" type="text/css" />
<link href="../stylesheet-jdiff.css" rel="stylesheet" type="text/css" />

<nobr>Android Developers | Android.com</nobr>

        API Diff Specification

        To Level:
        12

        From Level:
        11

        Generated
        2011.04.03 13:48

        Top of Report

API Change Statistics

The overall difference between API Levels 11 and 12 is approximately 1.15%.

Total of Differences, by Number and Type

The table below lists the numbers of program elements (packages, classes, constructors, methods, and fields) that were added, changed, or removed. The table includes only the highest-level program elements — that is, if a class with two methods was added, the number of methods added does not include those two methods, but the number of classes added does include that class.

  Type
  Additions
  Changes
  Removals
  Total

  Packages
  3
  24
  0
  27

  Classes and Interfaces
  5
  65
  6
  76

  Constructors
  4
  1
  6
  11

  Methods
  75
  27
  2
  104

  Fields
  87
  9
  0
  96

  Total
  174
  126
  14
  314

Changed Packages, Sorted by Percentage Difference

  Percentage Difference*
  Package

  9
  android.webkit

  4
  android.drm

  3
  android.util

  3
  android.text.format

  2
  android.appwidget

  2
  android.view

  2
  android.net.http

  1
  android.net

  1
  android.app

  <1
  android.view.inputmethod

  <1
  android.net.sip

  <1
  android.text.method

  <1
  android.graphics

  <1
  android.os

  <1
  android.hardware

  <1
  android.content.pm

  <1
  android.net.wifi

  <1
  android.animation

  <1
  android.view.animation

  <1
  android.text

  <1
  android.provider

  <1
  android.widget

  <1
  android.content

  <1
  android

* See Calculation of Change Percentages, below.

Changed Classes and Interfaces, Sorted by Percentage Difference

  Percentage
Difference*
  Class or Interface

  50

android.drm.DrmManagerClient.OnEventListener

  50

android.webkit.WebView.PictureListener

  33

android.util.DebugUtils

  29

android.net.TrafficStats

  25

android.webkit.WebSettings.LayoutAlgorithm

  21

android.view.MotionEvent

  20

android.util.TimeUtils

  20

android.view.InputEvent

  20

android.view.MotionEvent.PointerCoords

  18

android.view.InputDevice

  17

android.drm.DrmEvent

  16

android.view.InputDevice.MotionRange

  14

android.appwidget.AppWidgetProviderInfo

  14

android.drm.DrmInfoEvent

  12

android.text.format.Formatter

  11

android.drm.DrmErrorEvent

  11

android.view.inputmethod.InputMethodSubtype

  10

android.webkit.CookieManager

  10

android.webkit.WebHistoryItem

  9

android.graphics.Camera

  9

android.net.http.SslCertificate

  9

android.util.Config

  6

android.util.EventLog

  6

android.util.StateSet

  5

android.text.method.MovementMethod

  5

android.util.Xml

  5

android.webkit.WebView

  5

android.app.ActivityManager.RecentTaskInfo

  5

android.app.FragmentBreadCrumbs

  5

android.os.ParcelFileDescriptor

  4

android.graphics.Bitmap

  4

android.net.sip.SipProfile.Builder

  3

android.view.KeyEvent

  3

android.os.Build.VERSION_CODES

  3

android.net.sip.SipProfile

  3

android.webkit.WebSettings

  3

android.view.ViewConfiguration

  3

android.widget.DatePicker

  2

android.app.DialogFragment

  2

android.app.DownloadManager.Request

  2

android.app.Fragment

  2

android.view.Window.Callback

  2

android.app.ActivityManager

  2

android.app.DownloadManager

  2

android.text.method.BaseMovementMethod

  1

android.provider.MediaStore

  1

android.text.SpannableStringBuilder

  1

android.view.animation.Animation

  1

android.hardware.Camera

  1

android.webkit.WebViewClient

  1

android.provider.Browser

  1

android.animation.ValueAnimator

  1

android.app.Dialog

  1

android.os.Bundle

  1

android.content.pm.ApplicationInfo

  1

android.widget.RemoteViews

  1

android.app.SearchManager

  1

android.net.wifi.WifiManager

  <1

android.view.View

  <1

android.content.pm.PackageManager

  <1

android.content.Intent

  <1

android.app.Activity

  <1

android.view.Window

  <1

android.content.Context

  <1

android.R.attr

* See Calculation of Change Percentages, below.

Calculation of Change Percentages

The percent change statistic reported for all elements in the "to" API Level specification is defined recursively as follows:

Percentage difference = 100 * (added + removed + 2*changed)
                        -----------------------------------
                        sum of public elements in BOTH APIs

where added is the number of packages added, removed is the number of packages removed, and changed is the number of packages changed.
This definition is applied recursively for the classes and their program elements, so the value for a changed package will be less than 1, unless every class in that package has changed.
The definition ensures that if all packages are removed and all new packages are
added, the change will be 100%.

        Except as noted, this content is licensed under
         Creative Commons Attribution 2.5.
        For details and restrictions, see the Content License.

        Site Terms of Service -
        Privacy Policy -
        Brand Guidelines


text:
import { j2xParser } from 'fast-xml-parser';
import { is as typeIs } from 'type-is';

const xmlSerializer = new j2xParser({});

const serializers = [
  {
    test: (value: string) => !!typeIs(value, ['application/json', 'application/*+json']),
    serializer: JSON.stringify,
  },
  {
    test: (value: string) => !!typeIs(value, ['application/xml', 'application/*+xml']),
    serializer: (data: unknown) => (typeof data === 'string' ? data : xmlSerializer.parse({ xml: data })),
  },
  {
    test: (value: string) => !!typeIs(value, ['text/*']),
    serializer: (data: unknown) => {
      if (['string', 'undefined'].includes(typeof data)) {
        return data;
      }

      throw Object.assign(new Error('Cannot serialise complex objects as text'), {
        detail: 'Cannot serialise complex objects as text',
        status: 500,
        name: 'https://stoplight.io/prism/errors#NO_COMPLEX_OBJECT_TEXT',
      });
    },
  },
];

export const serialize = (payload: unknown, contentType?: string) => {
  if (!contentType && !payload) {
    return;
  }

  const serializer = contentType ? serializers.find(s => s.test(contentType)) : undefined;

  if (!serializer) {
    if (typeof payload === 'string') return payload;

    throw new Error(`Cannot find serializer for ${contentType}`);
  }

  return serializer.serializer(payload);
};


text:
local spawnProtectionTime = 18000

local hospitals = {
	-- ['name'] = { start x, start y, start z, end x, end y, end z, rot }
	['Saint General Hospital'] = { 1177.26, -1324.92, 14.06, 1205.53, -1332.19, 23, -90 },
	['County General Hospital'] = { 2029.25, -1419.17, 16.99, 1972.12, -1469.78, 35, 180 },
	['Las Venturas Hospital'] = { 1607.06, 1825.09, 10.82, 1622.59, 1855.38, 10, 0 },
	['Medical Clinic'] = { 2546.67, 1971.37, 10.82, 2566.92, 1936.79, 20, 180 },
	['Fort Carson Medical Center'] = { -320.21, 1055.96, 20, -302.87, 1072.36, 19, 0 },
	['San Fierro Medical Center'] = { -2644.37, 633.05, 14.45, -2621.81, 586.03, 23, 180 },
	['Angel Pine Medical Center'] = { -2201.14, -2292.66, 30.63, -2184.92, -2285.6, 35, 320.8 },
	['Crippen Memorial Hospital'] = { 1371.24, 406.06, 19.76, 1349.78, 401.49, 19.56, 85 },
	['El Quebrados Medical Center'] = { -1514.47, 2527.25, 55.74, -1505.11, 2549.74, 62, 0 }
}

addEvent ( "NGHospitals:onClientRequestLocations", true )
addEventHandler ( "NGHospitals:onClientRequestLocations", root, function ( )
	triggerClientEvent ( source, "NGHospitals:onServerSendClientLocRequest", source, hospitals )
end )

addEventHandler ( 'onPlayerWasted', root, function ( )
	exports['NGLogs']:outputActionLog ( getPlayerName ( source ).." died" )
	local weapons = { }
	for i=1,12 do weapons[i] = { getPedWeapon ( source, i ), getPedTotalAmmo ( source, i ) } end
	setTimer ( function ( p, weapons )
		local data = getNearestHospital ( p )
		data[9] = getElementModel ( p )
		data[10] = weapons
		triggerClientEvent ( p, 'NGHospitals:onClientWasted', p, data )
	end, 2000, 1, source, weapons )
end )

addEvent ( "NGHospitals:triggerPlayerSpawn", true )
addEventHandler ( "NGHospitals:triggerPlayerSpawn", root, function ( d )
	spawnPlayer ( source, d[2], d[3], d[4], d[8], d[9], 0, 0 )

	for i, v in pairs ( d[10] ) do
		giveWeapon ( source, v[1], v[2] )
	end
	setElementData ( source, "isSpawnProtectionEnabled", true )
	setElementData ( source, "isGodmodeEnabled", true )
	setElementAlpha ( source, 180 )
	toggleControl ( source, "fire", false )
	toggleControl ( source, "next_weapon", false )
	toggleControl ( source, "previous_weapon", false )

	setTimer ( function ( source )
		if ( not isElement ( source ) ) then return end
		outputChatBox ( "Spawn protection ending in 3...", source, 0, 255, 255 )
		setTimer ( function ( source )
			if ( not isElement ( source ) ) then return end
			outputChatBox ( "Spawn protection ending in 2...", source, 0, 255, 255 )
			setTimer ( function ( source )
				if ( not isElement ( source ) ) then return end
				outputChatBox ( "Spawn protection ending in 1...", source, 0, 255, 255 )
				setTimer ( function ( source )
					if ( not isElement ( source ) ) then return end
					outputChatBox ( "Spawn protection ended! You can now die.", source, 255, 0, 0 )
					setElementData ( source, "isGodmodeEnabled", false )
					setElementData ( source, "isSpawnProtectionEnabled", false )
					setElementAlpha ( source, 255 )

					toggleControl ( source, "fire", true )
					toggleControl ( source, "next_weapon", true )
					toggleControl ( source, "previous_weapon", true )
				end, 1000, 1, source )
			end, 1000, 1, source )
		end, 1000, 1, source )
	end, spawnProtectionTime-3000, 1, source )
end )

function getNearestHospital ( p )
	local dist = 9999999
	local loadedI = nil
	local data = nil
	for ind, var in pairs ( hospitals ) do
		local x, y, z = getElementPosition ( p )
		local c = getDistanceBetweenPoints3D ( x, y, z, var[1], var[2], var[3] )
		if ( c <= dist ) then
			dist = c
			loadedI = ind
			data = { ind, var[1], var[2], var[3], var[4], var[5], var[6], var[7] }
		end
	end
	return data
end

addEventHandler ( 'onVehicleDamage', root, function ( loss )
	local driver = getVehicleOccupant ( source )
	if driver and getElementData ( driver, 'isSpawnProtectionEnabled' ) then
		setElementHealth ( source, getElementHealth ( source ) + loss )
	end
end )


text:
import { RSAA } from "redux-api-middleware";
import { arrayOf } from "normalizr";

import spaceSchema from "dyn-load/schemas/space";

import APICall from "@app/core/APICall";
import schemaUtils from "utils/apiUtils/schemaUtils";
import actionUtils from "utils/actionUtils/actionUtils";
import {
  getParamsForSpacesUrl,
  updateSpacePermissions,
} from "dyn-load/actions/resources/spacesMixin";
import FormUtils from "dyn-load/utils/FormUtils/FormUtils";

export const SPACES_LIST_LOAD_START = "SPACES_LIST_LOAD_START";
export const SPACES_LIST_LOAD_SUCCESS = "SPACES_LIST_LOAD_SUCCESS";
export const SPACES_LIST_LOAD_FAILURE = "SPACES_LIST_LOAD_FAILURE";

export const ALL_SPACES_VIEW_ID = "AllSpaces";
function fetchSpaceListData(includeDatasetCount = false) {
  const meta = { viewId: ALL_SPACES_VIEW_ID, replaceEntities: true };

  const apiCall = new APICall()
    .path("catalog")
    .params({ include: getParamsForSpacesUrl(includeDatasetCount) })
    .uncachable();

  return {
    [RSAA]: {
      types: [
        { type: SPACES_LIST_LOAD_START, meta },
        schemaUtils.getSuccessActionTypeWithSchema(
          SPACES_LIST_LOAD_SUCCESS,
          { data: arrayOf(spaceSchema) },
          meta
        ),
        { type: SPACES_LIST_LOAD_FAILURE, meta },
      ],
      method: "GET",
      endpoint: apiCall,
    },
  };
}

export function loadSpaceListData() {
  return (dispatch) => {
    return dispatch(fetchSpaceListData()).then(
      dispatch(fetchSpaceListData(true))
    );
  };
}

export const SAVE_SPACE_START = "SAVE_SPACE_START";
export const SAVE_SPACE_SUCCESS = "SAVE_SPACE_SUCCESS";
export const SAVE_SPACE_FAILURE = "SAVE_SPACE_FAILURE";

function saveSpace(values, isCreate) {
  const meta = {
    invalidateViewIds: [ALL_SPACES_VIEW_ID], // cause data reload. See SpacesLoader
    mergeEntities: true,
    notification: {
      message: isCreate
        ? la("Successfully created.")
        : la("Successfully updated."),
      level: "success",
    },
  };
  // AccessControlsListSection mutates submit values to include "userControls" and
  // "groupControls" instead of "users" and "groups", expected in V3 /catalog/ API.
  const space = FormUtils.makeSpaceFromFormValues(values);

  const apiCall = new APICall();
  apiCall.path("catalog");

  if (!isCreate) {
    apiCall.path(space.id);
  }

  return {
    [RSAA]: {
      types: [
        SAVE_SPACE_START,
        schemaUtils.getSuccessActionTypeWithSchema(
          SAVE_SPACE_SUCCESS,
          spaceSchema,
          meta
        ),
        SAVE_SPACE_FAILURE,
      ],
      method: isCreate ? "POST" : "PUT",
      body: JSON.stringify(space),
      endpoint: apiCall,
    },
  };
}

export function createNewSpace(values) {
  return saveSpace(values, true);
}

export function updateSpace(values) {
  return saveSpace(values, false);
}

export function updateSpacePrivileges(values) {
  return updateSpacePermissions(values);
}

export const REMOVE_SPACE_START = "REMOVE_SPACE_START";
export const REMOVE_SPACE_SUCCESS = "REMOVE_SPACE_SUCCESS";
export const REMOVE_SPACE_FAILURE = "REMOVE_SPACE_FAILURE";

export function removeSpace(spaceId, spaceVersion) {
  const meta = {
    id: spaceId,
    invalidateViewIds: [ALL_SPACES_VIEW_ID], // cause data reload. See SpacesLoader
  };
  const errorMessage = la("There was an error removing the space.");

  const apiCall = new APICall()
    .path("catalog")
    .path(spaceId)
    .params({ tag: spaceVersion });

  return {
    [RSAA]: {
      types: [
        {
          type: REMOVE_SPACE_START,
          meta,
        },
        {
          type: REMOVE_SPACE_SUCCESS,
          meta: { ...meta, success: true },
        },
        {
          type: REMOVE_SPACE_FAILURE,
          meta: {
            ...meta,
            notification: actionUtils.humanizeNotificationMessage(errorMessage),
          },
        },
      ],
      method: "DELETE",
      endpoint: apiCall,
    },
  };
}


text:
Public Enum BaseReferenceType
    rftNone = 0
    rftTestStatus = 19000001
    rftActivityType = 19000002
    rftAdministativeLevel = 19000003
    rftAggregateFunction = 19000004
    rftAnimalAgeList = 19000005
    rftAnimalCondition = 19000006
    rftAnimalSex = 19000007
    rftAvianFarmType = 19000008
    rftCaseHistory = 19000010
    rftCaseClassification = 19000011
    rftCaseType = 19000012
    rftChart = 19000013
    rftContact_Type = 19000014
    rftSampleStatus = 19000015
    rftDataAuditEventType = 19000016
    rftDataAuditObjectType = 19000017
    rftDataExportDetailStatus = 19000018
    rftDiagnosis = 19000019
    rftDiagnosisUsingType = 19000020
    rftDiagnosticActionList = 19000021
    rftEmpGroupName = 19000022
    rftEmployeeType = 19000023
    rftEventType = 19000025
    rftFFCheckPoint = 19000028
    rftFFRule = 19000029
    rftFFRuleAction = 19000030
    rftFFRuleFunction = 19000031
    rftFFRuleMessage = 19000032
    rftFFTemplate = 19000033
    rftFFType = 19000034
    rftPatientState = 19000035
    rftGeoLocType = 19000036
    rftGroundType = 19000038
    rftGroupInterval = 19000039
    rftHA_Code_List = 19000040
    rftHospStatus = 19000041
    rftHumanAgeType = 19000042
    rftHumanGender = 19000043
    rftInstitutionAbbr = 19000045
    rftInstitutionName = 19000046
    rftLabelDBField = 19000047
    rftLabelType = 19000048
    rftLanguage = 19000049
    rftLayoutName = 19000050
    rftMeasures = 19000052
    rftMovementPattern = 19000053
    rftNationality = 19000054
    rftNotificationType = 19000056
    rftNumberingType = 19000057
    rftObjectActorType = 19000058
    rftObjectOperation = 19000059
    rftObjectType = 19000060
    rftOccupationType = 19000061
    rftOfficeType = 19000062
    rftOutbreakStatus = 19000063
    rftOutcome = 19000064
    rftOwnershipType = 19000065
    rftParameter = 19000066
    rftParameterEditorType = 19000067
    rftParameterMode = 19000068
    rftParametersFixedPresetValue = 19000069
    rftParameterToolTip = 19000070
    rftParameterType = 19000071
    rftPosition = 19000073
    rftProphilacticActionList = 19000074
    rftQueryName = 19000075
    rftReferenceTypeName = 19000076
    rftReportValues = 19000077
    rftSanitaryActionList = 19000079
    rftSearchField = 19000080
    rftSearchFieldType = 19000081
    rftSearchObject = 19000082
    rftSiteRelation_Type = 19000084
    rftSiteType = 19000085
    rftSpeciesList = 19000086
    rftSampleType = 19000087
    rftStatisticalAreas = 19000088
    rftStatisticAreaType = 19000089
    rftStatisticDataType = 19000090
    rftStatisticPeriodType = 19000091
    rftStorageType = 19000092
    rftSubdivisionType = 19000093
    rftSystemFunction = 19000094
    rftTestCategory = 19000095
    rftTestResult = 19000096
    rftTestName = 19000097
    rftVaccinationRoute = 19000098
    rftVaccinationType = 19000099
    rftYesNoValue = 19000100
    rftSection = 19000101
    rftAggregateCaseType = 19000102
    rftVetCaseLogStatus = 19000103
    rftPensideTestType = 19000104
    rftPensideTestResult = 19000105
    rftRuleInValue = 19000106
    rftDiagnosisConfirmationMethod = 19000107
    rftDecorateElementType = 19000108
    rftObjectTypeRelation = 19000109
    rftAccessionCondition = 19000110
    rftCaseProgressStatus = 19000111
    rftSecurityAuditAction = 19000112
    rftSecurityAuditResult = 19000113
    rftSecurityAuditProcessType = 19000114
    rftCampaignStatus = 19000115
    rftCampaignType = 19000116
    rftMonitoringSessionStatus = 19000117
    rftSecurityLevel = 19000119
    rftQueryDescription = 19000121
    rftLayoutDescription = 19000122
    rftFolderName = 19000123
    rftPivotName = 19000124
    rftChartName = 19000125
    rftMapName = 19000126
    rftMonitoringSessionActionType = 19000127
    rftMonitoringSessionActionStatus = 19000128
    rftSummaryReportType = 19000129
    rftReportDiagnosisGroup = 19000130
    rftFlexibleFormLabelText = 19000131
    rftReportAdditionalText = 19000132
    rftVectorSurveillanceSessionStatus = 19000133
    rftPensideTestCategory = 19000134
    rftCollectionMethod = 19000135
    rftCollectionTimePeriod = 19000136
    rftBasisOfRecord = 19000137
    rftIdentificationMethod = 19000138
    rftSurrounding = 19000139
    rftVectorType = 19000140
    rftVectorSubType = 19000141
    rftLayoutFieldName = 19000143
    rftCaseReportType = 19000144
    rftStatisticalAgeGroup = 19000145
    rftDiagnosisAgeGroup = 19000146
    rftChangeDiagnosisReason = 19000147
    rftPersonIDType = 19000148
    rftNonNotifiableDiagnosis = 19000149
    rftNotCollectedReason = 19000150
    rftMatrixType = 19000151
    rftMatrixColumn = 19000152
    rftEventSubscriptions = 19000155
    rftDiagnosisGroup = 19000156
    rftDestructionMethod = 19000157
    rftSampleKind = 19000158
    rftBssType = 19000159
    rftBssMethodOfMeasurement = 19000160
    rftBssOutcome = 19000161
    rftBssTestResult = 19000162
    rftBssAggregateColumns = 19000163
End Enum


text:
package org.sana.android.procedure;

import java.net.URISyntaxException;
import java.text.SimpleDateFormat;

import org.sana.android.Constants;
import org.sana.android.app.Preferences;
import org.sana.android.content.core.ObservationWrapper;
import org.sana.android.provider.Observations;
import org.w3c.dom.Node;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;

/**
 * TextElement is an answer-less ProcedureElement that represents a block of
 * text on a procedure page.
 *

 *

 *
Clinical UseWherever displaying a block of text may be useful.

 *
Collects
Nothing. Displays only.

 *

 *
 * @author Sana Dev Team
 */
public class HiddenElement extends ProcedureElement {
	public static final String TAG = HiddenElement.class.getSimpleName();
    /** {@inheritDoc} */
    @Override
    protected View createView(Context c) {
        return encapsulateQuestion(c, null);
    }

    /** {@inheritDoc} */
    @Override
    public ElementType getType() {
        return ElementType.HIDDEN;
    }

    /** {@inheritDoc} */
    @Override
    public String getAnswer() {
        Log.i(TAG, "getAnswer()");
        // set the default value if answer is empty
        if(TextUtils.isEmpty(answer) && hasDefault()){
            Log.d(TAG, "\tUsing default value");
            setAnswer(getDefault());
        }
        return answer;
    }

    public void setAnswer(String answer){
        Log.i(TAG, "setAnswer(String)");
        // set the default value if answer is empty
        if(TextUtils.isEmpty(answer) && hasDefault()){
            Log.w(TAG, "\tUsing default value");
            answer = getDefault();
        }
        this.answer = answer;
    }

    @Override
    public boolean isViewActive(){
    	return false;
    }

    public Intent getIntent(){

		Intent intent = null;
		try {
			intent = Intent.parseUri(action, Intent.URI_INTENT_SCHEME);
			intent.putExtra(Observations.Contract.ID, id);
			intent.putExtra(Observations.Contract.CONCEPT, concept);
		} catch (URISyntaxException e) {
			e.printStackTrace();
		}
		return intent;
    }

    public String getDefault(){
        Log.i(TAG, "getDefault()");
        final SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
        StringBuilder sb = new StringBuilder();
        String val = super.getDefault();
        for(String str:val.split(":")){
            if(str.length() > 1 && str.startsWith("@")){
                    str = str.substring(1);
                    if(str.compareTo("DEVICE") == 0){
                        // Get device id
                        str = Preferences.getString(getContext(),
                                Constants.PREFERENCE_PHONE_NAME);
                    } else if (str.compareTo("NOW") == 0){
                        // formats current date time as 'yyyyMMddHHmmss'
                        str = df.format(new java.util.Date());
                    }
            }
            sb.append(str);
        }
        return sb.toString();
    }

    /** Default constructor */
    private HiddenElement(String id, String question, String answer,
    		String concept, String figure, String audio)
    {
        super(id, question, answer, concept, figure, audio);
    }

    /** @see ProcedureElement#fromXML(String, String, String, String, String, String, Node) */
    public static HiddenElement fromXML(String id, String question, String answer,
    	String concept, String figure, String audio, Node node)
		throws ProcedureParseException
    {
    	HiddenElement el = new HiddenElement(id, question, answer, concept, figure, audio);
    	ProcedureElement.parseOptionalAttributes(node, el);
    	return el;
    }
}


text:
package org.apereo.cas.adaptors.u2f.storage;

import org.apereo.cas.util.crypto.CipherExecutor;

import lombok.val;

import java.io.Serializable;
import java.util.Collection;

/**
 * This is {@link U2FDeviceRepository}.
 *
 * @author Misagh Moayyed
 * @since 5.1.0
 */
public interface U2FDeviceRepository {

    /**
     * Gets registrations.
     *
     * @param username the username
     * @return the registrations
     */
    Collection<? extends U2FDeviceRegistration> getRegisteredDevices(String username);

    /**
     * Gets registrations.
     *
     * @return the registrations
     */
    Collection<? extends U2FDeviceRegistration> getRegisteredDevices();

    /**
     * Add registration.
     *
     * @param registration the registration
     * @return u2f device registration
     */
    U2FDeviceRegistration registerDevice(U2FDeviceRegistration registration);

    /**
     * Deliver authenticated device upon successful authentication events.
     *
     * @param registration the registration
     * @return u2f device registration
     */
    U2FDeviceRegistration verifyRegisteredDevice(U2FDeviceRegistration registration);

    /**
     * Delete registered device.
     *
     * @param registration the registration
     */
    void deleteRegisteredDevice(U2FDeviceRegistration registration);

    /**
     * Is registered ?
     *
     * @param username the username
     * @return true/false
     */
    boolean isDeviceRegisteredFor(String username);

    /**
     * Gets device registration request.
     *
     * @param requestId the request id
     * @param username  the username
     * @return the device registration request in JSON
     */
    String getDeviceRegistrationRequest(String requestId, String username);

    /**
     * Gets device authentication request.
     *
     * @param requestId the request id
     * @param username  the username
     * @return the device authentication request
     */
    String getDeviceAuthenticationRequest(String requestId, String username);

    /**
     * Request device registration.
     *
     * @param requestId            the request id
     * @param username             the username
     * @param registrationJsonData the registration json data
     */
    void requestDeviceRegistration(String requestId, String username, String registrationJsonData);

    /**
     * Request device authentication.
     *
     * @param requestId            the request id
     * @param username             the username
     * @param registrationJsonData the registration json data
     */
    void requestDeviceAuthentication(String requestId, String username, String registrationJsonData);

    /**
     * Clean up repository to remove expired records.
     */
    void clean();

    /**
     * Clean up repository to remove all records.
     *
     * @throws Exception the exception
     */
    void removeAll() throws Exception;

    /**
     * Gets cipher executor.
     *
     * @return the cipher executor
     */
    CipherExecutor<Serializable, String> getCipherExecutor();

    /**
     * Decode u2f device registration.
     *
     * @param registration the registration
     * @return the u2f device registration
     */
    default U2FDeviceRegistration decode(U2FDeviceRegistration registration) {
        val record = registration.clone();
        val data = getCipherExecutor().decode(record.getRecord());
        record.setRecord(data);
        return record;
    }
}


text:
package com.example.mypc.eyepetizer.ui.authorfragment;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.example.mypc.eyepetizer.AuthorBean;
import com.example.mypc.eyepetizer.R;
import com.example.mypc.eyepetizer.base.BaseFragment;

import java.util.List;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class AuthorFragment extends BaseFragment implements AuthorFragmentContract.View{

    private static Handler handler=new Handler();
    @BindView(R.id.author_rv)
    RecyclerView authorRv;
    private AuthorFragmentPresenter presenter;
    private AuthorFragmentModel model;
    public AuthorFragment() {
        // Required empty public constructor
    }

    @Override
    public int getContentViewId() {
        return R.layout.fragment_author_layout;
    }
    @Override
    protected void initAllMembersView(Bundle savedInstanceState) {
        model=new AuthorFragmentModel();
        presenter=new AuthorFragmentPresenter(model,this);
        presenter.getData(null);
        LinearLayoutManager manager = new LinearLayoutManager(getActivity());
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        authorRv.setLayoutManager(manager);
    }

    @Override
    public void getAuthorData(final AuthorBean authorBean) {
        handler.post(new Runnable() {
            @Override
            public void run() {
                AuthorAdapter adapter=new AuthorAdapter();
                List<AuthorBean.ItemListBean> itemList = authorBean.getItemList();
                adapter.setData(itemList,getActivity());
                authorRv.setAdapter(adapter);
            }
        });
    }

    @Override
    public void getAuthorDataFail(String s) {
        Toast.makeText(getActivity(),s,Toast.LENGTH_SHORT).show();
    }
}


text:
"""
Flagon errors.
"""

class FlagonError(Exception):
    """
    Base Flagon error.
    """
    pass

class UnknownFeatureError(FlagonError):
    """
    When a feature is not configured but is used.
    """
    pass


text:
{% extends 'konfera/base.html' %}
{% load i18n %}
{% load custom_filters %}

{% block title %}
    {% trans "Available tickets" %}
{% endblock %}

{% block content_details %}

        {% for ticket in tickets %}

 {{ ticket.title }}

{{ ticket.description }}

{% trans "Price" %}: {{ ticket.price|currency }}

        {%  endfor %}

    {% if tickets.num_pages > 1 %}

                {% if tickets.has_previous %}

                        «

                {% endif %}

                {% for page in tickets.paginator.page_range %}

 {{ page }}

                {% endfor %}

                {% if tickets.has_next %}

                        »

                {% endif %}

    {% endif %}
    {% block bottom_public_tickets %}{% endblock %}
{% endblock %}


text:
import requests.exceptions as exceptions

class HTTPError(exceptions.HTTPError):
    pass

class ConnectionError(exceptions.ConnectionError):
    pass

class ProxyError(exceptions.ProxyError):
    pass

class SSLError(exceptions.SSLError):
    pass

class Timeout(exceptions.Timeout):
    pass

class ConnectTimeout(exceptions.ConnectTimeout):
    pass

class ReadTimeout(exceptions.ReadTimeout):
    pass

class URLRequired(exceptions.URLRequired):
    pass

class TooManyRedirects(exceptions.TooManyRedirects):
    pass

class MissingSchema(exceptions.MissingSchema):
    pass

class InvalidSchema(exceptions.InvalidSchema):
    pass

class InvalidURL(exceptions.InvalidURL):
    pass

class InvalidHeader(exceptions.InvalidHeader):
    pass

class ChunkedEncodingError(exceptions.ChunkedEncodingError):
    pass

class ContentDecodingError(exceptions.ContentDecodingError):
    pass

class StreamConsumedError(exceptions.StreamConsumedError):
    pass

class RetryError(exceptions.RetryError):
    pass

class UnrewindableBodyError(exceptions.UnrewindableBodyError):
    pass

# Warnings

class RequestsWarning(exceptions.RequestsWarning):
    pass

class FileModeWarning(exceptions.FileModeWarning):
    pass


text:
using System;
using System.IO;
using DiscUtils.Registry;
using Xunit;

namespace LibraryTests.Registry
{
    public class RegistryKeyTest
    {
        private RegistryHive hive;

        public RegistryKeyTest()
        {
            hive = RegistryHive.Create(new MemoryStream());
        }

        [Fact]
        public void SetDefaultValue()
        {
            hive.Root.SetValue("", "A default value");
            Assert.Equal("A default value", (string)hive.Root.GetValue(""));

            hive.Root.SetValue(null, "Foobar");
            Assert.Equal("Foobar", (string)hive.Root.GetValue(null));

            hive.Root.SetValue(null, "asdf");
            Assert.Equal("asdf", (string)hive.Root.GetValue(""));
        }

        [Fact]
        public void ValueNameCaseSensitivity()
        {
            hive.Root.SetValue("nAmE", "value");
            Assert.Equal("value", (string)hive.Root.GetValue("NaMe"));

            hive.Root.SetValue("moreThanFourCharName", "foo");
            Assert.Equal("foo", (string)hive.Root.GetValue("moretHANfOURcHARnAME"));

            Assert.Equal(2, hive.Root.ValueCount);
            hive.Root.SetValue("NaMe", "newvalue");
            Assert.Equal(2, hive.Root.ValueCount);
            Assert.Equal("newvalue", (string)hive.Root.GetValue("NaMe"));
        }

        [Fact]
        public void SetLargeValue()
        {
            byte[] buffer = new byte[64 * 1024];
            buffer[5232] = 0xAD;
            hive.Root.SetValue("bigvalue", buffer);

            byte[] readVal = (byte[])hive.Root.GetValue("bigvalue");
            Assert.Equal(buffer.Length, readVal.Length);
            Assert.Equal(0xAD, readVal[5232]);
        }

        [Fact]
        public void SetStringValue()
        {
            hive.Root.SetValue("value", "string");
            Assert.Equal(RegistryValueType.String, hive.Root.GetValueType("value"));
            Assert.Equal("string", (string)hive.Root.GetValue("value"));

            hive.Root.SetValue("emptyvalue", "");
            Assert.Equal(RegistryValueType.String, hive.Root.GetValueType("emptyvalue"));
            Assert.Equal("", (string)hive.Root.GetValue("emptyvalue"));
        }

        [Fact]
        public void SetIntegerValue()
        {
            hive.Root.SetValue("value", 0x7342BEEF);
            Assert.Equal(RegistryValueType.Dword, hive.Root.GetValueType("value"));
            Assert.Equal(0x7342BEEF, (int)hive.Root.GetValue("value"));
        }

        [Fact]
        public void SetByteArrayValue()
        {
            hive.Root.SetValue("value", new byte[] { 1, 2, 3, 4 });
            Assert.Equal(RegistryValueType.Binary, hive.Root.GetValueType("value"));
            byte[] readVal = (byte[])hive.Root.GetValue("value");
            Assert.Equal(4, readVal.Length);
            Assert.Equal(3, readVal[2]);
        }

        [Fact]
        public void SetStringArrayValue()
        {
            hive.Root.SetValue("value", new string[] { "A", "B", "C" });
            Assert.Equal(RegistryValueType.MultiString, hive.Root.GetValueType("value"));
            string[] readVal = (string[])hive.Root.GetValue("value");
            Assert.Equal(3, readVal.Length);
            Assert.Equal("C", readVal[2]);
        }

        [Fact]
        public void SetEnvStringValue()
        {
            hive.Root.SetValue("value", "string", RegistryValueType.ExpandString);
            Assert.Equal(RegistryValueType.ExpandString, hive.Root.GetValueType("value"));
            Assert.Equal("string", (string)hive.Root.GetValue("value"));

            hive.Root.SetValue("value", "str%windir%ing", RegistryValueType.ExpandString);
            Assert.Equal(RegistryValueType.ExpandString, hive.Root.GetValueType("value"));
            Assert.Equal("str" + Environment.GetEnvironmentVariable("windir") + "ing", (string)hive.Root.GetValue("value"));

            hive.Root.SetValue("emptyvalue", "", RegistryValueType.ExpandString);
            Assert.Equal(RegistryValueType.ExpandString, hive.Root.GetValueType("emptyvalue"));
            Assert.Equal("", (string)hive.Root.GetValue("emptyvalue"));
        }

        [Fact]
        public void DeleteValue()
        {
            hive.Root.SetValue("aValue", "value");
            hive.Root.SetValue("nAmE", "value");
            hive.Root.SetValue("otherValue", "value");
            Assert.Equal(3, hive.Root.ValueCount);

            hive.Root.DeleteValue("NaMe");
            Assert.Equal(2, hive.Root.ValueCount);
        }

        [Fact]
        public void DeleteOnlyValue()
        {
            hive.Root.SetValue("nAmE", "value");
            Assert.Equal(1, hive.Root.ValueCount);

            hive.Root.DeleteValue("NaMe");
            Assert.Equal(0, hive.Root.ValueCount);
        }

        [Fact]
        public void DeleteDefaultValue()
        {
            hive.Root.SetValue("", "value");
            Assert.Equal(1, hive.Root.ValueCount);

            hive.Root.DeleteValue(null);
            Assert.Equal(0, hive.Root.ValueCount);
        }

        [Fact]
        public void EnumerateValues()
        {
            hive.Root.SetValue(@"C", "");
            hive.Root.SetValue(@"A", "");
            hive.Root.SetValue(@"B", "");

            string[] names = hive.Root.GetValueNames();
            Assert.Equal(3, names.Length);
            Assert.Equal("A", names[0]);
            Assert.Equal("B", names[1]);
            Assert.Equal("C", names[2]);
        }

        [Fact]
        public void CreateKey()
        {
            RegistryKey newKey = hive.Root.CreateSubKey(@"Child\Grandchild");
            Assert.NotNull(newKey);
            Assert.Equal(1, hive.Root.SubKeyCount);
            Assert.Equal(1, hive.Root.OpenSubKey("cHiLd").SubKeyCount);
        }

        [Fact]
        public void CreateExistingKey()
        {
            RegistryKey newKey = hive.Root.CreateSubKey(@"Child");
            Assert.NotNull(newKey);
            Assert.Equal(1, hive.Root.SubKeyCount);

            newKey = hive.Root.CreateSubKey(@"cHILD");
            Assert.NotNull(newKey);
            Assert.Equal(1, hive.Root.SubKeyCount);
        }

        [Fact]
        public void DeleteKey()
        {
            RegistryKey newKey = hive.Root.CreateSubKey(@"Child");
            hive.Root.OpenSubKey(@"Child").SetValue("value", "a value");
            Assert.Equal(1, hive.Root.SubKeyCount);
            hive.Root.DeleteSubKey("cHiLd");
            Assert.Equal(0, hive.Root.SubKeyCount);
        }

        [Fact]
        public void DeleteNonEmptyKey()
        {
            RegistryKey newKey = hive.Root.CreateSubKey(@"Child\Grandchild");
            Assert.Throws<InvalidOperationException>(() => hive.Root.DeleteSubKey("Child"));
        }

        [Fact]
        public void DeleteKeyTree()
        {
            RegistryKey newKey = hive.Root.CreateSubKey(@"Child\Grandchild");
            Assert.Equal(1, hive.Root.SubKeyCount);
            hive.Root.DeleteSubKeyTree("cHiLd");
            Assert.Equal(0, hive.Root.SubKeyCount);
        }

        [Fact]
        public void EnumerateSubKeys()
        {
            hive.Root.CreateSubKey(@"C");
            hive.Root.CreateSubKey(@"A");
            hive.Root.CreateSubKey(@"B");

            string[] names = hive.Root.GetSubKeyNames();
            Assert.Equal(3, names.Length);
            Assert.Equal("A", names[0]);
            Assert.Equal("B", names[1]);
            Assert.Equal("C", names[2]);
        }
    }
}


text:
package org.iotivity.cloud.accountserver.util;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 *
 * This class provides utility for parsing JSON object and converting data to
 * JSON string.
 *
 */
public class JSONUtil {

    private static ObjectMapper mapper = new ObjectMapper();

    public String parseJSON(String jsonString, String key) {

        if (jsonString == null || jsonString.equals(""))
            return null;

        String value = null;

        try {
            @SuppressWarnings("unchecked")
            Map<String, String> jsonMap = mapper.readValue(jsonString,
                    Map.class);
            value = jsonMap.get(key);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }

        return value;
    }

    public String writeJSON(HashMap<Object, Object> data) {
        if (data == null)
            return null;

        String json = null;
        try {
            json = mapper.writeValueAsString(data);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

        if (json == null)
            json = "{}";

        return json;
    }
}


text:
package jsettlers.logic.timer;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;

import jsettlers.common.map.MapLoadException;
import jsettlers.logic.constants.MatchConstants;
import jsettlers.network.client.interfaces.IGameClock;
import jsettlers.network.synchronic.timer.INetworkTimerable;

public final class RescheduleTimer implements INetworkTimerable, Serializable {
	private static final long serialVersionUID = -1962430988827211391L;

	private static final int FUTURE_TIME = 32000;
	private static final short TIME_SLICE = 25; // ms
	private static final int TIME_SLOTS = FUTURE_TIME / TIME_SLICE;

	private static RescheduleTimer uniIns;

	@SuppressWarnings("unchecked")
	private final ArrayList<IScheduledTimerable> timerables[] = new ArrayList[TIME_SLOTS];
	private int currTimeSlot = 0;

	protected RescheduleTimer() {
		for (int i = 0; i < TIME_SLOTS; i++) {
			timerables[i] = new ArrayList<IScheduledTimerable>();
		}
	}

	public static synchronized void stopAndClear() {
		if (uniIns != null) {
			if (MatchConstants.clock() != null) {
				MatchConstants.clock().remove(uniIns);
			}
			uniIns = null;
			try {
				Thread.sleep(100); // stopping takes some time
			} catch (InterruptedException e) {
			}
		}
	}

	/**
	 * Schedules the given {@link IScheduledTimerable} in max delay milliseconds.
	 *
	 * @param t
	 * @param delay
	 */
	public static void add(IScheduledTimerable t, int delay) {
		get().addTimerable(t, delay);
	}

	private void addTimerable(IScheduledTimerable t, int delay) {
		if (delay <= 0) {
			return; // don't schedule if requested delay is negative or zero
		}

		int delaySlots = delay / TIME_SLICE;
		delaySlots = delaySlots > 0 ? delaySlots : 1; // ensure at least one slot delay

		assert delaySlots < TIME_SLOTS : "SCHEDULED TO FAR IN THE FUTURE! " + delay + "ms";

		timerables[(currTimeSlot + delaySlots) % TIME_SLOTS].add(t);
	}

	private static synchronized RescheduleTimer get() {
		if (uniIns == null) {
			uniIns = new RescheduleTimer();
		}
		return uniIns;
	}

	@Override
	public void timerEvent() {
		ArrayList<IScheduledTimerable> queue = timerables[currTimeSlot];

		for (IScheduledTimerable curr : queue) {
			if (uniIns != this) { // fast stop when stopAndClear() is called.
				return;
			}

			try {
				int delay = curr.timerEvent();
				addTimerable(curr, delay);
			} catch (Throwable t) {
				System.err.println("RescheduleTimer catched: ");
				t.printStackTrace();
				try {
					curr.kill();
				} catch (Throwable t2) {
					System.err.println("RescheduleTimer had trouble killing bad timerable!");
					t2.printStackTrace();
				}
			}
		}

		queue.clear();
		currTimeSlot = (currTimeSlot + 1) % TIME_SLOTS;
	}

	public static void loadFrom(ObjectInputStream ois) throws MapLoadException {
		try {
			stopAndClear();
			uniIns = (RescheduleTimer) ois.readObject();
		} catch (Throwable t) {
			throw new MapLoadException(t);
		}
	}

	public static void saveTo(ObjectOutputStream oos) throws IOException {
		oos.writeObject(uniIns);
		oos.flush();
	}

	public static void schedule(IGameClock gameClock) {
		gameClock.schedule(get(), TIME_SLICE);
	}
}


text:
package com.sedmelluq.discord.lavaplayer.container.mpegts;

import com.sedmelluq.discord.lavaplayer.container.MediaContainerDetectionResult;
import com.sedmelluq.discord.lavaplayer.container.MediaContainerHints;
import com.sedmelluq.discord.lavaplayer.container.MediaContainerProbe;
import com.sedmelluq.discord.lavaplayer.container.adts.AdtsStreamReader;
import com.sedmelluq.discord.lavaplayer.tools.io.SavedHeadSeekableInputStream;
import com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream;
import com.sedmelluq.discord.lavaplayer.track.AudioReference;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoBuilder;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.sedmelluq.discord.lavaplayer.container.MediaContainerDetectionResult.supportedFormat;
import static com.sedmelluq.discord.lavaplayer.container.mpegts.MpegTsElementaryInputStream.ADTS_ELEMENTARY_STREAM;

public class MpegAdtsContainerProbe implements MediaContainerProbe {
  private static final Logger log = LoggerFactory.getLogger(MpegAdtsContainerProbe.class);

  @Override
  public String getName() {
    return "mpegts-adts";
  }

  @Override
  public boolean matchesHints(MediaContainerHints hints) {
    return "ts".equalsIgnoreCase(hints.fileExtension);
  }

  @Override
  public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream)
      throws IOException {

    SavedHeadSeekableInputStream head = inputStream instanceof SavedHeadSeekableInputStream ?
        (SavedHeadSeekableInputStream) inputStream : null;

    if (head != null) {
      head.setAllowDirectReads(false);
    }

    MpegTsElementaryInputStream tsStream = new MpegTsElementaryInputStream(inputStream, ADTS_ELEMENTARY_STREAM);
    PesPacketInputStream pesStream = new PesPacketInputStream(tsStream);
    AdtsStreamReader reader = new AdtsStreamReader(pesStream);

    try {
      if (reader.findPacketHeader() != null) {
        log.debug("Track {} is an MPEG-TS stream with an ADTS track.", reference.identifier);

        return supportedFormat(this, null,
            AudioTrackInfoBuilder.create(reference, inputStream)
                .apply(tsStream.getLoadedMetadata())
                .build()
        );
      }
    } catch (IndexOutOfBoundsException ignored) {
      // TS stream read too far and still did not find required elementary stream - SavedHeadSeekableInputStream throws
      // this because we disabled reads past the loaded "head".
    } finally {
      if (head != null) {
        head.setAllowDirectReads(true);
      }
    }

    return null;
  }

  @Override
  public AudioTrack createTrack(String parameters, AudioTrackInfo trackInfo, SeekableInputStream inputStream) {
    return new MpegAdtsAudioTrack(trackInfo, inputStream);
  }
}