To inform, empower, and entertain - 'jdksolutions' is here as a resource for people who are curious about the world of technology around them. Novices and experts are welcome to explore our ever-growing list of resources. Our contributors are full of passion. We will do our best to keep you informed on a daily basis.
-Admin-
Tuesday, July 12, 2011
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)
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 OptimizationThursday, June 9, 2011
Object Oriented Designs
SOLID
How I explained OOD to my wife
S = Single Responsibility Principle
O = Opened Closed Principle
L = Liscov Substitution Principle
I = Interface Segregation Principle
D = Dependency Inversion PrincipleHow I explained OOD to my wife
Thursday, May 26, 2011
Wednesday, May 18, 2011
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);
}
}
Subscribe to:
Posts (Atom)