Power to Build

Home » Articles posted by SamV

Author Archives: SamV


Tools: UMLet – Great tool for drawing UML diagrams

UMLet is an open source UML diagramming tool with a twist! I’ve used many UML tooumlet_logo_smallls in the past, but UMLet is different.

It’s a diagramming tool for the diagram-challenged in us!! You simply type text and it will convert to UML boxes and arrows immediately. It can create simple UML diagrams, Use cases, Activity diagrams and sequence diagrams. I use it to produce some non-UML diagrams as well.

It has a pallet of UML elements already available which you can double click or drag and drop onto your diagram. You will a properties box on the right, where you can start typing – rename, add arrows, lines etc. Yes, you can change the already present elements in the pallet as well!

I particularly like the fact that you can add custom elements to the already rich set of drawing elements. While creating a drawing element, you add Java code snippets to create shapes to your custom elements. Really powerful! OH yeah, it compiles the Java snippets on the fly!!!

Here is a really nice presentation on Prezi to get you started. It has an embedded video as well. Short and sweet.


If you want to learn more about the tool, you can always look at the Source code on github.

The diagrams are stored in UXF (UML Exchange format) format. It is really an XML file with specific format used by the tool. I’ve tried and succeeded in generating this file for some simple diagrams. It is available in various flavors – as a standalone (Java) executable or as a plugin in various IDE including Eclipse.

As a tool, it is intriguing – from the simplicity of use to the versatility of adding to new elements. Complex Diagrams can be produced quickly. I love it. Give it a try! You can download the tool here.


Java Code Search Engines

We all use Google and other Search Engines for searching anything under the sun. Are there any sites like these for searching source code, that new comers and experienced programmers alike, can search for sample code? Here are a couple of links to search for a particular class/method in Java:
You can search for keyword like Collection, it will fetch samples from a lot of Open Source projects. I use it to find standard (popular?) ways of using any API.
For e.g., ArrayList:
Krugle is another popular site. Here is Krugle search for Geocoding:
Here is a page listing few more sites like these:
Happy (code) surfing!

Mystery behind the name : Bluetooth

Bluetooth-PNG-Free-Download.pngWe all use Bluetooth. It’s on your cell phone, earphone, laptop, eve in your car. We use it to link up 2 devices so they can connect wireless-ly. I always wondered what kind of technical term is that. We all know Blu Ray – a device with Blue ray (laser) used to read/write to the disk. Infrared – uses infra red to connect. What kind of ray is in Blue tooth?

Recently, while I was browsing something else, came across a little anecdote about the name. Would you believe, it may be referring to blue teeth a king had due to eating too many blueberries or due to tooth infection!

When one of the founds of Bluetooth, Kardach from Intel, was looking for a name for the new technology, had been reading a book about Vikings that featured the reign of Harald Bluetooth (Scandinavian Blåtand/Blåtann), whom he viewed as an ideal symbol for bringing competing Danish tribes together, as he explained:

Bluetooth was borrowed from the 10th-century, second king of Denmark, King Harald Bluetooth; who was famous for uniting Scandinavia just as we intended to unite the PC and cellular industries with a short-range wireless link.

Apparently, the name stuck when he couldn’t register the technical name for it in time.

The bluetooth logo is a combination of couple of Rune characters as well, as Wikipedia article puts it:

The Bluetooth logo is a bind rune merging the Younger Futhark runes Runic letter ior.svg (Hagall) (ᚼ) and Runic letter berkanan.svg (Bjarkan) (ᛒ), Harald’s initials.


Sharing: A GUI for the Command Line Interface | JBoss Developer

We are getting into Redhat JBOSS for our Java project. I am currently exploring all the options available in JBOSS (also comparing it with Sybase EA Server we are using currently). I intend to share our experiences with the platform here.

One of the things I use a lot in EA Server will be the Jagtool – a command line interface to the app Server’s repository. In JBoss, I found Jboss-cli to do this for us. And I just found out from the below link, that you can actually start that in GUI mode as well. This link has a detailed information on the GUI mode. More on the tool later.

Source: A GUI for the Command Line Interface | JBoss Developer

Sharing: 5 Best C Programming Books A C Programmer Must Read


Learn C programming by reading some of the best books from expert authors

Source: 5 Best C Programming Books A C Programmer Must Read

27 Best Free Eclipse Plug-ins for Java Developer to be Productive


An exhaustive list of best hand picked free Eclipse plug-ins for a developer to be efficient

Source: 27 Best Free Eclipse Plug-ins for Java Developer to be Productive

Regex Part 2

I earlier posted about exciting world of Regex here.  Let’s try to learn some more in this followup post.

First if you want to play with Regex, here is a nice tool you can use:


2017-05-25 17_39_08-RegExr_ Learn, Build, & Test RegEx

Regex Tool online

By default it comes up with a sample pattern and the matches in the given sample text.  You can type in the pattern you are testing, the actual text in the middle box and if you chose Replace, you get to see what the output will look like.

Let’s use this tool to convert our RSVP list in free text to a spreadsheet list.

If you read my original post, we had 4 RSVPs. It looked somewhat like this:


Will you attend:
Will you be here for lunch:
How many:

Here is my session in Regexr testing this:

2017-05-25 17_44_49-regexr.com_3g1nb

Using Regexr to test/convert our RSVP text

The bottom portion shows the Replaced text – converted and cleaned, readied to be copied out to Excel. The spreadsheet will look like this:

2017-05-25 17_53_11-Microsoft Excel - Book3

Here is the actual regular expression used in this example:

RSVP[0-9]+:\n+Name:[ ]*(.+)\nWill you attend:(.*)\nWill you be here for lunch:(.*)\nHow many:.*([0-9]+).*[\n]*

Let’s go through the regular expression for arriving at this:

First line would have, RSVP:

In Regex any number can be represented by [0-9]+ **. That is a digit is represented by any character between 0 and 9. A whole number would then be one or more digits.

Thus, RSVP: can be written as,


Next text is actually on another line. This can represented by \n. You may know this is newline. Now we are on the second line.


This can be matched by, Name: (.*)

That would be any character after Name: . If you notice, we have a space after Name:. What if the user didn’t add any space or added many spaces in between? We can rewrite the above as,

Name:[ ]*(.*)

That’s a space inside the square brackets. [ ]* represents 0 or more spaces. This way, we will match it, even if there is no space between the label “Name:” and the name that followis it. If used with a +, it will mean one or more spaces – at least one space must be there.

Next we have (.*). Dot (.) is any character and .* means zero or more characters. By enclosing a pattern within parantheses (), we make a “Capture Group”. This is what will be remembered (like in a variable) when this pattern is matched with a text. This can be returned and useful in Replace functionality. Each captured group will have a number associated with it – like $1*** for the first, $2 for the second etc. This is also called back reference. More on this later.

And we continue with the rest of the lines. The replace pattern will look like this:


That’s all captured variables ($1 – $4) separated by tab characters recognized by Excel as cell separators (we could also use Comma). End it with \n to push to the next line.

Voila! We have successfully converted a free-form text into a spreadsheet.

That was a rudimentary example. And if you noticed, I left out some complications – for e.g., what if they said 1 or 2 people will be coming and I want to take the maximum, meaning 2.

The fact is, Regex is never used alone in a tool like this. Often times, you will build this (and more regex) into a script/program to achieve the full desired results. Perl and Python are heavily invested in Regex. Other programming languages (including Java) do support Regex using some library API.

To be contd…

** As an aside, this is similar to the BNF form for writing language grammar (I’ve considered only positive whole numbers for this discussion):

2017-05-26 09_58_13-Document6 - Microsoft Word.png

*** Sometimes you will see \1 instead of $1.