Tabnine Logo
String.offsetByCodePoints
Code IndexAdd Tabnine to your IDE (free)

How to use
offsetByCodePoints
method
in
java.lang.String

Best Java code snippets using java.lang.String.offsetByCodePoints (Showing top 20 results out of 918)

origin: wildfly/wildfly

int getPrevIdx() {
  return str.offsetByCodePoints(idx, -1);
}
origin: vavr-io/vavr

/**
 * Returns the index within this {@code CharSeq} that is
 * offset from the given {@code index} by
 * {@code codePointOffset} code points. Unpaired surrogates
 * within the text range given by {@code index} and
 * {@code codePointOffset} count as one code point each.
 *
 * @param index           the index to be offset
 * @param codePointOffset the offset in code points
 * @return the index within this {@code CharSeq}
 * @throws IndexOutOfBoundsException if {@code index}
 *                                   is negative or larger then the length of this
 *                                   {@code CharSeq}, or if {@code codePointOffset} is positive
 *                                   and the substring starting with {@code index} has fewer
 *                                   than {@code codePointOffset} code points,
 *                                   or if {@code codePointOffset} is negative and the substring
 *                                   before {@code index} has fewer than the absolute value
 *                                   of {@code codePointOffset} code points.
 */
public int offsetByCodePoints(int index, int codePointOffset) {
  return back.offsetByCodePoints(index, codePointOffset);
}
origin: wildfly/wildfly

int next() {
  final int idx = this.idx;
  try {
    return str.codePointAt(idx);
  } finally {
    this.idx = str.offsetByCodePoints(idx, 1);
  }
}
origin: wildfly/wildfly

IllegalArgumentException unexpectedCharacter() {
  return new IllegalArgumentException("Unexpected character at " + string.offsetByCodePoints(idx, -1));
}
origin: wildfly/wildfly

private static void appendSegment(final StringBuilder b, final String segment) {
  int cp;
  for (int i = 0; i < segment.length(); i = segment.offsetByCodePoints(i, 1)) {
    cp = segment.codePointAt(i);
    if (cp == '/' || cp == '\'' || cp == '"') {
      b.append('\\');
    }
    b.appendCodePoint(cp);
  }
}
origin: facebook/litho

private static String getBasePropMatcherName(final MethodParamModel prop, final String suffix) {
 final String name = prop.getName();
 final int fst = Character.toUpperCase(name.codePointAt(0));
 return 'm'
   + String.copyValueOf(Character.toChars(fst))
   + name.substring(name.offsetByCodePoints(0, 1))
   + suffix;
}
origin: apache/geode

 protected static String capitalize(String name) {
  if (name == null || name.length() == 0)
   return name;
  int offset1 = name.offsetByCodePoints(0, 1);
  return name.substring(0, offset1).toUpperCase() + name.substring(offset1);
 }
}
origin: neo4j/neo4j

@Override
public TextValue substring( int start, int length )
{
  int s = Math.min( start, length() );
  int e = Math.min( s + length, length() );
  int codePointStart = value.offsetByCodePoints( 0, s );
  int codePointEnd = value.offsetByCodePoints( 0, e );
  return Values.stringValue( value.substring( codePointStart, codePointEnd ) );
}
origin: wildfly/wildfly

public int next() {
  if (! hasNext()) throw new NoSuchElementException();
  try {
    offset++;
    return string.codePointAt(idx + offs);
  } finally {
    idx = string.offsetByCodePoints(idx + offs, 1) - offs;
  }
}
origin: wildfly/wildfly

public int prev() {
  if (! hasPrev()) throw new NoSuchElementException();
  idx = string.offsetByCodePoints(idx + offs, -1) - offs;
  offset--;
  return string.codePointAt(idx + offs);
}
origin: k9mail/k-9

private static String importStringFromIphone(String str) {
  StringBuilder buff = new StringBuilder(str.length());
  for (int i = 0; i < str.length(); i = str.offsetByCodePoints(i, 1)) {
    int codePoint = str.codePointAt(i);
    buff.appendCodePoint(importCodePointFromIphone(codePoint));
  }
  return buff.toString();
}
origin: wildfly/wildfly

public int previous() {
  if (! hasPrevious()) throw new NoSuchElementException();
  idx = string.offsetByCodePoints(idx + offs, - 1) - offs;
  offset--;
  return string.codePointAt(idx + offs);
}
origin: wildfly/wildfly

public int next() {
  if (! hasNext()) throw new NoSuchElementException();
  try {
    offset++;
    return string.codePointAt(idx + offs);
  } finally {
    idx = string.offsetByCodePoints(idx + offs, 1) - offs;
  }
}
origin: wildfly/wildfly

int prev() {
  final int idx = this.idx;
  try {
    return str.codePointBefore(idx);
  } finally {
    this.idx = str.offsetByCodePoints(idx, -1);
  }
}
origin: scouter-project/scouter

/**
 * Checks an identifier.
 *
 * @param signature a string containing the signature that must be checked.
 * @param startPos index of first character to be checked.
 * @return the index of the first character after the checked part.
 */
private static int checkSignatureIdentifier(final String signature, final int startPos) {
 int pos = startPos;
 while (pos < signature.length() && ".;[/<>:".indexOf(signature.codePointAt(pos)) == -1) {
  pos = signature.offsetByCodePoints(pos, 1);
 }
 if (pos == startPos) {
  throw new IllegalArgumentException(signature + ": identifier expected at index " + startPos);
 }
 return pos;
}
origin: apache/hive

public static String enforceMaxLength(String val, int maxLength) {
 if (val == null) {
  return null;
 }
 String value = val;
 if (maxLength > 0) {
  int valLength = val.codePointCount(0, val.length());
  if (valLength > maxLength) {
   // Truncate the excess chars to fit the character length.
   // Also make sure we take supplementary chars into account.
   value = val.substring(0, val.offsetByCodePoints(0, maxLength));
  }
 }
 return value;
}
origin: wildfly/wildfly

@Override
public void encodePrintableString(final String str) {
  for (int i = 0; i < str.length(); i = str.offsetByCodePoints(i, 1)) {
    validatePrintableByte(str.codePointAt(i));
  }
  writeElement(PRINTABLE_STRING_TYPE, str.getBytes(StandardCharsets.US_ASCII));
}
origin: wildfly/wildfly

private static IllegalArgumentException invalidExpressionSyntax(final String string, final int index) {
  String msg = CommonMessages.msg.invalidExpressionSyntax(index);
  StringBuilder b = new StringBuilder(msg.length() + string.length() + string.length() + 5);
  b.append(msg);
  b.append('\n').append('\t').append(string);
  b.append('\n').append('\t');
  for (int i = 0; i < index; i = string.offsetByCodePoints(i, 1)) {
    final int cp = string.codePointAt(i);
    if (Character.isWhitespace(cp)) {
      b.append(cp);
    } else if (Character.isValidCodePoint(cp) && ! Character.isISOControl(cp)) {
      b.append(' ');
    }
  }
  b.append('^');
  return new IllegalArgumentException(b.toString());
}
origin: wildfly/wildfly

int next() {
  if (! hasNext()) throw unexpectedEnd();
  try {
    return string.codePointAt(idx);
  } finally {
    idx = string.offsetByCodePoints(idx, 1);
  }
}
origin: wildfly/wildfly

private Path pathFor(String name) {
  assert name.codePointCount(0, name.length()) > 0;
  String normalizedName = name;
  if (encoded) {
    normalizedName = Normalizer.normalize(name, Normalizer.Form.NFKC)
        .toLowerCase(Locale.ROOT)
        .replaceAll("[^a-z0-9]", "_");
  }
  Path path = root;
  int idx = 0;
  for (int level = 0; level < levels; level ++) {
    int newIdx = normalizedName.offsetByCodePoints(idx, 1);
    path = path.resolve(normalizedName.substring(idx, newIdx));
    idx = newIdx;
    if (idx == normalizedName.length()) {
      break;
    }
  }
  if (encoded) {
    String base32 = ByteIterator.ofBytes(new ByteStringBuilder().append(name).toArray())
        .base32Encode(Base32Alphabet.STANDARD, false).drainToString();
    name = normalizedName + "-" + base32;
  }
  return path.resolve(name + ".xml");
}
java.langStringoffsetByCodePoints

Javadoc

Returns the index within this String that is offset from the given index by codePointOffset code points. Unpaired surrogates within the text range given by index and codePointOffset count as one code point each.

Popular methods of String

  • equals
  • length
    Returns the number of characters in this string.
  • substring
    Returns a string containing a subsequence of characters from this string. The returned string shares
  • startsWith
    Compares the specified string to this string, starting at the specified offset, to determine if the
  • format
    Returns a formatted string, using the supplied format and arguments, localized to the given locale.
  • split
    Splits this string using the supplied regularExpression. See Pattern#split(CharSequence,int) for an
  • trim
  • valueOf
    Creates a new string containing the specified characters in the character array. Modifying the chara
  • indexOf
  • endsWith
    Compares the specified string to this string to determine if the specified string is a suffix.
  • toLowerCase
    Converts this string to lower case, using the rules of locale.Most case mappings are unaffected by t
  • contains
    Determines if this String contains the sequence of characters in the CharSequence passed.
  • toLowerCase,
  • contains,
  • getBytes,
  • <init>,
  • equalsIgnoreCase,
  • replace,
  • isEmpty,
  • charAt,
  • hashCode,
  • lastIndexOf

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top plugins for WebStorm
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