All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.daxie.xops.openxops.WeaponDataCodeParser Maven / Gradle / Ivy

Go to download

XOPSManipulator is a Java library that offers several functions to manipulate matters relating to X operations.

The newest version!
package com.daxie.xops.openxops;

import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Pattern;

import com.daxie.basis.vector.Vector;
import com.daxie.log.LogFile;
import com.daxie.tool.FileFunctions;
import com.daxie.tool.StringFunctions;
import com.daxie.xops.weapon.WeaponData;
import com.daxie.xops.weapon.WeaponScopeMode;
import com.daxie.xops.weapon.WeaponShootingStance;

/**
 * Parses the source code of OpenXOPS and obtains weapon data.
 * @author Daba
 *
 */
public class WeaponDataCodeParser {
	private Map weapon_data_map;
	
	/**
	 * In case you already have lines of the code.
	 * @param lines Lines of the code
	 */
	public WeaponDataCodeParser(List lines) {
		weapon_data_map=new HashMap<>();
		
		if(lines==null) {
			LogFile.WriteWarn("[WeaponDataCodeParser-] Null argument.",true);
			return;
		}
		
		this.ParseLines(lines);
	}
	/**
	 * Parses the code after loading it from a file.
	 * @param code_filename Filename of the code
	 * @param encoding Encoding
	 * @throws FileNotFoundException Specified file not found
	 * @throws UnsupportedEncodingException Specified encoding not supported
	 */
	public WeaponDataCodeParser(String code_filename,String encoding)
			throws FileNotFoundException,UnsupportedEncodingException{
		weapon_data_map=new HashMap<>();
		
		List lines=FileFunctions.GetFileAllLines(code_filename, encoding);
		this.ParseLines(lines);
	}
	
	private void ParseLines(List lines) {
		for(int i=0;i GetWeaponDataMap(){
		return new HashMap<>(weapon_data_map);
	}
	public TreeMap GetWeaponDataOrderedMap(){
		return new TreeMap<>(weapon_data_map);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy