@Override public String renderContextRelativeUrl(String url) { Args.notNull(url, "url"); if (url.startsWith("/")) { url = url.substring(1); } PrependingStringBuffer buffer = new PrependingStringBuffer(url); buffer.prepend("/").prepend(ThreadPortletContext.getPortletRequest().getContextPath()); return buffer.toString(); }
/** * Gets this component's path. * * @return Colon separated path to this component in the component hierarchy */ public final String getPath() { final PrependingStringBuffer buffer = new PrependingStringBuffer(32); for (Component c = this; c != null; c = c.getParent()) { if (buffer.length() > 0) { buffer.prepend(PATH_SEPARATOR); } buffer.prepend(c.getId()); } return buffer.toString(); }
/** * Prepends one char to this PrependingStringBuffer * * @param ch * The char that will be prepended * @return this */ public PrependingStringBuffer prepend(char ch) { int len = 1; if (position < len) { expandCapacity(size + len); } position -= len; buffer[position] = ch; size += len; return this; }
/** * @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#getInputName() */ public String getInputName() { // TODO: This is a copy & paste from the FormComponent class. String id = getId(); final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length()); Component c = this; while (true) { inputName.prepend(id); c = c.getParent(); if (c == null || (c instanceof Form && ((Form)c).isRootForm()) || c instanceof Page) { break; } inputName.prepend(Component.PATH_SEPARATOR); id = c.getId(); } // having input name "submit" causes problems with javascript, so we // create a unique string to replace it by prepending a path separator if (inputName.equals("submit")) { inputName.prepend(Component.PATH_SEPARATOR); } return inputName.toString(); } }
@Override public int hashCode() { return toString().hashCode(); } }
/** * Constructs and direct inserts the given string. The buffer size will be string.length+16 * * @param start * The string that is directly inserted. */ public PrependingStringBuffer(String start) { this(start.length() + 16); prepend(start); }
final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length()); Component c = this; while (true) inputName.prepend(id); c = c.getParent(); if (c == null || (c instanceof Form && ((Form)c).isRootForm()) || c instanceof Page) inputName.prepend(Component.PATH_SEPARATOR); id = c.getId(); if (inputName.equals("submit")) inputName.prepend(Component.PATH_SEPARATOR); return inputName.toString();
public int hashCode() { return toString().hashCode(); } }
/** * Constructs and direct inserts the given string. The buffer size will be string.length+16 * * @param start * The string that is directly inserted. */ public PrependingStringBuffer(final String start) { this(start.length() + 16); prepend(start); }
/** * Encodes value into the specified alphabet * * @param value * @param alphabet * @return encoded value */ public static String encode(long value, final String alphabet) { final int len = alphabet.length() - 1; PrependingStringBuffer buff = new PrependingStringBuffer(); final boolean negative = value < 0; if (negative) { value = -value; } do { int mod = (int)(value % len); buff.prepend(alphabet.charAt(mod)); value = value / len; } while (value > 0); if (negative) { buff.prepend(alphabet.charAt(len)); } return buff.toString(); }
/** * Gets this component's path. * * @return Colon separated path to this component in the component hierarchy */ public final String getPath() { final PrependingStringBuffer buffer = new PrependingStringBuffer(32); for (Component c = this; c != null; c = c.getParent()) { if (buffer.length() > 0) { buffer.prepend(PATH_SEPARATOR); } buffer.prepend(c.getId()); } return buffer.toString(); }
final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length()); Component c = component; while (true) inputName.prepend(id); c = c.getParent(); if (c == null || (c instanceof Form<?> && ((Form<?>)c).isRootForm()) || inputName.prepend(Component.PATH_SEPARATOR); id = c.getId(); if (inputName.equals("submit")) inputName.prepend(Component.PATH_SEPARATOR); return inputName.toString();
@Override public int hashCode() { return toString().hashCode(); } }
/** * Constructs and direct inserts the given string. The buffer size will be string.length+16 * * @param start * The string that is directly inserted. */ public PrependingStringBuffer(String start) { this(start.length() + 16); prepend(start); }
/** * Prepends one char to this PrependingStringBuffer * * @param ch * The char that will be prepended * @return this */ public PrependingStringBuffer prepend(final char ch) { int len = 1; if (position < len) { expandCapacity(size + len); } position -= len; buffer[position] = ch; size += len; return this; }
@Override public String getPrefixToContextPath() { PrependingStringBuffer buffer = new PrependingStringBuffer(); Url filterPrefixUrl = Url.parse(filterPrefix, getCharset()); for (int i = 0; i < filterPrefixUrl.getSegments().size() - 1; ++i) { buffer.prepend("../"); } return buffer.toString(); }
/** * Gets this component's path. * * @return Colon separated path to this component in the component hierarchy */ public final String getPath() { final PrependingStringBuffer buffer = new PrependingStringBuffer(32); for (Component c = this; c != null; c = c.getParent()) { if (buffer.length() > 0) { buffer.prepend(PATH_SEPARATOR); } buffer.prepend(c.getId()); } return buffer.toString(); }
public boolean equals(Object obj) { if (obj == this) { return true; } else if (obj == null) { return false; } else { return toString().equals(obj.toString()); } }
/** * Prepends one char to this PrependingStringBuffer * * @param ch * The char that will be prepended * @return this */ public PrependingStringBuffer prepend(char ch) { int len = 1; if (position < len) { expandCapacity(size + len); } position -= len; buffer[position] = ch; size += len; return this; }
@Override public String getPrefixToContextPath() { PrependingStringBuffer buffer = new PrependingStringBuffer(); Url filterPrefixUrl = Url.parse(filterPrefix, getCharset()); for (int i = 0; i < filterPrefixUrl.getSegments().size() - 1; ++i) { buffer.prepend("../"); } return buffer.toString(); }