I’m following the Lars’ book “Contributing to Eclipse Platform”, and these are some synthetic notes on the content. These notes can be exploded into a real-life tutoria on contribution, by adding images, notes and personal experience.

Plugins and Features

create eclipse plugin, no activator, template hello world command
manifest.mf > launch eclipse application
export plugin > current eclipse installation
create feature, initialize from previous plugin
add category.xml, add category and feature
export deployable feature to local repository, install feature from local repo

Git and Eclipse

Most important thing to learn from me, since I’m an experienced Eclipse developer, but I’m not very “fluent” with Git.

The JSP Standard Taglibrary (JSTL) provides simple tags, encapsulating several core functionalities, to be added to any JSP application. As example, you can get tags to store and display variables, to make iterations, for XML manipulation, Input / Outputing , and so on.

This post explain how to setup a page with JSTL and make some examples for common tags.

Install JSTL

To use a tag library you need to import the jar libraries containing the implementation and define tags that invoke functions inside the library.

install JSTL by adding jar under lib folder

You can find jstl-1.2.jar on the web or from there: JSTL-1-2 (local archive).

Test JSTL

Since the jat we’ve copied contains both libraries and TLD definitions, we can start to use JSTL tags. To use them, first we need reference JSTL with a declaration at top of JSP. In the shippet below we reference the jstl/core library, whose tags are available under the prefix “c:” .

Then we could put some JSTL tags inside the page.

 

In the snippet above we used

  • c:import to read a file on the server, and store content inside a varuable
  • c:out to output the content of a variable to the page (you could escape xml)

See the screenshoot below

jstl-test-011

To make some further test with the jstl/core we insert another two snippet, for loops. The first show a simple loop that build a table

The second list page parameters. Take care that param is an implicit Map object.

 

The result, obvious, are a table and a list. But instead to watch the picture,  you can build yourself.

jstl-test-02

Enjoy.

References

This article explains how to generate an XHTML document using an XSL Transform.

XSL Transform for build XHTML

Assume we want transform following XML document

An XSL Transform starts from XML input and produces output in several  formats. To get XHTML output we’ll need to define the correct output format at the top of the document.

The transform is quite simple, and here, there is an image showing the output result.

xsl-to-xhtml

You can get the source from my Git folder: https://github.com/psuzzi/asegno/tree/master/codeexamples/2011/xsl-to-xhtml,

References

This is a snippet of code to show how to perform an XSL transformation with Java

Below you can see how to XSL Transform using File, StreamSource and StreamResult.

 

And there it is an example of XSL Transform using StringReader and StringWriter.

 

Source code is available on my Git repository:

.

This article introduces mybatis java (iBatis 3 for java) and summarizes its configuration and usage. The article also give suggestions on its usage.

ibatis-logo

Introduction

The iBATIS Data Mapper (born in 2002) is a framework that  introduces SQL Mapping approach to persistence layer development. The iBATIS name and code was donated to the Apache Software Foundation; that hosted project development for many years.

In 2010 the core development team of iBATIS has decided to continue development under the Google Code umbrella; then they switched to a new name: mybatis .

Actually mybatis is available both for Java and for .NET platform. Both the project teams forked their software to Google Code, on  mybatis Java and mybatis .NET . One of the best additions to the new version of the project it is the support for metadata annotations.

myBatis Configuration

building SqlSessionFactory from XML is quite simple:

The configuration file contains settings for the core of the MyBatis system

 

note:

  • ${parameterName} : indicate a parameter, usually taken via propery file ..
  • mapper: imply the existence of the BlogMapper.xml file

myBatis Generator

For java guys it is also possible to generate XML files using the  myBatis artifacts generator,  available as standalone JAR; Ant task; Maven plugin or Eclipse plugin. See description on:  code.google.com/p/mybatis/wiki/Generator, where you can get the JAR, and the Update Site for the Eclipse plugin.

 

Regular expression: sequence of characters representing a search pattern, to be used for operations like search and replace.

Standard Language

Regex, as we know them, are a standard adopted in many programming frameworks and languages, such as: Perl, Java, Javascript, Python, .NET, W3C XML Schema, etc. Generally there are only minos differences between languages.

Regex in Java

When using a regex in a Java application, I suggest to

  1. build the regexp according needs
  2. escape the regexp as java String.

See the examples below:

 

detect an email

The base regex is compound of three blocks:

  • account: letters, dots or numbers, representing the user
  • the @ character
  • provider: letters, dots or numbers, followed by a domain extension (.com, .net, etc.)

The base regexp look like this:

We will need to escape the “slash” and “dot” chars, to use the regex in java. The result is the following:

Usage of Regexp in Java

In java I can compile a regex to get a Pattern object instance, a compiled representation of the regex, built statically to match efficiently input strings.

The matched can be used to perform various operations on the String.

  • validate: tell if the String is compliant with the regex. As example you can validate user inputs, like an email address, a telephone number, or a postal address
  • replace : replace matching text
  • group: the regexp might define groups to be used for substring matching.

 

Simple example

Below there is the code for a matcher to match the filename extensions for xml, xsd and wsdl files

 

Advanced features

The advanced features i use more often are

  • groups – to match and capture a substring of the input
  • non capturing groups –  like (?:anything) – to improve performances

see: http://www.exampledepot.com/egs/java.util.regex/NoGroup.html

some examples you should know

http://www.mkyong.com/regular-expressions/10-java-regular-expression-examples-you-should-know/

 

References

  • Java Tutorial Essential – Regular Expressions : link
  • Vogella – Java and Regular Expressions : link
  • regex101.com – Online Regex Tester : link
  • RegexPlanet – Regular Expression Test Page for Java : link
  • Optimizing Regex in Java : link
  • Mykong – 10 Java Regular expressions you should know : link
  • Example Depot – using a non capturing group in Java : link

Java regex matcher : link