Trims the builder by removing characters less than or equal to a space
from the beginning and end.

@return this, to enable chaining
966914
public StrBuilder trim() {
        if (size == 0) {
            return this;
        }
        int len = size;
        final char[] buf = buffer;
        int pos = 0;
        while (pos < len && buf[pos] <= ' ') {
            pos++;
        }
        while (pos < len && buf[len - 1] <= ' ') {
            len--;
        }
        if (len < size) {
            delete(len, size);
        }
        if (pos > 0) {
            delete(0, pos);
        }
        return this;
    }
1270543
private static String trimSpaceAtStart(final String temp, final String termName) {
        if (termName != null && termName.charAt(termName.length() - 1) == ' ') {
            if (temp.charAt(0) == ' ') {
                return temp.substring(1);
            }
        }
        return temp;
    }
684790
private void trimToSize() {
		if (wordsInUse != words.length) {
			words = Arrays.copyOf(words, wordsInUse);
			checkInvariants();
		}
	}
611333
public ChainedProperty<S> trim() {
        if (getChainCount() == 0) {
            throw new IllegalStateException();
        }
        if (getChainCount() == 1) {
            if (!isOuterJoin(0)) {
                return get(mPrime);
            } else {
                return get(mPrime, null, new boolean[] {true});
            }
        }
        StorableProperty<?>[] newChain = new StorableProperty[getChainCount() - 1];
        System.arraycopy(mChain, 0, newChain, 0, newChain.length);

        boolean[] newOuterJoin = mOuterJoin;

        if (newOuterJoin != null && newOuterJoin.length > (newChain.length + 1)) {
            newOuterJoin = new boolean[newChain.length + 1];
            System.arraycopy(mOuterJoin, 0, newOuterJoin, 0, newChain.length + 1);
        }

        return get(mPrime, newChain, newOuterJoin);
    }
641710
public static String trimUrl(final StringBuilder s) {
        final String s1 = trimBy(s, 4, 1).trim();
        if (s1.length() == 0) {
            return s1;
        }

        final int end = s1.length() - 1;
        final char c0 = s1.charAt(0);
        if ((c0 == '"' && s1.charAt(end) == '"')
            || (c0 == '\'' && s1.charAt(end) == '\'')) {
            return s1.substring(1, end);
        }

        return s1;
    }
168399
private static String trimAtNull(final String s)
	{
		final int end = s.indexOf((char) 0);
		return end > -1 ? s.substring(0, end) : s;
	}
515694
public static String trimLeadingCharacter(String str, char leadingCharacter) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder buf = new StringBuilder(str);
        while (buf.length() > 0 && buf.charAt(0) == leadingCharacter) {
            buf.deleteCharAt(0);
        }
        return buf.toString();
    }
494003
private StringBuilder spacer(final int spaces) {
        final StringBuilder sb = new StringBuilder();
        for (int i = 0; i < spaces; i++) {
            sb.append(" ");
        }
        return sb;
    }
1330258
public final String trimFrom(String s) {
    int first;
    int last;

    // removes leading matches
    for (first = 0; first < s.length(); ) {
      final int codePoint = s.codePointAt(first);
      if (!matches(codePoint)) {
        break;
      }
      first += Character.charCount(codePoint);
    }

    //remove trailing matches
    for (last = s.length() - 1; last >= first; --last) {
      if (Character.isLowSurrogate(s.charAt(last))) {
        --last;
      }
      if (!matches(s.codePointAt(last))) {
        break;
      }
    }

    return s.substring(first, last + 1);
  }
792145
private String trimLeadingSlashIfNeeded(String rawName) {
        if (rawName != null && rawName.startsWith("/")) {
            return rawName.substring(1);
        }
        return rawName;
    }
387036
protected String trimSlash(@NonNull String target) {
        target = trimStartSlash(target);
        target = trimEndSlash(target);
        return target;
    }
1278426
public static Slice trim(Slice utf8, int[] whiteSpaceCodePoints)
    {
        int start = firstNonMatchPosition(utf8, whiteSpaceCodePoints);
        int end = lastNonMatchPosition(utf8, start, whiteSpaceCodePoints);
        return utf8.slice(start, end - start);
    }
938227
public function normalize() {
		// remove whitespace from the beginning
		$this->str = ltrim($this->str);

		// ensure that there is exactly one forward slash at the beginning
		$this->str = '/'.ltrim($this->str, '/');

		// remove whitespace from the end
		$this->str = rtrim($this->str);


		return $this;
	}
1103643
public void trim() {
    	try
    	{
    	//cut white spaces from the head
		while (len>0 && chars[pos] == ' ') {
			pos++;
			len--;
		}
    	
        //cut from the end
        while (len>0 && (chars[pos + len - 1] == ' ' || chars[pos + len - 1] == '\n' || chars[pos + len - 1] == '\r')) {
            len--;
        }
    	}
    	catch(Exception e)
    	{
    		System.out.println("len:" + len + ",pos:" + pos);
    	}
    }
624930
public static String trim(String value) {
    int start;
    int end;
    final int lengthMinusOne = value.length() - 1;
    for (start = 0; start <= lengthMinusOne; ++start) {
      if (!isSpace(value.charAt(start))) {
        break;
      }
    }
    for (end = lengthMinusOne; end >= start; --end) {
      if (!isSpace(value.charAt(end))) {
        break;
      }
    }
    if (start == 0 && end == lengthMinusOne) {
      return value;
    }
    if (start > lengthMinusOne) {
      return "";
    }
    return value.substring(start, end + 1);
  }
1236614
@Nullable
  @CheckReturnValue
  public static String trimLeadingWhitespaces (@Nullable final String s)
  {
    final int n = getLeadingWhitespaceCount (s);
    return n == 0 ? s : s.substring (n, s.length ());
  }
758278
public static String trim(String xml) {
        String content = removeDeclaration(xml);
        return trimElements(content);
    }