package com.mcpekorea.calcium.hangul;

public class Hangul {
	public static enum Mode {
		OBJECT, // 을/를
		NOUN, // 은/는
		CONJUNCTION, // 이/가
		AND; // 와/과
	}
	
	public static final char CHAR_BEGIN = 0xAC00;  //-> 가
	public static final char CHAR_END = 0xD7A3;    //-> 힣
	
	public static final char CHAR_EUL = 0xC744;    //-> 을
	public static final char CHAR_LEUL = 0xB97C;   //-> 를
	public static final char CHAR_I = 0xC774;      //-> 이
	public static final char CHAR_GA = CHAR_BEGIN; //-> 가
	public static final char CHAR_EUN = 0xC740;    //-> 은
	public static final char CHAR_NEUN = 0xB294;   //-> 는
	public static final char CHAR_WA = 0xC640;
	public static final char CHAR_GWA = 0xACFC; // 과
	
	
	public static boolean hasFinalConsonant(final char unicode){
		if(unicode < CHAR_BEGIN || unicode > CHAR_END)
			throw new CharacterIndexOutOfBoundsException(unicode);
		
		return (unicode - CHAR_BEGIN) % 28 != 0;
	}
	
	public static char getNext(final char unicode, final Hangul.Mode mode){
		if(unicode < CHAR_BEGIN || unicode > CHAR_END)
			throw new CharacterIndexOutOfBoundsException(unicode);
		
		switch(mode){
			case OBJECT:
				return hasFinalConsonant(unicode) ? CHAR_EUL : CHAR_LEUL;
					
			case NOUN:
				return hasFinalConsonant(unicode) ? CHAR_EUN : CHAR_NEUN;
				
			case CONJUNCTION:
				return hasFinalConsonant(unicode) ? CHAR_I : CHAR_GA;
			case AND:
				return hasFinalConsonant(unicode) ? CHAR_GWA : CHAR_WA;
			default:
				throw new IllegalArgumentException();
		}
	}
}

@@ -95,18 +95,25 @@
 OBJECT, 
-//
+     //-%3E
  %EC%9D%84/%EB%A5%BC%0D%0A%09%09
@@ -117,19 +117,28 @@
 %0A%09%09NOUN,
+       
  //
+-%3E
  %EC%9D%80/%EB%8A%94%0D%0A%09%09
@@ -152,16 +152,18 @@
 TION, //
+-%3E
  %EC%9D%B4/%EA%B0%80%0D%0A%09%09
@@ -167,18 +167,28 @@
 %0A%09%09AND; 
-//
+        //-%3E
  %EC%99%80/%EA%B3%BC%0D%0A%09%7D
@@ -686,16 +686,27 @@
  0xC640;
+     //-%3E %EC%99%80
 %0D%0A%09publi
@@ -744,18 +744,23 @@
 0xACFC; 
-//
+   //-%3E
  %EA%B3%BC%0D%0A%09%0D%0A%09
@@ -1443,24 +1443,38 @@
 HAR_GA;%0D%0A%09%09%09
+%0D%0A            
 case AND:%0D%0A%09
@@ -1533,19 +1533,33 @@
 AR_WA;%0D%0A
-
 %09%09%09
+%0D%0A            
 default:

Add comment