1 25 26 package com.j2biz.blogunity.web; 27 28 import com.j2biz.blogunity.i18n.I18N; 29 import com.j2biz.blogunity.i18n.I18NMessageManager; 30 31 public class ActionResultFactory { 32 33 public static IActionResult buildForward(String path) { 34 return new ForwardImpl(path); 35 } 36 37 public static IActionResult buildInclude(String path) { 38 return new IncludeImpl(path); 39 } 40 41 public static IActionResult buildRedirect(String path) { 42 return new RedirectImpl(path); 43 } 44 45 public static IActionResult buildForward(String i18nKey, String path) { 46 return new ForwardImpl(i18nKey, path); 47 } 48 49 public static IActionResult buildInclude(String i18nKey, String path) { 50 return new IncludeImpl(i18nKey, path); 51 } 52 53 public static IActionResult buildRedirect(String i18nKey, String path) { 54 return new RedirectImpl(i18nKey, path); 55 } 56 57 private static abstract class AbstractActionResultImpl implements IActionResult { 58 59 private String path; 60 61 private String i18nKey = I18N.MESSAGES.UNKNOWN; 62 63 public AbstractActionResultImpl(String path) { 64 this.path = path; 65 } 66 67 public AbstractActionResultImpl(String i18nKey, String path) { 68 this.path = path; 69 this.i18nKey = i18nKey; 70 } 71 72 77 public String getPath() { 78 return path; 79 } 80 81 86 public String getKey() { 87 return i18nKey; 88 } 89 90 95 public String getValue() { 96 return I18NMessageManager.getInstance().getNavigationText(i18nKey); 97 } 98 99 } 100 101 private static class ForwardImpl extends AbstractActionResultImpl { 102 103 public ForwardImpl(String path) { 104 super(path); 105 } 106 107 public ForwardImpl(String i18nKey, String path) { 108 super(i18nKey, path); 109 } 110 111 public int getType() { 112 return FORWARD; 113 } 114 115 } 116 117 private static class IncludeImpl extends AbstractActionResultImpl { 118 119 public IncludeImpl(String path) { 120 super(path); 121 } 122 123 public IncludeImpl(String i18nKey, String path) { 124 super(i18nKey, path); 125 } 126 127 public int getType() { 128 return INCLUDE; 129 } 130 131 } 132 133 private static class RedirectImpl extends AbstractActionResultImpl { 134 135 public RedirectImpl(String path) { 136 super(path); 137 } 138 139 public RedirectImpl(String i18nKey, String path) { 140 super(i18nKey, path); 141 } 142 143 public int getType() { 144 return REDIRECT; 145 } 146 147 } 148 } | Popular Tags |