1.1, Toldalékozás

A számok magyar toldalékozásához használható Java osztály

package hu.infokristaly.vpscalc.utils;
 
import org.apache.commons.lang3.ArrayUtils;
 
public final class SzamokToldalekozasa {
 
	private static String[] utolsoBetu1 = {"v","gy","v","m","gy","t","t","t","c","c"};
	private static String[] utolsoBetu10 = {"z","sz","c","n","n","n","n","n","n"};
	private static byte[] magasHangrend1 = { 1, 2, 4, 5, 7, 9 };
	private static byte[] melyHangrend1 = { 3, 6, 8 };
	private static byte[] magasHangrend10 = { 10, 40, 50, 70, 90 };
	private static byte[] melyHangrend10 = { 20, 30, 60, 80 };
	private static String VEL = "el";
	private static String VAL = "al";
	private static String NAL = "nál";
	private static String NEL = "nél";
 
	public static String getValVel(Integer num) {
		byte num1 = (byte) (num % 10);
		if (num1 != 0) {
			if (ArrayUtils.indexOf(magasHangrend1, num1) > -1) {
				return utolsoBetu1[num1] + VEL;
			} else {
				return utolsoBetu1[num1] + VAL;
			}
		} else {
			byte num10 = (byte) (num % 100);
			if (num10 != 0) {
				byte num0 = (byte) (num10 / 10);
				if (ArrayUtils.indexOf(magasHangrend10, num10) > -1) {
					return utolsoBetu10[num0-1] +VEL;
				} else {
					return utolsoBetu10[num0-1]+VAL;
				}
			} else {
				int num100 = num % 1000;
				if (num100 != 0) {
					return "z"+VAL;
				} else {
					int num1000 = num % 1000000;
					if (num1000 != 0) {
						return "r"+VEL;
					} else {
						return "v"+VAL;
					}
				}
			}
		}
	}
 
	public static String getNalNel(Integer num) {
		byte num1 = (byte) (num % 10);
		if (num1 != 0) {
			if (ArrayUtils.indexOf(magasHangrend1, num1) > -1) {
				return NEL;
			} else {
				return NAL;
			}
		} else {
			byte num10 = (byte) (num % 100);
			if (num10 != 0) {
				if (ArrayUtils.indexOf(magasHangrend10, num10) > -1) {
					return NEL;
				} else {
					return NAL;
				}
			} else {
				int num100 = num % 1000;
				if (num100 != 0) {
					return NAL;
				} else {
					int num1000 = num % 1000000;
					if (num1000 != 0) {
						return NEL;
					} else {
						return NAL;
					}
				}
			}
		}
	}
}