id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
00507239-c727-44ec-9f06-c30b1e3c6309 | public Date getCheckDate() {
return checkDate;
} |
baaa101e-b8cf-45fc-bfb3-5a842c43a782 | public void setCheckDate(Date checkDate) {
this.checkDate = checkDate;
} |
ff84b79c-ce95-4bef-8244-39c56f7e0f1b | public String getPaymentType() {
return paymentType;
} |
f53b2305-8753-4313-a8be-8b59aa9fd7f9 | public void setPaymentType(String paymentType) {
this.paymentType = paymentType;
} |
c9e5866e-6797-4045-93e0-38177cd5df02 | public double getDepositAmount() {
return depositAmount;
} |
ef20ed22-bfa6-4f37-8d95-403ece67a507 | public void setDepositAmount(double depositAmount) {
this.depositAmount = depositAmount;
} |
fead3cc8-95f2-4c77-af69-df35bf7fa600 | public double getPaymentAmount() {
return paymentAmount;
} |
b3a43082-31c0-4e65-aa18-aef066e872f5 | public void setPaymentAmount(double paymentAmount) {
this.paymentAmount = paymentAmount;
} |
06bd5fc9-d2d4-448d-a649-ea9981708b78 | public String getComments() {
return comments;
} |
befafdbc-315e-4235-8346-a377b424edc8 | public void setComments(String comments) {
this.comments = comments;
} |
edd6106d-d90b-4da8-9f71-82ccde574e52 | @Transactional(propagation = Propagation.REQUIRED)
public void save(final Ledger item) {
jdbcTemplate
.update("insert into ledger (rcv_dt, mbr_nm, chk_nbr, chk_dt, pymt_typ, dpst_amt, pymt_amt, comments) values(?,?,?,?,?,?,?,?)",
new PreparedStatementSetter() {
public void setValues(PreparedStatement stmt)
throws SQLException {
stmt.setDate(1, new java.sql.Date(item
.getReceiptDate().getTime()));
stmt.setString(2, item.getMemberName());
stmt.setString(3, item.getCheckNumber());
stmt.setDate(4, new java.sql.Date(item
.getCheckDate().getTime()));
stmt.setString(5, item.getPaymentType());
stmt.setDouble(6, item.getDepositAmount());
stmt.setDouble(7, item.getPaymentAmount());
stmt.setString(8, item.getComments());
}
});
} |
a6412024-da26-4909-b4b2-1c5fc3344e51 | public void setValues(PreparedStatement stmt)
throws SQLException {
stmt.setDate(1, new java.sql.Date(item
.getReceiptDate().getTime()));
stmt.setString(2, item.getMemberName());
stmt.setString(3, item.getCheckNumber());
stmt.setDate(4, new java.sql.Date(item
.getCheckDate().getTime()));
stmt.setString(5, item.getPaymentType());
stmt.setDouble(6, item.getDepositAmount());
stmt.setDouble(7, item.getPaymentAmount());
stmt.setString(8, item.getComments());
} |
b829f43b-c89d-4ccc-8acd-f6e0143fcb1d | public Object mapFieldSet(FieldSet fs) {
Ledger item = new Ledger();
int idx = 0;
item.setReceiptDate(fs.readDate(idx++, DATE_PATTERN));
item.setMemberName(fs.readString(idx++));
item.setCheckNumber(fs.readString(idx++));
item.setCheckDate(fs.readDate(idx++, DATE_PATTERN));
item.setPaymentType(fs.readString(idx++));
// deposit amount
try {
DecimalFormat fmttr = new DecimalFormat(DOLLAR_PATTERN);
Number number = fmttr.parse(fs.readString(idx++));
item.setDepositAmount(number.doubleValue());
} catch (ParseException e) {
item.setDepositAmount(0);
}
// payment amount
try {
DecimalFormat fmttr = new DecimalFormat(DOLLAR_PATTERN);
Number number = fmttr.parse(fs.readString(idx++));
item.setPaymentAmount(number.doubleValue());
} catch (ParseException e) {
item.setPaymentAmount(0);
}
//
return item;
} |
f2cb91d1-97e2-43b1-a496-28f910a898f3 | public void save(final Ledger note); |
84cad16c-12d2-4f63-861a-2d07eb59bf86 | public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Ledger ledger = new Ledger();
ledger.setId(rs.getInt("id"));
ledger.setReceiptDate(rs.getDate("rcv_dt"));
ledger.setMemberName(rs.getString("mbr_nm"));
ledger.setCheckNumber(rs.getString("chk_nbr"));
ledger.setCheckDate(rs.getDate("chk_dt"));
ledger.setPaymentType(rs.getString("pymt_typ"));
ledger.setDepositAmount(rs.getDouble("dpst_amt"));
ledger.setPaymentAmount(rs.getDouble("pymt_amt"));
ledger.setComments(rs.getString("comments"));
return ledger;
} |
db77188e-ecb1-422d-8ccd-8c5147b3ece4 | @Test
public void testLaunchJob() throws Exception {
StopWatch sw = new StopWatch();
sw.start();
jobLauncher.run(job, jobParameters);
sw.stop();
logger.info(">>> TIME ELAPSED:" + sw.prettyPrint());
} |
51a71bf3-f563-41d7-bf15-b2723379ffd4 | public AppTest( String testName )
{
super( testName );
} |
14672fb6-4e85-47a7-a0da-0b9143bc8e71 | public static Test suite()
{
return new TestSuite( AppTest.class );
} |
5e9b6257-ee3c-4319-adbe-b69d53ecf76f | public void testApp()
{
assertTrue( true );
} |
5c46fe95-1fee-4e31-9a49-39a5e941d063 | @Test
public void testLaunchJob() throws Exception {
StopWatch sw = new StopWatch();
sw.start();
launcher.run(job, jobParameters);
sw.stop();
logger.info(">>> TIME ELAPSED:" + sw.prettyPrint());
} |
74dc5f8e-25ab-4044-ad9f-c4c6715ae829 | @Test
public void testLaunchJob() throws Exception {
StopWatch sw = new StopWatch();
sw.start();
launcher.run(job, jobParameters);
sw.stop();
logger.info(">>> TIME ELAPSED:" + sw.prettyPrint());
} |
ac4499a0-1969-4024-89b9-c45c751f4390 | public String transforma(String textoASerTransformado); |
54f28cd5-862e-4d50-8d3e-e40c35101402 | @Override
public String transforma(String textoASerTransformado) {
textoASerTransformado = textoASerTransformado.replaceAll("_{2}(.*?)_{2}", "<u>$1</u>");
return textoASerTransformado;
} |
6d8188d9-d21a-4d20-be44-79abe664293b | @Override
public String transforma(String textoASerTransformado) {
textoASerTransformado = textoASerTransformado.replaceAll("\\*{2}(.*?)\\*{2}", "<br>$1</br>");
return textoASerTransformado;
} |
cf6ac7b2-9ded-42fd-ba3e-7b15e6c27c5f | @Override
public String transforma(String textoASerTransformado) {
textoASerTransformado = textoASerTransformado.replaceAll("[^\"]https?://w{3}.?\\..+\\.[^ ]+(\\.[^ ]+)*(//.*)*( |$|[^\\(])",
"<a href=\"$0\">$0</a>");
return textoASerTransformado;
} |
f86a4361-c552-4c39-a1b0-986cb10c2f34 | @Override
public String transforma(String textoASerTransformado) {
textoASerTransformado = textoASerTransformado.replaceAll("\\[image *src=\"(.*)\" *\\]", "<img src=\"$1\" />");
return textoASerTransformado;
} |
309469b1-4ca6-4dae-9d1b-2a5108a7910e | public static List<InterfaceTransformador> geraObjetosTransformadores(String textoASerValidado){
List<InterfaceTransformador> listaTransformadores = new ArrayList<InterfaceTransformador>();
listaTransformadores.addAll(Arrays.asList(new InterfaceTransformador[]{new TransformadorParaATagBR(),
new TransformadorParaATagI(),new TransformadorParaATagU(), new TransformadorParaCaminhoDeImg(),
new TransformadorParaLinkComApelido(), new TransformadorParaLink()}));
return listaTransformadores;
} |
5cf1f82c-5ff0-4458-af7b-e0e45f16d2a0 | public static boolean validaParaATagBR(String texto){
if(texto.matches(".*\\*{2}.*\\*{2}.*")){
return true;
}else{
return false;
}
} |
1f9670cf-5f59-4172-8ab7-ad90e5a087a0 | public static boolean validaParaATagI(String texto){
if(texto.matches(".*/{2}.*/{2}.*")){
return true;
}else{
return false;
}
} |
9aca5511-0465-4bda-bd42-fda5538322ef | public static void main(String[] args) {
String texto = "Testando a tag br ... **vivaaaaaa** \n" +
"Testando a tag i ... //vivaaaaaa// \n" +
"Testando a tag u ... __vivaaaaaa__ \n" +
"Testando path de img ... [image src=\"C:\\Users\\SAA\\Pictures\"] \n" +
"Testando path de link ... http://www.youtube.com \n" +
"Testando path de link ... http://www.youtube.com.br \n" +
"Testando path de link ... https://www.brasilmelhorpais.gov.net \n" +
"Testando path de link ... Link para youtube = http://www.youtube.com.br \n" +
"Testando path de link ... Link para youtube http://www.youtube.com/watch?v=/f46oqH/c8UF/E \n" +
"Testando path de link curto ... [http://www.google.com](Google)";
TransformaGeral transformaTudoEmHTML = new TransformaGeral();
System.out.println(transformaTudoEmHTML.transformaTextoEmHTML(texto));
} |
ca2d7c66-dd21-4cab-9859-f7f8c58a1187 | @Override
public String transforma(String textoASerTransformado) {
textoASerTransformado = textoASerTransformado.replaceAll("(\\[(https?://w{3}.?\\..+\\.[^ ]+(\\.[^ ]+)*(//.*)*)\\])\\((.*)\\)",
"<a href=\"$2\">$5</a>");
return textoASerTransformado;
} |
f1d9718a-341e-4507-bb48-ad39665d48c5 | public String transformaTextoEmHTML(String textoASerTransformado){
List<InterfaceTransformador> listaDeTransformadores = GeraObjetosDeTransformacaoNecessarios.geraObjetosTransformadores(textoASerTransformado);
for(InterfaceTransformador transforma : listaDeTransformadores){
textoASerTransformado = transforma.transforma(textoASerTransformado);
}
return textoASerTransformado;
} |
37492aeb-abcc-447c-abbb-313bfb339f93 | @Override
public String transforma(String textoASerTransformado) {
String textoAnterior = "";
String textoFinal = "";
while(validacaoDeListaNaString(textoASerTransformado)){
String textoAserTransformadoArray[] = textoASerTransformado.split("\n");
for(String texto : textoAserTransformadoArray){
if(textoAnterior.matches(".*<ul>.*")){
texto = texto.replaceAll("\\*(.*)", "<li>$1</li>");
}else if(texto.matches("\\*.*") && textoAnterior.matches("<li>.*</li>")){
texto = texto.replaceAll("\\*(.*)", "<li>$1</li>");
}
textoAnterior = texto;
textoFinal.concat(texto);
}
}
return textoASerTransformado;
} |
28a16035-c4f8-4f4a-a560-e7e59fa48aa3 | public boolean validacaoDeListaNaString(String textoASerTransformado){
if(textoASerTransformado.matches("<ul>.*\n\\*.*</ul>")){
return true;
}else{
return false;
}
} |
f0fc441b-ba95-4eb0-aa7a-9991aaeb84a0 | @Override
public String transforma(String textoASerTransformado) {
textoASerTransformado = textoASerTransformado.replaceAll("/{2}(.*?)/{2}", "<i>$1</i>");
return textoASerTransformado;
} |
1c9b7d7f-8569-4d37-b142-5d96883e70f4 | @Before
public void preparar() {
dao.preparar();
} |
8155275e-6d75-4936-96cb-79335107c2ee | @Test
public void test() {
List<Restaurante> restTest = dao.consultarRestaurantes();
assertEquals(4, restTest.size());
} |
ce67b22b-ba83-4e91-9fd6-a766ac264851 | @Test
public void testConsultarPorBairroCentro() {
List<Restaurante> restTest = dao.consultarRestaurantesBairro(new Bairro("Centro"));
assertEquals(2, restTest.size());
} |
763a3bfe-a13d-4cba-966f-1d0868ed35a2 | @Test
public void testConsultarPorBairroAuxiliadora() {
List<Restaurante> restTest = dao.consultarRestaurantesBairro(new Bairro("Auxiliadora"));
assertEquals(0, restTest.size());
} |
a7f9d96e-cdc2-4f41-9f01-6285b35436f7 | @Test
public void testConsultarPorBairroAzenha() {
List<Restaurante> restTest = dao.consultarRestaurantesBairro(new Bairro("Azenha"));
assertEquals(2, restTest.size());
} |
cebc3870-9656-4893-b167-8bcbe8734604 | @Test
public void testConsultarPorNome123() {
List<Restaurante> restTest = dao.consultarRestaurantesNome("Restaurante 123");
assertEquals(1, restTest.size());
} |
15a0294e-7876-4a22-83f0-7b7380cb3605 | @Test
public void testConsultarPorNomeABC() {
List<Restaurante> restTest = dao.consultarRestaurantesNome("Restaurante ABC");
assertEquals(1, restTest.size());
} |
b3caadd3-c657-41f5-a0ed-444b17241c40 | public JRestauranteFrame() {
initComponents();
rdao.preparar();
} |
b6c7e1e2-9499-4a55-aff0-c9bb0eac22c5 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Informe o bairro desejado:");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jButton1.setText("Consultar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jMenu1.setText("Arquivos");
jMenuItem1.setText("Adicionar Restaurante");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem2.setText("Adicionar Bairro");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenuBar1.add(jMenu1);
jMenu2.setText("Ajuda");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)
.addComponent(jButton1)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1))
.addContainerGap(23, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(35, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents |
cf5eae61-11d7-4fa6-830d-5fdb5e2e56e8 | public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
} |
6f81d404-ab2d-4709-9767-feaa46b4c718 | public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
} |
aa269503-8474-4744-8cbc-793c46245eb4 | public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
} |
32b8ceeb-285f-412a-a7ef-932c18a84fc2 | public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
} |
16736c2d-7c5a-4eef-a0a7-b6aae3a09566 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextField1ActionPerformed |
5135cba0-0e67-492a-88ea-99e3c1ba165b | private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
// TODO add your handling code here:
JOptionPane.showInputDialog(null, "Bairro a Cadastrar.");
}//GEN-LAST:event_jMenuItem2ActionPerformed |
6b596e7d-a1ea-40b8-a26e-27b5f0b70c99 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
Bairro b1 = new Bairro(jTextField1.getText());
String s = "";
List<Restaurante> rs = rdao.consultarRestaurantesBairro(b1);
for (Restaurante r : rs) {
s = s + r.toString() + "\n";
}
jTextArea1.setText(s); }//GEN-LAST:event_jButton1ActionPerformed |
a2a94cdf-a006-4b24-ae3b-fb8e0ebc9102 | private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
// TODO add your handling code here:
JOptionPane.showInputDialog(null, "Restaurante a Cadastrar.");
}//GEN-LAST:event_jMenuItem1ActionPerformed |
07446c5b-8a11-49e3-8a79-40e8e5ab7d0e | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JRestauranteFrame().setVisible(true);
}
});
} |
3fba2ff7-82dd-4875-acab-9f19d92d9893 | public void run() {
new JRestauranteFrame().setVisible(true);
} |
4a95f98d-14d1-4c93-85a8-20a498c83add | public Restaurante(String nome, String endereco, Bairro bairro) {
super();
this.nome = nome;
this.endereco = endereco;
this.bairro = bairro;
} |
b359f763-e36a-4812-b550-bc04cb3419b6 | public String getEndereco() {
return endereco;
} |
dc1b109d-9e6f-4b85-a824-00301425dbc1 | public String getNome() {
return nome;
} |
6619a1ec-15e9-45a0-a962-821296cc8498 | public Bairro getBairro() {
return bairro;
} |
3e8087de-102e-4ef0-8b98-fd6b448e14dd | @Override
public String toString() {
return nome + ", Endereço: " + endereco + ", Bairro: " + bairro;
} |
6e226604-9b25-4d10-8dff-3cefa1c2cd36 | public Bairro(String nome) {
this.nome = nome;
} |
825db304-116e-48d9-9f19-9b492faf6965 | public String getNome() {
return nome;
} |
7dfec9d4-295c-40e6-b450-17f5a95b912b | @Override
public String toString() {
return nome;
} |
179a1896-a85b-48c7-ae02-d1aad934c103 | @Override
public int hashCode() {
int hash = 7;
return hash;
} |
ba758f7c-8d16-4706-917d-2ee88421cddb | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Bairro other = (Bairro) obj;
if (!Objects.equals(this.nome, other.nome)) {
return false;
}
return true;
} |
41c4fa78-3fbf-48e6-b48d-5325fe4779d7 | public static void main(String[] args) throws IOException {
} |
aed5937f-5757-4f87-8149-4c76f3256914 | public List<Restaurante> consultarRestaurantes() {
return resultado;
} |
76351de0-388b-412f-96ed-a1bef9a682f3 | public void inserirRestaurante(String nome, String endereco, Bairro bairro) {
Restaurante rest = new Restaurante(nome, endereco, bairro);
resultado.add(rest);
} |
16cca43e-171a-43c4-8b0d-8867c79ff30e | public List<Restaurante> consultarRestaurantesBairro(Bairro bairro) {
List<Restaurante> r = new ArrayList<>();
for (Restaurante s : resultado) {
if (s.getBairro().equals(bairro)) {
r.add(s);
}
}
return r;
} |
30bf6013-305c-4bd0-9918-e5e9b5ce192f | public List<Restaurante> consultarRestaurantesNome(String nome) {
List<Restaurante> r = new ArrayList<>();
for (Restaurante s : resultado) {
if (s.getNome().equals(nome)) {
r.add(s);
}
}
return r;
} |
58242c3a-9aae-47ea-9b86-ad78c39408dd | public void preparar() {
Bairro b1 = new Bairro("Azenha");
Bairro b2 = new Bairro("Centro");
inserirRestaurante("Restaurante QWET","Rua A, nº1", b1);
inserirRestaurante("Restaurante #$%&","Rua B, nº2", b1);
inserirRestaurante("Restaurante ABC","Rua C, nº3", b2);
inserirRestaurante("Restaurante 123","Rua D, nº4", b2);
} |
e1d018c7-9a8e-425e-affc-4dd2aa0d71c8 | private Channels(int count) {
m_count = count;
} |
c97a7391-4e78-4ab2-9c44-b2e7ca5012bc | public int getCount() {
return m_count;
} |
dcab150f-d871-4784-a784-917bbb38c708 | private SampleRate(int rate) {
m_rate = rate;
} |
3155bc7f-1fc1-4e39-8cde-635ea5990ea4 | public int getRate() {
return m_rate;
} |
366f8386-8de4-47dd-bbbd-93e7f5284eb1 | public OpusDecoder(int sampleRate, byte[] firstPacket) throws Exception {
loadLibrary();
this.sampleRate = sampleRate;
if (sampleRate <= 0)
throw new IllegalArgumentException("Invalid sample rate");
this.channels = nativeParseChannels(firstPacket);
if (channels < 1)
throw new Exception("Failed to parse channels count from the first packet");
this.buffer = buildDecoder();
} |
5f1bd925-49c3-4c70-bf5a-95ea2c120a45 | public OpusDecoder(SampleRate sampleRate, Channels channels) throws Exception {
//System.out.println("java.library.path=" + System.getProperty("java.library.path"));
loadLibrary();
this.sampleRate = sampleRate.getRate();
this.channels = channels.getCount();
this.buffer = buildDecoder();
} |
637a5fb6-5919-4ed8-b55a-9b8bd93d79e4 | private short[] buildDecoder() throws Exception {
short[] buffer = new short[5760 * this.channels];
nativeDecoder = nativeCreate(this.sampleRate, this.channels);
if (nativeDecoder == 0)
throw new Exception();
return buffer;
} |
dc88f884-264f-4449-b2a8-bf2d55347ef2 | private void loadLibrary() {
try {
System.loadLibrary("opus");
} catch (UnsatisfiedLinkError e) {
try {
System.load(new File("target/native/libopus.jnilib").getAbsolutePath());
} catch (UnsatisfiedLinkError e2) {
System.load(new File("target/dependency/libopus.jnilib").getAbsolutePath());
}
}
} |
0ed6d6be-2e24-4866-bfdd-8a4bca418ad5 | public int getSampleRate() {
return sampleRate;
} |
176801de-ca42-4d88-902c-541b0172aece | public int getChannels() {
return channels;
} |
d992833c-d726-443b-8a41-6f55f27a683d | public short[] decode(byte[] packet) throws Exception {
int decoded = nativeDecode(nativeDecoder, packet, buffer, 5760);
if (decoded <= 0)
throw new Exception();
int samples = decoded * channels;
short[] out = new short[samples];
System.arraycopy(buffer, 0, out, 0, samples);
return out;
} |
8d088f35-0980-4b14-9715-f4217c9d82d1 | public void destroy() {
synchronized (this) {
if (nativeDecoder != 0) {
nativeDestroy(nativeDecoder);
nativeDecoder = 0;
}
}
} |
522788e3-8341-44f0-826b-3576b40bc580 | public void finalize() {
destroy();
} |
80f54b71-ff5f-45d9-bf8e-4bbbd4093f53 | private native long nativeCreate(int samplerate, int channels); |
b235a57c-5468-4de3-b848-869dafc07a8f | private native int nativeParseChannels(byte[] packet); |
be3428b0-22c2-4888-a43b-39bda35b5057 | private native int nativeDecode(long nativeDecoder, byte[] packet, short[] buffer, int nframes); |
f7fb3169-5590-4e79-83b3-c281108686cc | private native void nativeDestroy(long nativeDecoder); |
4535914a-4d17-47eb-956c-ee49f79894ea | @Test
public void test() throws Exception {
OpusDecoder decoder = new OpusDecoder(SampleRate.Rate_8Khz, Channels.Mono);
try {
Assert.assertNotNull(decoder);
} finally {
decoder.destroy();
}
} |
e4304d21-6326-4171-9a99-1ad3064d6e7a | public Map<String, Protocol> asMap() {
Map<String, Protocol> out = new HashMap<String, Protocol>();
for (Protocol protocol : protocols)
out.put(protocol.name, protocol);
return out;
} |
f506e3d2-134a-483b-b547-66f5a023bcf1 | public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("packet");
for (Protocol pr : protocols) {
sb.append(".").append(pr.name);
}
return sb.toString();
} |
28cd0e10-90dd-4088-9d45-6e0e3f51705b | public Map<String,Field> asMap() {
Map<String, Field> out = new HashMap<String, Field>();
for (Field field : fields)
out.put(field.name, field);
return out;
} |
cae035e1-80a2-4e29-b9b0-02e27b90854c | public String toString() {
return "protocol=" + name;
} |
857ae415-a014-4c2e-8d35-9fe9f148b707 | public Map<String, Protocol> asProtocolMap() {
Map<String, Protocol> out = new HashMap<String, Protocol>();
for (Protocol protocol : protocols)
out.put(protocol.name, protocol);
return out;
} |
1b032624-afed-49c2-b933-f9f5e6618678 | public Map<String, Field> asMap() {
Map<String, Field> out = new HashMap<String, Field>();
for (Field field : fields)
out.put(field.name, field);
return out;
} |
f7940e3a-fa18-4ba9-a6aa-ff84cfba1c3f | public String toString() {
return "field=" + name + "/" + value;
} |
4e386fb0-1e0f-4483-b202-697f8e166647 | public Pdml unmarshall(URL pdmlUrl) throws JAXBException {
JAXBContext c = JAXBContext.newInstance(Pdml.class);
Object o = c.createUnmarshaller().unmarshal(pdmlUrl);
if (o instanceof Pdml)
return (Pdml)o;
throw new JAXBException("Wrong unmarshalled type");
} |
cfdaeec3-cb03-4aa5-8d24-215c461b31f0 | public LittleEndianDataOutput(DataOutput out) {
this.out = out;
} |
0e8a164b-d2b4-432e-b12e-eb08f3766bb3 | private void swapOut() throws IOException {
byte[] b = baos.toByteArray();
for (int i=b.length-1; i>=0; --i)
out.write(b[i]);
baos.reset();
} |
af086d69-e6aa-4ad5-afe4-66b457dfed3e | @Override
public void write(int b) throws IOException {
out.write(b);
} |
0310a1f4-84d2-4ea7-bd99-e52c194bbad3 | @Override
public void write(byte[] b) throws IOException {
out.write(b);
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.