Checkstyle fix

This commit is contained in:
Jindra Petřík
2025-04-13 14:13:27 +02:00
parent 859a2f8bdb
commit b1c5f9d0c6
85 changed files with 2486 additions and 2340 deletions
@@ -41,7 +41,7 @@ import java.util.logging.Logger;
public class LsoTag extends Tag {
public static final int ID = 2;
public String fileName;
public int amfVersion;
public Map<String, Object> amfValues = new LinkedHashMap<>();
@@ -49,7 +49,7 @@ public class LsoTag extends Tag {
public LsoTag(byte[] data, boolean forceWriteAsLong) {
super(ID, "DefineLso", data, forceWriteAsLong);
}
public LsoTag(String fileName, int amfVersion, Map<String, Object> amfValues) {
super(ID, "DefineLso", new byte[0], true);
this.fileName = fileName;
@@ -81,7 +81,7 @@ public class LsoTag extends Tag {
while (ais.available() > 0) {
String varName = ais.readUtf8("varName");
try {
Object varValue = ais.readValue("varValue");
Object varValue = ais.readValue("varValue");
amfValues.put(varName, varValue);
} catch (NoSerializerExistsException ex) {
throw new IllegalArgumentException("Serializer for class " + ex.getClassName() + " not found");
@@ -89,7 +89,7 @@ public class LsoTag extends Tag {
ais.read(); //ending byte
}
ais.resolveMapReferences(amfValues);
}
}
if (amfVersion == 3) {
Amf3InputStream ais = new Amf3InputStream(new MemoryInputStream(amfData));
@@ -114,18 +114,18 @@ public class LsoTag extends Tag {
@Override
public void writeData(OutputStream os) throws IOException {
Amf0OutputStream aos = new Amf0OutputStream(os);
aos.write(new byte[] {'T', 'C', 'S', 'O'});
aos.write(new byte[] {0x00,0x04,0x00,0x00,0x00,0x00});
aos.write(new byte[]{'T', 'C', 'S', 'O'});
aos.write(new byte[]{0x00, 0x04, 0x00, 0x00, 0x00, 0x00});
byte[] fileNameData = fileName.getBytes("UTF-8");
aos.writeU16(fileNameData.length);
aos.write(fileNameData);
aos.writeU32(amfVersion);
if (amfVersion == 0) {
List<Object> complexObjects = new ArrayList<>();
for(String key: amfValues.keySet()) {
for (String key : amfValues.keySet()) {
aos.writeUtf8(key);
aos.writeValue(amfValues.get(key), complexObjects);
aos.writeValue(amfValues.get(key), complexObjects);
aos.write(0);
}
}
@@ -134,7 +134,7 @@ public class LsoTag extends Tag {
List<String> stringTable = new ArrayList<>();
List<Traits> traitTable = new ArrayList<>();
List<Object> objectTable = new ArrayList<>();
for(String key: amfValues.keySet()) {
for (String key : amfValues.keySet()) {
try {
a3os.writeUtf8Vr(key, stringTable);
a3os.writeValue(amfValues.get(key), new HashMap<>(), stringTable, traitTable, objectTable);
@@ -144,6 +144,6 @@ public class LsoTag extends Tag {
aos.write(0);
}
}
}
}
@@ -20,9 +20,9 @@ import com.jpexs.decompiler.flash.EndOfStreamException;
import com.jpexs.decompiler.flash.amf.amf0.Amf0OutputStream;
import com.jpexs.decompiler.flash.exporters.amf.amf0.Amf0Exporter;
import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter;
import com.jpexs.decompiler.flash.importers.amf.AmfParseException;
import com.jpexs.decompiler.flash.importers.amf.amf0.Amf0Importer;
import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer;
import com.jpexs.decompiler.flash.importers.amf.AmfParseException;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.EOFException;
@@ -46,24 +46,24 @@ public class SolFile {
private DataInputStream is;
private long pos = 0;
private List<Tag> tags = new ArrayList<>();
public SolFile(InputStream is) throws IOException {
this.is = new DataInputStream(is);
readTags();
}
public SolFile(String fileName, int amfVersion, Map<String, Object> amfValues) {
tags.add(new LsoTag(fileName, amfVersion, amfValues));
}
public void writeTo(OutputStream os) throws IOException {
for (Tag t: tags) {
for (Tag t : tags) {
writeTag(os, t);
}
}
private void readTags() throws IOException {
while (is.available() > 0) {
Tag t = readTag();
@@ -112,10 +112,10 @@ public class SolFile {
is.skip(count);
pos += count;
}
private void writeTag(OutputStream os, Tag t) throws IOException{
private void writeTag(OutputStream os, Tag t) throws IOException {
Amf0OutputStream aos = new Amf0OutputStream(os);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
t.writeData(baos);
int contentLength = baos.size();
@@ -137,7 +137,7 @@ public class SolFile {
contentLength = (int) readUI32();
writeAsLong = true;
}
int tagType = tagTypeAndLength >> 6;
int tagType = tagTypeAndLength >> 6;
byte[] data = readBytes(contentLength);
switch (tagType) {
@@ -153,8 +153,8 @@ public class SolFile {
public List<Tag> getTags() {
return tags;
}
private LsoTag getLsoTag() throws IOException {
private LsoTag getLsoTag() throws IOException {
for (Tag t : getTags()) {
if (t instanceof LsoTag) {
return (LsoTag) t;
@@ -162,7 +162,7 @@ public class SolFile {
}
return null;
}
public int getAmfVersion() throws IOException {
LsoTag lsoTag = getLsoTag();
if (lsoTag == null) {
@@ -170,7 +170,7 @@ public class SolFile {
}
return lsoTag.amfVersion;
}
public String getFileName() throws IOException {
LsoTag lsoTag = getLsoTag();
if (lsoTag == null) {
@@ -178,14 +178,14 @@ public class SolFile {
}
return lsoTag.fileName;
}
public Map<String, Object> getAmfValues() throws IOException {
LsoTag lsoTag = getLsoTag();
if (lsoTag == null) {
return new HashMap<>();
}
return lsoTag.amfValues;
}
}
public static void main(String[] args) throws FileNotFoundException, IOException {
SolFile sol0 = new SolFile(new FileInputStream("testdata/sharedobjects/data/amf0test.sol"));