$${aaa.bbb.ccc} 이라는 템플릿에 대한 검증 또는 데이터 저장하는 코드.
public class TemplatePropertyMaker {
public static boolean isAvailable(String value) {
return getGroup(value) == null ? false : true;
}
private static String getGroup(String value) {
Pattern pattern = Pattern.compile("\\$\\$\\{(.*)\\}");
Matcher matcher = pattern.matcher(value);
String content = null;
if (matcher.find()) {
if (Logger.DEBUG) {
System.out.println("TemplatePropertyMaker: " + value.substring(matcher.start(), matcher.end()));
System.out.println("TemplatePropertyMaker: " + matcher.group(1));
}
content = matcher.group(1);
}
if (content == null) {
return null;
}
return content;
}
public static TemplateProperty getTemplatProperty(String key, String value) {
String content = getGroup(value);
Pattern pattern = Pattern.compile("(\\w++).(\\w++).(\\w++)");
Matcher matcher = pattern.matcher(content);
TemplateProperty templateProperty = new TemplateProperty();
if (matcher.find()) {
int number = matcher.groupCount();
while (number > 0) {
templateProperty.setValue(number, matcher.group(number));
number--;
}
}
templateProperty.setKey(key);
return templateProperty;
}
}
'java core' 카테고리의 다른 글
파일 copy 테스트 (nio, inputstream) 테스트 in java (0) | 2009.09.11 |
---|---|
Java Memroy Model (0) | 2009.08.06 |
Symmetric Encryption by using java.security. (0) | 2009.07.22 |
URLConnection vs HTTPURLConnection (0) | 2009.07.20 |
Finally 범위 (0) | 2009.07.15 |