奇跡のjava
public List filterNames(List<String> names, int len) { List<String> result = new ArrayList(); for (String name : names) { if (name.length() >= len) { result.add(name.toUpperCase()); } } return result; }
def filterNames(list: List[String], len: Int) = list.filter(_.length() >= len).map(_.toUpperCase)
jdbcの性能
■ある検索処理について
・改善前
取得レコード数:4451(ほんとは9001だけど、途中でメモリエラー)
取得カラム数:278
フェッチ処理時間:24.51sec
1レコードあたり平均フェッチ処理時間:5.50msec
select * を使って、不要カラムも取得しているので、必要なカラムだけをselectするように改善。
・改善後
取得レコード数:9001
取得カラム数:7
フェッチ処理時間:10.12sec
1レコードあたり平均フェッチ処理時間:1.12msec
改善後が圧倒的に早い。
jdbcは遅いっていうけど、無駄なselectはよくない。
javaコーディングチェックリスト
Javaの机上チェックリスト
http://daipresents.com/weblog/fujihalab/archives/2008/05/java-selfcheck-sheet.php
頑健なJavaプログラムの書き方
http://www.alles.or.jp/~torutk/oojava/codingStandard/writingrobustjavacode.html
XML-RPCを使ったweb api通信
Jasper Reports
java帳票出力について調査。
JasperReports
米Jaspersoft Corporationが開発、公開しているオープンソース。
ライセンスはLGPL V3。
iReportという帳票デザイナを使用し、帳票テンプレートを作成し、JasperReportsで帳票出力する。
帳票は、pdf, html, xls, csv, xml形式などがあり、直接、プリンタ出力することも可能。
■入手先
iReport
http://jasperforge.org/projects/ireport
iReport(日本語訳版)
http://sourceforge.jp/projects/oss-ja-jpn/releases/47233
Jasper Reports
http://jasperforge.org/projects/jasperreports
■利用方法
iReportで簡単帳票作成
http://www.bbreak.co.jp/technique/doc/ireport/iReport_webdb.pdf
api仕様(英語)
http://jasperreports.sourceforge.net/api/index.html
ExCella Reportsと比較して、
帳票の出力形式が多い。
デザイナが高機能っぽいが、習得に時間がかかりそう。
ドキュメント、資料の類が少ない。
Excella Reports
java帳票出力について調査。
Excella Reports
株式会社ビーブレイクシステムズが開発、公開しているExcella Reportsというオープンソース。
ライセンスはLGPL v3。
http://excella-core.sourceforge.jp/
excelファイルでテンプレートを作成し、Javaで値をバインドしたexcelファイルを出力する。
さらに、それをopenofficeのpdf変換機能を利用し、pdfファイルで出力することもできる。
リファレンス
http://excella-core.sourceforge.jp/excella-reports/reference/index.html
openofficeでpdf変換するときに、openofficeを起動、停止するが、このときにopenofficeが起動した状態だとエラーになってしまうので、注意。
http://groups.google.co.jp/group/excella/browse_thread/thread/33065c2476e21867
openofficeをインストールする必要があり、pdfファイル変換はそこそこの時間がかかる。
同プロジェクトには、以下のものもあった。
・Excella Core
javaからexcelファイルを読み込み、値を取得する。
http://excella-core.sourceforge.jp/excella-core/reference/index.html
・Excella Trans
javaからexcelデータをSQLやO/Rマッピングツールで使用できるようなエンティティに変換する。
http://excella-core.sourceforge.jp/excella-trans/reference/index.html