Archive for the ‘pog’ Category

Interface Garantida

Posted: 24th maio 2012 by fabiojapa in pog

Tweet Quanta poeira neste blog…fazia tempo que eu não via um EJB bonito para postar… Esta contribuição veio de nosso colega VictorEM….não vou revelar o nome completo, pois vai que ele seja o autor do EJB…aí pode queimar o filme….rsrs public NaturezaBemEnum obterNaturezaBem(Garantia garantia) { if (garantia instanceof GarantiaAgricola) return NaturezaBemEnum.PRODUCAO_AGRICOLA; if (garantia instanceof GarantiaImovel) [...]

Quantidade de digitos em javascript é baba

Posted: 10th novembro 2011 by fabiojapa in gohorse, pog
Tags: ,

Tweet Um EJB em Javascript sugerido pelo Tiago Passos: Fui corrigir um problema em uma validação num JavaScript do Projeto “X”, e encontrei a seguinte obra-prima: if( !( ( (digitos / 10000000000) >= 1 ) && ( (digitos / 10000000000) < 10 ) ) ){ alert(‘O código deve conter 11 dígitos’); } Longe de mim [...]

Par? Pare!

Posted: 8th novembro 2011 by fabiojapa in pog, xgh - gohorse
Tags: ,

Tweet Opa… Voltei….só estava mexendo com códigos bem feitos… Por isso estava sem material pra postar aqui…hehehehehehe Mentira. Sempre tem EJB….hehehhe Olhem esse método bonito que diz se o int é par: public static boolean par(int i) { String str = “”+i; char lastChar = str.charAt(str.length()-1); if (lastChar == ’0′ || lastChar == ’2′ || [...]

StackTrace

Posted: 26th setembro 2011 by fabiojapa in pog

Tweet O que acontece? System.out.println(e.printStackTrace()); EJBs procurados:email compila com loc:BR

Finally

Posted: 25th setembro 2011 by fabiojapa in gohorse, pog
Tags:

Tweet // Porque diabos colocar um return deste de um finally? public int nomeDoMetodo() { try { // … } catc( Exception e ) { //… trata } finally { filePost.releaseConnection(); return (status == HttpStatus.SC_OK); } }

Extensão de arquivo

Posted: 24th setembro 2011 by fabiojapa in gohorse, pog, xgh - gohorse
Tags: ,

Tweet /** * aonde ele aprendeu isso? * @see java.io.FileFilter#accept(File) */ public boolean accept(File file) { if (filename.getName().substring((filename.getName().length() – 4), filename.getName().length()).compareTo(EXTENSAO) == 1) { return true; } else { return false; } } /** * Que tal fazer assim? * @see java.io.FileFilter#accept(File) */ public boolean accept(File file) { String filename = file.getName(); return filename.endsWith(EXTENSAO) }

IF?

Posted: 23rd setembro 2011 by fabiojapa in gohorse, pog, xgh - gohorse
Tags: ,

Tweet Fiquei tão espantando com a condição do IF… … if (rs.getString(“TIPO_CAMPO”).equals(“NR”)){ ps.setString(1, fvp.getValue()); } else { ps.setString(1, fvp.getValue()); } … …que tive dificulddes de enxergar que ele era inútil e o código seria correto assim: … ps.setString(1, fvp.getValue()); …

isNull

Posted: 23rd setembro 2011 by fabiojapa in pog

Tweet //sem comentarios…me recuso… public static boolean isNull(Object obj) { boolean isNull; try { obj.toString(); isNull = false; } catch (NullPointerException e) { isNull = true; } return isNull; }

Loop infinito

Posted: 23rd setembro 2011 by fabiojapa in pog
Tags:

Tweet Escolha sua opção: 1 int x = 0; for (x = 0; x < 1000; x++) { if (x == 999) x = 0; ... } 2 while (true) { .... } A opção 1 é bem criativa...rsrs

Funciona né?

Posted: 21st setembro 2011 by fabiojapa in pog

Tweet Com certeza funciona…. if(x.equals(“n”) { x=”n”; } Este também funciona…rs Quem me mostrou essa foi um stag….ele ficou com medo de mexer…Vai que ele mexe e dá M….rsrs if (str == null) return null; else return str;