public class Id extends Object implements Serializable, Comparable<Id>
Idオブジェクトの生成時には、byte列またはASCII文字列を指定する。 ASCII文字列を指定した場合でも、内部的にはbyte列に変換して管理する。 toStringメソッドを使うことで、指定したASCII文字列の表現を取得できる。 但し、ASCII文字列を指定しないで直接byte列を指定した場合でも、そのbyte列が7bitの ASCII列である場合は、toStringは、ASCII文字列の表現を返す。
newIdメソッドを使うと長さを指定したランダムなbyte列を持つIdオブジェクトを生成できる。 immutableなオブジェクトとして振舞う。
| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected byte[] |
bytes
Idオブジェクトを表現するbyte列。
|
protected String |
strVal
Idオブジェクトを文字列を使って生成した場合に保持される値。
|
| コンストラクタと説明 |
|---|
Id(byte[] bytes)
指定されたbyte列を値として持つIdオブジェクトを生成する。
|
Id(String str)
指定された文字列を値として持つIdオブジェクトを生成する。
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
byte[] |
_getBytes()
Idオブジェクトの内部表現であるbyte列を返す。
|
int |
commonPostfixLen(Id id) |
int |
commonPrefixLen(Id id) |
int |
compareTo(Id id) |
boolean |
equals(Object o) |
int |
getByteLen() |
byte[] |
getBytes()
Idオブジェクトの内部表現であるbyte列を返す。
|
int |
hashCode() |
static Id |
newId(int len)
指定された長さのランダムなbyte列を持つIdオブジェクトを生成する。
|
protected static byte[] |
newRandomBytes(int len)
指定された長さのランダムなbyte列を生成する。
|
void |
setBinaryString() |
void |
setHexString() |
boolean |
testBit(int ix) |
String |
toBinaryString()
Idを2進表記した文字列を返す。
|
String |
toHexString()
Idを16進表記した文字列を返す。
|
String |
toString()
Idの文字列表現を返す。
|
protected final byte[] bytes
継承したクラス内でこのbyte列を変更するのは構わないが、その場合は、hashCodeをキャッシュしている hash変数を0クリアする必要がある。
protected transient String strVal
public Id(byte[] bytes)
bytes - byte列public Id(String str) throws IllegalArgumentException
str - 文字列IllegalArgumentException - ASCII文字列でない場合protected static byte[] newRandomBytes(int len)
len - byte列の長さpublic static Id newId(int len)
len - byte列の長さpublic byte[] getBytes()
public byte[] _getBytes()
public int getByteLen()
public void setBinaryString()
public void setHexString()
public boolean testBit(int ix)
public int commonPostfixLen(Id id)
public int commonPrefixLen(Id id)
public int compareTo(Id id)
compareTo インタフェース内 Comparable<Id>public String toBinaryString()
public String toHexString()
Copyright © 2017. All rights reserved.