Java StringBuilder.subSequence Examples

Java StringBuilder.subSequence - 17 examples found. These are the top rated real world Java examples of StringBuilder.subSequence extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public String serialize() {
   StringBuilder builder = new StringBuilder();
   if (getItems() == null) {
     return "";
   }
   for (KeyValueLineModel keyValueLineModel : (List<KeyValueLineModel>) getItems()) {
     String key = keyValueLineModel.getKeys().getSelectedItem();
     if (!isKeyValid(key)) {
       continue;
     }
     builder.append(key);
     builder.append(KEY_VALUE_DELIMETER);
     if (keyValueLineModel.getValue().getIsAvailable()) {
       builder.append(keyValueLineModel.getValue().getEntity());
     } else if (keyValueLineModel.getValues().getIsAvailable()) {
       builder.append(keyValueLineModel.getValues().getSelectedItem());
     }
     builder.append(PROPERTIES_DELIMETER);
   }
   // remove the last delimiter
   if (builder.toString().endsWith(PROPERTIES_DELIMETER)) {
     return builder.subSequence(0, builder.length() - PROPERTIES_DELIMETER.length()).toString();
   }
   return builder.toString();
 }
  @Nullable
  private static String trimToValue(@Nullable StringBuilder output) {
    if (output == null) {
      return null;
    }
    int pos = output.lastIndexOf("  ");
    int pos2 = output.lastIndexOf("\t");
    pos = Math.max(pos, pos2);
    if (pos == -1) {
      return null;
    }

    output.delete(0, pos + 1);
    String blackList = "\r\n \"";
    int startPos = 0;
    int endPos = output.length() - 1;
    while (true) {
      if (startPos >= endPos) {
        return null;
      }
      if (blackList.indexOf(output.charAt(startPos)) != -1) {
        startPos++;
      } else {
        break;
      }
    }
    while (true) {
      if (blackList.indexOf(output.charAt(endPos)) != -1) {
        endPos--;
      } else {
        break;
      }
    }
    return output.subSequence(startPos, endPos + 1).toString();
  }
 private String toClassString(Collection<?> providers) {
   StringBuilder sb = new StringBuilder();
   for (Object provider : providers) {
     sb.append(provider.getClass().getName()).append(", ");
   }
   return sb.subSequence(0, sb.length() - 2).toString();
 }
 private <T> String toClassString(Collection<Class<? extends T>> providers) {
   StringBuilder sb = new StringBuilder();
   for (Class<?> provider : providers) {
     sb.append(provider.getName()).append(", ");
   }
   return sb.subSequence(0, sb.length() - 2).toString();
 }
Example #5
0
    @Override
    public void onTextAvailable(ProcessEvent event, Key outputType) {
      String text = event.getText();
      if (outputType == ProcessOutputTypes.STDERR) {
        output.append(text);

        // We loop until the state stabilizes
        State lastState;
        do {
          lastState = state;
          switch (state) {
            case WAITING:
              {
                Matcher matcher = matcher(DIAGNOSTIC_PATTERN);
                if (find(matcher)) {
                  currentCompilerMessage = new CompilerMessage();
                  currentCompilerMessage.setMessageCategoryFromString(matcher.group(1));
                  state = State.ATTRIBUTES;
                }
                break;
              }
            case ATTRIBUTES:
              {
                Matcher matcher = matcher(ATTRIBUTE_PATTERN);
                int indexDelta = 0;
                while (matcher.find()) {
                  handleSkippedOutput(
                      output.subSequence(
                          firstUnprocessedIndex + indexDelta,
                          firstUnprocessedIndex + matcher.start()));
                  currentCompilerMessage.setAttributeFromStrings(
                      matcher.group(1), matcher.group(2));
                  indexDelta = matcher.end();
                }
                firstUnprocessedIndex += indexDelta;

                Matcher endMatcher = matcher(OPEN_TAG_END_PATTERN);
                if (find(endMatcher)) {
                  state = State.MESSAGE;
                }
                break;
              }
            case MESSAGE:
              {
                Matcher matcher = matcher(MESSAGE_PATTERN);
                if (find(matcher)) {
                  currentCompilerMessage.setMessage(matcher.group(1));
                  currentCompilerMessage.reportTo(compileContext);
                  state = State.WAITING;
                }
                break;
              }
          }
        } while (state != lastState);

      } else {
        compileContext.addMessage(INFORMATION, text, "", -1, -1);
      }
    }
    public PathBuilder repeat(int count) {
      int pos = m_sb.length();

      for (int i = 0; i < count; i++) {
        m_sb.append(m_sb.subSequence(m_marker, pos));
      }

      return this;
    }