Changed switch to else if ladder for Java6 compatability