List of usage examples for java.lang StringBuffer indexOf
@Override public int indexOf(String str)
From source file:com.liferay.portal.util.HttpImpl.java
public String getCompleteURL(HttpServletRequest request) { StringBuffer sb = request.getRequestURL(); if (sb == null) { sb = new StringBuffer(); }/*from w w w . jav a 2s .c om*/ if (request.getQueryString() != null) { sb.append(StringPool.QUESTION); sb.append(request.getQueryString()); } String proxyPath = PortalUtil.getPathProxy(); if (Validator.isNotNull(proxyPath)) { int x = sb.indexOf(Http.PROTOCOL_DELIMITER) + Http.PROTOCOL_DELIMITER.length(); int y = sb.indexOf(StringPool.SLASH, x); sb.insert(y, proxyPath); } String completeURL = sb.toString(); if (request.isRequestedSessionIdFromURL()) { HttpSession session = request.getSession(); String sessionId = session.getId(); completeURL = PortalUtil.getURLWithSessionId(completeURL, sessionId); } if (_log.isWarnEnabled()) { if (completeURL.contains("?&")) { _log.warn("Invalid url " + completeURL); } } return completeURL; }
From source file:marytts.tools.dbselection.WikipediaMarkupCleaner.java
private StringBuffer removeSection(Scanner s, StringBuffer lineIn, String iniTag, String endTag) { String next;//from ww w . ja va 2s . c o m int index1 = 0, index2 = -1, endTagLength = 0, numRef = 0, lastEndTag = 0, lastIniTag = 0; boolean closeRef = true; StringBuffer line = new StringBuffer(lineIn); StringBuffer nextLine; if (debug) System.out.println("Removing tag: " + iniTag + " LINE (BEFORE): " + line); while ((index1 = line.indexOf(iniTag)) >= 0) { // in one line can be more than one iniTag numRef++; if ((index2 = line.indexOf(endTag, index1)) >= 0) endTagLength = endTag.length() + index2; if (index2 == -1) {// the iniTag most be in the next lines, so get more lines until the endTag is found lastEndTag = 0; // start to look for the endTag in 0 while (s.hasNext() && numRef != 0) { lastIniTag = 0; nextLine = new StringBuffer(s.nextLine()); //if(debug) // System.out.println(" NEXTLINE: " + nextLine); while ((index1 = nextLine.indexOf(iniTag, lastIniTag)) >= 0) { numRef++; lastIniTag = iniTag.length() + index1; } line.append(nextLine); // next time it will look for the endTag after the position of the last it found. while ((index2 = line.indexOf(endTag, lastEndTag)) >= 0) { numRef--; lastEndTag = index2 + endTag.length(); // I need to remember where the last endTag was found endTagLength = endTag.length() + index2; } //if(debug) // System.out.println("LINE (numRef=" + numRef + "): " + line); } } else // the endTag was found numRef--; if (numRef == 0) { index1 = line.indexOf(iniTag); // get again this because the position might change if (endTagLength > index1) { if (debug) { System.out.println(" FINAL LINE: " + line); System.out.print("iniTag: " + iniTag + " index1=" + index1); System.out.print(" endTagLength=" + endTagLength); System.out.println(" line.length=" + line.length() + " line: " + line); System.out.println(" line.length=" + line.length()); } line.delete(index1, endTagLength); } else { if (debug) { System.out.println("removeSection: WARNING endTagLength > length of line: "); System.out.print("iniTag: " + iniTag + " index1=" + index1); System.out.print(" endTagLength=" + endTagLength); System.out.println(" line.length=" + line.length() + " line: " + line); System.out.println("removeSection: WARNING endTagLength > length of line: " + line); } line = new StringBuffer(""); } //System.out.println("nextline="+line); } else { if (debug) System.out.println("removeSection: WARNING no " + endTag); line = new StringBuffer(""); } } // while this line contains iniTag-s if (debug) System.out.println(" LINE (AFTER): " + line); return line; }
From source file:marytts.tools.dbselection.WikipediaMarkupCleaner.java
private StringBuffer removeSectionTable(Scanner s, StringBuffer lineIn, String iniTag, String endTag) { String next;//from w w w . j ava2 s .c om int index1 = 0, index2 = -1, endTagLength = 0, numRef = 0, lastEndTag = 0, lastIniTag = 0; boolean closeRef = true; StringBuffer line = new StringBuffer(lineIn); StringBuffer nextLine; if (debug) System.out.println("Removing tag: " + iniTag + " LINE (BEFORE): " + line); while ((index1 = line.indexOf(iniTag)) >= 0) { // in one line can be more than one iniTag numRef++; if ((index2 = line.indexOf(endTag, index1)) >= 0) endTagLength = endTag.length() + index2; if (index2 == -1) {// the iniTag most be in the next lines, so get more lines until the endTag is found lastEndTag = 0; // start to look for the endTag in 0 while (s.hasNext() && numRef != 0) { lastIniTag = 0; nextLine = new StringBuffer(s.nextLine()); //if(debug) // System.out.println(" NEXTLINE: " + nextLine); while ((index1 = nextLine.indexOf(iniTag, lastIniTag)) >= 0) { numRef++; lastIniTag = iniTag.length() + index1; } // next time it will look for the endTag after the position of the last it found. //while( (index2 = line.indexOf(endTag, lastEndTag)) >= 0 ){ if (nextLine.toString().startsWith(endTag)) { numRef--; //index2 = line.length(); //lastEndTag = index2 + endTag.length(); // I need to remember where the last endTag was found endTagLength = line.length() + endTag.length(); } line.append(nextLine); //if(debug) // System.out.println("LINE (numRef=" + numRef + "): " + line); } } else // the endTag was found numRef--; if (numRef == 0) { index1 = line.indexOf(iniTag); // get again this because the position might change if (endTagLength > index1) { if (debug) { System.out.println(" FINAL LINE: " + line); System.out.print("iniTag: " + iniTag + " index1=" + index1); System.out.print(" endTagLength=" + endTagLength); System.out.println(" line.length=" + line.length() + " line: " + line); System.out.println(" line.length=" + line.length()); } line.delete(index1, endTagLength); } else { if (debug) { System.out.println("removeSection: WARNING endTagLength > length of line: "); System.out.print("iniTag: " + iniTag + " index1=" + index1); System.out.print(" endTagLength=" + endTagLength); System.out.println(" line.length=" + line.length() + " line: " + line); System.out.println("removeSection: WARNING endTagLength > length of line: " + line); } line = new StringBuffer(""); } //System.out.println("nextline="+line); } else { if (debug) System.out.println("removeSection: WARNING no " + endTag); line = new StringBuffer(""); } } // while this line contains iniTag-s if (debug) System.out.println(" LINE (AFTER): " + line); return line; }
From source file:marytts.tools.dbselection.WikipediaMarkupCleaner.java
/**** * This is also special because the line might contain sections with [[ ... ]] so the ]] after a [[ * is not the endTag of [[image: ... ]] * @param s/*from ww w.ja v a2s . c o m*/ * @param lineIn * @param iniTag * @param endTag * @param debug * @return */ private StringBuffer removeSectionImage(Scanner s, StringBuffer lineIn, String iniTag, String endTag) { String next; int index1 = 0, index2 = -1, index3 = -1, endTagLength = 0, numRef = 0, lastEndTag1 = 0, lastIniTag = 0; boolean closeRef = true; StringBuffer line = new StringBuffer(lineIn); StringBuffer nextLine; StringBuffer aux; if (debug) System.out.println("Removing tag: " + iniTag + " LINE (BEFORE): " + line); while ((index1 = line.indexOf(iniTag)) >= 0) { // in one line can be more than one iniTag numRef++; index3 = endTagLength = index1; while (s.hasNext() && numRef > 0) { while ((index2 = line.indexOf("]]", endTagLength)) >= 0 && numRef > 0) { aux = new StringBuffer(line.subSequence(index1 + 2, index2 + 2)); if (debug) System.out.println(" aux=" + aux); if ((index3 = aux.indexOf("[[")) == -1) { endTagLength = endTag.length() + index2; numRef--; } else { // The previous was a [[ ]] inside of a [[Image: so it has to be deleted index1 = index2; endTagLength = index2 + 2; index2 = -1; } } // so far it has not found the endTag, so get another line if (numRef > 0) line.append(s.nextLine()); } if (numRef == 0) { index1 = line.indexOf(iniTag); // get again this because the position might change if (endTagLength > index1) { if (debug) { System.out.println(" FINAL LINE: " + line); System.out.print("iniTag: " + iniTag + " index1=" + index1); System.out.print(" endTagLength=" + endTagLength); System.out.println(" line.length=" + line.length() + " line: " + line); System.out.println(" line.length=" + line.length()); } line.delete(index1, endTagLength); } else { if (debug) { System.out.println("removeSection: WARNING endTagLength > length of line: "); System.out.print("iniTag: " + iniTag + " index1=" + index1); System.out.print(" endTagLength=" + endTagLength); System.out.println(" line.length=" + line.length() + " line: " + line); System.out.println("removeSection: WARNING endTagLength > length of line: " + line); } line = new StringBuffer(""); } } else { if (debug) System.out.println("removeSection: WARNING no " + endTag); line = new StringBuffer(""); } } // while this line contains iniTag-s if (debug) System.out.println(" LINE (AFTER): " + line); return line; }
From source file:org.zkoss.poi.ss.format.CellNumberFormatter.java
private void writeFractional(StringBuffer result, StringBuffer output) { int digit;/*from w w w . j a va 2 s . com*/ int strip; ListIterator<Special> it; if (fractionalSpecials.size() > 0) { //20100914, henrichen@zkoss.org: respect given Locale final char dot = Formatters.getDecimalSeparator(locale); output.setCharAt(decimalPoint.pos, dot); digit = result.indexOf("" + dot) + 1; if (exponent != null) strip = result.indexOf("e") - 1; else strip = result.length() - 1; while (strip > digit && result.charAt(strip) == '0') strip--; it = fractionalSpecials.listIterator(); while (it.hasNext()) { Special s = it.next(); char resultCh = result.charAt(digit); if (resultCh != '0' || s.ch == '0' || digit < strip) output.setCharAt(s.pos, resultCh); else if (s.ch == '?') { // This is when we're in trailing zeros, and the format is '?'. We still strip out remaining '#'s later output.setCharAt(s.pos, ' '); } digit++; } } }
From source file:marytts.tools.dbselection.WikipediaMarkupCleaner.java
/*** * Internal links: /* w ww . ja va 2s .c om*/ * [[Name of page]] * [[Name of page|Text to display]] * External links: * [http://www.example.org Text to display] * [http://www.example.org] * http://www.example.org */ private StringBuffer processInternalAndExternalLinks(StringBuffer line) { int index1, index2, index3; StringBuffer linetmp = null; // for debugging boolean changed = false; if (debug) linetmp = new StringBuffer(line); // Internal links: while ((index1 = line.indexOf("[[")) >= 0) { changed = true; if ((index2 = line.indexOf("]]")) >= 0) { if ((index3 = line.indexOf("|", index1)) >= 0 && index3 < index2) { // if there is text to display line.delete(index1, index3 + 1); // delete the link and [[ ]] index2 = line.indexOf("]]"); // since i delete some text i need to find again the next ]] line.delete(index2, index2 + 2); } else { line.delete(index1, index1 + 2); // delete the [[ index2 = line.indexOf("]]"); // since i delete some text i need to find again the next ]] line.delete(index2, index2 + 2); // delete the ]] -2 because in the previous line i deleted two chars } //if(debug) // System.out.println("LINE (AFTER): " + line); } else { if (debug) { System.out.println("processInternalAndExternalLinks: WARNING no ]] tag in " + line); System.out.println("deleting [["); } line.delete(index1, index1 + 2); // delete the [[ } } // External links: just the ones started with [http: and here I am deleting the whole reference // i am not keeping the text to display of this link. while ((index1 = line.indexOf("[http:")) >= 0 || (index1 = line.indexOf("[https:")) >= 0) { //System.out.println("LINE(BEFORE): " + line); if ((index2 = line.indexOf("]", index1)) >= 0) { // line.delete(index1, index2+1); if ((index3 = line.indexOf(" ", index1)) >= 0 && index3 < index2) { // if there is text to display line.delete(index1, index3 + 1); // delete the link and [http: until first black space before ] index2 = line.indexOf("]"); // since i delete some text i need to find again the next ]] line.delete(index2, index2 + 1); } else { line.delete(index1, index2 + 1); // no text to display, delete the whole ref } //System.out.println("LINE (AFTER): " + line + "\n"); } else { if (debug) { System.out.println( "processInternalAndExternalLinks: WARNING no ] tag when processing lines with http: line=" + line); System.out.println("deleting ["); } line.delete(index1, index1 + 1); // delete the [ } } if (debug && changed) { System.out.println("Removing links, LINE(BEFORE): " + linetmp); System.out.println(" LINE (AFTER): " + line); } return line; }
From source file:com.panet.imeta.job.entries.dtdvalidator.JobEntryDTDValidator.java
public Result execute(Result previousResult, int nr, Repository rep, Job parentJob) { LogWriter log = LogWriter.getInstance(); Result result = previousResult; result.setResult(false);/*from w w w . ja v a 2 s . co m*/ String realxmlfilename = getRealxmlfilename(); String realDTDfilename = getRealDTDfilename(); FileObject xmlfile = null; FileObject DTDfile = null; try { if (xmlfilename != null && ((dtdfilename != null && !dtdintern) || (dtdintern))) { xmlfile = KettleVFS.getFileObject(realxmlfilename); if (xmlfile.exists()) { //URL xmlFile = new URL (KettleVFS.getFilename(xmlfile)); URL xmlFile = new File(KettleVFS.getFilename(xmlfile)).toURI().toURL(); // open XML File BufferedReader xmlBufferedReader = new BufferedReader( new InputStreamReader(xmlFile.openStream())); StringBuffer xmlStringbuffer = new StringBuffer(""); char[] buffertXML = new char[1024]; int LenXML = -1; while ((LenXML = xmlBufferedReader.read(buffertXML)) != -1) xmlStringbuffer.append(buffertXML, 0, LenXML); // Prepare parsing ... DocumentBuilderFactory DocBuilderFactory = DocumentBuilderFactory.newInstance(); Document xmlDocDTD = null; DocumentBuilder DocBuilder = DocBuilderFactory.newDocumentBuilder(); // Let's try to get XML document encoding DocBuilderFactory.setValidating(false); xmlDocDTD = DocBuilder .parse(new ByteArrayInputStream(xmlStringbuffer.toString().getBytes("UTF-8"))); String encoding = null; if (xmlDocDTD.getXmlEncoding() == null) { encoding = "UTF-8"; } else { encoding = xmlDocDTD.getXmlEncoding(); } int xmlStartDTD = xmlStringbuffer.indexOf("<!DOCTYPE"); if (dtdintern) { // DTD find in the XML document if (xmlStartDTD != -1) { if (log.isBasic()) log.logBasic(toString(), Messages .getString("JobEntryDTDValidator.ERRORDTDFound.Label", realxmlfilename)); } else { if (log.isBasic()) log.logBasic(toString(), Messages .getString("JobEntryDTDValidator.ERRORDTDNotFound.Label", realxmlfilename)); } } else { // DTD in external document // If we find an intern declaration, we remove it DTDfile = KettleVFS.getFileObject(realDTDfilename); if (DTDfile.exists()) { if (xmlStartDTD != -1) { int EndDTD = xmlStringbuffer.indexOf(">", xmlStartDTD); //String DocTypeDTD = xmlStringbuffer.substring(xmlStartDTD, EndDTD + 1); xmlStringbuffer.replace(xmlStartDTD, EndDTD + 1, ""); } String xmlRootnodeDTD = xmlDocDTD.getDocumentElement().getNodeName(); String RefDTD = "<?xml version='" + xmlDocDTD.getXmlVersion() + "' encoding='" + encoding + "'?>\n<!DOCTYPE " + xmlRootnodeDTD + " SYSTEM '" + KettleVFS.getFilename(DTDfile) + "'>\n"; int xmloffsetDTD = xmlStringbuffer.indexOf("<" + xmlRootnodeDTD); xmlStringbuffer.replace(0, xmloffsetDTD, RefDTD); } else { log.logError(Messages.getString("JobEntryDTDValidator.ERRORDTDFileNotExists.Subject"), Messages.getString("JobEntryDTDValidator.ERRORDTDFileNotExists.Msg", realDTDfilename)); } } if ((dtdintern && xmlStartDTD == -1 || (!dtdintern && !DTDfile.exists()))) { result.setResult(false); result.setNrErrors(1); } else { DocBuilderFactory.setValidating(true); // Let's parse now ... xmlDocDTD = DocBuilder .parse(new ByteArrayInputStream(xmlStringbuffer.toString().getBytes(encoding))); if (log.isDetailed()) log.logDetailed(Messages.getString("JobEntryDTDValidator.DTDValidatorOK.Subject"), Messages.getString("JobEntryDTDValidator.DTDValidatorOK.Label", realxmlfilename)); // Everything is OK result.setResult(true); } } else { if (!xmlfile.exists()) { log.logError(toString(), Messages.getString("JobEntryDTDValidator.FileDoesNotExist.Label", realxmlfilename)); } result.setResult(false); result.setNrErrors(1); } } else { log.logError(toString(), Messages.getString("JobEntryDTDValidator.AllFilesNotNull.Label")); result.setResult(false); result.setNrErrors(1); } } catch (Exception e) { log.logError(Messages.getString("JobEntryDTDValidator.ErrorDTDValidator.Subject"), Messages.getString("JobEntryDTDValidator.ErrorDTDValidator.Label", realxmlfilename, realDTDfilename, e.getMessage())); result.setResult(false); result.setNrErrors(1); } finally { try { if (xmlfile != null) xmlfile.close(); if (DTDfile != null) DTDfile.close(); } catch (IOException e) { } } return result; }
From source file:com.isecpartners.gizmo.HttpRequest.java
private String rewriteMethodLine(StringBuffer workingContents) { int host_index = workingContents.toString().toUpperCase().indexOf("HOST:"); if (host_index != -1) { int host_line_end_index = workingContents.toString().indexOf("\r\n", host_index); host = workingContents.toString().substring(host_index + 6, host_line_end_index).trim(); } else {/*from ww w . j av a 2 s . c o m*/ this.url = makeURL(workingContents); host = url.substring(url.indexOf("//") + 2, url.indexOf("/", url.indexOf("//") + 2)); } if (host.contains(":")) { port = Integer.parseInt(host.substring(host.indexOf(":") + 1)); user_defined_port = true; host = host.substring(0, host.indexOf(":")); } final String GET_HTTP = "^[a-zA-Z]+\\s+[hH][tT][tT][pP].*"; if (header.matches(GET_HTTP)) { String tmp = workingContents.toString().substring(0, workingContents.indexOf("\r\n")).trim() + "\r\n"; int start = tmp.indexOf("http://") + 8; String prefix = tmp.substring(0, start - 8); int end = tmp.indexOf("/", start); String postfix = tmp.substring(end, tmp.length()); String whole = prefix + postfix; workingContents.replace(0, tmp.length(), whole); } return host; }
From source file:org.zkoss.poi.ss.format.CellNumberFormatter.java
private void writeInteger(StringBuffer result, StringBuffer output, List<Special> numSpecials, Set<StringMod> mods, boolean showCommas, boolean fraction) {//20100924, henrichen@zkoss.org: fraction has special treatment about zero //20100914, henrichen@zkoss.org: repect the current locale final char comma = Formatters.getGroupingSeparator(locale); final String commaStr = "" + comma; final String dot = "" + Formatters.getDecimalSeparator(locale); int pos = result.indexOf(dot) - 1; if (pos < 0) { if (exponent != null && numSpecials == integerSpecials) pos = result.indexOf("E") - 1; else// www .j a va 2 s. co m pos = result.length() - 1; } int strip; for (strip = 0; strip < pos; strip++) { char resultCh = result.charAt(strip); if (resultCh != '0' && resultCh != comma) break; } //20100924, henrichen@zkoss.org: handle all zero case final char posCh = !fraction && strip == pos && pos >= 0 ? result.charAt(pos) : '\000'; final boolean allZeros = posCh == '0' || posCh == comma; ListIterator<Special> it = numSpecials.listIterator(numSpecials.size()); boolean followWithComma = false; Special lastOutputIntegerDigit = null; int digit = 0; while (it.hasPrevious()) { char resultCh; if (pos >= 0) resultCh = result.charAt(pos); else { // If result is shorter than field, pretend there are leading zeros resultCh = '0'; } Special s = it.previous(); followWithComma = showCommas && digit > 0 && digit % 3 == 0; boolean zeroStrip = false; if (resultCh != '0' || s.ch == '0' || s.ch == '?' || pos >= strip) { zeroStrip = s.ch == '?' && (pos < strip || allZeros); //20100924, henrichen@zkoss.org: handle all zero case output.setCharAt(s.pos, (zeroStrip ? ' ' : resultCh)); lastOutputIntegerDigit = s; } if (followWithComma) { //20100914, henrichen@zkoss.org: repect the current locale //mods.add(insertMod(s, zeroStrip ? " " : ",", StringMod.AFTER)); mods.add(insertMod(s, zeroStrip ? " " : commaStr, StringMod.AFTER)); followWithComma = false; } digit++; --pos; } StringBuffer extraLeadingDigits = new StringBuffer(); if (pos >= 0) { // We ran out of places to put digits before we ran out of digits; put this aside so we can add it later ++pos; // pos was decremented at the end of the loop above when the iterator was at its end extraLeadingDigits = new StringBuffer(result.substring(0, pos)); if (showCommas) { while (pos > 0) { if (digit > 0 && digit % 3 == 0) //20100914, henrichen@zkoss.org: repect the current locale //extraLeadingDigits.insert(pos, ','); extraLeadingDigits.insert(pos, comma); digit++; --pos; } } mods.add(insertMod(lastOutputIntegerDigit, extraLeadingDigits, StringMod.BEFORE)); } }
From source file:nl.b3p.kaartenbalie.service.requesthandler.WMSRequestHandler.java
protected StringBuffer createOnlineUrl(SpLayerSummary spInfo, OGCRequest ogc, String serviceUrl) throws UnsupportedEncodingException { StringBuffer returnValue = new StringBuffer(); List<String> newSldParams = new ArrayList<String>(); List<Integer> sldStyleIds = new ArrayList<Integer>(); String layersString = spInfo.getLayersAsString(); String kbProxySldUrl = serviceUrl.replace("/services/", "/proxysld/"); log.debug("Kb proxy url: " + kbProxySldUrl); List<LayerSummary> layersList = spInfo.getLayers(); returnValue.append(spInfo.getSpUrl()); if (returnValue.indexOf("?") != returnValue.length() - 1 && returnValue.indexOf("&") != returnValue.length() - 1) { if (returnValue.indexOf("?") >= 0) { returnValue.append("&"); } else {//from w w w .java2 s .c o m returnValue.append("?"); } } String[] params = ogc.getParametersArray(); for (int i = 0; i < params.length; i++) { //In SLD_BODY zitten = tekens. Dus niet splitten String[] keyValuePair = new String[2]; int indexOfIs = params[i].indexOf("="); if (indexOfIs == -1) continue; keyValuePair[0] = params[i].substring(0, indexOfIs); if (indexOfIs + 1 < params[i].length()) keyValuePair[1] = params[i].substring(indexOfIs + 1); else keyValuePair[1] = ""; if (keyValuePair[0].equalsIgnoreCase(OGCConstants.WMS_PARAM_LAYERS)) { returnValue.append(OGCConstants.WMS_PARAM_LAYERS); returnValue.append("="); returnValue.append(layersString); } else if (keyValuePair[0].equalsIgnoreCase(OGCConstants.WMS_PARAM_STYLES)) { returnValue.append(OGCConstants.WMS_PARAM_STYLES); returnValue.append("="); //maak alleen de styles goed als er geen sld= of sld_body= parameter aanwezig is. try { if (layersList != null && layersList.size() > 0) { String stylesParameter = ogc.getParameter(OGCConstants.WMS_PARAM_STYLES); if (stylesParameter != null && stylesParameter.length() > 0) { //splitten werkt niet. Een lege string (tussen 2 komma's) wordt dan niet gezien als waarde //String[] stylesArray = stylesParameter.split(","); String tempStyles = "" + stylesParameter; List<String> styles = new ArrayList<String>(); while (tempStyles != null) { if (tempStyles.length() == 0) { styles.add(""); tempStyles = null; break; } int kommaIndex = tempStyles.indexOf(","); if (kommaIndex < 0) { kommaIndex = tempStyles.length(); styles.add(tempStyles.substring(0)); tempStyles = null; break; } else { styles.add(tempStyles.substring(0, kommaIndex)); tempStyles = tempStyles.substring(kommaIndex + 1, tempStyles.length()); } } String layersParameter = ogc.getParameter(OGCConstants.WMS_PARAM_LAYERS); if (layersParameter != null && layersParameter.length() > 0) { String[] layersArray = layersParameter.split(","); if (styles.size() == layersArray.length) { //StringBuffer stylesString = new StringBuffer(); List<String> providerStyles = new ArrayList<String>(); for (int j = 0; j < layersArray.length; j++) { Iterator it = layersList.iterator(); while (it.hasNext()) { LayerSummary ls = (LayerSummary) it.next(); String completeName = OGCCommunication.buildFullLayerName(ls); //TODO: Moet het toegevoegd worden als Style= of als sld if (completeName.equals(layersArray[j])) { String style = styles.get(j); //als er een style is gekozen met een SLDpart //niet de style meenemen maar een sld bouwen Style s = spInfo.getStyle( OGCCommunication.buildLayerNameWithoutSp(ls), style); if (s != null && s.getSldPart() != null) { providerStyles.add(""); sldStyleIds.add(s.getId()); } else { providerStyles.add(style); } break; } } } String stylesString = ""; for (int p = 0; p < providerStyles.size(); p++) { if (p != 0) stylesString += ","; stylesString += providerStyles.get(p); } returnValue.append(stylesString); if (sldStyleIds.size() > 0) { String styleIdParam = ""; for (Integer sldStyleId : sldStyleIds) { if (styleIdParam.length() > 0) styleIdParam += ","; styleIdParam += sldStyleId; } StringBuffer sldUrl = new StringBuffer(); sldUrl.append(ProxySLDServlet.PARAM_STYLES); sldUrl.append("="); sldUrl.append(styleIdParam); newSldParams.add(sldUrl.toString()); } } } } } } catch (Exception e) { // so no styles param log.debug(e); } } else if (keyValuePair[0].equalsIgnoreCase(OGCConstants.WMS_PARAM_SLD) || keyValuePair[0].equalsIgnoreCase(OGCConstants.WMS_PARAM_SLD_BODY)) { //als SLD= dan url alvast cachen. if (keyValuePair[0].equalsIgnoreCase(OGCConstants.WMS_PARAM_SLD)) ProxySLDServlet.addSLDToCache(keyValuePair[1]); //SLD of SLD Body StringBuffer sldParam = new StringBuffer(); if (keyValuePair[0].equalsIgnoreCase(OGCConstants.WMS_PARAM_SLD)) { sldParam.append(ProxySLDServlet.PARAM_ORIGINAL_SLD_URL); } else { sldParam.append(ProxySLDServlet.PARAM_ORIGINAL_SLD_BODY); } sldParam.append("="); sldParam.append(URLEncoder.encode(keyValuePair[1], "utf-8")); newSldParams.add(sldParam.toString()); //service provider ID StringBuffer serviceProviderIds = new StringBuffer(); serviceProviderIds.append(ProxySLDServlet.PARAM_SERVICEPROVIDER_ID); serviceProviderIds.append("="); serviceProviderIds.append(spInfo.getServiceproviderId()); newSldParams.add(serviceProviderIds.toString()); } else { returnValue.append(params[i]); } returnValue.append("&"); } if (newSldParams.size() > 0) { //make a new SLD url to the proxySldServlet. StringBuffer sldUrl = new StringBuffer(); sldUrl.append(kbProxySldUrl); sldUrl.append(sldUrl.indexOf("?") > 0 ? "&" : "?"); for (String param : newSldParams) { sldUrl.append(param); sldUrl.append(sldUrl.indexOf("?") > 0 ? "&" : "?"); } //altijd een sld=. Ook sld_body zodat we kunnen opsplitsen returnValue.append(OGCConstants.WMS_PARAM_SLD); returnValue.append("="); returnValue.append(URLEncoder.encode(sldUrl.toString(), "utf-8")); returnValue.append("&"); } return returnValue; }