1 44 package org.jpublish.util.uri; 45 46 import org.apache.commons.logging.Log; 47 import org.apache.commons.logging.LogFactory; 48 49 54 public class TemplateURI extends InternalURI { 55 56 private Log log = LogFactory.getLog(TemplateURI.class); 57 58 61 protected String templateManagerName; 62 63 68 69 public String getTemplateManagerName() { 70 return templateManagerName; 71 } 72 73 78 79 public void setTemplateManagerName(String templateManagerName) { 80 this.templateManagerName = templateManagerName; 81 } 82 83 88 89 public String toURI() { 90 StringBuffer buffer = new StringBuffer (); 91 buffer.append(protocol); 92 if (templateManagerName != null) { 93 buffer.append(":"); 94 buffer.append(templateManagerName); 95 } 96 buffer.append("://"); 97 buffer.append(path); 98 return buffer.toString(); 99 } 100 101 106 107 public void setURI(String uriString) { 108 if (log.isDebugEnabled()) { 109 log.debug("setURI(" + uriString + ")"); 110 } 111 112 int protocolTerminatorIndex = uriString.indexOf(PROTOCOL_SEPARATOR); 113 if (uriString.indexOf("/", protocolTerminatorIndex) == 114 (protocolTerminatorIndex + 1)) { 115 protocol = uriString.substring(0, protocolTerminatorIndex); 116 path = uriString.substring(protocolTerminatorIndex + 117 URI_SEPARATOR.length()); 118 } else { 119 int nameTerminatorIndex = uriString.indexOf(PROTOCOL_SEPARATOR, 120 protocolTerminatorIndex + 1); 121 protocol = uriString.substring(0, protocolTerminatorIndex); 122 templateManagerName = uriString.substring(protocolTerminatorIndex + 1, 123 nameTerminatorIndex); 124 path = uriString.substring(nameTerminatorIndex + 125 URI_SEPARATOR.length()); 126 } 127 } 128 129 } 130 131 | Popular Tags |