-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/sotasan/decompiler/services/TypeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.sotasan.decompiler.services; | ||
|
||
import com.sotasan.decompiler.models.FileModel; | ||
import com.sotasan.decompiler.types.ClassType; | ||
import com.sotasan.decompiler.types.ManifestType; | ||
import com.sotasan.decompiler.types.Type; | ||
import lombok.experimental.UtilityClass; | ||
import org.jetbrains.annotations.Nullable; | ||
import java.util.List; | ||
|
||
@UtilityClass | ||
public class TypeService { | ||
|
||
private static final List<Type> TYPES = List.of( | ||
new ClassType(), | ||
new ManifestType() | ||
); | ||
|
||
public static @Nullable Type getType(FileModel fileModel) { | ||
for (Type format : TYPES) | ||
if (format.isFormat(fileModel)) | ||
return format; | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.sotasan.decompiler.types; | ||
|
||
import com.sotasan.decompiler.models.FileModel; | ||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ClassType extends Type { | ||
|
||
public ClassType() { | ||
super("icons/class.png", SyntaxConstants.SYNTAX_STYLE_JAVA); | ||
} | ||
|
||
@Override | ||
public boolean isFormat(@NotNull FileModel fileModel) { | ||
return fileModel.getName().toLowerCase().endsWith(".class"); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/sotasan/decompiler/types/ManifestType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.sotasan.decompiler.types; | ||
|
||
import com.sotasan.decompiler.models.FileModel; | ||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ManifestType extends Type { | ||
|
||
public ManifestType() { | ||
super("icons/manifest.png", SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE); | ||
} | ||
|
||
@Override | ||
public boolean isFormat(@NotNull FileModel fileModel) { | ||
return fileModel.getName().toLowerCase().endsWith(".mf"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.sotasan.decompiler.types; | ||
|
||
import com.sotasan.decompiler.models.FileModel; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public abstract class Type { | ||
|
||
private final String icon; | ||
private final String syntax; | ||
|
||
public Type(String icon, String syntax) { | ||
this.icon = icon; | ||
this.syntax = syntax; | ||
} | ||
|
||
public abstract boolean isFormat(FileModel fileModel); | ||
|
||
} |