/** * Get the current text for the element. * * @return the current text. */ public String getText() { return text.substring(0); } }
/** * get the eof string. * @return the eof string. */ public String getEofStr() { return eofStr.substring(0); }
private String baseURL( HttpServletRequest request ) { StringBuffer url = request.getRequestURL(); String baseURL = url.substring( 0, url.length() - request.getRequestURI().length() ) + "/"; return XForwardUtil.externalUri( baseURL, request.getHeader( X_FORWARD_HOST_HEADER_KEY ), request.getHeader( X_FORWARD_PROTO_HEADER_KEY ) ); }
private String toHexString(int v, int len) { StringBuffer b = new StringBuffer(); for (int i = 0; i < len; i++) b.append('0'); b.append(Long.toHexString(v)); return b.substring(b.length() - len).toUpperCase(); }
private boolean regionMatch(StringBuffer string, int index, String test) { boolean matches = false; if( index >= 0 && (index + test.length() - 1) < string.length() ) { String substring = string.substring( index, index + test.length()); matches = substring.equals( test ); } return matches; }
private String getContextPath(HttpServletRequest request) { StringBuffer requestURL = request.getRequestURL(); return requestURL.substring(0, requestURL.length() - request.getServletPath().length()); } }
private String getServerContextPath(HttpServletRequest request) { StringBuffer requestURL = request.getRequestURL(); return requestURL.substring(0, requestURL.length() - request.getServletPath().length()); }
public String substringData(int offset, int count) throws DOMException { try { return buffer.substring(offset, offset + count); } catch (ArrayIndexOutOfBoundsException ex) { throw new DOMException(DOMException.INDEX_SIZE_ERR, null); } }
/** * Changes the password to '***' so it isn't displayed on screen if the build fails * * @param cmd The command line to clean * @return The command line as a string with out the password */ private String formatCommandLine(Commandline cmd) { StringBuffer sBuff = new StringBuffer(cmd.toString()); int indexUser = sBuff.substring(0).indexOf(FLAG_LOGIN); if (indexUser > 0) { int indexPass = sBuff.substring(0).indexOf(",", indexUser); int indexAfterPass = sBuff.substring(0).indexOf(" ", indexPass); for (int i = indexPass + 1; i < indexAfterPass; i++) { sBuff.setCharAt(i, '*'); } } return sBuff.toString(); }
/** * Unicode编码转汉字 */ public static String UnicodeToChs(String s) { StringBuffer sb = new StringBuffer(s); int pos; while ((pos = sb.indexOf("\\u")) > -1) { String tmp = sb.substring(pos, pos + 6); sb.replace(pos, pos + 6, Character.toString((char) Integer.parseInt(tmp.substring(2), 16))); } s = sb.toString(); return s; } }
/** * Replace value occurances in a String with another value. * * @param string * The original String. * @param repl * The text to replace * @param with * The new text bit * @return The resulting string with the text pieces replaced. */ public static final String replace( String string, String repl, String with ) { StringBuffer str = new StringBuffer( string ); for ( int i = str.length() - 1; i >= 0; i-- ) { if ( str.substring( i ).startsWith( repl ) ) { str.delete( i, i + repl.length() ); str.insert( i, with ); } } return str.toString(); }
@Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node.isTextual()) { return node.textValue(); } else if (node.isObject()) { JsonNode allNode = node.get("__all__"); if (allNode != null && allNode.isArray()) { StringBuffer buf = new StringBuffer(); for (JsonNode msgNode : allNode) { buf.append(msgNode.textValue()); buf.append(","); } return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString(); } return node.toString(); } return null; } }
@Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node.isTextual()) { return node.textValue(); } else if (node.isObject()) { JsonNode allNode = node.get("__all__"); if (allNode != null && allNode.isArray()) { StringBuffer buf = new StringBuffer(); for (JsonNode msgNode : allNode) { buf.append(msgNode.textValue()); buf.append(","); } return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString(); } return node.toString(); } return null; } }
private String getTestOutput(HttpServletRequest req, HttpServletResponse resp) { synchronized (executor) { if (testRunner != null) { resp.setContentType("text"); return testRunner.getOutput(); } resp.setContentType("text/html"); int urlUriLenDiff = req.getRequestURL().length() - req.getRequestURI().length(); String link = req.getRequestURL().substring(0, urlUriLenDiff); return "Test hasn't been started yet. Go to <a href='" + link + "'>" + link + "</a> to start a new test"; } }
public String getStringAt(Cell cell, int length){ int x = cell.x; int y = cell.y; if(x > getWidth() - 1 || y > getHeight() - 1 || x < 0 || y < 0) return null; return rows.get(y).substring(x, x + length); }
private String extractSessionId() { final int prefix = getRequestURL().indexOf(URL_SESSION_IDENTIFIER); if (prefix != -1) { final int start = prefix + URL_SESSION_IDENTIFIER.length(); int suffix = getRequestURL().indexOf("?", start); if (suffix < 0) { suffix = getRequestURL().indexOf("#", start); } if (suffix <= prefix) { return getRequestURL().substring(start); } return getRequestURL().substring(start, suffix); } return null; } }
/** * Append StringBuffer * * @param sb StringBuffer to append. * @return Reference to this object. */ public CircularStringBuilder append(StringBuffer sb) { if (sb == null) return appendNull(); int len = sb.length(); if (len < value.length) append(sb.toString()); else { skipped += len - value.length; append(sb.substring(len - value.length)); } return this; }
/** * get the next element. * @return the next element. * @throws NoSuchElementException if there is no more. */ @Override public Object nextElement() throws NoSuchElementException { if (!hasMoreElements()) { throw new NoSuchElementException("OneLiner"); } BufferLine tmpLine = new BufferLine(line.toString(), eolStr.substring(0)); nextLine(); return tmpLine; }
@Override protected void onBindData(final EasyRVHolder holder, final int position, final BooksByTag.TagBook item) { StringBuffer sbTags = new StringBuffer(); for (String tag : item.tags) { if (!TextUtils.isEmpty(tag)) { sbTags.append(tag); sbTags.append(" | "); } } holder.setRoundImageUrl(R.id.ivBookCover, Constant.IMG_BASE_URL + item.cover, R.drawable.cover_default) .setText(R.id.tvBookListTitle, item.title) .setText(R.id.tvShortIntro, item.shortIntro) .setText(R.id.tvTags, (item.tags.size() == 0 ? "" : sbTags.substring(0, sbTags .lastIndexOf(" | ")))); holder.setOnItemViewClickListener(new View.OnClickListener() { @Override public void onClick(View v) { itemClickListener.onItemClick(holder.getItemView(), position, item); } }); } }