public class SpecificCharacterSet
extends java.lang.Object
A class to encapsulate the functionality defined by the DICOM Specific Character Set
attribute, including the ability to parse the string values of the attribute and then
apply the appropriate character conversions from byte array values into Java's internal
Unicode representation contained in String
.
Constructor and Description |
---|
SpecificCharacterSet(AttributeList list)
Construct a character set handler capable of handling characters from all the values of the string attributes of a dataset.
|
SpecificCharacterSet(java.util.Set setOfUnicodeBlocks)
Construct a character set handler capable of handling characters from the specified set of
Character.UnicodeBlock s. |
SpecificCharacterSet(java.lang.String[] specificCharacterSetAttributeValues)
Construct a character set handler from the values of the Specific Character Set attribute.
|
SpecificCharacterSet(java.lang.String[] specificCharacterSetAttributeValues,
byte[] specificCharacterSetByteValues)
Construct a character set handler from the values of the Specific Character Set attribute.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
byteArrayContainsNonASCIIValues(byte[] bytes)
Check a byte array for the presence of non-ASCII bytes.
|
static boolean |
byteArrayContainsNonASCIIValues(byte[] bytes,
int offset,
int length)
Check a byte array for the presence of non-ASCII bytes.
|
static java.util.Set |
getSetOfUnicodeBlocksUsedBy(AttributeList list)
Get the set of
Character.UnicodeBlock s used in all of the values of the string attributes of a dataset. |
static java.util.Set |
getSetOfUnicodeBlocksUsedBy(java.lang.String value)
Get the set of
Character.UnicodeBlock s used in a string. |
static java.lang.String |
getSuitableEncodingFromSetOfUnicodeBlocks(java.util.Set setOfUnicodeBlocks)
Get an encoding capable of handling characters from the specified set of
Character.UnicodeBlock ss. |
java.lang.String |
getValueToUseInSpecificCharacterSetAttribute() |
static void |
main(java.lang.String[] args) |
java.lang.String |
toString() |
java.lang.String |
translateByteArrayToString(byte[] bytes,
int offset,
int length)
Translate a byte array (such as a value from a DICOM attribute), using the
specified Specific Character Set, into a
String . |
byte[] |
translateStringToByteArray(java.lang.String string)
Encode a string into a byte array.
|
public SpecificCharacterSet(AttributeList list)
Construct a character set handler capable of handling characters from all the values of the string attributes of a dataset.
list
- the list of attributespublic SpecificCharacterSet(java.util.Set setOfUnicodeBlocks)
Construct a character set handler capable of handling characters from the specified set of Character.UnicodeBlock
s.
setOfUnicodeBlocks
- the set of Character.UnicodeBlock
s that need to be encodablepublic SpecificCharacterSet(java.lang.String[] specificCharacterSetAttributeValues)
Construct a character set handler from the values of the Specific Character Set attribute.
specificCharacterSetAttributeValues
- the values of Specific Character Setpublic SpecificCharacterSet(java.lang.String[] specificCharacterSetAttributeValues, byte[] specificCharacterSetByteValues)
Construct a character set handler from the values of the Specific Character Set attribute.
specificCharacterSetAttributeValues
- the values of Specific Character Set as StringspecificCharacterSetByteValues
- the values of Specific Character Set as byte[]public static boolean byteArrayContainsNonASCIIValues(byte[] bytes)
Check a byte array for the presence of non-ASCII bytes.
bytes
- the bytes to checkpublic static boolean byteArrayContainsNonASCIIValues(byte[] bytes, int offset, int length)
Check a byte array for the presence of non-ASCII bytes.
bytes
- the bytes to checkoffset
- the offset into the byte arraylength
- how many bytes to checkpublic static java.util.Set getSetOfUnicodeBlocksUsedBy(AttributeList list)
Get the set of Character.UnicodeBlock
s used in all of the values of the string attributes of a dataset.
Recurses into SequenceAttributes.
list
- the list of attributesSet
of Character.UnicodeBlock
spublic static java.util.Set getSetOfUnicodeBlocksUsedBy(java.lang.String value)
Get the set of Character.UnicodeBlock
s used in a string.
value
- the stringSet
of Character.UnicodeBlock
spublic static java.lang.String getSuitableEncodingFromSetOfUnicodeBlocks(java.util.Set setOfUnicodeBlocks)
Get an encoding capable of handling characters from the specified set of Character.UnicodeBlock
ss.
setOfUnicodeBlocks
- the set of Character.UnicodeBlock
s that need to be encodablepublic java.lang.String getValueToUseInSpecificCharacterSetAttribute()
public static void main(java.lang.String[] args)
args
- public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String translateByteArrayToString(byte[] bytes, int offset, int length)
Translate a byte array (such as a value from a DICOM attribute), using the
specified Specific Character Set, into a String
.
bytes
- the bytes to translateoffset
- the offset into the byte array to start translationlength
- how many bytes to translatepublic byte[] translateStringToByteArray(java.lang.String string) throws java.io.UnsupportedEncodingException
Encode a string into a byte array.
Does not currently support ISO 2022 (or JIS 0208 or 0212 if 1.4.1 bug present).
string
- the string to be encodedjava.io.UnsupportedEncodingException