Tabnine Logo
StringBuilder.indexOf
Code IndexAdd Tabnine to your IDE (free)

How to use
indexOf
method
in
java.lang.StringBuilder

Best Java code snippets using java.lang.StringBuilder.indexOf (Showing top 20 results out of 7,272)

origin: pockethub/PocketHub

private static StringBuilder strip(final StringBuilder input,
                  final String prefix, final String suffix) {
  int start = input.indexOf(prefix);
  while (start != -1) {
    int end = input.indexOf(suffix, start + prefix.length());
    if (end == -1) {
      end = input.length();
    }
    input.delete(start, end + suffix.length());
    start = input.indexOf(prefix, start);
  }
  return input;
}
origin: pockethub/PocketHub

private static boolean replace(final StringBuilder input,
                final String from, final String to) {
  int start = input.indexOf(from);
  if (start == -1) {
    return false;
  }
  final int fromLength = from.length();
  final int toLength = to.length();
  while (start != -1) {
    input.replace(start, start + fromLength, to);
    start = input.indexOf(from, start + toLength);
  }
  return true;
}
origin: stackoverflow.com

 public static void replaceAll(StringBuilder builder, String from, String to)
{
  int index = builder.indexOf(from);
  while (index != -1)
  {
    builder.replace(index, index + from.length(), to);
    index += to.length(); // Move to the end of the replacement
    index = builder.indexOf(from, index);
  }
}
origin: h2oai/h2o-2

static private void subsub( StringBuilder sb, String s1, String s2 ) {
 int idx;
 while( (idx=sb.indexOf(s1)) != -1 ) sb.replace(idx,idx+2,s2);
}
origin: hibernate/hibernate-orm

private static String getJavaAttributeNameFromXMLOne(String attributeName) {
  StringBuilder annotationAttributeName = new StringBuilder( attributeName );
  int index = annotationAttributeName.indexOf( WORD_SEPARATOR );
  while ( index != -1 ) {
    annotationAttributeName.deleteCharAt( index );
    annotationAttributeName.setCharAt(
        index, Character.toUpperCase( annotationAttributeName.charAt( index ) )
    );
    index = annotationAttributeName.indexOf( WORD_SEPARATOR );
  }
  return annotationAttributeName.toString();
}
origin: lets-blade/blade

private static String takeUntilDotOrEnd(StringBuilder buff) {
  final int firstPointIdx = buff.indexOf(".");
  String    result;
  if (-1 == firstPointIdx) {
    result = buff.toString();
    buff.setLength(0);
  } else {
    result = buff.substring(0, firstPointIdx);
    buff.delete(0, firstPointIdx + 1);
  }
  return result;
}
origin: lets-blade/blade

private static String takeUntilDotOrEnd(StringBuilder buff) {
  final int firstPointIdx = buff.indexOf(".");
  String    result;
  if (-1 == firstPointIdx) {
    result = buff.toString();
    buff.setLength(0);
  } else {
    result = buff.substring(0, firstPointIdx);
    buff.delete(0, firstPointIdx + 1);
  }
  return result;
}
origin: aws/aws-sdk-java

public static String replace( String originalString, String partToMatch, String replacement ) {
  StringBuilder buffer = new StringBuilder( originalString.length() );
  buffer.append( originalString );
  int indexOf = buffer.indexOf( partToMatch );
  while (indexOf != -1) {
    buffer = buffer.replace(indexOf, indexOf + partToMatch.length(), replacement);
    indexOf = buffer.indexOf(partToMatch, indexOf + replacement.length());
  }
  return buffer.toString();
}
origin: redisson/redisson

public Builder(String path,  boolean encodePath, String encoding) {
  this.encoding = encoding;
  url = new StringBuilder();
  if (encodePath) {
    url.append(encodeUri(path, encoding));
  } else {
    url.append(path);
  }
  this.hasParams = url.indexOf(StringPool.QUESTION_MARK) != -1;
}
origin: spring-projects/spring-framework

/**
 * Append the query string of the current request to the target redirect URL.
 * @param targetUrl the StringBuilder to append the properties to
 * @param request the current request
 * @since 4.1
 */
protected void appendCurrentQueryParams(StringBuilder targetUrl, HttpServletRequest request) {
  String query = request.getQueryString();
  if (StringUtils.hasText(query)) {
    // Extract anchor fragment, if any.
    String fragment = null;
    int anchorIndex = targetUrl.indexOf("#");
    if (anchorIndex > -1) {
      fragment = targetUrl.substring(anchorIndex);
      targetUrl.delete(anchorIndex, targetUrl.length());
    }
    if (targetUrl.toString().indexOf('?') < 0) {
      targetUrl.append('?').append(query);
    }
    else {
      targetUrl.append('&').append(query);
    }
    // Append anchor fragment, if any, to end of URL.
    if (fragment != null) {
      targetUrl.append(fragment);
    }
  }
}
origin: spring-projects/spring-framework

int searchIndex = 0;
while (searchIndex != -1) {
  int keyStart = sb.indexOf(PropertyAccessor.PROPERTY_KEY_PREFIX, searchIndex);
  searchIndex = -1;
  if (keyStart != -1) {
    int keyEnd = sb.indexOf(
        PropertyAccessor.PROPERTY_KEY_SUFFIX, keyStart + PropertyAccessor.PROPERTY_KEY_PREFIX.length());
    if (keyEnd != -1) {
origin: aws/aws-sdk-java

protected static String replaceChar(String value, String termToFind, String replacementTerm) {
  StringBuilder buffer = new StringBuilder(value);
  int searchIndex = 0;
  while (searchIndex < buffer.length()) {
    searchIndex = buffer.indexOf(termToFind, searchIndex);
    if (searchIndex == -1) {
      break;
    } else {
      buffer.replace(searchIndex, searchIndex + termToFind.length(), replacementTerm);
      searchIndex += replacementTerm.length();
    }
  }
  return buffer.toString();
}
origin: amitshekhariitbhu/Android-Debug-Database

private String removeComments(final String sql) {
  StringBuilder sb = new StringBuilder(sql);
  int nextCommentPosition = sb.indexOf(TOKEN_SINGLE_LINE_COMMENT);
  while (nextCommentPosition > -1) {
    int end = indexOfRegex(TOKEN_NEWLINE, sb.substring(nextCommentPosition));
    if (end == -1) {
      return sb.substring(0, nextCommentPosition);
    } else {
      sb.replace(nextCommentPosition, end + nextCommentPosition, "");
    }
    nextCommentPosition = sb.indexOf(TOKEN_SINGLE_LINE_COMMENT);
  }
  return sb.toString();
}
origin: oblac/jodd

public Builder(final String path, final boolean encodePath, final String encoding) {
  this.encoding = encoding;
  url = new StringBuilder();
  if (encodePath) {
    url.append(encodeUri(path, encoding));
  } else {
    url.append(path);
  }
  this.hasParams = url.indexOf(StringPool.QUESTION_MARK) != -1;
}
origin: MovingBlocks/Terasology

  private static String getCheckboxNameFor(StandardModuleExtension standardModuleExtension) {
    StringBuilder builder = new StringBuilder(standardModuleExtension.getKey());
    final int prefixIndex = builder.indexOf("is");

    if (prefixIndex == 0) {
      builder.delete(prefixIndex, prefixIndex + 2);
      builder.setCharAt(0, Character.toLowerCase(builder.charAt(0)));
    }

    return builder.append("Checkbox").toString();
  }
}
origin: immutables/immutables

Other replace(String search, String replacement) {
 StringBuilder builder = new StringBuilder(this);
 int index = builder.indexOf(search);
 if (index < 0) {
  return this;
 }
 builder.replace(index, index + search.length(), replacement);
 return new Other(builder.toString());
}
origin: spring-projects/spring-framework

int anchorIndex = targetUrl.indexOf("#");
if (anchorIndex > -1) {
  fragment = targetUrl.substring(anchorIndex);
origin: spring-projects/spring-framework

url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1)));
origin: ReactiveX/RxJava

int index = 0;
for (;;) {
  int idx = sourceCode.indexOf(annotation, index);
    int k = sourceCode.indexOf(inDoc, j);
      int ll = sourceCode.indexOf("You specify", k);
      int lm = sourceCode.indexOf("This operator", k);
      if ((ll < 0 || ll > idx) && (lm < 0 || lm > idx)) {
        int n = sourceCode.indexOf("{@code ", k);
        int endDD = sourceCode.indexOf("</dd>", k);
          int m = sourceCode.indexOf("}", n);
            int q = sourceCode.indexOf("@SuppressWarnings({", idx);
            int o = sourceCode.indexOf("{", idx);
              o = sourceCode.indexOf("{", q + 20);
              int p = sourceCode.indexOf(" " + mname + "(", idx);
origin: ReactiveX/RxJava

static final void scanFor(StringBuilder sourceCode, String annotation, String inDoc,
    StringBuilder e, String baseClassName) {
  int index = 0;
  for (;;) {
    int idx = sourceCode.indexOf(annotation, index);
    if (idx < 0) {
      break;
    }
    int j = sourceCode.lastIndexOf("/**", idx);
    // see if the last /** is not before the index (last time the annotation was found
    // indicating an uncommented method like subscribe()
    if (j > index) {
      int k = sourceCode.indexOf(inDoc, j);
      if (k < 0 || k > idx) {
        // when printed on the console, IDEs will create a clickable link to help navigate to the offending point
        e.append("java.lang.RuntimeException: missing ").append(inDoc).append(" section\r\n")
        ;
        int lc = lineNumber(sourceCode, idx);
        e.append(" at io.reactivex.").append(baseClassName)
        .append(" (").append(baseClassName).append(".java:")
        .append(lc).append(")").append("\r\n\r\n");
      }
    }
    index = idx + annotation.length();
  }
}
java.langStringBuilderindexOf

Popular methods of StringBuilder

  • append
  • toString
  • <init>
    Constructs a string builder initialized to the contents of the specified string. The initial capacit
  • length
  • setLength
  • charAt
  • deleteCharAt
  • insert
  • substring
  • delete
  • replace
  • setCharAt
  • replace,
  • setCharAt,
  • lastIndexOf,
  • reverse,
  • appendCodePoint,
  • getChars,
  • subSequence,
  • ensureCapacity,
  • trimToSize

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Notification (javax.management)
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JOptionPane (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now