Java
個人情報を含むデータをもとにプログラムのテストデータを作成する場合などには、データの匿名化が必要になります。個人情報保護委員会「個人情報の保護に関する法律についてのガイドライン(匿名加工情報編)」*1には、管理用IDなど特定の個人の識別に使え…
Context You are building a Java web application with JMS. You have added a reference to JMS queue with <res-ref-name>xxx/yyy/zzz</res-ref-name> in web.xml. You have changed the configuration file from standalone.xml to standalone-full.xml to use JMS module. You have a…
Test for RFC 5322: https://gist.github.com/satob/0dc003aefe020d5f1e9263bd7e173f9f (with regexp in http://www.din.or.jp/~ohzaki/mail_regex.htm#RFC) Test for RFC 821: https://gist.github.com/satob/8c5a42cf636732d81b850b58e8808eef (with regex…
じゃぁメールアドレスのバリデーションってどうやったらいいのさ、という話。 satob.hatenablog.com もちろんバリデーションをした後には、メールアドレスの実在性確認のために実際にメールを送信します*1。その前段で、画面に表示したときにセキュリティ的…
Javadoc of JavaMail API says InternetAddress class uses "the syntax of RFC822". https://javaee.github.io/javamail/docs/api/javax/mail/internet/InternetAddress.html Then how about actual implementation? Is it different from some other email…
A: Around 568 (But sometimes it could be compile) BeanWithSoManyFields.java · GitHub This class causes java.lang.StackOverflowError like this: java.lang.StackOverflowError at java.lang.reflect.Field.get(Field.java:393) at lombok.core.AST.b…
You will get error when you run following Maven command from Windows PowerShell: PS C:\workspace> mvn -B archetype:generate -DgroupId=com.example -DartifactId=hajiboot -Dversion=1.0.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-quicksta…
Both of String#split() in Java and -split operator in PowerShell take regex as argument, and split string into a list or an array, but there is some difference in behavior when you pass an empty string as argument. In Java: System.out.prin…
JIS X 0213など、シフトJISやマイクロソフト コードページ932以外の文字をプログラム上で紙に印刷する場合には、入力された文字列を枠内に確実に収めるため、文字数を正しくカウントする必要があります。 JIS X 0213では複数のコードポイントで1文字を表す文…
Java application uses ClassLoaders in parent-first mode. On the other hand, some JavaEE Application Servers are not parent-first mode in default, and/or have preferences to configure ClassLoader behavior. # Application Server Default mode …
JCache cannot save the order of insertion. You should use LinkedHashMap for that purposes. JCache cannot update whole entries in a cache atomically. You should use AtomicReference or some locking mechanisms for that purpose. (Ofcourse you …
For example, in PushOperation.java in EGit, PushOperationSpecification contains LinkedHashMap<URIish, Collection<RemoteRefUpdate>>. So you can join all remote name with Stream API like: String specs = this.specification.getURIs().stream() .map(uri -> this.specification.getRe</uriish,>…
Context You can use lambda as lazy evaluation syntax in Java. Problem You can wrap RuntimeException with lambda like (it shows "omit exception"): import java.util.function.Supplier; public class OmitRuntimeException { public static void ma…
Java Patten class (regexp) supports POSIX character classes like \p{XDigit}. They are very useful when you want to check hex strings. In Java API Document, POSIX character classes say (US-ASCII only). What does it mean? https://docs.oracle…
String object in .NET (PowerShell), JavaScript, and Java all have trim() method. But trimmed characters by trim() are different between these languages. # codepoint .NET JavaScript Java 1 0000-0008 ✘ ✘ ✔ 2 0009-000D ✔ ✔ ✔ 3 000E-001F ✘ ✘ ✔…
Context: You have a class that has one or more constructors other than default constructor, so you have to define the default constructor explicitly. You use Lombok to generate some methods/fields. You use static code analyzers that warn e…
Javadocには、static finalな定数のJavadocコメントに「{@value}」という内容を含めると、そこを定数の値で置き換えるという機能がある。 例えば、下記のようなコメントの場合Javadocには「ファイル名 ("AIUEO")」と表示される。 /** ファイル名 ({@value}) …
Eclipse 3.4 ではできるが、Eclipse 3.3 では行番号を付けた印刷ができない。 前述の設定を行っても、エディタのビューに行番号が表示されるだけで、印刷結果には行番号が含まれない。
以下の設定を行うとエディタのビューに行番号が表示される。 [設定]-[一般]-[エディター]-[テキスト・エディター]-[行番号の表示]この状態で印刷を行えば、印刷結果にも行番号が含まれるようになる。 (Eclipse 3.4 のリリースノートに記述がありそうだが、…
Struts(1.x系列)付属のTaglibには、再帰構造を扱えるものがない。再帰的なデータ構造を使う代わりに、平坦なデータ構造でまかなえないか検討すること。 あるいは、再起構造を扱うTaglibを作成すること。
Java VM 実行時のデフォルトエンコーディングは OS および実行時の locale によって決定される *1。 ……とあるが、どの OS でどの locale だったらどのエンコーディングになるかは規定されていない模様。 *1:http://sdc.sun.co.jp/java/docs/j2se/1.4/ja/docs…
Unix は本当にフォントの設定やら何やらこんがらがってますね…… orz
Tomcat 5.0 系列以前では、HttpServlet#log (GenericServlet#log) 等によるログ取りを有効にするためには、それを呼んだときのログの出力先を指定しなければならなかった。で、その指定には Administration Tool を使っていた。 Tomcat 5.5 では、次のような…
最もてこずったのは MySQL とそれを参照するための Tomcat の設定だった。それさえできてしまえば、アプリケーション自体はどうということはない。
http://www.ch-werner.de/javasqlite/ なんだけど、./configure; make; su -c "make install" としたまではいいけれど肝心のテストが通らない。 $ echo $CLASSPATH /opt/SUNWappserver/jdk/lib/tools.jar:/opt/SUNWappserver/jdk/lib/mysql-connector-java-3…
Servlet から JSP へ Dispatch している ブラウザの画面まっ白(ソースを見ても空) ロケーションバーの URL は Servlet のそれ という場合、Tomcat のログ (localhost_log.yyyy-mm-dd.txt) をチェック。次のような内容があって、タグの整合に間違いが見当た…
String#matches(String regex) では、単純な部分文字列のマッチングができない。Perl を使っていた身としては窮屈で仕方がない。 以下のコードでは "ONLY WITH .*" が出力される。 public class Hoge { public static void main(String[] args) { if (("FooB…
Tomcat で使う web.xml の の子要素 には glob しか指定できないみたい。regex が指定できればなぁ……
パラメタを含む SQL 文から PreparedStatement オブジェクトを得て、その SQL 文を実行しようとするとエラーが出る場合。次のようなエラーメッセージが特徴的。 java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0…
Tomcat の Web Application Manager であるアプリケーションを「配備解除」すると、そのアプリケーションのコンテキストに割り当てられたデータソースやデータリンクの情報は消去されてしまう。ログファイルに次のようなメッセージが残るのが特徴的。 javax.…