Monthly Archives: February 2011

What’s the tab for

Note: OS is an OutputStream

               private int numtab=0;
               private static final String tab="\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";

               OS.write(writeline(""));
               if(IT.getConfigFile()!=null && IT.getConfigFile().length()>0)
               {
                    numtab++;
                    OS.write(writeline(""));
                    writeParamHide(IT);
                    numtab--;
               }
               writeParam(IT);
               OS.write(writeline(""));
              
              
               private byte[] writeline(String str)
               {
                    return (tab.substring(0, numtab)+str+"\n").getBytes();
               }

Now I’d understood…

Actually in the production codebase of a biggest italian TLC company

Advertisements

Date parsing perversion

          private MapDF=new HashMap();
          private ConvertDate CD =new ConvertDate();

          DF.put("ddmmyyyy",new SimpleDateFormat ("ddMMyyyy",Locale.ITALIAN));
          DF.put("yyyymmdd",new SimpleDateFormat ("yyyyMMdd",Locale.ITALIAN));
          DF.put("yymmdd",new SimpleDateFormat ("yyMMdd",Locale.ITALIAN));
         
          String[] DI=IDS.getString(1).split(" ");
          dateIntervallo=new Date[]{CD.Convert("XXX"+DI[0], "???yyyymmdd"),
		CD.Convert("XXX"+DI[1], "???yyyymmdd")};
              
          class ConvertDate
          {
                 public Date Convert(String extrDate,String dateTemplate) throws Exception
                 {
                      String DT=dateTemplate.substring(dateTemplate.lastIndexOf("?")+1).
				replaceAll("[^a-zA-Z0-9]", "");
                      String date=extrDate.substring(dateTemplate.lastIndexOf("?")+1,
				dateTemplate.lastIndexOf("?")+dateTemplate.length()-dateTemplate.lastIndexOf("?"))
				.replaceAll("[^a-zA-Z0-9]", "");
                     
                      try{return DF.get(DT).parse(date);}
                      catch (Exception e){throw new Exception("Unknown Format Date");}
                 }
          }

Add the XXX
Add the ???
Remove the XXX
Remove the ???
Choose a pattern
Change the pattern
Lets it cook for 20 minutes
Done

Actually in the production codebase of a biggest italian TLC company


Constructor

	public class Pivot
    	{                        
    		public Pivot(){super();}
        }

SuperObject

Actually in the production codebase of a biggest italian TLC company


Inline

	Ret=PRE_STR+" "+((OLD_STR!=null && OLD_STR.length()>0)?OLD_STR+((NEW_STR!=null && 
		NEW_STR.length()>0)?ConcatSTR:""):"") + ((NEW_STR!=null && NEW_STR.length()>0)?NEW_STR:"");

Yeah, inline!

Actually in the production codebase of a biggest italian TLC company


Tab

	private static final String tab="\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";

Tab tab tab tab tab tab tab tab tab…

Actually in the production codebase of a biggest italian TLC company


The donothing nullTask…

public class nullTask extends SingleTask {

	private double k=0;
	private boolean interrompi=false;
	@Override
	protected void exec() throws Exception
	{
		for(double i=0;i<320000000 && !interrompi;i++)
		{
			k=i*100;
		}
	}
}

… is actually doing something.

Actually in the production codebase of a biggest italian TLC company