Package com.ultikits.ultitools.manager
Class ServerPropertiesManager.PropertiesText
java.lang.Object
com.ultikits.ultitools.manager.ServerPropertiesManager.PropertiesText
- Enclosing class:
ServerPropertiesManager
The file's bytes and its text as the server decodes them: strict UTF-8, or ISO-8859-1 when the bytes are not
valid UTF-8 (Paper 1.21.11
Settings#loadFromFile, measured from the server jar). Every line break is a
single byte in both encodings, so lines split the same way in the bytes and in the text.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static ServerPropertiesManager.PropertiesTextdecode(byte[] bytes) (package private) List<ServerPropertiesManager.Definition> definitionsOf(String key) Every logical line whose key iskey, with the grammar ofProperties.load(java.io.Reader).(package private) List<int[]> lines()Physical lines as[start, contentEnd, end]offsets intotext.(package private) Propertiesparse()The table the server reads;IllegalArgumentExceptionfor a malformed\uescape, as the server.(package private) static ServerPropertiesManager.PropertiesText(package private) byte[]replaceValue(ServerPropertiesManager.Definition definition, String value) The new bytes: only the value text ofdefinition's line replaced, re-encoded in the file's charset.private intskipWhitespace(int from, int to) (package private) Stringverify(byte[] next, ServerPropertiesManager.Definition definition, String key, String value, Properties before) Whynextmust not be written, ornull: every line other than the edited one keeps its bytes, and the server's own reading ofnextreturnsvalueforkeyand every other key unchanged.
-
Field Details
-
bytes
private final byte[] bytes -
text
-
charset
-
-
Constructor Details
-
PropertiesText
-
-
Method Details
-
read
- Throws:
IOException
-
decode
-
parse
Properties parse()The table the server reads;IllegalArgumentExceptionfor a malformed\uescape, as the server. -
lines
List<int[]> lines()Physical lines as[start, contentEnd, end]offsets intotext. -
definitionsOf
Every logical line whose key iskey, with the grammar ofProperties.load(java.io.Reader). -
replaceValue
byte[] replaceValue(ServerPropertiesManager.Definition definition, String value) throws CharacterCodingException The new bytes: only the value text ofdefinition's line replaced, re-encoded in the file's charset.- Throws:
CharacterCodingException
-
verify
String verify(byte[] next, ServerPropertiesManager.Definition definition, String key, String value, Properties before) Whynextmust not be written, ornull: every line other than the edited one keeps its bytes, and the server's own reading ofnextreturnsvalueforkeyand every other key unchanged. -
skipWhitespace
private int skipWhitespace(int from, int to)
-