1 37 package org.webharvest.utils; 38 39 import org.webharvest.runtime.variables.NodeVariable; 40 import org.webharvest.runtime.variables.IVariable; 41 import org.webharvest.exception.BaseException; 42 43 import java.text.SimpleDateFormat ; 44 import java.util.Date ; 45 46 50 public class SystemUtilities { 51 52 public static final IVariable lf = new NodeVariable("\n"); 53 public static final IVariable tab = new NodeVariable("\t"); 54 public static final IVariable cr = new NodeVariable("\r"); 55 public static final IVariable space = new NodeVariable(" "); 56 public static final IVariable quot = new NodeVariable("\""); 57 public static final IVariable apos = new NodeVariable("\'"); 58 public static final IVariable backspace = new NodeVariable("\b"); 59 60 65 public String datetime(Object format) { 66 if (format != null) { 67 SimpleDateFormat formatter = new SimpleDateFormat (format.toString()); 68 return formatter.format( new Date () ); 69 } 70 71 throw new BaseException("Cannot return datetime for null format!"); 72 } 73 74 77 public String date() { 78 return datetime("yyyyMMdd"); 79 } 80 81 84 public String time() { 85 return datetime("HHmmss"); 86 } 87 88 92 public String escapeXml(Object s) { 93 if (s != null) { 94 return CommonUtil.escapeXml(s.toString()); 95 } 96 97 throw new BaseException("Cannot escape XML for null argumant!"); 98 } 99 100 105 public String fullUrl(Object pageUrl, Object link) { 106 if (pageUrl != null && link != null) { 107 return CommonUtil.fullUrl(pageUrl.toString(), link.toString()); 108 } 109 110 throw new BaseException("Cannot make full url for null argumants!"); 111 } 112 113 } | Popular Tags |