The article includes a nice overview of notes.ini settings applicable to the SMTP task. Remember to also check Chris Linfoots blog…
Java in Notes/Domino Explained: Testing for equality

When comparing strings in Java you are actually comparing the objects and not the string itself. If you read my resent post on common operators in Java you would have read the following explanation for the == operator: “Test for object reference equality or equality of primitive data types.”
So what does “object reference equality” mean? It means that the == operator will object return true if the references are pointing to the same object. It doesn’t look inside the object or make any assertations as to whether the “real world” value of the objects are the same. The below example should clarify:
String s1 = new String("lekkimworld");
String s2 = new String("lekkimworld");
String s3 = s1;
String s4 = s2;
System.out.println(s1 == s2);
System.out.println(s1 == s3);
System.out.println(s2 == s4);
System.out.println(s1 == s4);
The above code will provide the following output:
false true true false
The above output shows you that the string s1 and s2 are different references and hence are not equal in the == sense. Once we create s3 and s4 pointing to s1 and s2 respectively, == return true since s1/s3 and s2/s4 are pointing to the same object.
So the rule of thumb is: Only use == to compare primitive datatypes (int, long etc.) or objects if you need to see if it is the same object (being referenced) – not necessarily the same value.
It’s actually a more general problem
To alleviate the problem of comparing references all objects in Java has a method called equals. The method is inherited from java.lang.Object, from which all classes inherit, and if not overridden by the class will revert to using the == operator for comparisons.
The String class overrides the equals() method to test whether the value of the strings are the same. Since the equals() method is case sensitive the String class also have an equalsIgnoreCase() method. Let’s see the equals() method in action:
String s1 = new String("lekkimworld");
String s2 = new String("lekkimworld");
String s3 = s1;
String s4 = s2;
System.out.println(s1.equals(s2));
System.out.println(s1.equals(s3));
System.out.println(s2.equals(s4));
System.out.println(s1.equals(s4));
The above code will provide the following output:
true true true true
Notice the difference between the output of this code and the code in the first example. Now we test the “real world” value of the objects hence all comparisons are true.
The concept of the equals() method carry across to custom objects you write. If you plan to test if two objects are the same, which is almost always the case, you should override the equals() method. Let me show how this works in the case of a simple Employee class. I have decided that comparisons should be based on the employee id and not the name:
public class Employee {
private String id = null;
private String firstname = null;
private String lastname = null;
public Employee(String first, String last, String id) {
this.firstname = first;
this.lastname = last;
this.id = id;
}
public boolean equals(Object obj) {
// if null it can never be the same
if (null == obj) return false;
// if of another type if can never be the same
if (!(obj instanceof Employee)) return false;
// same class - compare
return ((Employee)obj).getId().equals(this.id);
}
public String getFirstname() {
return firstname;
}
public String getId() {
return id;
}
public String getLastname() {
return lastname;
}
}
Notice how I start by verifying that the supplied object isn’t null and that it is of the same type. If not the objects can never be equal. If both the supplied object passes both tests I use the equals() method of the String class to compare the ids. Below is a snippet of code to illustrate:
Employee e1 = new Employee("John", "Doe", "111");
Employee e2 = new Employee("Jane", "Doe", "222");
Employee e3 = new Employee("John", "Doe", "111");
System.out.println(e1 == e2);
System.out.println(e1 == e3);
System.out.println(e1.equals(null));
System.out.println(e1.equals(new String("lekkimworld")));
System.out.println(e1.equals(e2));
System.out.println(e1.equals(e3));
…and the output
false false false false false true
Pay special notice to the fact that e1 == e3 returns false since it is different objects. Only our own custom equals() method will return true.
Did you notice? – the caveat about strings in Java
The astute reader might have noticed that I used the new keyword to create new strings in the first example instead of the “normal” approach:
String s1 = new String("lekkimworld");
instead of
String s1 = "lekkimworld";
The result will actually be quite different if you use the latter approach instead:
String s1 = "lekkimworld"; String s2 = "lekkimworld"; String s3 = s1; String s4 = s2; System.out.println(s1 == s2); System.out.println(s1 == s3); System.out.println(s2 == s4); System.out.println(s1 == s4);
The above code will produce the following output:
true true true true
Isn’t that wierd? To understand it we need to dive a little deeper into how strings are managed in Java.
How strings are managed in Java
In Java strings are imutable that is they cannot change once created. If you concatenate two strings the result will be the creation of a new third object:
String full = "Mikkel " + "Heisterberg";
The problem is actually due to the fact that we cannot redimension arrays in Java (the char[] array that backs the string object) as described in an earlier post. You can imagine that concatenating a lot of strings can yield quite a lot of objects. To alleviate this potential performance problem you can use the java.lang.StringBuffer class.
Since strings are used so much and because they are imutable the String class holds an internal pool of created Strings (a “cache” if you will). It can hold on to the previously created strings since the imutable property makes the class thread-safe and hence safe to reuse. It also means that if you create the same string twice the String class will return the cached object the second time around. This isn’t the case when using the new keyword which is why there is a difference between the examples above.
So what do you do if the returned string was created using the new keyword but you really want the one from the string pool? Well you’re in luck – you can use the intern() method of the String class:
String s1 = "lekkimworld";
String s2 = "lekkimworld";
String s3 = new String("lekkimworld");
System.out.println(s1 == s2);
System.out.println(s1 == s3);
System.out.println(s2 == s3);
String s4 = s3.intern();
System.out.println(s1 == s4);
This will produce the following output:
true false false true
The last line is true since the intern() method returns the copy of “lekkimworld” from the string pool and not the one from the s3 object. Normally you don’t have to spend too much time thinking about the intern() method but now you know… 🙂
Happy comparisons…
IT-Conversations: Ray Ozzie
Saw this podcast with Ray Ozzie on the IT-Conversations network and thought I would share even through the podcast isn’t on Notes/Domino…
“Ray Ozzie, Chief Technical Officer at Microsoft, sees Really Simple Syndication (RSS) as a building block for the future Web. When combined with new tools that make it easier to use, RSS could bring the ability to write powerful composite web applications to the level of a script programmer or even a non-technical computer user. [snip] How can we move information as easily from one website to another? What kind of a tool could act as a clipboard for the web?”
Microsoft RSS feeds
Microsoft has gathered all their RSS feeds on a single page. Via Robert Scoble.
Is the LotusUserGroup.org server improperly configured?
I was quite surprised to receive this e-mail in my inbox today… I’m not amused! How can a person, and a bad speller at that, get at the mailing list for the newsletter?

Need to access Domino from PHP?
If so check out the new article on Lotus developerWorks called Building PHP-based UIs for IBM Lotus Domino. The article shows you how to use COM to access Domino on Windows and XML for other platforms. Worth a read if you’re into PHP…
Java in Notes/Domino Explained: Operators

Java has a series of operators that can make the code less verbose, quicker to write and more readable. Below is a table of the most commonly used operators and an explanation of how to use them. At the bottom of the post you’ll find all the code if you want to play around with it.
| Operator | Description |
|---|---|
| == | Test for object reference equality or equality of primitive data types.
int i=1; int j=1; System.out.println(i == j); Output: true String s1 = "lekkim"; String s2 = "lekkimworld"; System.out.println(s1 == s2); Output: false System.out.println(s1 == s1); Output: true |
| != | Test for object reference non-equality or non-equality of primitive data types.
int i=1; int j=2; System.out.println(i != j); Output: true String s1 = "lekkim"; String s2 = "lekkimworld"; System.out.println(s1 != s2); Output: true System.out.println(s1 != s1); Output: false |
| && | Logical AND operator.
boolean b1 = true; boolean b2 = true; System.out.println(b1 && b2); Output: true |
| || | Logical OR operator.
boolean b1=true; boolean b2=false; System.out.println(b1 || b2); Output: true |
| ++ | This operator can mean two things depending on which side of the variable the operator is on.
If the operator is to the right of the variable it means to use the value of the variable, increment the value and then store result back in the same variable.
int i=0;
System.out.println("i=" + (i++));
Output: i=0
System.out.println("i=" + (i++));
Output: i=1
If the operator is to the left of the variable it means that the JVM should increment the variable, use the variable and store the result back in the variable.
int i=0;
System.out.println("i=" + (++i));
Output: i=1
System.out.println("i=" + (++i));
Output: i=2
Much used in for-loops:
for (int i=0; i<3; i++) {
System.out.print(i + " ");
}
Output: 0 1 2
|
| — | Same as ++ but subtracting instead of incrementing.
int k=2;
System.out.println("k=" + (k--));
Output: k=2
System.out.println("k=" + (k--));
Output: k=1
int k=2;
System.out.println("k=" + (--k));
Output: k=1
System.out.println("k=" + (--k));
Output: k=0
Can also be used in for-loops:
for (int i=2; i>=0; i--) {
System.out.print(i + " ");
}
Output: 2 1 0
|
| += | Evaluate the + operator using the value in the variable on the left hand side and the right hand side and store result back in the same variable.
String s1 = "Mikkel";
s1 += " ";
s1 += "Heisterberg";
System.out.println("s1=" + s1);
Output: s1=Mikkel Heisterberg
|
| -= | Evaluate the – operator using the value in the variable on the left hand side and the right hand side and store result back in the same variable.
int i=10;
int k=5;
i -= k;
System.out.println("i=" + i);
Output: i=5
|
Below is the code for the above examples if you want to play around with it:
public class Main {
public static void main(String[] args) {
equal_equal();
exclamation_equal();
ampersand_ampersand();
pipe_pipe();
plus_plus1();
plus_plus2();
plus_plus3();
minus_minus1();
minus_minus2();
minus_minus3();
plus_equal();
minus_equal();
}
public static void equal_equal() {
int i=1;
int j=1;
System.out.println(i == j);
String s1 = "lekkim";
String s2 = "lekkimworld";
System.out.println(s1 == s2);
System.out.println(s1 == s1);
}
public static void exclamation_equal() {
int i=1;
int j=2;
System.out.println(i != j);
String s1 = "lekkim";
String s2 = "lekkimworld";
System.out.println(s1 != s2);
System.out.println(s1 != s1);
}
public static void ampersand_ampersand() {
boolean b1 = true;
boolean b2 = true;
System.out.println(b1 && b2);
}
public static void pipe_pipe() {
boolean b1=true;
boolean b2=false;
System.out.println(b1 || b2);
}
public static void plus_plus1() {
int i=0;
System.out.println("i=" + (i++));
System.out.println("i=" + (i++));
}
public static void plus_plus2() {
int i=0;
System.out.println("i=" + (++i));
System.out.println("i=" + (++i));
}
public static void plus_plus3() {
for (int i=0; i=0; i--) {
System.out.print(i + " ");
}
System.out.println("");
}
public static void plus_equal() {
String s1 = "Mikkel";
s1 += " ";
s1 += "Heisterberg";
System.out.println("s1=" + s1);
}
public static void minus_equal() {
int i=10;
int k=5;
i -= k;
System.out.println("i=" + i);
}
}
Address Picker on the web
For a customer project I need an address picker for the web. Instead of starting to build one from scratch myself I looked a little around and found one in the R6 NAB with a little help from the forum at developerWorks.
This just raises the question whether one is allowed, license-wise, to reuse components from the templates supplied by Lotus… Anyone who knows?
Comments feed for lekkimworld
Recently I was asked whether I had a comments feed to lekkimworld which I didn’t at the time, but I have created one. The feed isn’t perfect since the name of the comment author is missing but it is a start. I’m working on improving it.
You can access the comments feed using the following link.
Notes calendar iCal export
Nice for import into Google Calendar – iCal export from Lotus Notes via Indcentral.com.