List of usage examples for org.apache.wicket.util.string PrependingStringBuffer PrependingStringBuffer
public PrependingStringBuffer()
From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java
License:Apache License
@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("../"); }/*from w w w .jav a 2 s .c o m*/ return buffer.toString(); }
From source file:org.brixcms.web.util.PathLabel.java
License:Apache License
@Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { PrependingStringBuffer b = new PrependingStringBuffer(); BrixNode current = getModelObject(); while (true) { StringBuilder builder = new StringBuilder(); writePath(current, builder, current.equals(getModelObject())); if (b.length() > 0) { b.prepend(" / "); }// w ww .jav a 2s .com b.prepend(builder.toString()); if (current.getDepth() == 0 || current.getPath().equals(rootPath)) { break; } current = (BrixNode) current.getParent(); } final Response r = getResponse(); r.write(b.toString()); }
From source file:org.hippoecm.frontend.model.JcrItemModel.java
License:Apache License
private void doSave() { if (!isValidSession()) { return;/*from w w w. j av a 2s. co m*/ } try { relPath = null; Node node = null; PrependingStringBuffer spb = new PrependingStringBuffer(); // if we have an item, use it to update the path Item item = getObject(); if (item != null) { try { absPath = item.getPath(); if (item.isNode()) { node = (Node) item; } else { node = item.getParent(); spb.prepend(item.getName()); spb.prepend('/'); } } catch (InvalidItemStateException ex) { // ignore; item doesn't exist anymore super.detach(); } } // no node was found, use path to resolve an ancestor if (node == null) { if (absPath != null) { Session session = UserSession.get().getJcrSession(); String path = absPath; while (path.lastIndexOf('/') > 0) { spb.prepend(path.substring(path.lastIndexOf('/'))); path = path.substring(0, path.lastIndexOf('/')); try { node = (Node) session.getItem(path); break; } catch (PathNotFoundException ignored) { } } } else { log.debug("Neither path nor uuid present"); return; } } while (node != null && JcrHelper.isVirtualNode(node)) { if (node.getIndex() > 1) { spb.prepend(']'); spb.prepend(Integer.toString(node.getIndex())); spb.prepend('['); } spb.prepend(node.getName()); spb.prepend('/'); node = node.getParent(); } if (node != null) { uuid = node.getIdentifier(); if (spb.length() > 1) { relPath = spb.toString().substring(1); } } } catch (RepositoryException ex) { log.error(ex.toString()); } }