Spring type conversion make it possible to create converters which can convert between different types of objects. These converters can be registered to a conversion service. This service can be used to convert a given object to a given type.

To create a converter you have to write a class which implements the following interface.

public interface Converter<S, T> {
T convert(S source);
}

Built in converters

Several converter implementations are provided in the core.convert.support package as a convenience. These include converters from Strings to Numbers and other common types. Consider StringToInteger as an example Converter implementation:

ConsumerBo on the other hand contains the fields that we would like to display about the consumer. It is called a BO (Business Object) because it contains data important to the business. In this case it means data we would like to display about a consumer.

Invoking the conversion service

Below there is an examaple of using the conversion service we created. The service itself is autowired by Spring into the controller. This autowired object can be used to explicitly perform the conversion from one class to another.

Blogger has a lot of great widgets built in to include various funcionality in your blog, but syntax highlighting is not one of them. Fortunately it is fairly easy to add this capability, you just have to do some customizing as described below.

Add custom CSS and JavaScript includes to the template

As the first step you have to include the CSS and JavaScript code into the template you are currently using. On you blog’s admin panel select Template and click Edit HTML.

In the code search for the </head> tag and just before that insert the following code.

Keep in mind that if you have angle brackets in your code then you have to escape them (with this tool for example), otherwise it will be interpreted as part of the HTML.

Getting rid of unnecessary brushes

The code I pasted above contains a lot of brushes, which make it possible to use a lot of different highlighting methods. However if you know for sure that you will never need some of them, then you can just delete the unnecessary ones saving some HTTP requests.

Use other themes

There are a few CSS themes available on the author’s website if you would like to change the appearance of the code blocks.

Recently I was writing my first ever blog post and wanted to include some screenshots in it. I uploaded the screenshots in Blogger’s editor and I noticed that something was off with them. It became even more apparent when I published the post and viewed it on the live site.

The images had too much grey in them. My first though was that I messed them up when converting to a smaller size, but quickly ruled out this possibility when I saw that the images on my local drive had no traces of the unwanted greyness.

The first image is the original, the second is after it was uploaded to blogger.

It turned out that Google has some “smart” algorithms which try to enhance to quality of your uploaded images. And of course it is enabled by default. I don’t know how they perform on regular pictures taken for example on a holiday, but they definitely do bad for screenshots with a lot of white in them.

The following images illustrate step-by-step how to turn this feature off: