Input: <editor - fold defaultstate = collapsed desc = Generated Code > // GEN - BEGIN : initComponents [CODESPLIT] private void initComponents ( ) { jTabbedPane6 = new javax . swing . JTabbedPane ( ) ; jPanel2 = new javax . swing . JPanel ( ) ; jTabbedPane3 = new javax . swing . JTabbedPane ( ) ; jScrollPane7 = new javax . swing . JScrollPane ( ) ; jTextArea7 = new javax . swing . JTextArea ( ) ; jTabbedPane1 = new javax . swing . JTabbedPane ( ) ; jScrollPane3 = new javax . swing . JScrollPane ( ) ; jTextArea1 = new javax . swing . JTextArea ( ) ; jLabel2 = new javax . swing . JLabel ( ) ; jTabbedPane2 = new javax . swing . JTabbedPane ( ) ; jScrollPane4 = new javax . swing . JScrollPane ( ) ; jTextArea4 = new javax . swing . JTextArea ( ) ; jTabbedPane4 = new javax . swing . JTabbedPane ( ) ; jScrollPane5 = new javax . swing . JScrollPane ( ) ; jTextArea5 = new javax . swing . JTextArea ( ) ; jTabbedPane5 = new javax . swing . JTabbedPane ( ) ; jScrollPane6 = new javax . swing . JScrollPane ( ) ; jTextArea6 = new javax . swing . JTextArea ( ) ; jButton2 = new javax . swing . JButton ( ) ; jTextField1 = new HistoryComboBox ( ) ; jButton4 = new javax . swing . JButton ( ) ; jButton5 = new javax . swing . JButton ( ) ; jButton6 = new javax . swing . JButton ( ) ; jButton8 = new javax . swing . JButton ( ) ; jButton9 = new javax . swing . JButton ( ) ; jPanel1 = new javax . swing . JPanel ( ) ; jLabel1 = new javax . swing . JLabel ( ) ; jComboBox1 = new javax . swing . JComboBox ( ) ; jLabel3 = new javax . swing . JLabel ( ) ; jLabel4 = new javax . swing . JLabel ( ) ; jComboBox2 = new javax . swing . JComboBox ( ) ; jComboBox3 = new javax . swing . JComboBox ( ) ; jLabel5 = new javax . swing . JLabel ( ) ; jComboBox4 = new javax . swing . JComboBox ( ) ; jLabel6 = new javax . swing . JLabel ( ) ; jComboBox5 = new javax . swing . JComboBox ( ) ; jLabel7 = new javax . swing . JLabel ( ) ; jComboBox6 = new javax . swing . JComboBox ( ) ; jLabel12 = new javax . swing . JLabel ( ) ; jTextField5 = new javax . swing . JTextField ( ) ; jLabel10 = new javax . swing . JLabel ( ) ; jLabel9 = new javax . swing . JLabel ( ) ; jTextField3 = new javax . swing . JTextField ( ) ; jTextField2 = new javax . swing . JTextField ( ) ; jLabel11 = new javax . swing . JLabel ( ) ; jLabel8 = new javax . swing . JLabel ( ) ; jTextField4 = new javax . swing . JTextField ( ) ; jLabel13 = new javax . swing . JLabel ( ) ; jTextField7 = new javax . swing . JTextField ( ) ; jTextField6 = new javax . swing . JTextField ( ) ; jLabel14 = new javax . swing . JLabel ( ) ; jComboBox7 = new javax . swing . JComboBox ( ) ; jLabel15 = new javax . swing . JLabel ( ) ; jComboBox8 = new javax . swing . JComboBox ( ) ; jPanel3 = new javax . swing . JPanel ( ) ; jTabbedPane7 = new javax . swing . JTabbedPane ( ) ; jScrollPane1 = new javax . swing . JScrollPane ( ) ; jTextPane1 = new javax . swing . JTextPane ( ) ; jScrollPane17 = new javax . swing . JScrollPane ( ) ; jTextPane12 = new javax . swing . JTextPane ( ) ; jScrollPane16 = new javax . swing . JScrollPane ( ) ; jTextPane11 = new javax . swing . JTextPane ( ) ; jScrollPane2 = new javax . swing . JScrollPane ( ) ; jTextPane2 = new javax . swing . JTextPane ( ) ; jScrollPane15 = new javax . swing . JScrollPane ( ) ; jTextPane10 = new javax . swing . JTextPane ( ) ; jScrollPane8 = new javax . swing . JScrollPane ( ) ; jTextPane3 = new javax . swing . JTextPane ( ) ; jScrollPane9 = new javax . swing . JScrollPane ( ) ; jTextPane4 = new javax . swing . JTextPane ( ) ; jScrollPane10 = new javax . swing . JScrollPane ( ) ; jTextPane5 = new javax . swing . JTextPane ( ) ; jScrollPane11 = new javax . swing . JScrollPane ( ) ; jTextPane6 = new javax . swing . JTextPane ( ) ; jScrollPane12 = new javax . swing . JScrollPane ( ) ; jTextPane7 = new javax . swing . JTextPane ( ) ; jScrollPane13 = new javax . swing . JScrollPane ( ) ; jTextPane8 = new javax . swing . JTextPane ( ) ; jScrollPane14 = new javax . swing . JScrollPane ( ) ; jTextPane9 = new javax . swing . JTextPane ( ) ; setDefaultCloseOperation ( javax . swing . WindowConstants . EXIT_ON_CLOSE ) ; java . util . ResourceBundle bundle = java . util . ResourceBundle . getBundle ( "com/github/moneytostr/messages_ru" ) ; // NOI18N setTitle ( bundle . getString ( "MONEYTOSTR" ) ) ; // NOI18N jPanel2 . setBorder ( javax . swing . BorderFactory . createTitledBorder ( "" ) ) ; jPanel2 . setMaximumSize ( new java . awt . Dimension ( 610 , 444 ) ) ; jPanel2 . setPreferredSize ( new java . awt . Dimension ( 662 , 447 ) ) ; jScrollPane7 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea7 . setColumns ( 20 ) ; jTextArea7 . setRows ( 5 ) ; jScrollPane7 . setViewportView ( jTextArea7 ) ; jTabbedPane3 . addTab ( bundle . getString ( "fromCapitalLetter" ) , jScrollPane7 ) ; // NOI18N jScrollPane3 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea1 . setColumns ( 20 ) ; jTextArea1 . setRows ( 5 ) ; jScrollPane3 . setViewportView ( jTextArea1 ) ; jTabbedPane1 . addTab ( bundle . getString ( "result" ) , jScrollPane3 ) ; // NOI18N jLabel2 . setText ( bundle . getString ( "enterTheDigitalAmount" ) ) ; // NOI18N jScrollPane4 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea4 . setColumns ( 20 ) ; jTextArea4 . setRows ( 5 ) ; jScrollPane4 . setViewportView ( jTextArea4 ) ; jTabbedPane2 . addTab ( bundle . getString ( "penniesByDigits" ) , jScrollPane4 ) ; // NOI18N jScrollPane5 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea5 . setColumns ( 20 ) ; jTextArea5 . setRows ( 5 ) ; jScrollPane5 . setViewportView ( jTextArea5 ) ; jTabbedPane4 . addTab ( bundle . getString ( "withVat" ) , jScrollPane5 ) ; // NOI18N jScrollPane6 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea6 . setColumns ( 20 ) ; jTextArea6 . setRows ( 5 ) ; jScrollPane6 . setViewportView ( jTextArea6 ) ; jTabbedPane5 . addTab ( bundle . getString ( "withVatByString" ) , jScrollPane6 ) ; // NOI18N jButton2 . setText ( "*" ) ; jButton2 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton2 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton2ActionPerformed ( evt ) ; } } ) ; jTextField1 . setEditable ( true ) ; jTextField1 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jTextField1ActionPerformed ( evt ) ; } } ) ; jButton4 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N jButton4 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N jButton4 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton4 . setFocusable ( false ) ; jButton4 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton4 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton4 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton4 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton4ActionPerformed ( evt ) ; } } ) ; jButton5 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N jButton5 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N jButton5 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton5 . setFocusable ( false ) ; jButton5 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton5 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton5 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton5 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton5ActionPerformed ( evt ) ; } } ) ; jButton6 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N jButton6 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N jButton6 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton6 . setFocusable ( false ) ; jButton6 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton6 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton6 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton6 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton6ActionPerformed ( evt ) ; } } ) ; jButton8 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N jButton8 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N jButton8 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton8 . setFocusable ( false ) ; jButton8 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton8 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton8 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton8 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton8ActionPerformed ( evt ) ; } } ) ; jButton9 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N jButton9 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N jButton9 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton9 . setFocusable ( false ) ; jButton9 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton9 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton9 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton9 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton9ActionPerformed ( evt ) ; } } ) ; org . jdesktop . layout . GroupLayout jPanel2Layout = new org . jdesktop . layout . GroupLayout ( jPanel2 ) ; jPanel2 . setLayout ( jPanel2Layout ) ; jPanel2Layout . setHorizontalGroup ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . addContainerGap ( ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . TRAILING ) . add ( jTabbedPane2 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane5 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane4 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane3 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jPanel2Layout . createSequentialGroup ( ) . add ( jLabel2 ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jTextField1 , 0 , 636 , Short . MAX_VALUE ) ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane1 ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jButton8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jButton2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jButton4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( jButton5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jButton6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( jButton9 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addContainerGap ( ) ) ) ; jPanel2Layout . setVerticalGroup ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . addContainerGap ( ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel2 ) . add ( jButton2 ) . add ( jTextField1 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane1 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 112 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jPanel2Layout . createSequentialGroup ( ) . add ( 23 , 23 , 23 ) . add ( jButton4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane3 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 106 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 52 , 52 , 52 ) ) ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 107 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 53 , 53 , 53 ) ) ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 112 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 57 , 57 , 57 ) ) ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 112 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton9 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 58 , 58 , 58 ) ) ) . addContainerGap ( org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) ) ) ; jTabbedPane6 . addTab ( bundle . getString ( "converter" ) , jPanel2 ) ; // NOI18N jLabel1 . setText ( bundle . getString ( "language" ) ) ; // NOI18N jComboBox1 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "Русский", "Укра и ский", "Английсикй" }) )      jComboBox1 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox1ActionPerformed ( evt ) ; } } ) ; jLabel3 . setText ( bundle . getString ( "currency" ) ) ; // NOI18N jLabel4 . setText ( bundle . getString ( "pennies" ) ) ; // NOI18N jComboBox2 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "RUR" , "UAH" , "USD" , "Custom" } ) ) ; jComboBox2 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox2ActionPerformed ( evt ) ; } } ) ; jComboBox3 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "Цифрами", "Проп и ью" }));     jComboBox3 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox3ActionPerformed ( evt ) ; } } ) ; jLabel5 . setText ( bundle . getString ( "toCopyToTheBuffer" ) ) ; // NOI18N jComboBox4 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "не копировать", "Результат "  "С заглавной буквы" , "С НДС", "С НДС прописью", "Копейк и цифрами" }) )        jComboBox4 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox4ActionPerformed ( evt ) ; } } ) ; jLabel6 . setText ( bundle . getString ( "vat" ) ) ; // NOI18N jComboBox5 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "10%" , "12%" , "18%" , "20%" , "22%" , "25%" } ) ) ; jComboBox5 . setSelectedIndex ( 2 ) ; jComboBox5 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox5ActionPerformed ( evt ) ; } } ) ; jLabel7 . setText ( bundle . getString ( "interfaceLanguage" ) ) ; // NOI18N jComboBox6 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "Русский", "Укра и ский" }));     jComboBox6 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox6ActionPerformed ( evt ) ; } } ) ; jLabel12 . setText ( bundle . getString ( "kopTwoUnit" ) ) ; // NOI18N jTextField5 . setText ( "евроцент");   jTextField5 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField5KeyTyped ( evt ) ; } } ) ; jLabel10 . setText ( bundle . getString ( "rubFiveUnit" ) ) ; // NOI18N jLabel9 . setText ( bundle . getString ( "rubTwoUnit" ) ) ; // NOI18N jTextField3 . setText ( "евро");   jTextField3 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField3KeyTyped ( evt ) ; } } ) ; jTextField2 . setText ( "евро");   jTextField2 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField2KeyTyped ( evt ) ; } } ) ; jLabel11 . setText ( bundle . getString ( "kopOneUnit" ) ) ; // NOI18N jLabel8 . setText ( bundle . getString ( "rubOneUnit" ) ) ; // NOI18N jTextField4 . setText ( "евро");   jTextField4 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField4KeyTyped ( evt ) ; } } ) ; jLabel13 . setText ( bundle . getString ( "kopFiveUnit" ) ) ; // NOI18N jTextField7 . setText ( "евроцентов");   jTextField7 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField7KeyTyped ( evt ) ; } } ) ; jTextField6 . setText ( "евроцента");   jTextField6 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField6KeyTyped ( evt ) ; } } ) ; jLabel14 . setText ( bundle . getString ( "rubSex" ) ) ; // NOI18N jComboBox7 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "M" , "F" } ) ) ; jComboBox7 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox7ActionPerformed ( evt ) ; } } ) ; jLabel15 . setText ( bundle . getString ( "kopSex" ) ) ; // NOI18N jComboBox8 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "M" , "F" } ) ) ; jComboBox8 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox8ActionPerformed ( evt ) ; } } ) ; org . jdesktop . layout . GroupLayout jPanel1Layout = new org . jdesktop . layout . GroupLayout ( jPanel1 ) ; jPanel1 . setLayout ( jPanel1Layout ) ; jPanel1Layout . setHorizontalGroup ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( 23 , 23 , 23 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel1 ) . add ( jLabel3 ) . add ( jLabel4 ) . add ( jLabel5 ) . add ( jLabel6 ) . add ( jLabel7 ) ) . add ( 29 , 29 , 29 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jComboBox5 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( jComboBox2 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jComboBox3 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jComboBox4 , 0 , 658 , Short . MAX_VALUE ) . add ( jComboBox1 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( jComboBox6 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) ) ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel9 ) . add ( jLabel8 ) . add ( jLabel10 ) . add ( jLabel11 ) . add ( jLabel12 ) . add ( jLabel13 ) . add ( jLabel14 ) . add ( jLabel15 ) ) . add ( 25 , 25 , 25 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTextField7 ) . add ( jTextField6 ) . add ( jTextField5 ) . add ( jTextField4 ) . add ( jTextField2 ) . add ( jTextField3 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , 659 , Short . MAX_VALUE ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jComboBox8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jComboBox7 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( 0 , 0 , Short . MAX_VALUE ) ) ) ) ) . addContainerGap ( ) ) ) ; jPanel1Layout . setVerticalGroup ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( 23 , 23 , 23 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel1 ) . add ( jComboBox1 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel3 ) . add ( jComboBox2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel8 ) . add ( jTextField2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel9 ) . add ( jTextField3 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel10 ) . add ( jTextField4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( 10 , 10 , 10 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jComboBox7 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jLabel14 ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel11 ) . add ( jTextField5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel12 ) . add ( jTextField6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel13 ) . add ( jTextField7 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel15 ) . add ( jComboBox8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( 8 , 8 , 8 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel4 ) . add ( jComboBox3 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel5 ) . add ( jComboBox4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel6 ) . add ( jComboBox5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel7 ) . add ( jComboBox6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addContainerGap ( 207 , Short . MAX_VALUE ) ) ) ; jTabbedPane6 . addTab ( bundle . getString ( "settings" ) , jPanel1 ) ; // NOI18N jTabbedPane7 . setTabPlacement ( javax . swing . JTabbedPane . LEFT ) ; jScrollPane1 . setBorder ( null ) ; jTextPane1 . setEditable ( false ) ; jTextPane1 . setBorder ( null ) ; jTextPane1 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane1 . setViewportView ( jTextPane1 ) ; jTabbedPane7 . addTab ( "c#" , jScrollPane1 ) ; jScrollPane17 . setBorder ( null ) ; jTextPane12 . setEditable ( false ) ; jTextPane12 . setBorder ( null ) ; jTextPane12 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane17 . setViewportView ( jTextPane12 ) ; jTabbedPane7 . addTab ( "c++" , jScrollPane17 ) ; jScrollPane16 . setBorder ( null ) ; jTextPane11 . setEditable ( false ) ; jTextPane11 . setBorder ( null ) ; jTextPane11 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane16 . setViewportView ( jTextPane11 ) ; jTabbedPane7 . addTab ( "coffeescript" , jScrollPane16 ) ; jScrollPane2 . setBorder ( null ) ; jTextPane2 . setEditable ( false ) ; jTextPane2 . setBorder ( null ) ; jTextPane2 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane2 . setViewportView ( jTextPane2 ) ; jTabbedPane7 . addTab ( "dart" , jScrollPane2 ) ; jScrollPane15 . setBorder ( null ) ; jTextPane10 . setEditable ( false ) ; jTextPane10 . setBorder ( null ) ; jTextPane10 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane15 . setViewportView ( jTextPane10 ) ; jTabbedPane7 . addTab ( "groovy" , jScrollPane15 ) ; jScrollPane8 . setBorder ( null ) ; jTextPane3 . setEditable ( false ) ; jTextPane3 . setBorder ( null ) ; jTextPane3 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane8 . setViewportView ( jTextPane3 ) ; jTabbedPane7 . addTab ( "java" , jScrollPane8 ) ; jScrollPane9 . setBorder ( null ) ; jTextPane4 . setEditable ( false ) ; jTextPane4 . setBorder ( null ) ; jTextPane4 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane9 . setViewportView ( jTextPane4 ) ; jTabbedPane7 . addTab ( "js" , jScrollPane9 ) ; jScrollPane10 . setBorder ( null ) ; jTextPane5 . setEditable ( false ) ; jTextPane5 . setBorder ( null ) ; jTextPane5 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane10 . setViewportView ( jTextPane5 ) ; jTabbedPane7 . addTab ( "php" , jScrollPane10 ) ; jScrollPane11 . setBorder ( null ) ; jTextPane6 . setEditable ( false ) ; jTextPane6 . setBorder ( null ) ; jTextPane6 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane11 . setViewportView ( jTextPane6 ) ; jTabbedPane7 . addTab ( "python" , jScrollPane11 ) ; jScrollPane12 . setBorder ( null ) ; jTextPane7 . setEditable ( false ) ; jTextPane7 . setBorder ( null ) ; jTextPane7 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane12 . setViewportView ( jTextPane7 ) ; jTabbedPane7 . addTab ( "ruby" , jScrollPane12 ) ; jScrollPane13 . setBorder ( null ) ; jTextPane8 . setEditable ( false ) ; jTextPane8 . setBorder ( null ) ; jTextPane8 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane13 . setViewportView ( jTextPane8 ) ; jTabbedPane7 . addTab ( "scala" , jScrollPane13 ) ; jScrollPane14 . setBorder ( null ) ; jTextPane9 . setEditable ( false ) ; jTextPane9 . setBorder ( null ) ; jTextPane9 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N jScrollPane14 . setViewportView ( jTextPane9 ) ; jTabbedPane7 . addTab ( "typescript" , jScrollPane14 ) ; org . jdesktop . layout . GroupLayout jPanel3Layout = new org . jdesktop . layout . GroupLayout ( jPanel3 ) ; jPanel3 . setLayout ( jPanel3Layout ) ; jPanel3Layout . setHorizontalGroup ( jPanel3Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane7 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , 825 , Short . MAX_VALUE ) ) ; jPanel3Layout . setVerticalGroup ( jPanel3Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane7 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , 614 , Short . MAX_VALUE ) ) ; jTabbedPane6 . addTab ( bundle . getString ( "sourceCodes" ) , jPanel3 ) ; // NOI18N org . jdesktop . layout . GroupLayout layout = new org . jdesktop . layout . GroupLayout ( getContentPane ( ) ) ; getContentPane ( ) . setLayout ( layout ) ; layout . setHorizontalGroup ( layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane6 ) ) ; layout . setVerticalGroup ( layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane6 ) ) ; pack ( ) ; }


Input: GEN - LAST : event_jButton2ActionPerformed [CODESPLIT] private void jTextField1ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jTextField1ActionPerformed Object obj = jTextField1 . getSelectedItem ( ) ; if ( obj != null && evt . getActionCommand ( ) . equals ( "comboBoxEdited" ) ) { generateResult ( ) ; } }


Input: GEN - LAST : event_jComboBox3ActionPerformed [CODESPLIT] private void jButton4ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jButton4ActionPerformed StringSelection ss = new StringSelection ( jTextArea1 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ; }


Input: GEN - LAST : event_jButton4ActionPerformed [CODESPLIT] private void jButton5ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jButton5ActionPerformed StringSelection ss = new StringSelection ( jTextArea5 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ; }


Input: GEN - LAST : event_jButton5ActionPerformed [CODESPLIT] private void jButton6ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jButton6ActionPerformed StringSelection ss = new StringSelection ( jTextArea7 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ; }


Input: GEN - LAST : event_jButton6ActionPerformed [CODESPLIT] private void jButton8ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jButton8ActionPerformed StringSelection ss = new StringSelection ( jTextArea6 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ; }


Input: GEN - LAST : event_jButton8ActionPerformed [CODESPLIT] private void jButton9ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jButton9ActionPerformed StringSelection ss = new StringSelection ( jTextArea4 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ; }


Input: GEN - LAST : event_jComboBox5ActionPerformed [CODESPLIT] private void jComboBox6ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jComboBox6ActionPerformed int selected = ( ( javax . swing . JComboBox ) evt . getSource ( ) ) . getSelectedIndex ( ) ; setupLanguage ( selected ) ; }


Input: GEN - LAST : event_jTextField7KeyTyped [CODESPLIT] private void setupMoneyToStrVariables ( ) { moneyToStrTxt = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . values ( ) [ jComboBox3 . getSelectedIndex ( ) ] ) ; moneyToStrNum = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . NUMBER ) ; if ( jComboBox2 . getSelectedIndex ( ) == 3 ) { String [ ] names = new String [ 8 ] ; names [ 0 ] = jTextField2 . getText ( ) ; names [ 1 ] = jTextField3 . getText ( ) ; names [ 2 ] = jTextField4 . getText ( ) ; names [ 3 ] = jComboBox7 . getModel ( ) . getSelectedItem ( ) . toString ( ) ; names [ 4 ] = jTextField5 . getText ( ) ; names [ 5 ] = jTextField6 . getText ( ) ; names [ 6 ] = jTextField7 . getText ( ) ; names [ 7 ] = jComboBox8 . getModel ( ) . getSelectedItem ( ) . toString ( ) ; moneyToStrTxt = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . values ( ) [ jComboBox3 . getSelectedIndex ( ) ] , names ) ; moneyToStrNum = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . NUMBER , names ) ; } boolean isCustomCurrency = jComboBox2 . getSelectedIndex ( ) == 3 ; jTextField2 . setEnabled ( isCustomCurrency ) ; jTextField3 . setEnabled ( isCustomCurrency ) ; jTextField4 . setEnabled ( isCustomCurrency ) ; jComboBox7 . setEnabled ( isCustomCurrency ) ; jTextField5 . setEnabled ( isCustomCurrency ) ; jTextField6 . setEnabled ( isCustomCurrency ) ; jTextField7 . setEnabled ( isCustomCurrency ) ; jComboBox8 . setEnabled ( isCustomCurrency ) ; }


Input: Converts percent to string . [CODESPLIT] public static String percentToStr ( Double amount , Language lang ) { return percentToStr ( amount , lang , Pennies . TEXT ) ; }


Input: Converts percent to string . [CODESPLIT] public static String percentToStr ( Double amount , Language lang , Pennies pennies ) { if ( amount == null ) { throw new IllegalArgumentException ( "amount is null" ) ; } if ( lang == null ) { throw new IllegalArgumentException ( "language is null" ) ; } if ( pennies == null ) { throw new IllegalArgumentException ( "pennies is null" ) ; } Long intPart = amount . longValue ( ) ; Long fractPart = 0L ; String result ; if ( amount . floatValue ( ) == amount . intValue ( ) ) { result = new MoneyToStr ( Currency . PER10 , lang , pennies ) . convert ( amount . longValue ( ) , 0L ) ; } else if ( Double . valueOf ( amount * NUM10 ) . floatValue ( ) == Double . valueOf ( amount * NUM10 ) . intValue ( ) ) { fractPart = Math . round ( ( amount - intPart ) * NUM10 ) ; result = new MoneyToStr ( Currency . PER10 , lang , pennies ) . convert ( intPart , fractPart ) ; } else if ( Double . valueOf ( amount * NUM100 ) . floatValue ( ) == Double . valueOf ( amount * NUM100 ) . intValue ( ) ) { fractPart = Math . round ( ( amount - intPart ) * NUM100 ) ; result = new MoneyToStr ( Currency . PER100 , lang , pennies ) . convert ( intPart , fractPart ) ; } else if ( Double . valueOf ( amount * NUM1000 ) . floatValue ( ) == Double . valueOf ( amount * NUM1000 ) . intValue ( ) ) { fractPart = Math . round ( ( amount - intPart ) * NUM1000 ) ; result = new MoneyToStr ( Currency . PER1000 , lang , pennies ) . convert ( intPart , fractPart ) ; } else { fractPart = Math . round ( ( amount - intPart ) * NUM10000 ) ; result = new MoneyToStr ( Currency . PER10000 , lang , pennies ) . convert ( intPart , fractPart ) ; } return result ; }


Input: Converts double value to the text description . [CODESPLIT] public String convert ( Double theMoney ) { if ( theMoney == null ) { throw new IllegalArgumentException ( "theMoney is null" ) ; } Long intPart = theMoney . longValue ( ) ; Long fractPart = Math . round ( ( theMoney - intPart ) * NUM100 ) ; if ( currency == Currency . PER1000 ) { fractPart = Math . round ( ( theMoney - intPart ) * NUM1000 ) ; } return convert ( intPart , fractPart ) ; }


Input: Converts amount to words . Usage : MoneyToStr moneyToStr = new MoneyToStr ( MoneyToStr . Currency . UAH MoneyToStr . Language . UKR MoneyToStr . Pennies . NUMBER ) ; String result = moneyToStr . convert ( 123D ) ; Expected : result = сто двадцять три гривні 00 копійок [CODESPLIT] public String convert ( Long theMoney , Long theKopeiki ) { if ( theMoney == null ) { throw new IllegalArgumentException ( "theMoney is null" ) ; } if ( theKopeiki == null ) { throw new IllegalArgumentException ( "theKopeiki is null" ) ; } StringBuilder money2str = new StringBuilder ( ) ; Long triadNum = 0L ; Long theTriad ; Long intPart = theMoney ; if ( intPart == 0 ) { money2str . append ( messages . get ( "0" ) [ 0 ] + " " ) ; } do { theTriad = intPart % NUM1000 ; money2str . insert ( 0 , triad2Word ( theTriad , triadNum , rubSex ) ) ; if ( triadNum == 0 ) { if ( ( theTriad % NUM100 ) / NUM10 == NUM1 ) { money2str . append ( rubFiveUnit ) ; } else { switch ( Long . valueOf ( theTriad % NUM10 ) . byteValue ( ) ) { case NUM1 : money2str . append ( rubOneUnit ) ; break ; case NUM2 : case NUM3 : case NUM4 : money2str . append ( rubTwoUnit ) ; break ; default : money2str . append ( rubFiveUnit ) ; break ; } } } intPart /= NUM1000 ; triadNum ++ ; } while ( intPart > 0 ) ; if ( pennies == Pennies . TEXT ) { money2str . append ( language == Language . ENG ? " and " : " " ) . append ( theKopeiki == 0 ? messages . get ( "0" ) [ 0 ] + " " : triad2Word ( theKopeiki , 0L , kopSex ) ) ; } else { money2str . append ( " " + ( theKopeiki < 10 ? "0" + theKopeiki : theKopeiki ) + " " ) ; } if ( theKopeiki >= NUM11 && theKopeiki <= NUM14 ) { money2str . append ( kopFiveUnit ) ; } else { switch ( ( byte ) ( theKopeiki % NUM10 ) ) { case NUM1 : money2str . append ( kopOneUnit ) ; break ; case NUM2 : case NUM3 : case NUM4 : money2str . append ( kopTwoUnit ) ; break ; default : money2str . append ( kopFiveUnit ) ; break ; } } return money2str . toString ( ) . trim ( ) ; }


Input: Attempt to release any locks on shutdown so that other clients can obtain those locks without having to wait for them to expire . [CODESPLIT] public void shutdown ( ) { try { locksExecutor . shutdown ( ) ; locksExecutor . awaitTermination ( 5 , TimeUnit . SECONDS ) ; CountDownLatch latch = new CountDownLatch ( 1 ) ; activeLocksLock . writeLock ( ) . lock ( ) ; Observable . from ( activeLocks . entrySet ( ) ) . map ( Map . Entry :: getValue ) . flatMap ( lock -> releaseLock ( lock . getName ( ) , lock . getValue ( ) ) . map ( released -> new Lock ( lock . getName ( ) , lock . getValue ( ) , lock . getExpiration ( ) , lock . getRenewalRate ( ) , ! released ) ) ) . subscribe ( lock -> { if ( lock . isLocked ( ) ) { logger . infof ( "Failed to release lock %s" , lock . getName ( ) ) ; } } , t -> { logger . info ( "There was an error while releasing locks" , t ) ; latch . countDown ( ) ; } , latch :: countDown ) ; latch . await ( ) ; logger . info ( "Shutdown complete" ) ; } catch ( InterruptedException e ) { logger . debug ( "Shutdown was interrupted. Some locks may not have been released but they will still expire." ) ; } }


Input: Observes { @link ServletOutputStream } . [CODESPLIT] public static Observable < Void > create ( final ServletOutputStream out ) { return Observable . unsafeCreate ( subscriber -> { final ServletWriteListener listener = new ServletWriteListener ( subscriber , out ) ; out . setWriteListener ( listener ) ; } ) ; }


Input: Writes the given Observable data to ServletOutputStream . [CODESPLIT] public static Observable < Void > write ( final Observable < byte [ ] > data , final ServletOutputStream out ) { return Observable . create ( new Observable . OnSubscribe < Void > ( ) { @ Override public void call ( Subscriber < ? super Void > subscriber ) { Observable < Void > events = create ( out ) . onBackpressureBuffer ( ) ; Observable < Void > writeobs = Observable . zip ( data , events , ( b , aVoid ) -> { try { out . write ( b ) ; } catch ( IOException ioe ) { Exceptions . propagate ( ioe ) ; } return null ; } ) ; writeobs . subscribe ( subscriber ) ; } } ) ; }


Input: functionality into a separate class . [CODESPLIT] @ Override public Observable < Void > addTags ( Metric < ? > metric , Map < String , String > tags ) { try { checkArgument ( tags != null , "Missing tags" ) ; checkArgument ( isValidTagMap ( tags ) , "Invalid tags; tag key is required" ) ; } catch ( Exception e ) { return Observable . error ( e ) ; } return dataAccess . insertIntoMetricsTagsIndex ( metric , tags ) . concatWith ( dataAccess . addTags ( metric , tags ) ) . toList ( ) . map ( l -> null ) ; }


Input: Intended to be used at the startup of the MetricsServiceImpl to ensure we have enough tables for processing [CODESPLIT] public void verifyAndCreateTempTables ( ) { ZonedDateTime currentBlock = ZonedDateTime . ofInstant ( Instant . ofEpochMilli ( DateTimeService . now . get ( ) . getMillis ( ) ) , UTC ) . with ( DateTimeService . startOfPreviousEvenHour ( ) ) ; ZonedDateTime lastStartupBlock = currentBlock . plus ( 6 , ChronoUnit . HOURS ) ; verifyAndCreateTempTables ( currentBlock , lastStartupBlock ) . await ( ) ; }


Input: Returns the namespace id for a particular namespace name [CODESPLIT] public String getNamespaceId ( String namespaceName ) { return namespaces . computeIfAbsent ( namespaceName , n -> getProjectId ( namespaceName , token ) ) ; }


Input: Returns if the request is a query request eg to perform a READ [CODESPLIT] private boolean isQuery ( HttpServerExchange serverExchange ) { if ( serverExchange . getRequestMethod ( ) . toString ( ) . equalsIgnoreCase ( "GET" ) || serverExchange . getRequestMethod ( ) . toString ( ) . equalsIgnoreCase ( "HEAD" ) ) { // all GET requests are considered queries return true ; } else if ( serverExchange . getRequestMethod ( ) . toString ( ) . equalsIgnoreCase ( "POST" ) ) { // some POST requests may be queries we need to check. if ( postQuery != null && postQuery . matcher ( serverExchange . getRelativePath ( ) ) . find ( ) ) { return true ; } else { return false ; } } else { return false ; } }


Input: Executed when a pooled connection is acquired . [CODESPLIT] private void sendAuthenticationRequest ( HttpServerExchange serverExchange , PooledConnection connection ) { AuthContext context = serverExchange . getAttachment ( AUTH_CONTEXT_KEY ) ; String verb = getVerb ( serverExchange ) ; String resource ; // if we are not dealing with a query if ( ! isQuery ( serverExchange ) ) { // is USER_WRITE_ACCESS is disabled, then use the legacy check. // Otherwise check using the actual resource (eg 'hawkular-metrics', 'hawkular-alerts', etc) if ( USER_WRITE_ACCESS . equalsIgnoreCase ( "true" ) ) { resource = RESOURCE ; } else { resource = resourceName ; } } else { resource = RESOURCE ; } context . subjectAccessReview = generateSubjectAccessReview ( context . tenant , verb , resource ) ; ClientRequest request = buildClientRequest ( context ) ; context . clientRequestStarting ( ) ; connection . sendRequest ( request , new RequestReadyCallback ( serverExchange , connection ) ) ; }


Input: Determine the verb we should apply based on the HTTP method being requested . [CODESPLIT] private String getVerb ( HttpServerExchange serverExchange ) { // if its a query type verb, then treat as a GET type call. if ( isQuery ( serverExchange ) ) { return VERBS . get ( GET ) ; } else { String verb = VERBS . get ( serverExchange . getRequestMethod ( ) ) ; if ( verb == null ) { log . debugf ( "Unhandled http method '%s'. Checking for read access." , serverExchange . getRequestMethod ( ) ) ; verb = VERBS_DEFAULT ; } return verb ; } }


Input: Generates a SubjectAccessReview object used to request if a user has a certain permission or not . [CODESPLIT] private String generateSubjectAccessReview ( String namespace , String verb , String resource ) { ObjectNode objectNode = objectMapper . createObjectNode ( ) ; objectNode . put ( "apiVersion" , "v1" ) ; objectNode . put ( "kind" , KIND ) ; objectNode . put ( "resource" , resource ) ; objectNode . put ( "verb" , verb ) ; objectNode . put ( "namespace" , namespace ) ; return objectNode . toString ( ) ; }


Input: Called when the Kubernetes master server reponse has been inspected . [CODESPLIT] private void onRequestResult ( HttpServerExchange serverExchange , PooledConnection connection , boolean allowed ) { connectionPools . get ( serverExchange . getIoThread ( ) ) . release ( connection ) ; // Remove attachment early to make it eligible for GC AuthContext context = serverExchange . removeAttachment ( AUTH_CONTEXT_KEY ) ; apiLatency . update ( context . getClientResponseTime ( ) , NANOSECONDS ) ; authLatency . update ( context . getLatency ( ) , NANOSECONDS ) ; if ( allowed ) { serverExchange . dispatch ( containerHandler ) ; } else { endExchange ( serverExchange , FORBIDDEN ) ; } }


Input: Called if an exception occurs at any stage in the process . [CODESPLIT] private void onRequestFailure ( HttpServerExchange serverExchange , PooledConnection connection , IOException e , boolean retry ) { log . debug ( "Client request failure" , e ) ; IoUtils . safeClose ( connection ) ; ConnectionPool connectionPool = connectionPools . get ( serverExchange . getIoThread ( ) ) ; connectionPool . release ( connection ) ; AuthContext context = serverExchange . getAttachment ( AUTH_CONTEXT_KEY ) ; if ( context . retries < MAX_RETRY && retry ) { context . retries ++ ; PooledConnectionWaiter waiter = createWaiter ( serverExchange ) ; if ( ! connectionPool . offer ( waiter ) ) { endExchange ( serverExchange , INTERNAL_SERVER_ERROR , TOO_MANY_PENDING_REQUESTS ) ; } } else { endExchange ( serverExchange , INTERNAL_SERVER_ERROR , CLIENT_REQUEST_FAILURE ) ; } }


Input: eventually I would like service initialization async . [CODESPLIT] public void init ( RxSession session ) { this . session = session ; findConfigurationGroup = session . getSession ( ) . prepare ( "SELECT name, value FROM sys_config WHERE config_id = ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; findConfigurationValue = session . getSession ( ) . prepare ( "SELECT value FROM sys_config WHERE config_id = ? AND name= ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; updateConfigurationValue = session . getSession ( ) . prepare ( "INSERT INTO sys_config (config_id, name, value) VALUES (?, ?, ?)" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; deleteConfigurationValue = session . getSession ( ) . prepare ( "DELETE FROM sys_config WHERE config_id =? and name = ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; deleteConfiguration = session . getSession ( ) . prepare ( "DELETE FROM sys_config WHERE config_id = ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; }


Input: If a job is single execution then this is a no - op ; otherwise the scheduled jobs index and jobs tables are updated with the next execution time / details . If the job has missed its next execution it will get scheduled in the next available time slice . The job scheduler will actually execute the job immediately when the job falls behind but we still want to persist the scheduling update for durability . [CODESPLIT] private Single < JobExecutionState > reschedule ( JobExecutionState executionState ) { Trigger nextTrigger = executionState . currentDetails . getTrigger ( ) . nextTrigger ( ) ; if ( nextTrigger == null ) { logger . debugf ( "No more scheduled executions for %s" , executionState . currentDetails ) ; return Single . just ( executionState ) ; } JobDetailsImpl details = executionState . currentDetails ; JobDetailsImpl newDetails = new JobDetailsImpl ( details , nextTrigger ) ; if ( nextTrigger . getTriggerTime ( ) <= now . get ( ) . getMillis ( ) ) { logger . infof ( "%s missed its next execution at %d. It will be rescheduled for immediate execution." , details , nextTrigger . getTriggerTime ( ) ) ; AtomicLong nextTimeSlice = new AtomicLong ( currentMinute ( ) . getMillis ( ) ) ; Observable < Lock > scheduled = Observable . defer ( ( ) -> lockManager . acquireLock ( QUEUE_LOCK_PREFIX + nextTimeSlice . addAndGet ( 60000L ) , SCHEDULING_LOCK , SCHEDULING_LOCK_TIMEOUT_IN_SEC , false ) ) . map ( lock -> { if ( ! lock . isLocked ( ) ) { throw new RuntimeException ( ) ; } return lock ; } ) . retry ( ) ; return scheduled . map ( lock -> new JobExecutionState ( executionState . currentDetails , executionState . timeSlice , newDetails , new Date ( nextTimeSlice . get ( ) ) , executionState . activeJobs ) ) . flatMap ( state -> jobsService . insert ( state . nextTimeSlice , state . nextDetails ) . map ( updated -> state ) ) . doOnNext ( state -> logger . debugf ( "Rescheduled %s to execute in time slice %s with trigger time " + "of %s" , state . nextDetails . getJobName ( ) , state . nextTimeSlice , new Date ( state . nextDetails . getTrigger ( ) . getTriggerTime ( ) ) ) ) . toSingle ( ) ; } logger . debugf ( "Scheduling %s for next execution at %s" , newDetails , new Date ( nextTrigger . getTriggerTime ( ) ) ) ; JobExecutionState newState = new JobExecutionState ( details , executionState . timeSlice , newDetails , new Date ( nextTrigger . getTriggerTime ( ) ) , executionState . activeJobs ) ; return jobsService . insert ( newState . nextTimeSlice , newState . nextDetails ) . map ( updated -> newState ) . toSingle ( ) ; }


Input: This method is currently unused . [CODESPLIT] public Observable < JobDetails > findScheduledJobs ( Date timeSlice , rx . Scheduler scheduler ) { return session . executeAndFetch ( findAllScheduled . bind ( ) , scheduler ) . filter ( filterNullJobs ) . filter ( row -> row . getTimestamp ( 0 ) . compareTo ( timeSlice ) <= 0 ) . map ( row -> createJobDetails ( row . getUUID ( 1 ) , row . getString ( 2 ) , row . getString ( 3 ) , row . getMap ( 4 , String . class , String . class ) , getTrigger ( row . getUDTValue ( 5 ) ) , JobStatus . fromCode ( row . getByte ( 6 ) ) , timeSlice ) ) . collect ( HashMap :: new , ( Map < UUID , SortedSet < JobDetails > > map , JobDetails details ) -> { SortedSet < JobDetails > set = map . get ( details . getJobId ( ) ) ; if ( set == null ) { set = new TreeSet <> ( ( JobDetails d1 , JobDetails d2 ) -> Long . compare ( d1 . getTrigger ( ) . getTriggerTime ( ) , d2 . getTrigger ( ) . getTriggerTime ( ) ) ) ; } set . add ( details ) ; map . put ( details . getJobId ( ) , set ) ; } ) . flatMap ( map -> Observable . from ( map . entrySet ( ) ) ) . map ( entry -> entry . getValue ( ) . first ( ) ) ; }


Input: Converts bucket points indexed by start time into a list ordered by start time . Blanks will be filled with empty bucket points . [CODESPLIT] public static < T extends BucketPoint > List < T > toList ( Map < Long , T > pointMap , Buckets buckets , BiFunction < Long , Long , T > emptyBucketFactory ) { List < T > result = new ArrayList <> ( buckets . getCount ( ) ) ; for ( int index = 0 ; index < buckets . getCount ( ) ; index ++ ) { long from = buckets . getBucketStart ( index ) ; T bucketPoint = pointMap . get ( from ) ; if ( bucketPoint == null ) { long to = from + buckets . getStep ( ) ; bucketPoint = emptyBucketFactory . apply ( from , to ) ; } result . add ( bucketPoint ) ; } return result ; }


Input: JMX management [CODESPLIT] private void submitCompressJob ( Map < String , String > parameters ) { String jobName = String . format ( "%s_single_%s" , CompressData . JOB_NAME , parameters . get ( CompressData . TARGET_TIME ) ) ; // Blocking to ensure it is actually scheduled.. scheduler . scheduleJob ( CompressData . JOB_NAME , jobName , parameters , new SingleExecutionTrigger . Builder ( ) . withDelay ( 1 , TimeUnit . MINUTES ) . build ( ) ) . toBlocking ( ) . value ( ) ; }


Input: Allow special cases to Pattern matching such as * - > . * and ! indicating the match shouldn t happen . The first ! indicates the rest of the pattern should not match . [CODESPLIT] public static Pattern filterPattern ( String inputRegexp ) { if ( inputRegexp . equals ( "*" ) ) { inputRegexp = ".*" ; } else if ( inputRegexp . startsWith ( "!" ) ) { inputRegexp = inputRegexp . substring ( 1 ) ; } return Pattern . compile ( inputRegexp ) ; // Catch incorrect patterns.. }


Input: Asynchronously performs gc_grace_seconds updates if necessary . This method should <strong > not< / strong > be called until schema updates have finished . [CODESPLIT] public void maybeUpdateGCGraceSeconds ( ) { logger . info ( "Checking tables in " + keyspace + " to see if gc_grace_seconds needs to be updated" ) ; Stopwatch stopwatch = Stopwatch . createStarted ( ) ; Map < String , String > replication = session . getCluster ( ) . getMetadata ( ) . getKeyspace ( keyspace ) . getReplication ( ) ; String replicationFactor = replication . get ( "replication_factor" ) ; Completable check ; if ( getClusterSize ( ) == 1 || replicationFactor . equals ( "1" ) ) { check = updateAllGCGraceSeconds ( 0 ) ; } else { // Need to call Completable.merge in order for subscriptions to happen correctly. See https://goo.gl/l15CRV check = Completable . merge ( configurationService . load ( "org.hawkular.metrics" , "gcGraceSeconds" ) . switchIfEmpty ( Observable . just ( Integer . toString ( DEFAULT_GC_GRACE_SECONDS ) ) ) . map ( property -> { int gcGraceSeconds = Integer . parseInt ( property ) ; return updateAllGCGraceSeconds ( gcGraceSeconds ) ; } ) ) ; } check . subscribe ( ( ) -> { stopwatch . stop ( ) ; logger . info ( "Finished gc_grace_seconds updates in " + stopwatch . elapsed ( TimeUnit . MILLISECONDS ) + " ms" ) ; updatesFinished . ifPresent ( subject -> subject . onNext ( null ) ) ; } , t -> { logger . warn ( "There was an error checking and updating gc_grace_seconds" ) ; updatesFinished . ifPresent ( subject -> subject . onNext ( t ) ) ; } ) ; }


Input: Changes the status code of the response sets the HTTP reason phrase and ends the exchange . [CODESPLIT] public static void endExchange ( HttpServerExchange exchange , int statusCode , String reasonPhrase ) { exchange . setStatusCode ( statusCode ) ; if ( reasonPhrase != null ) { exchange . setReasonPhrase ( reasonPhrase ) ; } exchange . endExchange ( ) ; }


Input: Parses the string into an interval . The string must match the regular expression ( \ d + ) ( min|hr|d ) ; otherwise an exception is thrown . [CODESPLIT] public static Interval parse ( String s ) { if ( s . isEmpty ( ) ) { return NONE ; } Matcher matcher = INTERVAL_PATTERN . matcher ( s ) ; if ( ! ( matcher . matches ( ) && matcher . groupCount ( ) == 2 ) ) { throw new IllegalArgumentException ( s + " is not a valid interval. It must follow the pattern " + INTERVAL_PATTERN . pattern ( ) ) ; } return new Interval ( Integer . parseInt ( matcher . group ( 1 ) ) , Units . fromCode ( matcher . group ( 2 ) ) ) ; }


Input: Fetch all the data from a temporary table for the compression job . Using TokenRanges avoids fetching first all the metrics partition keys and then requesting them . [CODESPLIT] @ Override public Observable < Observable < Row > > findAllDataFromBucket ( long timestamp , int pageSize , int maxConcurrency ) { PreparedStatement ts = getTempStatement ( MetricType . UNDEFINED , TempStatement . SCAN_WITH_TOKEN_RANGES , timestamp ) ; // The table does not exists - case such as when starting Hawkular-Metrics for the first time just before // compression kicks in. if ( ts == null || prepMap . floorKey ( timestamp ) == 0L ) { return Observable . empty ( ) ; } return Observable . from ( getTokenRanges ( ) ) . map ( tr -> rxSession . executeAndFetch ( ts . bind ( ) . setToken ( 0 , tr . getStart ( ) ) . setToken ( 1 , tr . getEnd ( ) ) . setFetchSize ( pageSize ) ) ) ; }


Input: / * Applies micro - batching capabilities by taking advantage of token ranges in the Cassandra [CODESPLIT] private Observable . Transformer < BoundStatement , Integer > applyMicroBatching ( ) { return tObservable -> tObservable . groupBy ( b -> { ByteBuffer routingKey = b . getRoutingKey ( ProtocolVersion . NEWEST_SUPPORTED , codecRegistry ) ; Token token = metadata . newToken ( routingKey ) ; for ( TokenRange tokenRange : session . getCluster ( ) . getMetadata ( ) . getTokenRanges ( ) ) { if ( tokenRange . contains ( token ) ) { return tokenRange ; } } log . warn ( "Unable to find any Cassandra node to insert token " + token . toString ( ) ) ; return session . getCluster ( ) . getMetadata ( ) . getTokenRanges ( ) . iterator ( ) . next ( ) ; } ) . flatMap ( g -> g . compose ( new BoundBatchStatementTransformer ( ) ) ) . flatMap ( batch -> rxSession . execute ( batch ) . compose ( applyInsertRetryPolicy ( ) ) . map ( resultSet -> batch . size ( ) ) ) ; }


Input: / * Apply our current retry policy to the insert behavior [CODESPLIT] private < T > Observable . Transformer < T , T > applyInsertRetryPolicy ( ) { return tObservable -> tObservable . retryWhen ( errors -> { Observable < Integer > range = Observable . range ( 1 , 2 ) ; return errors . zipWith ( range , ( t , i ) -> { if ( t instanceof DriverException ) { return i ; } throw Exceptions . propagate ( t ) ; } ) . flatMap ( retryCount -> { long delay = ( long ) Math . min ( Math . pow ( 2 , retryCount ) * 1000 , 3000 ) ; log . debug ( "Retrying batch insert in " + delay + " ms" ) ; return Observable . timer ( delay , TimeUnit . MILLISECONDS ) ; } ) ; } ) ; }


Input: Force bucket count . This method does not guarantee that the last bucket includes the { @code end } value . [CODESPLIT] public static Buckets fromCount ( long start , long end , int count ) { checkTimeRange ( start , end ) ; checkArgument ( count > 0 , "count is not positive: %s" , count ) ; long quotient = ( end - start ) / count ; long remainder = ( end - start ) % count ; long step ; // count * quotient + remainder = end - start // If the remainder is greater than zero, we should try with (quotient + 1), provided that this greater step // does not make the number of buckets smaller than the expected count if ( remainder != 0 && ( count - 1 ) * ( quotient + 1 ) < ( end - start ) ) { step = quotient + 1 ; } else { step = quotient ; } checkArgument ( step > 0 , "Computed step is equal to zero" ) ; return new Buckets ( start , step , count ) ; }


Input: Force bucket step . [CODESPLIT] public static Buckets fromStep ( long start , long end , long step ) { checkTimeRange ( start , end ) ; checkArgument ( step > 0 , "step is not positive: %s" , step ) ; if ( step > ( end - start ) ) { return new Buckets ( start , step , 1 ) ; } long quotient = ( end - start ) / step ; long remainder = ( end - start ) % step ; long count ; if ( remainder == 0 ) { count = quotient ; } else { count = quotient + 1 ; } checkArgument ( count <= Integer . MAX_VALUE , "Computed number of buckets is too big: %s" , count ) ; return new Buckets ( start , step , ( int ) count ) ; }


Input: send msg . [CODESPLIT] public boolean sendMsg ( Message msg ) { SendResult sendResult = null ; try { sendResult = producer . send ( msg ) ; } catch ( Exception e ) { logger . error ( "send msg error" , e ) ; } return sendResult != null && sendResult . getSendStatus ( ) == SendStatus . SEND_OK ; }


Input: sene one way msg . [CODESPLIT] public void sendOneWayMsg ( Message msg ) { try { producer . sendOneway ( msg ) ; } catch ( Exception e ) { logger . error ( "send msg error" , e ) ; } }


Input: send delay msg . [CODESPLIT] public boolean sendDelayMsg ( String topic , String tag , Message msg , int delayLevel ) { msg . setDelayTimeLevel ( delayLevel ) ; SendResult sendResult = null ; try { sendResult = producer . send ( msg ) ; } catch ( Exception e ) { logger . error ( "send msg error" , e ) ; } return sendResult != null && sendResult . getSendStatus ( ) == SendStatus . SEND_OK ; }


Input: In this simple proposal we re not testing complex iterations of scan cursor . SCAN is simply a wrapper for KEYS and the result is given in one single response no matter the COUNT argument . [CODESPLIT] @ Override public ScanResult < String > scan ( String cursor , ScanParams params ) { // We need to extract the MATCH argument from the scan params Collection < byte [ ] > rawParams = params . getParams ( ) ; // Raw collection is a list of byte[], made of: key1, value1, key2, value2, etc. boolean isKey = true ; String match = null ; boolean foundMatchKey = false ; // So, we run over the list, where any even index is a key, and the following data is its value. for ( byte [ ] raw : rawParams ) { if ( isKey ) { String key = new String ( raw ) ; if ( key . equals ( new String ( MATCH . raw ) ) ) { // What really interests us is the MATCH key. foundMatchKey = true ; } } // As soon as we've found the MATCH key, we can stop searching. else if ( foundMatchKey ) { match = new String ( raw ) ; break ; } isKey = ! isKey ; } // Our simple implementation of SCAN is really a plain wrapper for KEYS, // relying on the current mock implementation of the pattern search. return new ScanResult < String > ( "0" , new ArrayList < String > ( keys ( match ) ) ) ; }


Input: Performs a wildcard matching for the text and pattern provided . Source : http : // www . adarshr . com / papers / wildcard [CODESPLIT] public boolean match ( String text , final String pattern ) { // Create the cards by splitting using a RegEx. If more speed // is desired, a simpler character based splitting can be done. final String [ ] cards = REGEX_STAR . split ( pattern ) ; final int numCards = cards . length ; // Iterate over the cards. for ( int i = 0 ; i < numCards ; ++ i ) { final String card = cards [ i ] ; final int idx = text . indexOf ( card ) ; // Card not detected in the text. if ( idx == - 1 ) { return false ; } if ( idx != 0 && i == 0 ) { return false ; // test needs to start from 'card' } // Move ahead, towards the right of the text. text = text . substring ( idx + card . length ( ) ) ; } return true ; }


Input: https : // confluence . atlassian . com / bamboo / bamboo - variables - 289277087 . html [CODESPLIT] private static CIEnvironment detectBamboo ( Map < String , String > env ) { String revision = env . get ( "bamboo_planRepository_revision" ) ; String branch = env . get ( "bamboo_repository_git_branch" ) ; if ( revision == null || branch == null ) return null ; String tag = null ; String projectName = env . get ( "bamboo_planRepository_name" ) ; return new CIEnvironment ( "Bamboo" , revision , branch , tag , projectName ) ; }


Input: https : // docs . travis - ci . com / user / environment - variables / #Default - Environment - Variables [CODESPLIT] private static CIEnvironment detectTravis ( Map < String , String > env ) { String revision = env . get ( "TRAVIS_COMMIT" ) ; String branch = env . get ( "TRAVIS_BRANCH" ) ; if ( revision == null || branch == null ) return null ; String tag = null ; String repoSlug = env . get ( "TRAVIS_REPO_SLUG" ) ; String projectName = repoSlug . split ( "/" ) [ 1 ] ; return new CIEnvironment ( "Travis CI" , revision , branch , tag , projectName ) ; }


Input: Use by loaders [CODESPLIT] public void setValue ( String property , Value value ) { this . valueByProperty . put ( property . toLowerCase ( ) , value ) ; }


Input: Add a file to the ZIP . [CODESPLIT] public String add ( File file , boolean preserveExternalFileName ) { File existingFile = checkFileExists ( file ) ; String result = zipPathFor ( existingFile , preserveExternalFileName ) ; entries . put ( existingFile , result ) ; return result ; }


Input: Replace the contents of a file with a different text . [CODESPLIT] public void replace ( File file , boolean preserveExternalFileName , String text ) { String path = entries . containsKey ( file ) ? entries . remove ( file ) : zipPathFor ( file , preserveExternalFileName ) ; entries . put ( text , path ) ; }


Input: Build a ZIP file containing the added entries . [CODESPLIT] public File build ( ) throws IOException { if ( entries . isEmpty ( ) ) { throw new EmptyZipException ( ) ; } String fileName = "import_configuration" + System . currentTimeMillis ( ) + ".zip" ; File result = new File ( TEMP_DIR . toFile ( ) , fileName ) ; try ( ZipOutputStream zip = new ZipOutputStream ( Files . newOutputStream ( result . toPath ( ) , StandardOpenOption . CREATE_NEW ) ) ) { customization . init ( entries . values ( ) , this :: streamFor ) ; for ( Entry < Object , String > entry : entries . entrySet ( ) ) { try ( InputStream input = toInputStream ( entry . getKey ( ) ) ) { addEntry ( ExtraZipEntry . of ( entry . getValue ( ) , customization . customize ( entry . getValue ( ) , input ) ) , zip ) ; } } customization . extraEntries ( ) . forEach ( entry -> addEntry ( entry , zip ) ) ; zip . closeEntry ( ) ; } return result ; }


Input: Generate a product by assembling components . [CODESPLIT] public Metrics generate ( Iterable < C > components , DataBuffer product ) throws IOException { return generate ( components . iterator ( ) , product ) ; }


Input: Generate a product by assembling components . [CODESPLIT] public Metrics generate ( Iterator < C > components , DataBuffer product ) throws IOException { assembler . start ( product ) ; try { while ( components . hasNext ( ) ) { assembler . add ( components . next ( ) ) ; } } finally { assembler . end ( ) ; } return assembler . getMetrics ( ) ; }


Input: Generate a product by assembling components . [CODESPLIT] public Metrics generate ( Enumeration < C > components , DataBuffer product ) throws IOException { return generate ( new EnumerationIterator < C > ( components ) , product ) ; }


Input: Generate a product from a single piece . [CODESPLIT] public Metrics generate ( C component , DataBuffer product ) throws IOException { return generate ( Collections . singletonList ( component ) , product ) ; }


Input: Fetch the content for the specified content id . [CODESPLIT] @ Override @ Deprecated public ContentResult fetchContent ( String contentId ) throws IOException { try { String contentResource = resourceCache . getCiResourceUri ( ) ; URIBuilder builder = new URIBuilder ( contentResource ) ; builder . setParameter ( "cid" , contentId ) ; URI uri = builder . build ( ) ; return restClient . get ( uri . toString ( ) , contentResultFactory ) ; } catch ( URISyntaxException e ) { throw new IllegalStateException ( "Failed to create content resource uri." , e ) ; } }


Input: Fetch the content for the specified order item . [CODESPLIT] @ Override @ Deprecated public ContentResult fetchOrderContent ( OrderItem orderItem ) throws IOException { String downloadUri = Objects . requireNonNull ( Objects . requireNonNull ( orderItem , "Missing order item" ) . getUri ( LINK_DOWNLOAD ) , "Missing download URI" ) ; String fetchUri = restClient . uri ( downloadUri ) . addParameter ( "downloadToken" , "" ) . build ( ) ; return restClient . get ( fetchUri , contentResultFactory ) ; }


Input: Upload the transformation zip with the stylesheet into Archive . [CODESPLIT] @ Override @ Deprecated public LinkContainer uploadTransformation ( ExportTransformation exportTransformation , InputStream zip ) throws IOException { String uri = exportTransformation . getUri ( LINK_EXPORT_TRANSFORMATION_ZIP ) ; return restClient . post ( uri , LinkContainer . class , new BinaryPart ( "file" , zip , "stylesheet.zip" ) ) ; }


Input: Generate a file by assembling components . [CODESPLIT] public FileGenerationMetrics generate ( Iterator < C > components ) throws IOException { File result = fileSupplier . get ( ) ; return new FileGenerationMetrics ( result , generate ( components , new FileBuffer ( result ) ) ) ; }


Input: Create a new directory in the given parent directory . [CODESPLIT] public static File in ( File parentDir ) { File result = new File ( parentDir , UUID . randomUUID ( ) . toString ( ) ) ; if ( ! result . mkdirs ( ) ) { throw new RuntimeIoException ( new IOException ( "Could not create directory: " + result ) ) ; } return result ; }


Input: End this builder . [CODESPLIT] public P end ( ) { parent . addChildObject ( English . plural ( object . getType ( ) ) , object ) ; return parent ; }


Input: Prepares a group by adding renderers adaptors and sub templates . Override this if you want to add additional renderers . By default adds : <ul > <li > an { [CODESPLIT] protected void prepareGroup ( STGroup group ) { registerAdaptor ( group , Map . class , new MapModelAdaptor ( ) ) ; registerRenderer ( group , Date . class , new XmlDateRenderer ( ) ) ; }


Input: Registers a ModelAdaptor with the group . Override this method if you want to suppress one OOTB adaptor but not all . [CODESPLIT] protected < S > void registerAdaptor ( STGroup group , Class < S > type , ModelAdaptor adaptor ) { group . registerModelAdaptor ( type , adaptor ) ; }


Input: Registers a renderer with the group . Override this method if you want to suppress one OOTB renderer but not all . [CODESPLIT] protected < S > void registerRenderer ( STGroup group , Class < S > type , AttributeRenderer attributeRenderer ) { group . registerRenderer ( type , attributeRenderer ) ; }


Input: Prepares the template by adding the variables . [CODESPLIT] protected ST prepareTemplate ( ST prototype , D domainObject , Map < String , ContentInfo > contentInfo ) { ST template = new ST ( prototype ) ; template . add ( MODEL_VARIABLE , domainObject ) ; template . add ( CONTENT_VARIABLE , contentInfo ) ; return template ; }


Input: Add a domain object to the batch of SIPs . [CODESPLIT] public synchronized void add ( D domainObject ) throws IOException { if ( shouldStartNewSip ( domainObject ) ) { startSip ( ) ; } assembler . add ( domainObject ) ; }


Input: Set the value of a property . [CODESPLIT] public void setProperty ( String name , Object value ) { properties . put ( name , toJsonValue ( value ) ) ; }


Input: Add an object that is to be owned by this object . [CODESPLIT] public void addChildObject ( String collection , ConfigurationObject childObject ) { childObjects . computeIfAbsent ( collection , ignored -> new ArrayList <> ( ) ) . add ( childObject ) ; }


Input: Convert a date to <a href = https : // tools . ietf . org / html / rfc3339#section - 5 . 6 > ISO 8601 dateTime< / a > format . [CODESPLIT] @ Nullable public static String toIso ( Date dateTime ) { if ( dateTime == null ) { return null ; } Calendar calendar = Calendar . getInstance ( ) ; calendar . setTime ( dateTime ) ; return DatatypeConverter . printDateTime ( calendar ) ; }


Input: Convert an <a href = https : // tools . ietf . org / html / rfc3339#section - 5 . 6 > ISO 8601 dateTime< / a > string to a date . [CODESPLIT] @ Nullable public static Date fromIso ( String dateTime ) { if ( dateTime == null ) { return null ; } return DatatypeConverter . parseDateTime ( dateTime ) . getTime ( ) ; }


Input: Returns a supplier that creates sequentially named files in the given directory . [CODESPLIT] public static Supplier < File > fromDirectory ( File dir , String prefix , String suffix ) { return new Supplier < File > ( ) { private int count ; @ Override public File get ( ) { return new File ( ensureDir ( dir ) , String . format ( "%s%d%s" , prefix , ++ count , suffix ) ) ; } } ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdi ( PackagingInformation prototype , Assembler < HashedContents < D > > pdiAssembler ) { return forPdiWithHashing ( prototype , pdiAssembler , new NoHashAssembler ( ) ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdi ( PackagingInformationFactory factory , Assembler < HashedContents < D > > pdiAssembler ) { return forPdiWithHashing ( factory , pdiAssembler , new NoHashAssembler ( ) ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiWithHashing ( PackagingInformation prototype , Assembler < HashedContents < D > > pdiAssembler , HashAssembler pdiHashAssembler ) { return forPdiAndContentWithHashing ( prototype , pdiAssembler , pdiHashAssembler , ContentAssembler . ignoreContent ( ) ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiWithHashing ( PackagingInformationFactory factory , Assembler < HashedContents < D > > pdiAssembler , HashAssembler pdiHashAssembler ) { return forPdiAndContentWithHashing ( factory , pdiAssembler , pdiHashAssembler , ContentAssembler . ignoreContent ( ) ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContent ( PackagingInformation prototype , Assembler < HashedContents < D > > pdiAssembler , DigitalObjectsExtraction < D > contentsExtraction ) { HashAssembler noHashAssembler = new NoHashAssembler ( ) ; return forPdiAndContentWithHashing ( prototype , pdiAssembler , noHashAssembler , contentsExtraction , noHashAssembler ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContent ( PackagingInformation prototype , Assembler < HashedContents < D > > pdiAssembler , ContentAssembler < D > contentAssembler ) { HashAssembler noHashAssembler = new NoHashAssembler ( ) ; return forPdiAndContentWithHashing ( prototype , pdiAssembler , noHashAssembler , contentAssembler ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContent ( PackagingInformationFactory factory , Assembler < HashedContents < D > > pdiAssembler , ContentAssembler < D > contentAssembler ) { HashAssembler noHashAssembler = new NoHashAssembler ( ) ; return forPdiAndContentWithHashing ( factory , pdiAssembler , noHashAssembler , contentAssembler ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContent ( PackagingInformationFactory factory , Assembler < HashedContents < D > > pdiAssembler , DigitalObjectsExtraction < D > contentsExtraction ) { HashAssembler noHashAssembler = new NoHashAssembler ( ) ; return forPdiAndContentWithHashing ( factory , pdiAssembler , noHashAssembler , ContentAssembler . noDedup ( contentsExtraction , noHashAssembler ) ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContentWithContentHashing ( PackagingInformation prototype , Assembler < HashedContents < D > > pdiAssembler , DigitalObjectsExtraction < D > contentsExtraction , HashAssembler contentHashAssembler ) { return forPdiAndContentWithHashing ( prototype , pdiAssembler , new NoHashAssembler ( ) , contentsExtraction , contentHashAssembler ) ; }


Input: Assemble a SIP that contains only structured data and is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContentWithContentHashing ( PackagingInformationFactory factory , Assembler < HashedContents < D > > pdiAssembler , DigitalObjectsExtraction < D > contentsExtraction , HashAssembler contentHashAssembler ) { return forPdiAndContentWithHashing ( factory , pdiAssembler , new NoHashAssembler ( ) , new ContentAssemblerDefault < D > ( contentsExtraction , contentHashAssembler ) ) ; }


Input: Assemble a SIP that is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContentWithHashing ( PackagingInformation prototype , Assembler < HashedContents < D > > pdiAssembler , HashAssembler pdiHashAssembler , DigitalObjectsExtraction < D > contentsExtraction , HashAssembler contentHashAssembler ) { return new SipAssembler <> ( new DefaultPackagingInformationFactory ( prototype ) , pdiAssembler , pdiHashAssembler , new DataBufferSupplier <> ( MemoryBuffer . class ) , new ContentAssemblerDefault < D > ( contentsExtraction , contentHashAssembler ) ) ; }


Input: Assemble a SIP that is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContentWithHashing ( PackagingInformation prototype , Assembler < HashedContents < D > > pdiAssembler , HashAssembler pdiHashAssembler , ContentAssembler < D > contentAssembler ) { return new SipAssembler <> ( new DefaultPackagingInformationFactory ( prototype ) , pdiAssembler , pdiHashAssembler , new DataBufferSupplier <> ( MemoryBuffer . class ) , contentAssembler ) ; }


Input: Assemble a SIP that is the only SIP in its DSS . [CODESPLIT] public static < D > SipAssembler < D > forPdiAndContentWithHashing ( PackagingInformationFactory factory , Assembler < HashedContents < D > > pdiAssembler , HashAssembler pdiHashAssembler , ContentAssembler < D > contentAssembler ) { return new SipAssembler <> ( factory , pdiAssembler , pdiHashAssembler , new DataBufferSupplier <> ( MemoryBuffer . class ) , contentAssembler ) ; }


Input: Utility method to copy the bytes from an InputStream to an OutputStream while also assembling a hash value in the process . [CODESPLIT] public static void copy ( InputStream in , OutputStream out , int bufferSize , HashAssembler hashAssembler ) throws IOException { byte [ ] buffer = new byte [ bufferSize ] ; int numRead = Objects . requireNonNull ( in , "Missing input" ) . read ( buffer ) ; if ( numRead == 0 ) { throw new IllegalArgumentException ( "Missing content" ) ; } Objects . requireNonNull ( out , "Missing output" ) ; while ( numRead > 0 ) { out . write ( buffer , 0 , numRead ) ; hashAssembler . add ( buffer , numRead ) ; numRead = in . read ( buffer ) ; } }


Input: Return a new factory for building XML documents that is configured to operate securely . The factory also supports <a href = http : // www . w3 . org / TR / REC - xml - names / > XML namespaces< / a > and validation . [CODESPLIT] public static DocumentBuilderFactory newSecureDocumentBuilderFactory ( ) { try { DocumentBuilderFactory result = DocumentBuilderFactory . newInstance ( ) ; result . setFeature ( "http://javax.xml.XMLConstants/feature/secure-processing" , true ) ; result . setFeature ( "http://xml.org/sax/features/external-general-entities" , false ) ; result . setFeature ( "http://xml.org/sax/features/external-parameter-entities" , false ) ; result . setNamespaceAware ( true ) ; result . setValidating ( true ) ; return result ; } catch ( ParserConfigurationException e ) { throw new IllegalStateException ( e ) ; } }


Input: Parse the content of a given file into an XML document . [CODESPLIT] public static Document parse ( File file ) { if ( ! file . isFile ( ) ) { throw new IllegalArgumentException ( "Missing file: " + file . getAbsolutePath ( ) ) ; } try { try ( InputStream stream = Files . newInputStream ( file . toPath ( ) , StandardOpenOption . READ ) ) { return parse ( stream ) ; } } catch ( IOException e ) { throw new IllegalArgumentException ( "Failed to parse " + file . getAbsolutePath ( ) , e ) ; } }


Input: Parse the content of a given reader into an XML document . [CODESPLIT] public static Document parse ( Reader reader ) { DocumentBuilder documentBuilder = getDocumentBuilder ( ) ; try { return documentBuilder . parse ( new InputSource ( reader ) ) ; } catch ( SAXException | IOException e ) { throw new IllegalArgumentException ( "Failed to parse XML document" , e ) ; } finally { documentBuilder . reset ( ) ; } }


Input: Return the elements under a given parent element . [CODESPLIT] public static Stream < Element > elementsIn ( Element parent ) { return nodesIn ( parent ) . filter ( n -> n . getNodeType ( ) == Node . ELEMENT_NODE ) . map ( n -> ( Element ) n ) ; }


Input: Return the nodes under a given parent element . [CODESPLIT] public static Stream < Node > nodesIn ( Element parent ) { return StreamSupport . stream ( new ChildNodesSpliterator ( parent ) , false ) ; }


Input: Return the first child element of a given parent element whose tag matches any of the given names . When no child names are given the first child element is returned . [CODESPLIT] public static Element getFirstChildElement ( Element parent , String ... childNames ) { return firstOf ( namedElementsIn ( parent , childNames ) ) ; }


Input: Return the elements under a given parent element whose tag matches any of the given names . When no child names are given all child elements are returned . [CODESPLIT] public static Stream < Element > namedElementsIn ( Element parent , String ... childNames ) { return elementsIn ( parent ) . filter ( e -> isName ( e , childNames ) ) ; }


Input: Validate an XML document against an XML Schema document . [CODESPLIT] public static void validate ( InputStream xml , InputStream xmlSchema , String humanFriendlyDocumentType ) throws IOException { try { newXmlSchemaValidator ( xmlSchema ) . validate ( new StreamSource ( Objects . requireNonNull ( xml ) ) ) ; } catch ( SAXException e ) { throw new ValidationException ( "Invalid " + humanFriendlyDocumentType , e ) ; } }


Input: Returns an { [CODESPLIT] public static ArchiveClient configuringApplicationUsing ( ApplicationConfigurer configurer , ArchiveConnection connection ) throws IOException { configurer . configure ( connection ) ; return usingAlreadyConfiguredApplication ( configurer . getApplicationName ( ) , connection ) ; }


Input: Returns an { [CODESPLIT] public static ArchiveClient usingAlreadyConfiguredApplication ( String applicationName , ArchiveConnection connection ) throws IOException { RestClient restClient = connection . getRestClient ( ) ; return new InfoArchiveRestClient ( restClient , appResourceCache ( applicationName , connection , restClient ) ) ; }


Input: Parses the given YAML . [CODESPLIT] public static YamlMap from ( String yaml ) { assertNotNull ( yaml ) ; try ( InputStream input = streamOf ( yaml ) ) { return from ( input ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Failed to parse YAML string" , e ) ; } }


Input: Parses the given YAML . [CODESPLIT] public static YamlMap from ( File yaml ) throws IOException { assertNotNull ( yaml ) ; if ( ! yaml . isFile ( ) ) { return new YamlMap ( ) ; } try ( InputStream input = Files . newInputStream ( yaml . toPath ( ) ) ) { return from ( input ) ; } }


Input: Build a SIP archive from all files in a given directory tree . [CODESPLIT] public static void main ( String [ ] args ) { try { Arguments arguments = new Arguments ( args ) ; File root = new File ( arguments . next ( "content" ) ) ; if ( ! root . isDirectory ( ) ) { root = new File ( "." ) ; } String rootPath = root . getCanonicalPath ( ) ; String sip = arguments . next ( "build/files.zip" ) ; new FileArchiver ( ) . run ( rootPath , sip ) ; } catch ( IOException e ) { e . printStackTrace ( System . out ) ; System . exit ( 1 ) ; } }


Input: Sets the content . [CODESPLIT] public ContentBuilder < P > as ( InputStream content ) { try { return as ( IOUtils . toString ( content , StandardCharsets . UTF_8 ) ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Failed to read content" , e ) ; } }


Input: Sets the content from a named resource . [CODESPLIT] public ContentBuilder < P > fromResource ( String name ) { try ( InputStream content = ContentBuilder . class . getResourceAsStream ( name ) ) { return as ( content ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Failed to read resource: " + name , e ) ; } }


Input: Process a named entry in the ZIP file . [CODESPLIT] public < T > T andProcessEntry ( String entry , Function < InputStream , T > processor ) { try ( ZipFile zipFile = new ZipFile ( zip ) ) { return processEntry ( zipFile , entry , processor ) ; } catch ( IOException e ) { throw new RuntimeIoException ( e ) ; } }


Input: Chinese characters transform [CODESPLIT] public static String asciiCharactersEncoding ( String str ) throws QSException { if ( QSStringUtil . isEmpty ( str ) ) { return "" ; } try { String encoded = URLEncoder . encode ( str , QSConstant . ENCODING_UTF8 ) ; encoded = encoded . replace ( "%2F" , "/" ) ; encoded = encoded . replace ( "%3D" , "=" ) ; encoded = encoded . replace ( "+" , "%20" ) ; encoded = encoded . replace ( "%3A" , ":" ) ; return encoded ; } catch ( UnsupportedEncodingException e ) { throw new QSException ( "UnsupportedEncodingException:" , e ) ; } }


Input: Generate signature for request against QingStor . [CODESPLIT] public static String generateAuthorization ( String accessKey , String secretKey , String method , String requestURI , Map < String , String > params , Map < String , String > headers ) { String signature = generateSignature ( secretKey , method , requestURI , params , headers ) ; return String . format ( "QS %s:%s" , accessKey , signature ) ; }


Input: Generate signature for request against QingStor . [CODESPLIT] public static String generateAuthorization ( String accessKey , String secretKey , String strToSign ) { String signature = generateSignature ( secretKey , strToSign ) ; return String . format ( "QS %s:%s" , accessKey , signature ) ; }


Input: Generate signature for request against QingStor . [CODESPLIT] public static String generateSignature ( String secretKey , String method , String requestURI , Map < String , String > params , Map < String , String > headers ) { String signature = "" ; String strToSign = getStringToSignature ( method , requestURI , params , headers ) ; logger . log ( Level . INFO , "== String to sign ==\n" + strToSign + "\n" ) ; signature = generateSignature ( secretKey , strToSign ) ; return signature ; }


Input: Generate signature for request against QingStor . [CODESPLIT] public static String generateAuthorization ( String accessKey , String secretKey , String strToSign ) { return QSSignatureUtil . generateAuthorization ( accessKey , secretKey , strToSign ) ; }


Input: Generate signature for request against QingStor . [CODESPLIT] public static String generateSignature ( String secretKey , String strToSign ) { return QSSignatureUtil . generateSignature ( secretKey , strToSign ) ; }


Input: <p > OkHttp will use Accept - Encoding : gzip as default header which may not get Content - Length form server when download . < / p > [CODESPLIT] private void checkDownloadRequest ( ) { if ( outputClass == null ) return ; boolean isDownloadRequest = false ; Field [ ] declaredField = outputClass . getDeclaredFields ( ) ; for ( Field field : declaredField ) { String methodName = "get" + QSParamInvokeUtil . capitalize ( field . getName ( ) ) ; Method [ ] methods = outputClass . getDeclaredMethods ( ) ; for ( Method m : methods ) { if ( m . getName ( ) . equalsIgnoreCase ( methodName ) ) { ParamAnnotation annotation = m . getAnnotation ( ParamAnnotation . class ) ; if ( annotation == null ) continue ; if ( "BodyInputStream" . equals ( annotation . paramName ( ) ) ) { isDownloadRequest = true ; break ; } } } } if ( isDownloadRequest ) { getBuilder ( ) . setHeader ( "Accept-Encoding" , "identity" ) ; } }


Input: Set signature and server time . [CODESPLIT] public void setSignature ( String accessKey , String signature , String gmtTime ) throws QSException { builder . setHeader ( QSConstant . HEADER_PARAM_KEY_DATE , gmtTime ) ; setSignature ( accessKey , signature ) ; }


Input: Encodes hex octects into Base64 [CODESPLIT] public static String encode ( byte [ ] binaryData ) { if ( binaryData == null ) { return null ; } int lengthDataBits = binaryData . length * EIGHTBIT ; if ( lengthDataBits == 0 ) { return "" ; } int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP ; int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP ; int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets ; char encodedData [ ] = null ; encodedData = new char [ numberQuartet * 4 ] ; byte k = 0 , l = 0 , b1 = 0 , b2 = 0 , b3 = 0 ; int encodedIndex = 0 ; int dataIndex = 0 ; for ( int i = 0 ; i < numberTriplets ; i ++ ) { b1 = binaryData [ dataIndex ++ ] ; b2 = binaryData [ dataIndex ++ ] ; b3 = binaryData [ dataIndex ++ ] ; l = ( byte ) ( b2 & 0x0f ) ; k = ( byte ) ( b1 & 0x03 ) ; byte val1 = ( ( b1 & SIGN ) == 0 ) ? ( byte ) ( b1 >> 2 ) : ( byte ) ( ( b1 ) >> 2 ^ 0xc0 ) ; byte val2 = ( ( b2 & SIGN ) == 0 ) ? ( byte ) ( b2 >> 4 ) : ( byte ) ( ( b2 ) >> 4 ^ 0xf0 ) ; byte val3 = ( ( b3 & SIGN ) == 0 ) ? ( byte ) ( b3 >> 6 ) : ( byte ) ( ( b3 ) >> 6 ^ 0xfc ) ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ val1 ] ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ val2 | ( k << 4 ) ] ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ ( l << 2 ) | val3 ] ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ b3 & 0x3f ] ; } // form integral number of 6-bit groups if ( fewerThan24bits == EIGHTBIT ) { b1 = binaryData [ dataIndex ] ; k = ( byte ) ( b1 & 0x03 ) ; byte val1 = ( ( b1 & SIGN ) == 0 ) ? ( byte ) ( b1 >> 2 ) : ( byte ) ( ( b1 ) >> 2 ^ 0xc0 ) ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ val1 ] ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ k << 4 ] ; encodedData [ encodedIndex ++ ] = PAD ; encodedData [ encodedIndex ++ ] = PAD ; } else if ( fewerThan24bits == SIXTEENBIT ) { b1 = binaryData [ dataIndex ] ; b2 = binaryData [ dataIndex + 1 ] ; l = ( byte ) ( b2 & 0x0f ) ; k = ( byte ) ( b1 & 0x03 ) ; byte val1 = ( ( b1 & SIGN ) == 0 ) ? ( byte ) ( b1 >> 2 ) : ( byte ) ( ( b1 ) >> 2 ^ 0xc0 ) ; byte val2 = ( ( b2 & SIGN ) == 0 ) ? ( byte ) ( b2 >> 4 ) : ( byte ) ( ( b2 ) >> 4 ^ 0xf0 ) ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ val1 ] ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ val2 | ( k << 4 ) ] ; encodedData [ encodedIndex ++ ] = lookUpBase64Alphabet [ l << 2 ] ; encodedData [ encodedIndex ++ ] = PAD ; } return new String ( encodedData ) ; }


Input: Decodes Base64 data into octects [CODESPLIT] public static byte [ ] decode ( String encoded ) { if ( encoded == null ) { return null ; } char [ ] base64Data = encoded . toCharArray ( ) ; // remove white spaces int len = removeWhiteSpace ( base64Data ) ; if ( len % FOURBYTE != 0 ) { return null ; // should be divisible by four } int numberQuadruple = ( len / FOURBYTE ) ; if ( numberQuadruple == 0 ) { return new byte [ 0 ] ; } byte decodedData [ ] = null ; byte b1 = 0 , b2 = 0 , b3 = 0 , b4 = 0 ; char d1 = 0 , d2 = 0 , d3 = 0 , d4 = 0 ; int i = 0 ; int encodedIndex = 0 ; int dataIndex = 0 ; decodedData = new byte [ ( numberQuadruple ) * 3 ] ; for ( ; i < numberQuadruple - 1 ; i ++ ) { if ( ! isData ( ( d1 = base64Data [ dataIndex ++ ] ) ) || ! isData ( ( d2 = base64Data [ dataIndex ++ ] ) ) || ! isData ( ( d3 = base64Data [ dataIndex ++ ] ) ) || ! isData ( ( d4 = base64Data [ dataIndex ++ ] ) ) ) { return null ; } // if found "no data" just return null b1 = base64Alphabet [ d1 ] ; b2 = base64Alphabet [ d2 ] ; b3 = base64Alphabet [ d3 ] ; b4 = base64Alphabet [ d4 ] ; decodedData [ encodedIndex ++ ] = ( byte ) ( b1 << 2 | b2 >> 4 ) ; decodedData [ encodedIndex ++ ] = ( byte ) ( ( ( b2 & 0xf ) << 4 ) | ( ( b3 >> 2 ) & 0xf ) ) ; decodedData [ encodedIndex ++ ] = ( byte ) ( b3 << 6 | b4 ) ; } if ( ! isData ( ( d1 = base64Data [ dataIndex ++ ] ) ) || ! isData ( ( d2 = base64Data [ dataIndex ++ ] ) ) ) { return null ; // if found "no data" just return null } b1 = base64Alphabet [ d1 ] ; b2 = base64Alphabet [ d2 ] ; d3 = base64Data [ dataIndex ++ ] ; d4 = base64Data [ dataIndex ++ ] ; if ( ! isData ( ( d3 ) ) || ! isData ( ( d4 ) ) ) { // Check if they are PAD characters if ( isPad ( d3 ) && isPad ( d4 ) ) { if ( ( b2 & 0xf ) != 0 ) // last 4 bits should be zero { return null ; } byte [ ] tmp = new byte [ i * 3 + 1 ] ; System . arraycopy ( decodedData , 0 , tmp , 0 , i * 3 ) ; tmp [ encodedIndex ] = ( byte ) ( b1 << 2 | b2 >> 4 ) ; return tmp ; } else if ( ! isPad ( d3 ) && isPad ( d4 ) ) { b3 = base64Alphabet [ d3 ] ; if ( ( b3 & 0x3 ) != 0 ) // last 2 bits should be zero { return null ; } byte [ ] tmp = new byte [ i * 3 + 2 ] ; System . arraycopy ( decodedData , 0 , tmp , 0 , i * 3 ) ; tmp [ encodedIndex ++ ] = ( byte ) ( b1 << 2 | b2 >> 4 ) ; tmp [ encodedIndex ] = ( byte ) ( ( ( b2 & 0xf ) << 4 ) | ( ( b3 >> 2 ) & 0xf ) ) ; return tmp ; } else { return null ; } } else { // No PAD e.g 3cQl b3 = base64Alphabet [ d3 ] ; b4 = base64Alphabet [ d4 ] ; decodedData [ encodedIndex ++ ] = ( byte ) ( b1 << 2 | b2 >> 4 ) ; decodedData [ encodedIndex ++ ] = ( byte ) ( ( ( b2 & 0xf ) << 4 ) | ( ( b3 >> 2 ) & 0xf ) ) ; decodedData [ encodedIndex ++ ] = ( byte ) ( b3 << 6 | b4 ) ; } return decodedData ; }


Input: remove WhiteSpace from MIME containing encoded Base64 data . [CODESPLIT] private static int removeWhiteSpace ( char [ ] data ) { if ( data == null ) { return 0 ; } // count characters that's not whitespace int newSize = 0 ; int len = data . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( ! isWhiteSpace ( data [ i ] ) ) { data [ newSize ++ ] = data [ i ] ; } } return newSize ; }


Input: Upload a file with a sync request . [CODESPLIT] public void put ( File file ) throws QSException { if ( ! file . exists ( ) || file . isDirectory ( ) ) throw new QSException ( "File does not exist or it is a directory." ) ; put ( file , file . getName ( ) , null , "" ) ; }


Input: Upload a file with a sync request . [CODESPLIT] public void put ( File file , String objectKey , String fileName , String eTag ) throws QSException { // Check the file does exist or not. if ( ! file . exists ( ) || file . isDirectory ( ) ) throw new QSException ( "File does not exist or it is a directory." ) ; // Check file's length. long length = file . length ( ) ; if ( length < 1 ) throw new QSException ( "The size of file cannot be smaller than 1 byte." ) ; if ( length <= partSize ) { partCounts = 1 ; putFile ( file , objectKey , fileName , length ) ; } else { // Do multi uploads. // Calculate part counts. if ( length / partSize > MAX_PART_COUNTS ) { partSize = length / MAX_PART_COUNTS ; partCounts = MAX_PART_COUNTS ; // Check every part's size(max 5GB). if ( partSize > 5 * 1024 * 1024 * 1024L ) throw new QSException ( "The size of file is too large." ) ; } else { partCounts = ( int ) ( length / partSize ) ; if ( length % partSize > 0 ) partCounts += 1 ; } putFileMulti ( file , objectKey , fileName , eTag , length ) ; } }