I guess your question is looking not for practicality, in which case lxrec's answer is the correct one, but to learn about design patterns.
Obviously the command pattern is an overkill for such a trivial problem as the one you propose but for the sake of illustration here it goes:
public interface Command { public String transform(String s); } public class CompressCommand implements Command { @Override public String transform(String s) { String compressedString=null; //Compression code here return compressedString; } } public class EncryptCommand implements Command { @Override public String transform(String s) { String EncrytedString=null; // Encryption code goes here return null; } } public class Test { public static void main(String[] args) { List<Command> commands = new ArrayList<Command>(); commands.add(new CompressCommand()); commands.add(new EncryptCommand()); String myString="Test String"; for (Command c: commands){ myString = c.transform(myString); } // now myString can be stored in the database } } As you see putting the commands/transformation in a list allows for ther to be executed sequentially. Obviously it will execute both, or only one of them dependind og what you put in the list without if conditions.
Obviously the conditionals will end up in some kind of factory that puts together the command list.
EDIT for @texacre's comment:
There are many ways of avoiding the if conditions in the creational part of the solution, let's take for example a desktop GUI app. You can have checkboxes for the compress and encrypt options. In the on clic event of those checkboxes you instantiate the corresponding command and add it to the list, or remove from the list if you are deselecting the option.