List of usage examples for java.lang StringBuffer substring
@Override public synchronized String substring(int start, int end)
From source file:URLUtilities.java
/** * Report the site name, e.g. http://www.openeditpro.com * /*from w w w . j a v a 2s .c o m*/ * @return The site's root URL */ public String siteRoot() { if (fieldRequest == null) { return null; } StringBuffer ctx = fieldRequest.getRequestURL(); String siteRoot = ctx.substring(0, ctx.indexOf("/", 8)); //8 comes from https:// return siteRoot; }
From source file:URLUtilities.java
/** * This is the server name only /* w w w . j a v a2 s .com*/ * * returns http://www.acme.com/ */ public String buildRoot() { if (fieldRequest == null) { return null; } StringBuffer ctx = fieldRequest.getRequestURL(); String servername = ctx.substring(0, ctx.indexOf("/", 7)); return servername + "/"; }
From source file:URLUtilities.java
/** * This includes the webapp name but not the page name * * @return http://www.acme.com/webapp//*from ww w . j av a2 s .co m*/ */ public String buildBasePath(String path) { if (fieldRequest == null) { return null; } StringBuffer ctx = fieldRequest.getRequestURL(); String servername = ctx.substring(0, ctx.indexOf("/", 7)); //just the server name if (path.lastIndexOf('/') > -1) { path = path.substring(0, path.lastIndexOf('/')); return servername + path + "/"; } else { return servername + "/"; } }
From source file:org.bedework.util.security.pki.PkiUtil.java
private void dumpHex(final byte[] hex) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < hex.length; i++) { sb.append(toHex(hex[i]));/*from w w w . j a v a 2 s.c o m*/ // string += toHex(byteArray[i]) + " "; } int pos = 0; int seglen = 50; while (pos < sb.length()) { int len = Math.min(seglen, sb.length() - pos); error(" " + sb.substring(pos, pos + len)); pos += len; } }
From source file:org.tdod.ether.areabuilder.MobDataReader.java
private void parseDescLine(BufferedReader bufferedReader, String line, String keyword) throws IOException { _log.debug("Found the " + keyword + " section"); String data = line.substring(keyword.length()); String[] split = data.split(" "); int index = new Integer(split[0]); StringBuffer buffer = new StringBuffer(); buffer.append(getDescriptionData(data)); while (!line.endsWith(new String("}"))) { line = bufferedReader.readLine(); // buffer.append("\\n" + line); buffer.append(" " + line); }/* www .ja va2 s . c o m*/ // Strip out the ending } String tmpStr1 = buffer.substring(0, buffer.length() - 1); // Replace %s with {0} String tmpStr2 = getModifiedStringVariableToken(tmpStr1); // Replace ' with '' // String tmpStr3 = replaceQuotes(tmpStr2); Mob mob = getOrCreateMob(index); mob.setDescription(tmpStr2); }
From source file:com.sec.ose.osi.report.standard.data.BillOfMaterialsRowGenerator.java
private String getFullPaths(ArrayList<IdentifiedFilesRow> fileEntList) { StringBuffer paths = new StringBuffer(""); for (IdentifiedFilesRow ent : fileEntList) { paths.append(ent.getFullPath() + "\n"); }// w w w. j a va 2 s .c o m if (paths.length() > 0) { return paths.substring(0, paths.length() - 1); } return ""; }
From source file:nl.b3p.kaartenbalie.struts.WMSUrlCreatorAction.java
public ActionForward getMapUrl(ActionMapping mapping, DynaValidatorForm dynaForm, HttpServletRequest request, HttpServletResponse response) throws Exception { if (!isTokenValid(request)) { prepareMethod(dynaForm, request, EDIT, LIST); addAlternateMessage(mapping, request, TOKEN_ERROR_KEY); return getAlternateForward(mapping, request); }/* w w w . j a v a 2 s . co m*/ ActionErrors errors = dynaForm.validate(mapping, request); if (!errors.isEmpty()) { super.addMessages(request, errors); prepareMethod(dynaForm, request, EDIT, LIST); addAlternateMessage(mapping, request, VALIDATION_ERROR_KEY); return getAlternateForward(mapping, request); } //Create the String String[] layers = (String[]) dynaForm.get("sortedLayers"); String projectie = (String) dynaForm.get("selectedProjectie"); String bbox = (String) dynaForm.get("bbox"); Integer height = (Integer) dynaForm.get("height"); Integer width = (Integer) dynaForm.get("width"); String format = (String) dynaForm.get("selectedFormat"); String pUrl = (String) dynaForm.get("personalUrl"); if (layers.length == 0) { prepareMethod(dynaForm, request, LIST, LIST); addAlternateMessage(mapping, request, NO_LAYERS_SELECTED_ERROR_KEY); return getAlternateForward(mapping, request); } /* * Get the URL to start with */ User user = (User) request.getUserPrincipal(); if (user == null) { prepareMethod(dynaForm, request, LIST, LIST); addAlternateMessage(mapping, request, UNKNOWN_SES_USER_ERROR_KEY); return getAlternateForward(mapping, request); } StringBuffer layerString = new StringBuffer(); for (int i = 0; i < layers.length; i++) { layerString.append(layers[i]); layerString.append(","); } String layer = layerString.substring(0, layerString.lastIndexOf(",")); StringBuffer getMapUrl = new StringBuffer(user.getPersonalURL(request)); getMapUrl.append("?"); getMapUrl.append(OGCConstants.WMS_SERVICE); getMapUrl.append("="); getMapUrl.append(OGCConstants.WMS_SERVICE_WMS); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_VERSION); getMapUrl.append("="); getMapUrl.append(OGCConstants.WMS_VERSION_111); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_REQUEST); getMapUrl.append("="); getMapUrl.append(OGCConstants.WMS_REQUEST_GetMap); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_LAYERS); getMapUrl.append("="); getMapUrl.append(layer); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_BBOX); getMapUrl.append("="); getMapUrl.append(bbox); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_SRS); getMapUrl.append("="); getMapUrl.append(projectie); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_HEIGHT); getMapUrl.append("="); getMapUrl.append(height); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_WIDTH); getMapUrl.append("="); getMapUrl.append(width); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_FORMAT); getMapUrl.append("="); getMapUrl.append(format); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_BGCOLOR); getMapUrl.append("="); getMapUrl.append("0xF0F0F0"); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_EXCEPTIONS); getMapUrl.append("="); getMapUrl.append(OGCConstants.WMS_PARAM_EXCEPTION_INIMAGE); getMapUrl.append("&"); getMapUrl.append(OGCConstants.WMS_PARAM_STYLES); getMapUrl.append("="); user.setDefaultGetMap(getMapUrl.toString()); log.debug("Getting entity manager ......"); EntityManager em = getEntityManager(); if (user.getId() == null) { em.persist(user); } else { em.merge(user); } em.flush(); populateForm(getMapUrl.toString(), dynaForm, request); prepareMethod(dynaForm, request, LIST, EDIT); addDefaultMessage(mapping, request, ACKNOWLEDGE_MESSAGES); return getDefaultForward(mapping, request); }
From source file:org.j2free.util.HtmlFilter.java
/** * * @param msg/*from w ww . j a v a2 s .com*/ * @param allowedTags * @return */ public String filter(String msg, String[] allowedTags) { if (msg == null) return ""; else if (msg.length() == 0 || msg.equals("") || !msg.contains("<")) return msg; okayTags.clear(); if (allowedTags != null && allowedTags.length > 0) okayTags.addAll(Arrays.asList(allowedTags)); StringBuffer line = new StringBuffer(msg); for (int i = 0; i < line.length(); i++) { if (line.charAt(i) == '<') { int begin = i, end = i; for (int j = i + 1; j < line.length(); j++) { if (line.charAt(j) == '>') { end = j + 1; break; } } if (!isOkayTag(new String(line.substring(begin, end)))) { line = line.delete(begin, end); } } } return new String(line); }
From source file:org.tdod.ether.areabuilder.MessageDataReader.java
private void getData(BufferedReader bufferedReader, String line) throws IOException, InvalidFileException { StringBuffer buffer = new StringBuffer(); int index = line.indexOf("{"); String key = line.substring(0, index); String subString = line.substring(index + 1, line.length()); buffer.append(subString);//from w w w . ja v a 2 s. co m while (!buffer.toString().contains(new String("}"))) { line = bufferedReader.readLine(); buffer.append("\\n\\" + "\n" + line); } // Remove the last } String tmpMsg1 = buffer.substring(0, buffer.toString().indexOf("}")); // Convert %s to {0} String tmpMsg2 = getModifiedStringVariableToken(tmpMsg1); // If the string contains {0}, then replace any ' with ''. MessageFormat gets confused if there are single '. if (tmpMsg2.contains("{0}")) { tmpMsg2 = replaceQuotes(tmpMsg2); } if (tmpMsg2.startsWith(" ")) { tmpMsg2 = replaceInitialSpacing(tmpMsg2); } _messageMap.put(key.trim(), tmpMsg2); }
From source file:org.kopi.ebics.letter.AbstractInitLetter.java
/** * Formats a hash 256 input.//from w w w. j av a 2 s . c om * @param hash256 the hash input * @return the formatted hash */ private String format(String hash256) { StringBuffer buffer; String formatted; buffer = new StringBuffer(); for (int i = 0; i < hash256.length(); i += 2) { buffer.append(hash256.charAt(i)); buffer.append(hash256.charAt(i + 1)); buffer.append(' '); } formatted = buffer.substring(0, 48) + LINE_SEPARATOR + buffer.substring(48) + LINE_SEPARATOR; return formatted; }