The Answer to Life, the Universe, and Everything

Thursday, May 17, 2007

Commons Digester Variable

The variable in xml data can be converted with Digester with the easy following codes.
Digester digester = DigesterLoader.createDigester(getURL(ruleFile));
Map vars = new HashMap();
vars.put("hello","Czesc!");
MultiVariableExpander expander = new MultiVariableExpander();
expander.addSource("$", vars);
Substitutor substitutor = new VariableSubstitutor(expander);
digester.setSubstitutor(substitutor);

Tuesday, May 15, 2007

Commons Lang toString()

Jakarta Commons Lang support the reflection for toString() which need to synchronize with the changes made for the object model.

public String toString(){
return ReflectionToStringBuilder.toString(this);
}


For the customization of the output,
public String toString(){
return ReflectionToStringBuilder.toString(this,ToStringStyle.MULTI_LINE_STYLE)
.append("lastName",lastName).append("firstName",firstName).toString();
}

Sunday, May 13, 2007

Encoding to 3gp file for mobile phones

If h/s support AAC.
#ffmpeg -i infile.mpeg -vcodec mpeg4 -r 15 -b 128k -s qcif -acodec aac -ar 8000
-ac 1 -ab 13 -f 3gp -y output.3gp


If not
ffmpeg -i infile.mpeg -vcodec mpeg4 -r 15 -b 128k -s qcif -acodec amr_nb -ar 8000
-ac 1 -ab 13 -f 3gp -y output.3gp


For video editing on Linux, LiVES would be very nice.