MyRot13ButtonComponent.java from redshed at Krugle
Show MyRot13ButtonComponent.java syntax highlighted
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
import com.webobjects.directtoweb.*;
public class MyRot13ButtonComponent extends D2WComponent {
public MyRot13ButtonComponent(WOContext context) {
super(context);
}
public WOComponent rot13TitleAction() {
String input = (String) object().valueForKey( "title" );
String output = rot13( input );
object().takeValueForKey( output, "title" );
return null;
}
private static String rot13( String input ) {
StringBuffer out = new StringBuffer( input.length() );
for (int i = 0; i < input.length(); i++) {
int c = input.charAt(i);
if (c >= 'A' && c <= 'M') out.append((char) (c+13));
else if (c >= 'N' && c <= 'Z') out.append((char) (c-13));
else if (c >= 'a' && c <= 'm') out.append((char) (c+13));
else if (c >= 'n' && c <= 'z') out.append((char) (c-13));
else out.append((char) c);
}
return out.toString();
}
}
See more files for this project here