mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
Use UTF_8 object instead of "UTF-8" string literal.
This commit is contained in:
parent
91749a2da3
commit
e3e2c2836e
@ -35,6 +35,7 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static net.sourceforge.plantuml.utils.CharsetUtils.charsetOrDefault;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -186,7 +187,7 @@ public class BlockUml {
|
||||
final AsciiEncoder coder = new AsciiEncoder();
|
||||
final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
|
||||
for (StringLocated s : data) {
|
||||
msgDigest.update(s.getString().getBytes("UTF-8"));
|
||||
msgDigest.update(s.getString().getBytes(UTF_8));
|
||||
}
|
||||
final byte[] digest = msgDigest.digest();
|
||||
return coder.encode(digest);
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -77,7 +79,7 @@ public class Pipe {
|
||||
for(String source = readFirstDiagram(); source != null; source = readSubsequentDiagram()) {
|
||||
final Defines defines = option.getDefaultDefines();
|
||||
final SFile newCurrentDir = option.getFileDir() == null ? null : new SFile(option.getFileDir());
|
||||
final SourceStringReader sourceStringReader = new SourceStringReader(defines, source, "UTF-8",
|
||||
final SourceStringReader sourceStringReader = new SourceStringReader(defines, source, UTF_8,
|
||||
option.getConfig(), newCurrentDir);
|
||||
|
||||
if (option.isComputeurl()) {
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -127,12 +129,12 @@ public class SignatureUtils {
|
||||
public static synchronized byte[] getMD5raw(String s)
|
||||
throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
||||
final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
|
||||
msgDigest.update(s.getBytes("UTF-8"));
|
||||
msgDigest.update(s.getBytes(UTF_8));
|
||||
return msgDigest.digest();
|
||||
}
|
||||
|
||||
public static byte[] getSHA512raw(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
||||
return getSHA512raw(s.getBytes("UTF-8"));
|
||||
return getSHA512raw(s.getBytes(UTF_8));
|
||||
}
|
||||
|
||||
public static synchronized byte[] getSHA512raw(byte data[])
|
||||
|
@ -35,12 +35,14 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
|
||||
import static net.sourceforge.plantuml.utils.CharsetUtils.charsetOrDefault;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -62,31 +64,39 @@ public class SourceStringReader {
|
||||
}
|
||||
|
||||
public SourceStringReader(String source, String charset) {
|
||||
this(Defines.createEmpty(), source, "UTF-8", Collections.<String>emptyList());
|
||||
this(Defines.createEmpty(), source, UTF_8.name(), Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public SourceStringReader(String source, Charset charset) {
|
||||
this(Defines.createEmpty(), source, charset.name(), Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public SourceStringReader(Defines defines, String source, List<String> config) {
|
||||
this(defines, source, "UTF-8", config);
|
||||
this(defines, source, UTF_8.name(), config);
|
||||
}
|
||||
|
||||
public SourceStringReader(Defines defines, String source) {
|
||||
this(defines, source, "UTF-8", Collections.<String>emptyList());
|
||||
this(defines, source, UTF_8.name(), Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public SourceStringReader(String source, SFile newCurrentDir) {
|
||||
this(Defines.createEmpty(), source, "UTF-8", Collections.<String>emptyList(), newCurrentDir);
|
||||
this(Defines.createEmpty(), source, UTF_8, Collections.<String>emptyList(), newCurrentDir);
|
||||
}
|
||||
|
||||
public SourceStringReader(Defines defines, String source, String charset, List<String> config) {
|
||||
this(defines, source, charset, config, FileSystem.getInstance().getCurrentDir());
|
||||
}
|
||||
|
||||
public SourceStringReader(Defines defines, String source, String charset, List<String> config,
|
||||
public SourceStringReader(Defines defines, String source, String charset, List<String> config, SFile newCurrentDir) {
|
||||
this(defines, source, charsetOrDefault(charset), config, newCurrentDir);
|
||||
}
|
||||
|
||||
public SourceStringReader(Defines defines, String source, Charset charset, List<String> config,
|
||||
SFile newCurrentDir) {
|
||||
// // WARNING GLOBAL LOCK HERE
|
||||
// synchronized (SourceStringReader.class) {
|
||||
try {
|
||||
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charsetOrDefault(charset), defines, new StringReader(source),
|
||||
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
|
||||
newCurrentDir, "string");
|
||||
this.blocks = builder.getBlockUmls();
|
||||
} catch (IOException e) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.argon2;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static net.sourceforge.plantuml.argon2.Constants.Defaults.LANES_DEF;
|
||||
import static net.sourceforge.plantuml.argon2.Constants.Defaults.LOG_M_COST_DEF;
|
||||
import static net.sourceforge.plantuml.argon2.Constants.Defaults.OUTLEN_DEF;
|
||||
@ -42,7 +43,6 @@ public class Argon2 {
|
||||
private Argon2Type type;
|
||||
|
||||
private boolean clearMemory = true;
|
||||
private Charset charset = Charset.forName("UTF-8");
|
||||
|
||||
private boolean encodedOnly = false;
|
||||
private boolean rawOnly = false;
|
||||
@ -125,11 +125,11 @@ public class Argon2 {
|
||||
}
|
||||
|
||||
public Argon2 setPassword(char[] password) {
|
||||
return setPassword(toByteArray(password, charset));
|
||||
return setPassword(toByteArray(password, UTF_8));
|
||||
}
|
||||
|
||||
public Argon2 setSalt(String salt) {
|
||||
return setSalt(salt.getBytes(charset));
|
||||
return setSalt(salt.getBytes(UTF_8));
|
||||
}
|
||||
|
||||
public byte[] getOutput() {
|
||||
@ -254,7 +254,7 @@ public class Argon2 {
|
||||
}
|
||||
|
||||
public Charset getCharset() {
|
||||
return charset;
|
||||
return UTF_8;
|
||||
}
|
||||
|
||||
public void setEncodedOnly(boolean encodedOnly) {
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.code;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@ -53,7 +55,7 @@ public class ByteArray {
|
||||
}
|
||||
|
||||
public String toUFT8String() throws UnsupportedEncodingException {
|
||||
return new String(data, 0, length, "UTF-8");
|
||||
return new String(data, 0, length, UTF_8);
|
||||
}
|
||||
|
||||
public String toUPF9String() throws IOException {
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.code;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TranscoderImpl implements Transcoder {
|
||||
@ -68,7 +70,7 @@ public class TranscoderImpl implements Transcoder {
|
||||
final String stringAnnoted = stringCompressor.compress(text);
|
||||
final byte[] data;
|
||||
if (format == Format.UTF8)
|
||||
data = stringAnnoted.getBytes("UTF-8");
|
||||
data = stringAnnoted.getBytes(UTF_8);
|
||||
else
|
||||
data = Upf9Encoder.getBytes(stringAnnoted);
|
||||
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.creole.atom;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -184,7 +186,7 @@ public class AtomImg extends AbstractAtom implements Atom {
|
||||
if (read == null) {
|
||||
return AtomTextUtils.createLegacy("(Cannot decode SVG: " + text + ")", fc);
|
||||
}
|
||||
return new AtomImgSvg(new TileImageSvg(new String(read, "UTF-8")));
|
||||
return new AtomImgSvg(new TileImageSvg(new String(read, UTF_8)));
|
||||
}
|
||||
|
||||
// End
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -158,7 +160,7 @@ public final class CucaDiagramTxtMaker {
|
||||
|
||||
public List<SFile> createFiles(SFile suggestedFile) throws IOException {
|
||||
if (fileFormat == FileFormat.UTXT) {
|
||||
globalUg.getCharArea().print(suggestedFile.createPrintStream("UTF-8"));
|
||||
globalUg.getCharArea().print(suggestedFile.createPrintStream(UTF_8));
|
||||
} else {
|
||||
globalUg.getCharArea().print(suggestedFile.createPrintStream());
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.dedication;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.math.BigInteger;
|
||||
@ -76,10 +78,10 @@ public class DedicationCrypted implements Dedication {
|
||||
this.next = System.currentTimeMillis() + 5000L;
|
||||
}
|
||||
|
||||
final byte[] hash1 = Noise.computeArgon2bytes(line.getBytes("UTF-8"),
|
||||
(pq.toString(35) + line).getBytes("UTF-8"));
|
||||
final byte[] hash2 = Noise.computeArgon2bytes(line.getBytes("UTF-8"),
|
||||
(pq.toString(36) + line).getBytes("UTF-8"));
|
||||
final byte[] hash1 = Noise.computeArgon2bytes(line.getBytes(UTF_8),
|
||||
(pq.toString(35) + line).getBytes(UTF_8));
|
||||
final byte[] hash2 = Noise.computeArgon2bytes(line.getBytes(UTF_8),
|
||||
(pq.toString(36) + line).getBytes(UTF_8));
|
||||
|
||||
final BlumBlumShub rndBBS = new BlumBlumShub(pq, hash1);
|
||||
final MTRandom rndMT = new MTRandom(hash2);
|
||||
@ -87,7 +89,7 @@ public class DedicationCrypted implements Dedication {
|
||||
byte[] current = crypted.clone();
|
||||
Noise.shuffle(current, rndMT);
|
||||
Noise.xor(current, rndBBS);
|
||||
Noise.xor(current, line.getBytes("UTF-8"));
|
||||
Noise.xor(current, line.getBytes(UTF_8));
|
||||
|
||||
Noise.shuffle(current, rndMT);
|
||||
|
||||
@ -99,7 +101,7 @@ public class DedicationCrypted implements Dedication {
|
||||
Noise.shuffle(current, rndMT);
|
||||
Noise.xor(current, rndBBS);
|
||||
|
||||
final String argon = Noise.computeArgon2String(current, (pq.toString(34) + line).getBytes("UTF-8"));
|
||||
final String argon = Noise.computeArgon2String(current, (pq.toString(34) + line).getBytes(UTF_8));
|
||||
|
||||
if (this.argon2.equals(argon) == false) {
|
||||
return null;
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.dedication;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public final class TinyHashableString {
|
||||
@ -52,7 +54,7 @@ public final class TinyHashableString {
|
||||
|
||||
public final synchronized int tinyHash() throws UnsupportedEncodingException {
|
||||
if (cachedTinyHash == -1) {
|
||||
cachedTinyHash = Noise.shortHash(sentence.getBytes("UTF-8"), Dedication.N.toByteArray());
|
||||
cachedTinyHash = Noise.shortHash(sentence.getBytes(UTF_8), Dedication.N.toByteArray());
|
||||
}
|
||||
return cachedTinyHash;
|
||||
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.eggs;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class SentenceDecoder {
|
||||
@ -44,7 +46,7 @@ public class SentenceDecoder {
|
||||
public SentenceDecoder(String sentence1, byte[] crypted) throws UnsupportedEncodingException {
|
||||
final byte[] key = EggUtils.fromSecretSentence(sentence1).toByteArray();
|
||||
final byte[] sen2 = EggUtils.xor(crypted, key);
|
||||
this.secret = new String(sen2, "UTF-8");
|
||||
this.secret = new String(sen2, UTF_8);
|
||||
}
|
||||
|
||||
public boolean isOk() {
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.eggs;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class SentenceProducer {
|
||||
@ -43,7 +45,7 @@ public class SentenceProducer {
|
||||
|
||||
public SentenceProducer(String sentence1, String sentence2) throws UnsupportedEncodingException {
|
||||
final byte[] key = EggUtils.fromSecretSentence(sentence1).toByteArray();
|
||||
final byte[] sen2 = sentence2.getBytes("UTF-8");
|
||||
final byte[] sen2 = sentence2.getBytes(UTF_8);
|
||||
final byte[] crypted = EggUtils.xor(sen2, key);
|
||||
this.secret = EggUtils.fromByteArrays(crypted);
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ package net.sourceforge.plantuml.ftp;
|
||||
// server
|
||||
|
||||
// FtpServer.java
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
@ -53,7 +55,6 @@ public class FtpServer {
|
||||
|
||||
private final Map<String, FtpConnexion> datas = new TreeMap<String, FtpConnexion>();
|
||||
private final ExecutorService exeImage = Executors.newFixedThreadPool(2);
|
||||
private final String charset = "UTF-8";
|
||||
|
||||
private final int listenPort;
|
||||
|
||||
@ -120,7 +121,7 @@ public class FtpServer {
|
||||
}
|
||||
|
||||
public final String getCharset() {
|
||||
return charset;
|
||||
return UTF_8.name();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.math;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.io.BufferedReader;
|
||||
@ -63,7 +65,7 @@ public class AsciiMathJs implements ScientificEquation {
|
||||
static {
|
||||
try {
|
||||
final BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
AsciiMathJs.class.getResourceAsStream(ASCIIMATH_PARSER_JS_LOCATION + "ASCIIMathTeXImg.js"), "UTF-8"));
|
||||
AsciiMathJs.class.getResourceAsStream(ASCIIMATH_PARSER_JS_LOCATION + "ASCIIMathTeXImg.js"), UTF_8));
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
String s = null;
|
||||
while ((s = br.readLine()) != null) {
|
||||
|
@ -187,7 +187,7 @@ public class PicoWebServer implements Runnable {
|
||||
: "@startuml\n" + renderRequest.getSource() + "\n@enduml";
|
||||
|
||||
final SFile newCurrentDir = option.getFileDir() == null ? null : new SFile(option.getFileDir());
|
||||
final SourceStringReader ssr = new SourceStringReader(option.getDefaultDefines(), source, "UTF-8",
|
||||
final SourceStringReader ssr = new SourceStringReader(option.getDefaultDefines(), source, UTF_8,
|
||||
option.getConfig(), newCurrentDir);
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
final Diagram system;
|
||||
@ -263,7 +263,7 @@ public class PicoWebServer implements Runnable {
|
||||
|
||||
private void write(OutputStream os, String s) throws IOException {
|
||||
s = s + "\r\n";
|
||||
os.write(s.getBytes("UTF-8"));
|
||||
os.write(s.getBytes(UTF_8));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.posimo;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -105,7 +107,7 @@ public class GraphvizSolverB {
|
||||
throw new IllegalStateException("Timeout2 " + state);
|
||||
}
|
||||
final byte[] result = baos.toByteArray();
|
||||
final String s = new String(result, "UTF-8");
|
||||
final String s = new String(result, UTF_8);
|
||||
// Log.println("result=" + s);
|
||||
|
||||
// if (OptionFlags.getInstance().isKeepTmpFiles()) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
@ -49,7 +51,7 @@ public class Stdlib {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
return new ByteArrayInputStream(data.getBytes("UTF-8"));
|
||||
return new ByteArrayInputStream(data.getBytes(UTF_8));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
@ -50,6 +50,7 @@ import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -358,4 +359,8 @@ public class SFile implements Comparable<SFile> {
|
||||
return new PrintStream(internal, charset);
|
||||
}
|
||||
|
||||
public PrintStream createPrintStream(Charset charset) throws FileNotFoundException, UnsupportedEncodingException {
|
||||
return new PrintStream(internal, charset.name());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -124,6 +125,11 @@ public class SecurityUtils {
|
||||
return new PrintStream(os, autoFlush, charset);
|
||||
}
|
||||
|
||||
public static PrintStream createPrintStream(OutputStream os, boolean autoFlush, Charset charset)
|
||||
throws UnsupportedEncodingException {
|
||||
return new PrintStream(os, autoFlush, charset.name());
|
||||
}
|
||||
|
||||
public synchronized static BufferedImage readRasterImage(final ImageIcon imageIcon) {
|
||||
final Image tmpImage = imageIcon.getImage();
|
||||
if (imageIcon.getIconWidth() == -1) {
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.sequencediagram.graphic;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -126,7 +128,7 @@ public class SequenceDiagramTxtMaker implements FileMaker {
|
||||
|
||||
public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
|
||||
if (fileFormat == FileFormat.UTXT) {
|
||||
final PrintStream ps = SecurityUtils.createPrintStream(os, true, "UTF-8");
|
||||
final PrintStream ps = SecurityUtils.createPrintStream(os, true, UTF_8);
|
||||
ug.getCharArea().print(ps);
|
||||
} else {
|
||||
final PrintStream ps = SecurityUtils.createPrintStream(os);
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.sprite;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
@ -70,9 +72,9 @@ public class RessourcesUtils {
|
||||
final URL versionURL = Version.class.getClassLoader().getResource(classFile);
|
||||
final String jarPath = versionURL.getPath().substring(5, versionURL.getPath().indexOf("!"));
|
||||
if (folder) {
|
||||
return listFolders(new JarFile(URLDecoder.decode(jarPath, "UTF-8")), path + "/");
|
||||
return listFolders(new JarFile(URLDecoder.decode(jarPath, UTF_8.name())), path + "/");
|
||||
} else {
|
||||
return listFiles(new JarFile(URLDecoder.decode(jarPath, "UTF-8")), path + "/");
|
||||
return listFiles(new JarFile(URLDecoder.decode(jarPath, UTF_8.name())), path + "/");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.svek;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@ -323,7 +325,7 @@ public class DotStringFactory implements Moveable {
|
||||
}
|
||||
}
|
||||
final byte[] result = baos.toByteArray();
|
||||
final String s = new String(result, "UTF-8");
|
||||
final String s = new String(result, UTF_8);
|
||||
|
||||
if (basefile != null) {
|
||||
final SFile f = basefile.getTraceFile("svek.svg");
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.tikz;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.io.IOException;
|
||||
@ -271,8 +273,8 @@ public class TikzGraphics {
|
||||
}
|
||||
|
||||
private void out(OutputStream os, String s) throws IOException {
|
||||
os.write(s.getBytes("UTF-8"));
|
||||
os.write("\n".getBytes("UTF-8"));
|
||||
os.write(s.getBytes(UTF_8));
|
||||
os.write("\n".getBytes(UTF_8));
|
||||
}
|
||||
|
||||
public void text(double x, double y, String text, boolean underline, boolean italic, boolean bold) {
|
||||
|
@ -34,6 +34,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.debug;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
@ -295,8 +297,8 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
|
||||
}
|
||||
|
||||
private void print(OutputStream os, String out) throws UnsupportedEncodingException, IOException {
|
||||
os.write(out.getBytes("UTF-8"));
|
||||
os.write("\n".getBytes("UTF-8"));
|
||||
os.write(out.getBytes(UTF_8));
|
||||
os.write("\n".getBytes(UTF_8));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.txt;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -115,7 +117,7 @@ public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer
|
||||
}
|
||||
|
||||
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
|
||||
final PrintStream ps = SecurityUtils.createPrintStream(os, true, "UTF-8");
|
||||
final PrintStream ps = SecurityUtils.createPrintStream(os, true, UTF_8);
|
||||
getCharArea().print(ps);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.version;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -147,7 +149,7 @@ public class PLSSignature {
|
||||
if (read != size) {
|
||||
throw new IOException();
|
||||
}
|
||||
return new String(result, "UTF-8");
|
||||
return new String(result, UTF_8);
|
||||
}
|
||||
|
||||
private static long readLong(ByteArrayInputStream bais) throws IOException {
|
||||
@ -207,7 +209,7 @@ public class PLSSignature {
|
||||
}
|
||||
|
||||
public static byte[] getSalt(final String signature) throws UnsupportedEncodingException {
|
||||
final Random rnd = new Random(getSeed(signature.getBytes("UTF-8")));
|
||||
final Random rnd = new Random(getSeed(signature.getBytes(UTF_8)));
|
||||
final byte salt[] = new byte[512];
|
||||
rnd.nextBytes(salt);
|
||||
return salt;
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.xmi;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -133,7 +135,7 @@ abstract class XmiClassDiagramAbstract implements IXmiClassDiagram {
|
||||
final Transformer transformer = fabrique.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
// transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, UTF_8.name());
|
||||
// tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
transformer.transform(source, resultat);
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.xmi;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -234,7 +236,7 @@ public class XmiDescriptionDiagram implements IXmiClassDiagram {
|
||||
final Transformer transformer = fabrique.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
// transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, UTF_8.name());
|
||||
// tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
transformer.transform(source, resultat);
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.xmi;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -248,7 +250,7 @@ public class XmiStateDiagram implements IXmiClassDiagram {
|
||||
final Transformer transformer = fabrique.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
// transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, UTF_8.name());
|
||||
// tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
transformer.transform(source, resultat);
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.xmlsc;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -133,7 +135,7 @@ public class ScxmlStateDiagramStandard {
|
||||
final TransformerFactory fabrique = TransformerFactory.newInstance();
|
||||
final Transformer transformer = fabrique.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, UTF_8.name());
|
||||
transformer.transform(source, resultat);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.sourceforge.plantuml.code;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -13,8 +14,8 @@ class CompressionTest {
|
||||
@Test
|
||||
public void no_100_000_limit() throws Exception {
|
||||
final Compression compression = new CompressionZlib();
|
||||
compression.decompress(compression.compress(repeat("x", 100_000).getBytes("UTF-8")));
|
||||
compression.decompress(compression.compress(repeat("x", 100_001).getBytes("UTF-8")));
|
||||
compression.decompress(compression.compress(repeat("x", 100_000).getBytes(UTF_8)));
|
||||
compression.decompress(compression.compress(repeat("x", 100_001).getBytes(UTF_8)));
|
||||
|
||||
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
|
||||
transcoder.decode(transcoder.encode(repeat("x", 100_000)));
|
||||
|
@ -19,7 +19,7 @@ public class TestUtils {
|
||||
final Option option = new Option(options);
|
||||
option.setFileFormatOption(new FileFormatOption(FileFormat.UTXT));
|
||||
|
||||
final SourceStringReader ssr = new SourceStringReader(option.getDefaultDefines(), source, "UTF-8", option.getConfig());
|
||||
final SourceStringReader ssr = new SourceStringReader(option.getDefaultDefines(), source, UTF_8.name(), option.getConfig());
|
||||
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nonreg;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@ -7,8 +8,6 @@ import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -33,8 +32,6 @@ public class BasicTest {
|
||||
|
||||
private static final String TRIPLE_QUOTE = "\"\"\"";
|
||||
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
private static final boolean FORCE_RESULT_GENERATION = false;
|
||||
private static final boolean ENABLE_RESULT_GENERATION_IF_NONE_PRESENT = false;
|
||||
|
||||
@ -49,7 +46,7 @@ public class BasicTest {
|
||||
final String actualResult = runPlantUML(expectedDescription);
|
||||
if (FORCE_RESULT_GENERATION
|
||||
|| (ENABLE_RESULT_GENERATION_IF_NONE_PRESENT && Files.exists(getResultFile()) == false)) {
|
||||
generatedResultJavaFile(actualResult, actualResult.getBytes(UTF8));
|
||||
generatedResultJavaFile(actualResult, actualResult.getBytes(UTF_8));
|
||||
}
|
||||
final String imageExpectedResult = readTripleQuotedString(getResultFile());
|
||||
assertEquals(imageExpectedResult, actualResult);
|
||||
@ -57,7 +54,7 @@ public class BasicTest {
|
||||
|
||||
private void generatedResultJavaFile(String actualResult, byte[] bytes) throws IOException {
|
||||
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(getResultFile(), StandardCharsets.UTF_8)) {
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(getResultFile(), UTF_8)) {
|
||||
writer.write("package " + getPackageName() + ";\n");
|
||||
writer.write("\n");
|
||||
writer.write("public class " + getClass().getSimpleName() + "Result {\n");
|
||||
@ -89,18 +86,18 @@ public class BasicTest {
|
||||
|
||||
protected String runPlantUML(String expectedDescription) throws IOException, UnsupportedEncodingException {
|
||||
final String diagramText = readTripleQuotedString(getDiagramFile());
|
||||
final SourceStringReader ssr = new SourceStringReader(diagramText, "UTF-8");
|
||||
final SourceStringReader ssr = new SourceStringReader(diagramText, UTF_8);
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final DiagramDescription diagramDescription = ssr.outputImage(baos, 0, new FileFormatOption(FileFormat.DEBUG));
|
||||
assertEquals(expectedDescription, diagramDescription.getDescription(), "Bad description");
|
||||
|
||||
return new String(baos.toByteArray(), UTF8);
|
||||
return new String(baos.toByteArray(), UTF_8);
|
||||
}
|
||||
|
||||
protected String readTripleQuotedString(Path path) throws IOException {
|
||||
assertTrue(Files.exists(path), "Cannot find " + path);
|
||||
assertTrue(Files.isReadable(path), "Cannot read " + path);
|
||||
final List<String> allLines = Files.readAllLines(path, UTF8);
|
||||
final List<String> allLines = Files.readAllLines(path, UTF_8);
|
||||
final int first = allLines.indexOf(TRIPLE_QUOTE);
|
||||
final int last = allLines.lastIndexOf(TRIPLE_QUOTE);
|
||||
assertTrue(first != -1);
|
||||
|
Loading…
Reference in New Issue
Block a user