1 25 package org.snipsnap.snip.name; 26 27 28 34 35 public class WeblogNameFormatter implements NameFormatter { 36 private NameFormatter parent = new NoneFormatter(); 38 39 public void setParent(NameFormatter parent) { 40 this.parent = parent; 41 } 42 43 public String format(String name) { 44 String parentName = parent.format(name); 45 if (parentName.matches(".*/[0-9]{4}-[0-9][0-9]-[0-9][0-9]/[0-9]+")) { 46 int lastSlashIndex = parentName.lastIndexOf('/'); 47 String date = parentName.substring(parentName.lastIndexOf("/", lastSlashIndex - 1) + 1, lastSlashIndex); 48 return date + " #" + parentName.substring(lastSlashIndex + 1); 49 } 50 return parentName; 51 } 52 } 53 | Popular Tags |