bulids regular expression from prefix-tree {@code alt} into buffer {@code sb}.
@param alt prefix tree root.
@param sb StringBuffer to store regular expression.
495855
protected static void buildRegex(Node alt, StringBuilder sb) {
        String close = null;
        if (alt.cs != null) {
            // actually '!' always be the first character, because it is
            // always used along with '*'.
            for (int i = 0; i < alt.cs.length(); i++) {
                char c = alt.cs.charAt(i);
                if (c == '!') {
                    if (close != null)
                        throw new RuntimeException("more than one '!'");
                    sb.append("(?=");
                    close = ")";
                } else if (c == '*') {
                    sb.append("[-\\w]+");
                } else {
                    sb.append(c);
                }
            }
        }
        if (alt.branches != null) {
            // alt.branches.size() should always be > 1
            if (alt.branches.size() > 1) {
                sb.append("(?:");
            }
            String sep = "";
            for (Node alt1 : alt.branches) {
                sb.append(sep); sep = "|";
                buildRegex(alt1, sb);
            }
            if (alt.branches.size() > 1) {
                sb.append(")");
            }
        }
        if (close != null)
            sb.append(close);
    }
1170255
private String escapeText(StringBuilder sb, String text)
   {
      int length = text.length();
      char c;

      sb.setLength(0);

      for (int loop = 0; loop < length; loop++)
      {
         c = text.charAt(loop);

         switch (c)
         {
            case '<':
            {
               sb.append("&lt;");
               break;
            }

            case '>':
            {
               sb.append("&gt;");
               break;
            }

            case '&':
            {
               sb.append("&amp;");
               break;
            }

            default:
            {
               if (validXMLCharacter(c))
               {
                  if (c > 127)
                  {
                     sb.append("&#" + (int) c + ";");
                  }
                  else
                  {
                     sb.append(c);
                  }
               }

               break;
            }
         }
      }

      return (sb.toString());
   }
791694
private void encode(long bits, StringBuilder sb) {
        if (bits < 0) {
            sb.append(characters[(int) ((bits % base + base) % base)]);

            bits /= -base;
        }

        while (bits > 0) {
            sb.append(characters[(int) (bits % base)]);

            bits /= base;
        }
    }
339579
public static void writeToNBT(NBTTagCompound tag, AxisAlignedBB aabb, String prefix)
	{
		if (tag == null || aabb == null)
			return;

		prefix = prefix == null ? "" : prefix + ".";
		tag.setDouble(prefix + "minX", aabb.minX);
		tag.setDouble(prefix + "minY", aabb.minY);
		tag.setDouble(prefix + "minZ", aabb.minZ);
		tag.setDouble(prefix + "maxX", aabb.maxX);
		tag.setDouble(prefix + "maxY", aabb.maxY);
		tag.setDouble(prefix + "maxZ", aabb.maxZ);
	}
1188811
private static final int previousSpaceIndex(StringBuffer sb, int seek) {
    seek--;
    while (seek > 0) {
      if (sb.charAt(seek) == ' ') {
        while (seek > 0 && sb.charAt(seek - 1) == ' ')
          seek--;
        return seek;
      }
      seek--;
    }
    return 0;
  }
848103
public StringBuffer addLinkTag(StringBuffer sb)
    {
        int iIndex = sb.lastIndexOf(Utility.endTag(this.getTableNames(false)));
        if (iIndex != -1)
        {
            String strLink = Utility.encodeXML(this.getLink());
            String strHelpLink = strLink;
            if (strLink.indexOf('?') != -1)   // Always
                strHelpLink = "?" + DBParams.HELP + "=" + "&amp;" + strLink.substring(strLink.indexOf('?') + 1);
            sb.insert(iIndex,
                    Utility.startTag(XMLTags.LINK) +
                        strLink +
                    Utility.endTag(XMLTags.LINK) + XmlUtilities.NEWLINE +
                    Utility.startTag(XMLTags.HELPLINK) +
                        strHelpLink +
                    Utility.endTag(XMLTags.HELPLINK) + XmlUtilities.NEWLINE);
        }
        return sb;
    }
341666
protected synchronized void addPrefix(final String prefixString) {
		if (prefixString != null) {
			final Set<String> prefixes = getPrefixes();
			prefixes.add(prefixString);
			setPrefixes(prefixes);
		}
	}
1364770
protected void normalizeAndPrint(String s, boolean isAttValue) {
        
        int len = (s != null) ? s.length() : 0;
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            normalizeAndPrint(c, isAttValue);
        }
        
    }
625859
private void toStringCondition(final StringBuilder sb) {
        if (getConditionLiterals().size() > 0) {
            toStringList(sb, getConditionLiterals(), "conditionLiterals");
        }
        if (getConditionRanges().size() > 0) {
            toStringList(sb, getConditionRanges(), "conditionRanges");
        }

    }
455506
public static boolean startsWith(String str, char prefix) {
	return str != null && str.length() > 0 && str.charAt(0) == prefix;
    }
472898
public static StringBuilder appendKeyDqValue(final StringBuilder sb, final String key, final Object value) {
        return sb.append(key).append(Chars.EQ).append(Chars.DQUOTE).append(value).append(Chars.DQUOTE);
    }
136666
protected void appendText(StringBuilder sb, Text aNode) {
        sb.append("<")
            .append(aNode.getParentNode().getNodeName())
            .append(" ...>");

        if (aNode instanceof CDATASection) {
            sb.append("<![CDATA[")
                .append(aNode.getNodeValue())
                .append("]]>");
        } else {
            sb.append(aNode.getNodeValue());
        }

        sb.append("</")
            .append(aNode.getParentNode().getNodeName())
            .append(">");
    }
641887
private static int quoteSingle(final StringBuilder sb, final String string, final int start) {
        int i = start+1;
        if (needsBlockQuoting(string.charAt(start))) return -i;
        int unquoteLen = 0;
        int quotedMap = 1;
        for (int j = 1; i < string.length(); i++, j++) {
            char c = string.charAt(i);
            if (needsQuoting(c)) {
                if (j > MAX_SINGLE_QUOTE_LEN || needsBlockQuoting(c)) return -i-1;
                quotedMap |= 1 << j;
                unquoteLen = 0;
            } else {
                if (unquoteLen == MAX_UNQUOTE_LEN ||
                        (quotedMap == 1 && 
                         unquoteLen == MAX_SINGLE_UNQUOTE_LEN)) {
                    break;
                }
                unquoteLen++;
            }
        }
        appendSingleQuoted(sb, string, start, i - unquoteLen, quotedMap);
        sb.append(string, i - unquoteLen, i);
        return i;
    }
310083
public void show(final StringBuffer sb) {
    int start;
    start = this.span.getStart();
    if (!this.type.equals(ShiftReduceParser.TOK_NODE)) {
      sb.append("(");
      sb.append(this.type).append(" ");
      // System.out.print(label+" ");
      // System.out.print(head+" ");
      // System.out.print(df.format(prob)+" ");
    }
    for (Parse c : this.parts) {
      final Span s = c.span;
      if (start < s.getStart()) {
        // System.out.println("pre "+start+" "+s.getStart());
        sb.append(encodeToken(this.text.substring(start, s.getStart())));
      }
      c.show(sb);
      start = s.getEnd();
    }
    if (start < this.span.getEnd()) {
      sb.append(encodeToken(this.text.substring(start, this.span.getEnd())));
    }
    if (!this.type.equals(ShiftReduceParser.TOK_NODE)) {
      sb.append(")");
    }
  }
553299
public final void mNS_PREFIX() throws RecognitionException {
        try {
            int _type = NS_PREFIX;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // BELStatement.g:279:10: ( LETTER ( LETTER | DIGIT )* ':' )
            // BELStatement.g:280:5: LETTER ( LETTER | DIGIT )* ':'
            {
            mLETTER(); 
            // BELStatement.g:280:12: ( LETTER | DIGIT )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( ((LA1_0>='0' && LA1_0<='9')||(LA1_0>='A' && LA1_0<='Z')||(LA1_0>='a' && LA1_0<='z')) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // BELStatement.g:
            	    {
            	    if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||(input.LA(1)>='a' && input.LA(1)<='z') ) {
            	        input.consume();

            	    }
            	    else {
            	        MismatchedSetException mse = new MismatchedSetException(null,input);
            	        recover(mse);
            	        throw mse;}


            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);

            match(':'); 

            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
520520
public static final StringBuilder sprintf0d(StringBuilder sb, int value, int width) {
        long d = value;
        if (d < 0) {
            sb.append('-');
            d = -d;
            --width;
        }
        int n = 10;
        for (int i = 2; i < width; i++) {
            n *= 10;
        }
        for (int i = 1; i < width && d < n; i++) {
            sb.append('0');
            n /= 10;
        }
        sb.append(d);
        return sb;
    }
246414
public void addAllowedPrefix(String prefix) {
        if (prefix.endsWith(".")) {
            prefix = prefix.substring(0, prefix.length() - 1);
        }
        LOG.debug("Allowed prefix: {}", prefix);
        String packageRegex = START + dotsToRegex(prefix) + SEP;
        LOG.debug("Prefix regex: {}", packageRegex);
        patternList.add(Pattern.compile(packageRegex).matcher(""));
    }