Hello! My name is Michel. I'm a researcher, software developer, musician, and photographer living in Darmstadt, Germany. More ...

Michel Krämer

bson4jackson 2.4 has just been released!

Version 2.4 of bson4jackson has just been released. bson4jackson adds support for BSON, a binary representation of JSON, to the Jackson JSON processor.

The latest release of bson4jackson now supports Jackson 2.4. Apart from that, the following things have been changed:

  • Added support for Jackson 2.4
  • Allow BigDecimal to be serialized as String in order to avoid losing precision
  • Added deserializers for Date and Calendar to the BsonModule
  • Byte arrays are now correctly deserialized
  • Added integration tests to ensure compatibility with multiple Jackson versions

Grab the new version while it’s still hot:
https://github.com/michel-kraemer/bson4jackson

Projects using bson4jackson

bson4jackson is used in several other Open Source projects including the following one:

  • Immutables is an annotation processor that is able to generate immutable objects which help tackle complexity and concurrency. The library also includes serializers for immutable objects based on Jackson and bson4jackson.

    http://immutables.org

  • Jongo is a rather cool library that allows MongoDB to be queried in Java just like you would query it in the MongoDB shell. Jongo uses bson4jackson to serialize objects before they are sent to the database, and of course to deserialize queried documents.

    http://jongo.org/

  • MongoJack is a POJO mapper that uses Jackson and bson4jackson to serialize and deserialize objects before they are sent to the database. MongoJack is extremely fast and very easy to handle.

    http://mongojack.org/

I know that there are a lot of other projects out there that use bson4jackson. If you want your project to be added to this list please leave a comment below or send me a message.

More information

For a complete description of bson4jackson (including how to download it) have a look at my tutorial.


gradle-download-task: download files with progress

I really like how Gradle displays progress while it’s fetching artifacts from Maven repositories, but I was always wondering why you cannot use the same functionality when you’re downloading arbitrary files in your build script. You can of course use Ant’s download task to fetch files, but it does not display progress information. Since I couldn’t find a solution on the Internet I decided to write a plugin.

gradle-download-task has initially been released in September 2013 and is now available in version 1.0. The plugin contributes a download task that shows progress information just like Gradle does when it fetches artifacts from a repository.

You can use it like this:

task downloadFile(type: Download) {
    src 'http://www.example.com/index.html'
    dest buildDir
}

The output will look like this:

Download http://www.example.com/index.html
> Building > :downloadFile > 320 KB/6,78 MB downloaded

In order to use the plugin you have to add the following lines to your build file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'de.undercouch:gradle-download-task:1.0'
    }
}

import de.undercouch.gradle.tasks.download.Download

You can also use the download extension to retrieve a file anywhere in your build script:

apply plugin: 'download-task'

task myTask << {
    //do something ...
    //... then download a file
    download {
        src 'http://www.example.com/index.html'
        dest buildDir
    }
    //... do something else
}

With version 1.0 you can now also sequentially download a list of files to a directory. Please note that you have to specify a directory as destination if you download multiple files. Otherwise the plugin will fail.

task downloadMultipleFiles(type: Download) {
    src([
        'http://www.example.com/index.html',
        'http://www.example.com/test.html'
    ])
    dest buildDir
}

Many thanks go to Bright Fulton who contributed support for custom HTTP request headers. You can use this new feature as follows:

task downloadWithCustomHeader(type: Download) {
    src 'http://download.oracle.com/otn-pub/java/jdk/8-b132/jre-8-windows-x64.exe'
    dest buildDir
    header 'Cookie', 'oraclelicense=accept-securebackup-cookie'
}

The plugin supports a wide range of other options. Please read the README file for more information.

Happy downloading!


Command line tool for citations and bibliographies

I was working very hard on the new version of citeproc-java lately and I’m glad to announce that it has just been released. The highlights in version 0.6 are:

  • The binary distribution of citeproc-java contains a command line tool that can be used to generate citations and bibliographies without setting up a complete development environment. Just download and extract the zip file and then run citeproc-java -b references.bib -s ieee to create a bibliography in ieee style for your BibTeX input file. This feature makes the library very useful even for non-programmers.
  • The new Mendeley connector allows you to use documents stored in Mendeley Web as input for citations and bibliographies. Of course this feature also works on the command line.
  • The library has been tested with the CSL test suite. All 750+ tests run successfully! I put a lot of work into this to bring citeproc-java on par with other CSL processors.
  • Performance has been improved a lot.

I particularly like the new command line tool that can be used to generate citations and bibliographies from various sources such as BibTeX files or your Mendeley Web catalog. I expect the tool to be quite useful for the following users:

  • Authors who want a quick way to preview citations or bibliographies in various styles
  • Citation Style Language style authors who want to test their style files very quickly

In order to use the tool you just have to download citeproc-java and extract the ZIP file. Then you can run the following command to convert a BibTeX file to a bibliography using the ieee style, for example:

citeproc-java -b references.bib

If you want to generate a bibliography that only contains items with certain citation IDs (for example Fowler_2010 and Kisker_2012) use the following command:

citeproc-java -b references.bib Fowler_2010 Kisker_2012

The tool will even notify you if you misspelled a citation ID:

citeproc-java: unknown citation id: Fwler_2010
Did you mean `Fowler_2010'?

If you want to connect to your Mendeley Web account, use the following command:

citeproc-java --mendeley Fowler_2010 Kisker_2012

The tool has a lot more to offer. For more information run citeproc-java --help or read the library’s documentataion.


Generating citations and bibliographies with CSL and citeproc-java

I was recently writing a scientific document with AsciiDoc. As usual my toolchain was AsciiDoc → DocBook → FO → PDF. It really worked quite well until I came to the point where manually adding citations and editing the biblioghraphy by hand became really complex and I suddenly found myself yearning for more automation.

I asked Google what I could do and Google told me about BibTeX and all that stuff. There even was a tool called asciidoc-bib by Peter Lane that was able to read BibTeX files to generate citations and bibliographies and then put them into an AsciiDoc source file. I tested this tool for a while and contributed one or two commits via GitHub. However, I was not yet convinced by the flexibility and maturity of asciidoc-bib by that time, so I started looking for ways how to extend it.

Enter the Citation Style Language (CSL). CSL is an XML-based description of citation styles and bibliographies that’s maintained by a number of people from the scientific community. They say it’s “by academics, for academics”. I really loved the idea of having a more modern alternative to BibTeX and natbib which I never found particularly mind-blowing by the way.

I started with extending asciidoc-bib with support for a library called citeproc-ruby by Sylvester Keil. citeproc-ruby is a so-called CSL processor. That means it reads CSL styles and transforms them to citations and bibliographies. However, I still found asciidoc-bib too cumbersome to use, in particular since it was written in Ruby and my toolchain was based on Java.

So I asked Google again, if they could tell me something about CSL and Java, but they said they didn’t know very much about that. That was when I finally decided to write my own CSL processor for Java.

citeproc-java

Today I’m pleased to announce the first release of citeproc-java, a CSL processor for Java! An (almost) complete documentation is available at the following site:

http://michel-kraemer.github.io/citeproc-java/

I have to be honest with you guys. I didn’t implement the whole CSL specification myself. Instead I tried to incorporate existing code as much as possible. citeproc-java uses the great citeproc-js by Frank G. Bennett, Jr. internally. It is therefore fully CSL 1.0.1-compliant. Apart from that, it offers some cool additional features such as BibTeX import as well as export to AsciiDoc and FO.

For convenience I uploaded citeproc-java and the CSL styles and locales to Maven central. Please see the installation instructions for more information:

http://michel-kraemer.github.io/citeproc-java/download/

citeproc-java’s BibTeX to CSL mapping is based on the one used in the Docear software. It has been converted to Java by permission from the Docear authors, in particular Joeran Beel. The BibTeX converter imports author names using the name parser from the citeproc-ruby project. It has been converted to Java by permission from Sylvester Keil. Thank you very much for that!

Although citeproc-java is a very young project and this is the very first release, I consider it rather stable already—not least because it uses citeproc-js under the hood. Nevertheless, development of citeproc-java has just begun and I’m sure there are great features to come. If you want to participate, don’t hesitate to fork my GitHub repository and send me pull requests:

https://github.com/michel-kraemer/citeproc-java

Finally, big thanks go to the CSL community for the great work and support!

License

citeproc-java is licensed under the Apache License, Version 2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


bson4jackson 2.2 has just been released!

Version 2.2 of bson4jackson has just been released. bson4jackson adds support for BSON, a binary representation of JSON, to the Jackson JSON processor.

The latest release of bson4jackson now supports Jackson 2.2. Apart from that, Ben McCann and John Stoneham fixed the Maven dependencies and updated some 3rd party libraries, so project builds depending on bson4jackson should now be more stable. Thanks a lot for that, guys!

Projects using bson4jackson

bson4jackson is used in several other Open Source projects including the following one:

  • Jongo is a rather cool library that allows MongoDB to be queried in Java just like you would query it in the MongoDB shell. Jongo uses bson4jackson to serialize objects before they are sent to the database, and of course to deserialize queried documents.

    http://jongo.org/

  • MongoJack is a POJO mapper that uses Jackson and bson4jackson to serialize and deserialize objects before they are sent to the database. MongoJack is extremely fast and very easy to handle.

    http://mongojack.org/

I know that there are a lot of other projects out there that use bson4jackson. If you want your project to be added to this list please leave a comment below or send me a message.

More information

For a complete description of bson4jackson (including how to download it) have a look at my tutorial.