1 package de.webman.duplication.eventhandler; 2 3 import com.teamkonzept.web.servlet.*; 4 import com.teamkonzept.webman.mainint.*; 5 import com.teamkonzept.webman.db.*; 6 import com.teamkonzept.web.*; 7 import com.teamkonzept.lib.*; 8 9 import com.teamkonzept.web.oracle.*; 10 import com.teamkonzept.field.*; 11 import com.teamkonzept.db.*; 12 import de.webman.generator.*; 13 import com.teamkonzept.webman.*; 14 15 import java.io.*; 16 import java.util.*; 17 import java.sql.*; 18 import java.text.*; 19 20 import org.apache.log4j.Category; 21 22 27 public class DateNameModifier extends NameModifier 28 { 29 private static final Category CATEGORY = Category.getInstance(DateNameModifier.class); 30 31 GregorianCalendar startDate = new GregorianCalendar(); 32 33 String PARAMETER_CLASS = "MOD_DATE"; 35 String APPEND_DATE = "APPEND_DATE"; String DAY = "DAY"; 37 String MONTH = "MONTH"; 38 String YEAR = "YEAR"; 39 40 String TRUE = "1"; 41 42 43 44 DateNameModifier(){ 45 classIdentifier = PARAMETER_CLASS; 46 } 47 void localInit(){ 48 } 49 50 public boolean checkParams(){ 51 boolean appendDate = ((myParams.get(APPEND_DATE)) != null) && (((String ) myParams.get(APPEND_DATE)).equals(TRUE)); 52 try{ 53 startDate.set(Calendar.DATE, (new Integer ( (String ) myParams.get(DAY))).intValue()); 54 startDate.set(Calendar.MONTH,(new Integer ( (String ) myParams.get(MONTH))).intValue() -1 ); 55 startDate.set(Calendar.YEAR, (new Integer ( (String ) myParams.get(YEAR))).intValue()); 56 } 57 catch(NumberFormatException e){ 58 CATEGORY.error(" DateNameModifier NumberFormatException :",e); 59 } 60 CATEGORY.debug(" using startDate: " +startDate); 61 return appendDate; 62 } 63 64 public String modify(int copyNr, String oldName){ 65 66 67 68 GregorianCalendar currentDate = (GregorianCalendar)startDate.clone(); 69 currentDate.add(Calendar.DATE, copyNr); 70 71 Integer day = new Integer (currentDate.get(Calendar.DATE )); 72 Integer month = new Integer (currentDate.get(Calendar.MONTH ) +1 ); 73 Integer year = new Integer (currentDate.get(Calendar.YEAR )); 74 75 String dateString = "_" + day.toString() + "_"+month.toString()+"_"+year.toString(); 76 return oldName + dateString; 77 } 78 } 79 80 | Popular Tags |