1 25 26 package org.snipsnap.snip; 27 28 import org.snipsnap.config.Configuration; 29 import org.snipsnap.app.Application; 30 31 import java.io.IOException ; 32 import java.io.Writer ; 33 34 40 41 public class SnipPath { 42 private Snip snip; 43 44 public SnipPath(Snip snip) { 45 this.snip = snip; 46 } 47 48 public Writer append(Writer writer, SnipSpace space) { 50 try { 51 Configuration config = Application.get().getConfiguration(); 52 String name = snip.getName(); 53 if (!name.startsWith(config.getStartSnip())) { 54 SnipLink.appendLink(writer, config.getStartSnip()); 55 writer.write(" > "); 56 } 57 58 String part = null; 59 String snipName = null; 60 int lastIndex = 0; 61 int i = 0; 62 int index = name.indexOf('/'); 63 while (index != -1 && i++ < 10) { 64 part = name.substring(lastIndex, index); 65 snipName = name.substring(0, index); 66 if(space.exists(snipName) || 67 Application.get().getConfiguration().allow(Configuration.APP_PERM_CREATESNIP)) { 68 SnipLink.appendLink(writer, snipName, part); 69 } else { 70 writer.write(part); 71 } 72 lastIndex = index + 1; 73 index = name.indexOf('/', lastIndex); 74 writer.write(" > "); 75 } 76 writer.write(name.substring(lastIndex)); 79 } catch (IOException e) { 80 System.out.println("SnipPath: Error writing to writer."); 81 } 82 return writer; 83 } 84 85 } 86 | Popular Tags |