Class SpecificCharacterSet
- java.lang.Object
-
- com.pixelmed.dicom.SpecificCharacterSet
-
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 Summary
Constructors Constructor 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.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.SpecificCharacterSet(java.util.Set setOfUnicodeBlocks)
Construct a character set handler capable of handling characters from the specified set ofCharacter.UnicodeBlock
s.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.lang.String
getAllStringValuesAffectedBySpecificCharacterSet(AttributeList list)
Get all of the values of the string attributes of a dataset.static java.util.Set
getSetOfUnicodeBlocksUsedBy(AttributeList list)
Get the set ofCharacter.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 ofCharacter.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 ofCharacter.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 aString
.byte[]
translateStringToByteArray(java.lang.String string)
Encode a string into a byte array.
-
-
-
Constructor Detail
-
SpecificCharacterSet
public SpecificCharacterSet(AttributeList list)
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
public SpecificCharacterSet(java.util.Set setOfUnicodeBlocks)
Construct a character set handler capable of handling characters from the specified set of
Character.UnicodeBlock
s.- Parameters:
setOfUnicodeBlocks
- the set ofCharacter.UnicodeBlock
s that need to be encodable
-
SpecificCharacterSet
public SpecificCharacterSet(java.lang.String[] specificCharacterSetAttributeValues)
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(java.lang.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 Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
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
public static java.lang.String getSuitableEncodingFromSetOfUnicodeBlocks(java.util.Set setOfUnicodeBlocks)
Get an encoding capable of handling characters from the specified set of
Character.UnicodeBlock
ss.- Parameters:
setOfUnicodeBlocks
- the set ofCharacter.UnicodeBlock
s that need to be encodable- Returns:
- an encoding to feed to
-
getSetOfUnicodeBlocksUsedBy
public static java.util.Set getSetOfUnicodeBlocksUsedBy(java.lang.String value)
Get the set of
Character.UnicodeBlock
s used in a string.- Parameters:
value
- the string- Returns:
- a
Set
ofCharacter.UnicodeBlock
s
-
getAllStringValuesAffectedBySpecificCharacterSet
public static java.lang.String getAllStringValuesAffectedBySpecificCharacterSet(AttributeList list)
Get all of the values of the string attributes of a dataset.
Recurses into SequenceAttributes.
- Parameters:
list
- the list of attributes- Returns:
- a
Set
ofCharacter.UnicodeBlock
s
-
getSetOfUnicodeBlocksUsedBy
public 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.
- Parameters:
list
- the list of attributes- Returns:
- a
Set
ofCharacter.UnicodeBlock
s
-
getValueToUseInSpecificCharacterSetAttribute
public java.lang.String getValueToUseInSpecificCharacterSetAttribute()
-
translateByteArrayToString
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
.- 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
public 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).
- Parameters:
string
- the string to be encoded- Returns:
- the byte array encoded according to the specific character set
- Throws:
java.io.UnsupportedEncodingException
-
main
public static void main(java.lang.String[] args)
- Parameters:
args
-
-
-