Class SpecificCharacterSet
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 Summary
ConstructorsConstructorDescriptionConstruct a character set handler capable of handling characters from all the values of the string attributes of a dataset.SpecificCharacterSet(String[] specificCharacterSetAttributeValues) Construct a character set handler from the values of the Specific Character Set attribute.SpecificCharacterSet(String[] specificCharacterSetAttributeValues, byte[] specificCharacterSetByteValues) Construct a character set handler from the values of the Specific Character Set attribute.SpecificCharacterSet(Set setOfUnicodeBlocks) Construct a character set handler capable of handling characters from the specified set ofCharacter.UnicodeBlocks. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbyteArrayContainsNonASCIIValues(byte[] bytes) Check a byte array for the presence of non-ASCII bytes.static booleanbyteArrayContainsNonASCIIValues(byte[] bytes, int offset, int length) Check a byte array for the presence of non-ASCII bytes.static SetGet the set ofCharacter.UnicodeBlocks used in all of the values of the string attributes of a dataset.static SetGet the set ofCharacter.UnicodeBlocks used in a string.static StringgetSuitableEncodingFromSetOfUnicodeBlocks(Set setOfUnicodeBlocks) Get an encoding capable of handling characters from the specified set ofCharacter.UnicodeBlockss.static voidtoString()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 aString.byte[]translateStringToByteArray(String string) Encode a string into a byte array.
-
Constructor Details
-
SpecificCharacterSet
Construct a character set handler capable of handling characters from all the values of the string attributes of a dataset.
- Parameters:
list- the list of attributes
-
SpecificCharacterSet
Construct a character set handler capable of handling characters from the specified set of
Character.UnicodeBlocks.- Parameters:
setOfUnicodeBlocks- the set ofCharacter.UnicodeBlocks that need to be encodable
-
SpecificCharacterSet
Construct a character set handler from the values of the Specific Character Set attribute.
- Parameters:
specificCharacterSetAttributeValues- the values of Specific Character Set
-
SpecificCharacterSet
public SpecificCharacterSet(String[] specificCharacterSetAttributeValues, byte[] specificCharacterSetByteValues) Construct a character set handler from the values of the Specific Character Set attribute.
- Parameters:
specificCharacterSetAttributeValues- the values of Specific Character Set as StringspecificCharacterSetByteValues- the values of Specific Character Set as byte[]
-
-
Method Details
-
toString
-
byteArrayContainsNonASCIIValues
public static boolean byteArrayContainsNonASCIIValues(byte[] bytes, int offset, int length) Check a byte array for the presence of non-ASCII bytes.
- Parameters:
bytes- the bytes to checkoffset- the offset into the byte arraylength- how many bytes to check
-
byteArrayContainsNonASCIIValues
public static boolean byteArrayContainsNonASCIIValues(byte[] bytes) Check a byte array for the presence of non-ASCII bytes.
- Parameters:
bytes- the bytes to check
-
getSuitableEncodingFromSetOfUnicodeBlocks
Get an encoding capable of handling characters from the specified set of
Character.UnicodeBlockss.- Parameters:
setOfUnicodeBlocks- the set ofCharacter.UnicodeBlocks that need to be encodable- Returns:
- an encoding to feed to
-
getSetOfUnicodeBlocksUsedBy
Get the set of
Character.UnicodeBlocks used in a string.- Parameters:
value- the string- Returns:
- a
SetofCharacter.UnicodeBlocks
-
getSetOfUnicodeBlocksUsedBy
Get the set of
Character.UnicodeBlocks used in all of the values of the string attributes of a dataset.Recurses into SequenceAttributes.
- Parameters:
list- the list of attributes- Returns:
- a
SetofCharacter.UnicodeBlocks
-
getValueToUseInSpecificCharacterSetAttribute
-
translateByteArrayToString
Translate a byte array (such as a value from a DICOM attribute), using the specified Specific Character Set, into a
String.- Parameters:
bytes- the bytes to translateoffset- the offset into the byte array to start translationlength- how many bytes to translate- Returns:
- the string decoded according to the specific character set
-
translateStringToByteArray
Encode a string into a byte array.
Does not currently support ISO 2022 (or JIS 0208 or 0212 if 1.4.1 bug present).
- Parameters:
string- the string to be encoded- Returns:
- the byte array encoded according to the specific character set
- Throws:
UnsupportedEncodingException
-
main
- Parameters:
args-
-