List of usage examples for java.lang StringBuilder insert
@Override public StringBuilder insert(int offset, double d)
From source file:com.yuga.ygplatform.common.persistence.Page.java
/** * ? //from ww w .j a v a 2 s. co m * <div class="page">${page}</div> */ @Override public String toString() { initialize(); StringBuilder sb = new StringBuilder(); if (pageNo == first) {// sb.append("<li class=\"disabled\"><a href=\"javascript:\">« </a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + prev + "," + pageSize + ");\">« </a></li>\n"); } int begin = pageNo - (length / 2); if (begin < first) { begin = first; } int end = begin + length - 1; if (end >= last) { end = last; begin = end - length + 1; if (begin < first) { begin = first; } } if (begin > first) { int i = 0; for (i = first; i < first + slider && i < begin; i++) { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (i < begin) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); } } for (int i = begin; i <= end; i++) { if (i == pageNo) { sb.append("<li class=\"active\"><a href=\"javascript:\">" + (i + 1 - first) + "</a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } } if (last - end > slider) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); end = last - slider; } for (int i = end + 1; i <= last; i++) { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (pageNo == last) { sb.append("<li class=\"disabled\"><a href=\"javascript:\"> »</a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + next + "," + pageSize + ");\">" + " »</a></li>\n"); } sb.append("<li class=\"disabled controls\"><a href=\"javascript:\">? "); sb.append("<input type=\"text\" value=\"" + pageNo + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(this.value," + pageSize + ");\" onclick=\"this.select();\"/> / "); sb.append("<input type=\"text\" value=\"" + pageSize + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(" + pageNo + ",this.value);\" onclick=\"this.select();\"/> ?"); sb.append(" " + count + " ?</a><li>\n"); sb.insert(0, "<ul>\n").append("</ul>\n"); sb.append("<div style=\"clear:both;\"></div>"); // sb.insert(0,"<div class=\"page\">\n").append("</div>\n"); return sb.toString(); }
From source file:com.hongqiang.shop.common.persistence.Page.java
/** * ? //from ww w .jav a2 s . c o m * <div class="page">${page}</div> */ @Override public String toString() { initialize(); StringBuilder sb = new StringBuilder(); if (pageNo == first) {// sb.append("<li class=\"disabled\"><a href=\"javascript:\">« </a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + prev + "," + pageSize + ");\">« </a></li>\n"); } int begin = pageNo - (length / 2); if (begin < first) { begin = first; } int end = begin + length - 1; if (end >= last) { end = last; begin = end - length + 1; if (begin < first) { begin = first; } } if (begin > first) { int i = 0; for (i = first; i < first + slider && i < begin; i++) { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (i < begin) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); } } for (int i = begin; i <= end; i++) { if (i == pageNo) { sb.append("<li class=\"active\"><a href=\"javascript:\">" + (i + 1 - first) + "</a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } } if (last - end > slider) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); end = last - slider; } for (int i = end + 1; i <= last; i++) { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (pageNo == last) { sb.append("<li class=\"disabled\"><a href=\"javascript:\"> »</a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + next + "," + pageSize + ");\">" + " »</a></li>\n"); } sb.append("<li class=\"disabled controls\"><a href=\"javascript:\">? "); sb.append("<input type=\"text\" value=\"" + pageNo + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(this.value," + pageSize + ");\" onclick=\"this.select();\"/> / "); sb.append("<input type=\"text\" value=\"" + pageSize + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(" + pageNo + ",this.value);\" onclick=\"this.select();\"/> ?"); sb.append(" " + count + " ?" + (message != null ? message : "") + "</a><li>\n"); sb.insert(0, "<ul>\n").append("</ul>\n"); sb.append("<div style=\"clear:both;\"></div>"); // sb.insert(0,"<div class=\"page\">\n").append("</div>\n"); return sb.toString(); }
From source file:io.manasobi.utils.StringUtils.java
/** * ? ? <br><br>/*from ww w.j a v a 2 s .c o m*/ * * StringUtils.swapFirstLetterCase("java") = "Java" * * @param str ? * @return ? ? ? */ public static String swapFirstLetterCase(String str) { StringBuilder sbuf = new StringBuilder(str); sbuf.deleteCharAt(0); if (Character.isLowerCase(str.substring(0, 1).toCharArray()[0])) { sbuf.insert(0, str.substring(0, 1).toUpperCase()); } else { sbuf.insert(0, str.substring(0, 1).toLowerCase()); } return sbuf.toString(); }
From source file:com.joey.Fujikom.common.persistence.Page.java
/** * ? //from w w w. ja v a 2 s. c om * <div class="page">${page}</div> */ @Override public String toString() { initialize(); StringBuilder sb = new StringBuilder(); if (pageNo == first) {// sb.append("<li class=\"disabled\"><a href=\"javascript:\">« ??</a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + prev + "," + pageSize + ");\">« ??</a></li>\n"); } int begin = pageNo - (length / 2); if (begin < first) { begin = first; } int end = begin + length - 1; if (end >= last) { end = last; begin = end - length + 1; if (begin < first) { begin = first; } } if (begin > first) { int i = 0; for (i = first; i < first + slider && i < begin; i++) { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (i < begin) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); } } for (int i = begin; i <= end; i++) { if (i == pageNo) { sb.append("<li class=\"active\"><a href=\"javascript:\">" + (i + 1 - first) + "</a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } } if (last - end > slider) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); end = last - slider; } for (int i = end + 1; i <= last; i++) { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (pageNo == last) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">? »</a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + next + "," + pageSize + ");\">" + "? »</a></li>\n"); } sb.append("<li class=\"disabled controls\"><a href=\"javascript:\"> "); sb.append("<input type=\"text\" value=\"" + pageNo + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(this.value," + pageSize + ");\" onclick=\"this.select();\"/> / "); sb.append("<input type=\"text\" value=\"" + pageSize + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(" + pageNo + ",this.value);\" onclick=\"this.select();\"/> "); sb.append("? " + count + " " + (message != null ? message : "") + "</a><li>\n"); sb.insert(0, "<ul>\n").append("</ul>\n"); sb.append("<div style=\"clear:both;\"></div>"); // sb.insert(0,"<div class=\"page\">\n").append("</div>\n"); return sb.toString(); }
From source file:com.bootcamp.persistence.Page.java
/** * ? //from w w w. j a va 2 s . c o m * <div class="page">${page}</div> */ @Override public String toString() { initialize(); StringBuilder sb = new StringBuilder(); if (pageNo == first) {// sb.append("<li class=\"disabled\"><a href=\"javascript:\">« </a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + prev + "," + pageSize + ");\">« </a></li>\n"); } int begin = pageNo - (length / 2); if (begin < first) { begin = first; } int end = begin + length - 1; if (end >= last) { end = last; begin = end - length + 1; if (begin < first) { begin = first; } } if (begin > first) { int i = 0; for (i = first; i < first + slider && i < begin; i++) { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (i < begin) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); } } for (int i = begin; i <= end; i++) { if (i == pageNo) { sb.append("<li class=\"active\"><a href=\"javascript:\">" + (i + 1 - first) + "</a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } } if (last - end > slider) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); end = last - slider; } for (int i = end + 1; i <= last; i++) { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (pageNo == last) { sb.append("<li class=\"disabled\"><a href=\"javascript:\"> »</a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + next + "," + pageSize + ");\">" + " »</a></li>\n"); } sb.append("<li class=\"disabled controls\"><a href=\"javascript:\">? "); sb.append("<input type=\"text\" value=\"" + pageNo + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(this.value," + pageSize + ");\" onclick=\"this.select();\"/> / "); sb.append("<input type=\"text\" value=\"" + pageSize + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(" + pageNo + ",this.value);\" onclick=\"this.select();\"/> ?"); sb.append(" " + count + " ?" + (message != null ? message : "") + "</a><li>\n"); sb.insert(0, "<ul>\n").append("</ul>\n"); sb.append("<div style=\"clear:both;\"></div>"); // sb.insert(0,"<div class=\"page\">\n").append("</div>\n"); return sb.toString(); }
From source file:net.sourceforge.processdash.ev.ui.EVReport.java
private String fixChartHelpContent(String helpContent, String helpBaseUri, Map<String, String> chartHelp) { // discard headers and footers from the help content int cutStart = helpContent.indexOf("</h1>"); if (cutStart != -1) helpContent = helpContent.substring(cutStart + 5); int cutEnd = helpContent.lastIndexOf("</body"); if (cutEnd != -1) helpContent = helpContent.substring(0, cutEnd); // create a map of the chart help topics Map<String, String> chartUrls = new HashMap<String, String>(); for (Map.Entry<String, String> e : chartHelp.entrySet()) { String chartId = e.getKey(); String chartUrl = getChartDrillDownUrl(chartId); String helpUri = e.getValue(); String helpName = hrefFileName(helpUri); chartUrls.put(helpName, chartUrl); }/*from w w w. j a v a2 s .c o m*/ // find and fix all the hrefs in this help topic: // * If any hrefs point to the help topic for a different chart, // rewrite the href so it actually loads the "drill-down page" // for that chart instead. // * For links that point to some non-chart help topic, rewrite the // href to be absolute (so the help-relative URI won't break) StringBuilder html = new StringBuilder(helpContent); int pos = 0; while (true) { // find the next href in the document. pos = html.indexOf("href=", pos); if (pos == -1) break; // no more hrefs to fix pos += 6; int beg = pos; // the first character of the href value itself char delim = html.charAt(beg - 1); int end = html.indexOf(String.valueOf(delim), beg); if (end == -1) continue; // invalid href syntax. Skip to the next one. // extract the href value String oneHref = html.substring(beg, end); // extract the final portion of the path name String oneName = hrefFileName(oneHref); // see if that name refers to one of the charts we can display String chartUrl = chartUrls.get(oneName); if (chartUrl != null) { // replace the href with a chart drill-down URL html.replace(beg, end, chartUrl); pos = beg + chartUrl.length(); } else { try { // make the URL absolute, and set a "target" attribute // so it will open in another window. URI base = new URI(helpBaseUri); URI target = base.resolve(oneHref); String newUri = target.toString(); html.replace(beg, end, newUri); html.insert(beg - 6, "target='evHelp' "); pos = beg + newUri.length() + 16; } catch (Exception e) { // problems resolving the URI? Turn the link into an // anchor so it can't be clicked on anymore. html.replace(beg - 6, beg - 2, "name"); } } } return html.toString(); }
From source file:com.noah.ai.platform.pub.entity.Pager.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); if (pageNo == first) {// sb.append("<li class=\"disabled\"><a href=\"javascript:\">« </a></li>\n"); } else {// w ww . ja va2s. c o m sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + prev + "," + pageSize + ",'" + funcParam + "');\">« </a></li>\n"); } int begin = pageNo - (length / 2); if (begin < first) { begin = first; } int end = begin + length - 1; if (end >= last) { end = last; begin = end - length + 1; if (begin < first) { begin = first; } } if (begin > first) { int i = 0; for (i = first; i < first + slider && i < begin; i++) { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ",'" + funcParam + "');\">" + (i + 1 - first) + "</a></li>\n"); } if (i < begin) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); } } for (int i = begin; i <= end; i++) { if (i == pageNo) { sb.append("<li class=\"active\"><a href=\"javascript:\">" + (i + 1 - first) + "</a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ",'" + funcParam + "');\">" + (i + 1 - first) + "</a></li>\n"); } } if (last - end > slider) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); end = last - slider; } for (int i = end + 1; i <= last; i++) { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ",'" + funcParam + "');\">" + (i + 1 - first) + "</a></li>\n"); } if (pageNo == last) { sb.append("<li class=\"disabled\"><a href=\"javascript:\"> »</a></li>\n"); } else { sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + next + "," + pageSize + ",'" + funcParam + "');\">" + " »</a></li>\n"); } sb.append("<li class=\"disabled controls\"><a href=\"javascript:\">? "); sb.append("<input type=\"text\" value=\"" + pageNo + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append( funcName + "(this.value," + pageSize + ",'" + funcParam + "');\" onclick=\"this.select();\"/> / "); sb.append("<input type=\"text\" value=\"" + pageSize + "\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)"); sb.append(funcName + "(" + pageNo + ",this.value,'" + funcParam + "');\" onclick=\"this.select();\"/> ?"); sb.append(" " + count + " ?" + (message != null ? message : "") + "</a></li>\n"); sb.insert(0, "<ul>\n").append("</ul>\n"); sb.append("<div style=\"clear:both;\"></div>"); // sb.insert(0,"<div class=\"page\">\n").append("</div>\n"); return sb.toString(); }
From source file:com.dcampus.common.persistence.Page.java
/** * ? // ww w . ja va2 s.co m * <div class="page">${page}</div> */ @Override public String toString() { initialize(); StringBuilder sb = new StringBuilder(); if (pageNo == first) {// sb.append("<li class=\"disabled\"><a href=\"javascript:\">« </a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + prev + "," + pageSize + ");\">« </a></li>\n"); } int begin = pageNo - (length / 2); if (begin < first) { begin = first; } int end = begin + length - 1; if (end >= last) { end = last; begin = end - length + 1; if (begin < first) { begin = first; } } if (begin > first) { int i = 0; for (i = first; i < first + slider && i < begin; i++) { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (i < begin) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); } } for (int i = begin; i <= end; i++) { if (i == pageNo) { sb.append("<li class=\"active\"><a href=\"javascript:\">" + (i + 1 - first) + "</a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } } if (last - end > slider) { sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n"); end = last - slider; } for (int i = end + 1; i <= last; i++) { sb.append("<li><a href=\"javascript:" + funcName + "(" + i + "," + pageSize + ");\">" + (i + 1 - first) + "</a></li>\n"); } if (pageNo == last) { sb.append("<li class=\"disabled\"><a href=\"javascript:\"> »</a></li>\n"); } else { sb.append("<li><a href=\"javascript:" + funcName + "(" + next + "," + pageSize + ");\">" + " »</a></li>\n"); } sb.append( "<li class=\"disabled\"><a href=\"javascript:\" style=\"border:0;padding-top:1px;_padding-top:7px;\">? "); sb.append("<input type=\"text\" value=\"" + pageNo + "\" style=\"width:30px;padding:0;margin:0 2px 3px 2px;text-align:center;\" "); sb.append("onkeypress=\"if(window.event.keyCode==13) " + funcName + "(this.value," + pageSize + ");\" onclick=\"this.select();\"/> / "); sb.append("<input type=\"text\" value=\"" + pageSize + "\" style=\"width:30px;padding:0;margin:0 2px 3px 2px;text-align:center;\" "); sb.append("onkeypress=\"if(window.event.keyCode==13) " + funcName + "(" + pageNo + ",this.value);\" onclick=\"this.select();\"/> ?"); sb.append(" " + count + " ?</a><li>\n"); sb.insert(0, "<ul>\n").append("</ul>\n"); sb.append("<div style=\"clear:both;\"></div>"); // sb.insert(0,"<div class=\"page\">\n").append("</div>\n"); return sb.toString(); }
From source file:mergedoc.core.Comment.java
/** * ????????????/* ww w. j a va 2 s .c o m*/ * ????????? * <p> * @param lineValue * @param resultBuf ????? * @param width ?? */ private void wrap(String lineValue, StringBuilder resultBuf, int width) { final int minWidth = width - 10; final int maxWidth = width + 10; final int ADJUST_SKIP_WIDTH = width + 4; final int lastPos = lineValue.length() - 1; final String PUNCTS = "??)}"; final String PARTICLES = "???????"; StringBuilder buf = new StringBuilder(); int bufLen = 0; for (int pos = 0; pos < lastPos; pos++) { if (bufLen == 0) { String after = lineValue.substring(pos, lastPos); int afterLen = after.getBytes().length; if (afterLen <= ADJUST_SKIP_WIDTH) { buf.append(after); break; } } char c = lineValue.charAt(pos); int cLen = String.valueOf(c).getBytes().length; bufLen += cLen; boolean isChangeLine = false; if (bufLen > minWidth) { // ??????????? if (c == ' ') { isChangeLine = true; buf.append('\n'); } else if (PUNCTS.indexOf(c) != -1 || PARTICLES.indexOf(c) != -1) { char next = lineValue.charAt(pos + 1); if (PUNCTS.indexOf(next) == -1 && next != ' ' && next != '.') { isChangeLine = true; buf.append(c); buf.append('\n'); } } else if (bufLen > width) { // ?????? // ??????????? if (c == '<' || cLen > 1) { isChangeLine = true; buf.append('\n'); buf.append(c); } else if (bufLen > maxWidth) { // ?????? // ???? for (int bPos = buf.length() - 1; bPos > 0; bPos--) { char bc = buf.charAt(bPos); if (bc == ' ') { buf.replace(bPos, bPos + 1, "\n"); bufLen = buf.substring(bPos + 1).getBytes().length; break; } else { int bcLen = String.valueOf(bc).getBytes().length; if (bcLen > 1) { buf.insert(bPos + 1, '\n'); bufLen = buf.substring(bPos + 2).getBytes().length; break; } } } } } } if (isChangeLine) { resultBuf.append(buf); buf = new StringBuilder(); bufLen = 0; } else { buf.append(c); } } buf.append(lineValue.charAt(lastPos)); resultBuf.append(buf); resultBuf.append('\n'); }