-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: ES2Excavator can fully import/export between DAT and JSON.
+ refactored FileProcessor to abstract class. + Implements FIleProcessor per file-type. + Cmd line will filter args out of the args[] array before file filtering. + Processors will filter-greedy for their chosen file types.
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
ES2Excavator/src/main/java/org/hercworks/extract/util/FileMatch.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,51 @@ | ||
package org.hercworks.extract.util; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Used to match incoming .JSON files against known file types for conversion to ES2 DAT binary formats. | ||
*/ | ||
public enum FileMatch { | ||
|
||
ARM_WEAP("ARM_WEAP"), | ||
WEAPONS("WEAPONS"), | ||
ARM_HERC("ARM_"), | ||
RPR_HERC("RPR_"), | ||
INI_HERC("INI_"), | ||
HERCS("HERCS"), | ||
HERC_INF("HERC_INF"), | ||
CAREER("CAREER"), | ||
TRAINING_HERCS("TRN_HERCS"); | ||
|
||
private String namePattern; | ||
private static final Map<String,FileMatch> ENUM_MAP; | ||
|
||
|
||
private FileMatch(String pattern) { | ||
this.namePattern = pattern; | ||
} | ||
|
||
public String getPattern() { | ||
return this.namePattern; | ||
} | ||
|
||
static { | ||
Map<String,FileMatch> map = new HashMap<String, FileMatch>(); | ||
for (FileMatch instance : FileMatch.values()) { | ||
map.put(instance.getPattern(),instance); | ||
} | ||
ENUM_MAP = Collections.unmodifiableMap(map); | ||
} | ||
|
||
public static FileMatch getByPattern(String file) { | ||
for(String pattern : ENUM_MAP.keySet()) { | ||
if(file.toUpperCase().contains(pattern)) { | ||
return ENUM_MAP.get(pattern); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
ES2Excavator/src/test/java/org/hercworks/extract/cmd/TestExports.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,45 @@ | ||
package org.hercworks.extract.cmd; | ||
|
||
import org.hercworks.extract.CommandLineMain; | ||
import org.junit.Test; | ||
|
||
|
||
public class TestExports { | ||
|
||
public static String[] wepDatArgs = new String[] {"-x","/UNPACK/SHELL0/GAM/WEAPONS.DAT"}; | ||
public static String[] wepJsonArgs = new String[] {"-x","/UNPACK/WEAPONS.json"}; | ||
|
||
public static String[] hercsDatArgs = new String[] {"-x","/UNPACK/SHELL0/GAM/HERCS.DAT"}; | ||
public static String[] hercsJsonArgs = new String[] {"-x","/UNPACK/HERCS.json"}; | ||
|
||
public static String[] hercInfDatArgs = new String[] {"-x","/UNPACK/SHELL0/GAM/HERC_INF.DAT"}; | ||
public static String[] hercInfJsonArgs = new String[] {"-x","/UNPACK/HERC_INF.json"}; | ||
|
||
@Test | ||
public void testWeaponsDat() { | ||
|
||
// CommandLineMain.main(wepDatArgs); | ||
|
||
CommandLineMain.main(wepJsonArgs); | ||
|
||
} | ||
|
||
@Test | ||
public void testHercs() { | ||
|
||
CommandLineMain.main(hercsDatArgs); | ||
|
||
CommandLineMain.main(hercsJsonArgs); | ||
|
||
|
||
} | ||
|
||
@Test | ||
public void testHercInf() { | ||
|
||
CommandLineMain.main(hercInfDatArgs); | ||
|
||
CommandLineMain.main(hercInfJsonArgs); | ||
|
||
} | ||
} |