Thursday, December 15, 2011

Sunday, August 28, 2011

XML

XStream
XStream is a simple library to serialize objects to XML and back again.

Thursday, July 7, 2011

Computer Science

Recursion 
Recursion is the process of repeating items in a self-similar way


For example 7! equals 7*6*5*4*3*2*1 


public int factorial(int n)
{
  if (n <= 1) 
    return 1;
  else
    return n * factorial(n-1);
}

Tail Recursion


Tail call Optimization

Thursday, June 9, 2011

Object Oriented Designs

SOLID

S = Single Responsibility Principle
O = Opened Closed Principle 
L = Liscov Substitution Principle
I = Interface Segregation Principle
D = Dependency Inversion Principle

How I explained OOD to my wife

Tuesday, April 12, 2011

Extract tokens from velocity template

public class MyVariableVisitor extends BaseVisitor
{

public static final String SOURCE_VERSION_ID = "$Id$";

public Object visit(ASTReference arg0, Object arg1)
{
String name = arg0.literal();
List tokenList = (List) arg1;
tokenList.add(name);
return super.visit(arg0, arg1);
}

}


public static void main(String[] args) throws Exception
{
Properties p = new Properties();
p.setProperty("file.resource.loader.path", "D:\\");
VelocityEngine vEngine = new VelocityEngine(p);
Template template = vEngine.getTemplate("just.html");
SimpleNode simpleNode = (SimpleNode) template.getData();
MyVariableVisitor mvVisitor = new MyVariableVisitor();
List tokenList = new ArrayList();
simpleNode.jjtAccept(mvVisitor, tokenList);
for (String item : tokenList)
{
System.out.println(item);
}
}



Ref: http://permalink.gmane.org/gmane.comp.jakarta.velocity.user/14824

Wednesday, February 16, 2011

OWASP AntiSamy Project

OWASP AntiSamy Project for preventing Cross Site Scripting (XSS)

http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project