public class TextEncodedStringSizeTerminated extends AbstractString
frameBody, identifier, logger, size, TYPE_ELEMENT, value
Constructor and Description |
---|
TextEncodedStringSizeTerminated(String identifier,
AbstractTagFrameBody frameBody)
Creates a new empty TextEncodedStringSizeTerminated datatype.
|
TextEncodedStringSizeTerminated(TextEncodedStringSizeTerminated object)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(String value)
Add an additional String to the current String value
|
protected void |
checkTrailingNull(List<String> values,
String stringValue)
Because nulls are stripped we need to check if not removing trailing nulls whether the original
value ended with a null and if so add it back in.
|
boolean |
equals(Object obj) |
int |
getNumberOfValues()
How many values are held, each value is separated by a null terminator
|
String |
getValueAtIndex(int index)
Get the nth value
|
List<String> |
getValues() |
String |
getValueWithoutTrailingNull()
Get value(s) whilst removing any trailing nulls
|
void |
readByteArray(byte[] arr,
int offset)
Read a 'n' bytes from buffer into a String where n is the framesize - offset
so therefore cannot use this if there are other objects after it because it has no
delimiter.
|
static List<String> |
splitByNullSeperator(String value)
Split the values separated by null character
|
protected void |
stripTrailingNull()
Removing trailing null from end of String, this should not be there but some applications continue to write
this unnecessary null char.
|
byte[] |
writeByteArray()
Write String into byte array
It will remove a trailing null terminator if exists if the option
RemoveTrailingTerminatorOnWrite has been set.
|
protected ByteBuffer |
writeString(CharsetEncoder encoder,
String next,
int i,
int noOfValues)
Write String using specified encoding
When this is called multiple times, all but the last value has a trailing null
|
protected ByteBuffer |
writeStringUTF16BEBOM(String next,
int i,
int noOfValues)
Write String in UTF-BEBOM format
When this is called multiple times, all but the last value has a trailing null
|
protected ByteBuffer |
writeStringUTF16LEBOM(String next,
int i,
int noOfValues)
Write String in UTF-LEBOM format
When this is called multiple times, all but the last value has a trailing null
Remember we are using this charset because the charset that writes BOM does it the wrong way for us
so we use this none and then manually add the BOM ourselves.
|
canBeEncoded, getCorrectDecoder, getSize, getTextEncodingCharSet, setSize, toString
createStructure, getBody, getIdentifier, getValue, readByteArray, setBody, setValue
public TextEncodedStringSizeTerminated(String identifier, AbstractTagFrameBody frameBody)
identifier
- identifies the frame typeframeBody
- public TextEncodedStringSizeTerminated(TextEncodedStringSizeTerminated object)
object
- public boolean equals(Object obj)
equals
in class AbstractDataType
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException
readByteArray
in class AbstractDataType
arr
- this is the buffer for the frameoffset
- this is where to start reading in the buffer for this fieldNullPointerException
IndexOutOfBoundsException
InvalidDataTypeException
protected ByteBuffer writeString(CharsetEncoder encoder, String next, int i, int noOfValues) throws CharacterCodingException
encoder
- next
- i
- noOfValues
- CharacterCodingException
protected ByteBuffer writeStringUTF16LEBOM(String next, int i, int noOfValues) throws CharacterCodingException
next
- i
- noOfValues
- CharacterCodingException
protected ByteBuffer writeStringUTF16BEBOM(String next, int i, int noOfValues) throws CharacterCodingException
next
- i
- noOfValues
- CharacterCodingException
protected void stripTrailingNull()
protected void checkTrailingNull(List<String> values, String stringValue)
values
- stringValue
- public byte[] writeByteArray()
writeByteArray
in class AbstractDataType
public static List<String> splitByNullSeperator(String value)
value
- the raw valuepublic void addValue(String value)
value
- public int getNumberOfValues()
public String getValueAtIndex(int index)
index
- IndexOutOfBoundsException
- if value does not existpublic String getValueWithoutTrailingNull()
Copyright © 2005–2020 jthink.net. All rights reserved.