org.trypticon.hex.interpreters.strings.SimpleBinaryStringValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hex-interpreter Show documentation
Show all versions of hex-interpreter Show documentation
API for interpreting runs of binary as values humans can understand
package org.trypticon.hex.interpreters.strings;
import org.trypticon.hex.binary.Binary;
import org.trypticon.hex.interpreters.AbstractValue;
import org.trypticon.hex.util.Format;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
/**
* Simple implementation of a binary string value.
*
* @author trejkaz
*/
public class SimpleBinaryStringValue extends AbstractValue implements BinaryStringValue {
private final Binary binary;
public SimpleBinaryStringValue(Binary binary) {
this.binary = binary;
}
@Override
public long length() {
return binary.length();
}
@Override
public String toLocalisedString(Format style, Locale locale) {
return new StringInterpreter(StandardCharsets.UTF_8)
.interpret(binary, 0, binary.length())
.toLocalisedString(style, locale);
}
}