001 package nl.cwi.sen1.gui.plugin; 002 003 import aterm.ATermAppl; 004 import aterm.ATermList; 005 006 public class StringFormatter { 007 public static String format(String format, ATermList args) { 008 int index; 009 String prefix = ""; 010 String postfix = format; 011 while ((index = postfix.indexOf("%")) != -1) { 012 prefix += postfix.substring(0, index); 013 switch (postfix.charAt(index + 1)) { 014 case 't': 015 case 'd': 016 prefix += args.getFirst().toString(); 017 break; 018 case 's': 019 prefix += ((ATermAppl) args.getFirst()).getName(); 020 break; 021 default: 022 prefix += "%" + postfix.charAt(index + 1); 023 } 024 postfix = postfix.substring(index + 2); 025 args = args.getNext(); 026 } 027 return prefix + postfix; 028 } 029 }