Determines the number of consecutive characters that are encodable using numeric compaction.

@param msg      the message
@param startpos the start position within the message
@return the requested character count
497102
public static int determineConsecutiveDigitCount(CharSequence msg, int startpos) {
    int count = 0;
    int len = msg.length();
    int idx = startpos;
    if (idx < len) {
      char ch = msg.charAt(idx);
      while (isDigit(ch) && idx < len) {
        count++;
        idx++;
        if (idx < len) {
          ch = msg.charAt(idx);
        }
      }
    }
    return count;
  }
30879
public static int writeAsciiString(byte[] array, int startPos, String attribute) {
        Preconditions.checkArgument(isAsciiString(attribute));
        if (attribute.length()==0) {
            array[startPos++] = (byte)0x80;
        } else {
            for (int i = 0; i < attribute.length(); i++) {
                int c = attribute.charAt(i);
                assert c <= 127;
                byte b = (byte)c;
                if (i+1==attribute.length()) b |= 0x80; //End marker
                array[startPos++]=b;
            }
        }
        return startPos;
    }
1228050
function start (msg) {
    const msgLength = strip(msg).length,
          diff      = lineWidth - 4 - msgLength;
    write(msg + Array(diff + 1).join(' '));
  }
26618
private List<HashMap<String, String>> createSegmentListFromMessage(String msg) {
        List<HashMap<String, String>> segmentList = new ArrayList<HashMap<String, String>>();

        boolean quoteNext = false;
        int startPosi = 0;

        for (int i = 0; i < msg.length(); i++) {
            char ch = msg.charAt(i);

            if (!quoteNext && ch == '@') {
                // skip binary values
                int idx = msg.indexOf("@", i + 1);
                String len_st = msg.substring(i + 1, idx);
                i += Integer.parseInt(len_st) + 1 + len_st.length();
            } else if (!quoteNext && ch == '\'') {
                // segment-ende gefunden
                HashMap<String, String> segmentInfo = new HashMap<>();
                segmentInfo.put("code", msg.substring(startPosi, msg.indexOf(":", startPosi)));
                segmentInfo.put("start", Integer.toString(startPosi));
                segmentInfo.put("length", Integer.toString(i - startPosi + 1));

                segmentList.add(segmentInfo);
                startPosi = i + 1;
            }
            quoteNext = !quoteNext && ch == '?';
        }

        return segmentList;
    }
1098885
protected static String getStartedWord(String str, int pos){
		assert(pos < str.length() && pos >= 0);

		if(	posIsAtWordStart(str, pos) ){
			int nextSpace = findNextNonLetterOrDigit(str, pos);
			if(nextSpace == -1){
				nextSpace = str.length();
			}
			
			return str.substring(pos, nextSpace);
		}
		return null;
	}
265209
public int getGetCursorIndex(SIMPMessage msg)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getGetCursorIndex");
    
    // The zeroth index is reserved for non-classified messages
    int classPos = 0;
    synchronized(classifications)
    {
      if(classifications.getNumberOfClasses()>0)
      {
        // Need to get the classification out of the message
        String keyClassification = msg.getMessageControlClassification(true);        

        // In the special case where the weighting for the classification in the
        // message was zero, we use the Default cursor
        if(keyClassification != null && classifications.getWeight(keyClassification) > 0)
          // Get the position of the classification
          classPos = classifications.getPosition(keyClassification);
      }
    }
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getGetCursorIndex", classPos);
    
    return classPos;
  }
1098084
public synchronized List<Message> getFromRange(final int startPosition, final int endPosition) {
        // cache this here, so all parts of the method operate on the same data
        final int firstMessageId = this.getFirstPosition();
        // input validation
        if ((startPosition < MessageStore.INITIAL_MESSAGE_POSITION)
                || (endPosition < MessageStore.INITIAL_MESSAGE_POSITION)) {
            throw new IllegalArgumentException("Message position cannot be negative.");
        } else if ((firstMessageId >= MessageStore.INITIAL_MESSAGE_POSITION) && (startPosition < firstMessageId)) {
            throw new IllegalArgumentException("Message at position " + startPosition
                    + " had already been discarded. First available message position is " + firstMessageId + ".");
        } else if (endPosition <= startPosition) {
            throw new IllegalArgumentException("Ending position must be larger than starting message position.");
        } else if (endPosition > this.getNextPosition()) {
            throw new IllegalArgumentException("Range end cannot be greater than the next message position.");
        }
        // and properly synchronized range retrieval
        return Collections.unmodifiableList(new LinkedList<>(this.store.subMap(startPosition, endPosition)
                .values()));
    }
1008019
@Nonnegative
  public static int getLeadingWhitespaceCount (@Nullable final String s)
  {
    int ret = 0;
    if (s != null)
    {
      final int nMax = s.length ();
      while (ret < nMax && Character.isWhitespace (s.charAt (ret)))
        ++ret;
    }
    return ret;
  }
189598
public static int w(String msg) {
        // This is a quick check to avoid the expensive stack trace reflection.
        if (!activated) {
            return 0;
        }
        String caller = LogHelper.getCaller();
        if (caller != null) {
            return w(caller, msg);
        }
        return 0;
    }
539272
@Deprecated
    public static int getSingleCodePoint(CharSequence s) {
        int length = s.length();
        if (length < 1 || length > 2) {
            return Integer.MAX_VALUE;
        }
        int result = Character.codePointAt(s, 0);
        return (result < 0x10000) == (length == 1) ? result : Integer.MAX_VALUE;
    }
340260
@Nonnegative
  public static int getLeadingCharCount (@Nullable final String s, final char c)
  {
    int ret = 0;
    if (s != null)
    {
      final int nMax = s.length ();
      while (ret < nMax && s.charAt (ret) == c)
        ++ret;
    }
    return ret;
  }
1203308
static int nextPrintfTerm(String message, int pos) throws ParseException {
    while (pos < message.length()) {
      if (message.charAt(pos++) != '%') {
        continue;
      }
      if (pos < message.length()) {
        char c = message.charAt(pos);
        if (c == '%' || c == 'n') {
          // We encountered '%%' or '%n', so keep going (these will be unescaped later).
          pos += 1;
          continue;
        }
        // We were pointing at the character after the '%', so adjust back by one.
        return pos - 1;
      }
      // We ran off the end while looking for the character after the first '%'.
      throw ParseException.withStartPosition("trailing unquoted '%' character", message, pos - 1);
    }
    // We never found another unescaped '%'.
    return -1;
  }
472963
@Override
    public boolean hasNext(int startPosition, int contentLength) {
        char ch = nextGoodChar();
        if (ch == ',') return true;
        if (ch == '}' || ch == ']' || ch == 0) return false;
        backChar(ch); // { [ 交由 readObjectB 或 readMapB 或 readArrayB 读取
        return true;
    }
582750
public static int getTrimmedLength(CharSequence s) {
        int len = s.length();

        int start = 0;
        while (start < len && s.charAt(start) <= ' ') {
            start++;
        }

        int end = len;
        while (end > start && s.charAt(end - 1) <= ' ') {
            end--;
        }

        return end - start;
    }
867666
static void unescapePrintf(StringBuilder out, String message, int start, int end) {
    int pos = start;
    while (pos < end) {
      if (message.charAt(pos++) != '%') {
        continue;
      }
      if (pos == end) {
        // Ignore unexpected trailing '%'.
        break;
      }
      char chr = message.charAt(pos);
      if (chr == '%') {
        // Append the section up to and including the first '%'.
        out.append(message, start, pos);
      } else if (chr == 'n') {
        // %n encountered, rewind one position to not emit leading '%' and emit newline.
        out.append(message, start, pos - 1);
        out.append(SYSTEM_NEWLINE);
      } else {
        // A single unescaped '%' is ignored and left in the output as-is.
        continue;
      }
      // Increment the position and reset the start point after the last processed character.
      start = ++pos;
    }
    // Append the last section (if it's non empty).
    if (start < end) {
      out.append(message, start, end);
    }
  }
1300223
public static int getWhiteSpaceOrCommentLineStartBefore( String script, int start )
  {
    int startLine = getLineStart( script, start );
    if( startLine > 0 )
    {
      int nextLineEnd = startLine - 1;
      int previousLineStart = getLineStart( script, nextLineEnd );
      String line = script.substring( previousLineStart, nextLineEnd );
      boolean whitespace = GosuStringUtil.isWhitespace( line ) || line.trim().startsWith( "//" );
      if( whitespace )
      {
        return previousLineStart;
      }
    }
    return -1;
  }
799108
public IoBuffer encodeFlexMessage(FlexMessage msg) {
        IoBuffer out = IoBuffer.allocate(1024);
        out.setAutoExpand(true);
        // Unknown byte, always 0?
        out.put((byte) 0);
        encodeCommand(out, msg);
        return out;
    }