Appends the given mailto link using obfuscation.

@param out
The StringBuilder to write to.
@param in
Input String.
@param start
Input String starting position.
@param end
Input String end position.
19910
public static void appendMailto (final StringBuilder out, final String in, final int start, final int end)
  {
    for (int i = start; i < end; i++)
    {
      final char c = in.charAt (i);
      final int r = rnd ();
      switch (c)
      {
        case '&':
        case '<':
        case '>':
        case '"':
        case '\'':
        case '@':
          if (r < 512)
            _appendDecEntity (out, c);
          else
            _appendHexEntity (out, c);
          break;
        default:
          if (r < 32)
            out.append (c);
          else
            if (r < 520)
              _appendDecEntity (out, c);
            else
              _appendHexEntity (out, c);
          break;
      }
    }
  }
1373336
public Object execute() throws Throwable {
		try {
			URL u = new URL("mailto:" + mailto);
			URLConnection c = u.openConnection();
			c.setDoInput(false);
			c.setDoOutput(true);
			c.connect();
			outMail = new PrintWriter(c.getOutputStream(), true);
			outMail.println("From: " + mailfrom);
			outMail.println("To: " + mailto);
			outMail.println("Subject: " + subject);
			if (attachments == null) {
				outMail.println("Content-Type: text/plain;");
				outMail.println("	charset=\"UTF-8\"");
				outMail.println();
				if (message != null) {
					outMail.println(message);
				}
			}
			else {
				String boundary = "----=" + KeyGenerator.generateKey();
				outMail.println("MIME-Version: 1.0\n" +
						"Content-Type: multipart/mixed; " +
						"boundary=\"" + boundary + '\"');

				outMail.println();
				if (message != null) {
					outMail.println("--" + boundary);
					outMail.println("Content-Type: text/plain;");
					outMail.println("	charset=\"UTF-8\"");
	//				outMail.println("Content-Transfer-Encoding: quoted-printable");
					outMail.println();
					outMail.println(message);
				}
				for (int i = 0; i < attachments.length; i++) {
					outMail.println();
					outMail.println("--" + boundary);
					outMail.println("Content-Type: " + attachments[i].getMimeType() + ';');
					outMail.println("	name=\"" + attachments[i].getFileName() + '\"');
					outMail.println("Content-Transfer-Encoding: base64");
					outMail.println("Content-Disposition: attachment;");
					outMail.println("	filename=\"" + attachments[i].getFileName() + '\"');
					outMail.println();
					outMail.println(attachments[i].getRawDataBase64Encoded());
					outMail.println();
				}
				outMail.println("--" + boundary + "--");

			}
		}
		catch (Throwable t) {
			//failure of async action must be logged somewhere
			t.printStackTrace();
			throw new java.lang.RuntimeException("mailing " + mailto + " via " + mailserver + " failed", t);
		}
		finally {
			if (outMail != null) {
				outMail.close();
			}
		}
		return null;
	}
1173427
synchronized void link(final OtpErlangPid from, final OtpErlangPid to)
            throws OtpErlangExit {
        try {
            super.sendLink(from, to);
            links.addLink(from, to);
        } catch (final IOException e) {
            throw new OtpErlangExit("noproc", to);
        }
    }
473381
public void out2out(String out, Object to, String to_out) {
        controller.mapOut(out, to, to_out);
    }
1319335
public void append(long start, long end) {
        assert(start <= end && (m_map.isEmpty() || start > end(m_map.span())));
        addRange(start, end);
    }
383122
public String mkString(String start, String sep, String end) {
		StringBuilder ret = new StringBuilder(start);
		for (int i = 0; i < inner.size(); i++) {
			ret.append(inner.get(i));
			if (i != (inner.size() - 1)) {
				ret.append(sep);
			}
		}
		return ret.append(end).toString();
	}
1275889
private void writeEscaped(String in)
		throws IOException
	{
		for(int i=0, n=in.length(); i<n; i++)
		{
			char c = in.charAt(i);
			if(c == '"' || c == '\\')
			{
				writer.write('\\');
				writer.write(c);
			}
			else if(c == '\r')
			{
				writer.write('\\');
				writer.write('r');
			}
			else if(c == '\n')
			{
				writer.write('\\');
				writer.write('n');
			}
			else if(c == '\t')
			{
				writer.write('\\');
				writer.write('t');
			}
			else if(c == '\b')
			{
				writer.write('\\');
				writer.write('b');
			}
			else if(c == '\f')
			{
				writer.write('\\');
				writer.write('f');
			}
			else if(c <= 0x1F)
			{
				writer.write('\\');
				writer.write('u');

				int v = c;
				int pos = 4;
				do
				{
					encoded[--pos] = DIGITS[v & HEX_MASK];
					v >>>= 4;
				}
				while (v != 0);

				for(int j=0; j<pos; j++) writer.write('0');
				writer.write(encoded, pos, 4 - pos);
			}
			else
			{
				writer.write(c);
			}
		}
	}

	/**
	 * Increase the level by one.
	 *
	 * @param list
	 */
	private void increaseLevel(boolean list)
	{
		level++;

		if(hasData.length == level)
		{
			// Grow lists when needed
			hasData = Arrays.copyOf(hasData, hasData.length * 2);
			lists = Arrays.copyOf(lists, hasData.length * 2);
		}

		hasData[level] = false;
		lists[level] = list;
	}

	/**
	 * Decrease the level by one.
	 *
	 * @throws IOException
	 */
	private void decreaseLevel()
		throws IOException
	{
		level--;

		if(beautify && hasData[level])
		{
			writer.write('\n');

			for(int i=0; i<level; i++)
			{
				writer.write("\t");
			}
		}
	}

	/**
	 * Start a write, will output commas and beautification if needed.
	 *
	 * @throws IOException
	 */
	private void startWrite()
		throws IOException
	{
		if(hasData[level]) writer.write(',');

		hasData[level] = true;

		if(beautify && level > 0)
		{
			writer.write('\n');

			for(int i=0; i<level; i++)
			{
				writer.write('\t');
			}
		}
	}

	/**
	 * Check if the name should be written or not.
	 *
	 * @return
	 */
	private boolean shouldOutputName()
	{
		return level != 0 && ! lists[level];
	}

	@Override
	public void writeObjectStart(String name)
		throws IOException
	{
		startWrite();

		if(shouldOutputName())
		{
			writer.write('"');
			writeEscaped(name);
//			writer.write("\": {");
			writer.write('"');
			writer.write(':');
		}

		writer.write('{');

		increaseLevel(false);
	}

	@Override
	public void writeObjectEnd(String name)
		throws IOException
	{
		decreaseLevel();

		writer.write('}');
	}

	@Override
	public void writeListStart(String name)
		throws IOException
	{
		startWrite();

		if(shouldOutputName())
		{
			writer.write('"');
			writeEscaped(name);
//			writer.write("\": [");
			writer.write('"');
			writer.write(':');
		}

		writer.write('[');

		increaseLevel(true);
	}

	@Override
	public void writeListEnd(String name)
		throws IOException
	{
		decreaseLevel();
		writer.write(']');
	}

	@Override
	public void write(String name, String value)
		throws IOException
	{
		startWrite();

		if(shouldOutputName())
		{
			writer.write('"');
			writeEscaped(name);
//			writer.write("\": ");
			writer.write('"');
			writer.write(':');
		}

		if(value == null)
		{
			writer.write("null");
		}
		else
		{
			writer.write('"');
			writeEscaped(value);
			writer.write('"');
		}
	}

	private void writeUnescaped(String name, String value)
		throws IOException
	{
		startWrite();

		if(shouldOutputName())
		{
			writer.write('"');
			writeEscaped(name);
//			writer.write("\": ");
			writer.write('"');
			writer.write(':');
		}

		if(value == null)
		{
			writer.write("null");
		}
		else
		{
			writer.write(value);
		}
	}

	@Override
	public void write(String name, int number)
		throws IOException
	{
		writeUnescaped(name, Integer.toString(number));
	}

	@Override
	public void write(String name, long number)
		throws IOException
	{
		writeUnescaped(name, Long.toString(number));
	}

	@Override
	public void write(String name, float number)
		throws IOException
	{
		writeUnescaped(name, Float.toString(number));
	}

	@Override
	public void write(String name, double number)
		throws IOException
	{
		writeUnescaped(name, Double.toString(number));
	}

	@Override
	public void write(String name, boolean bool)
		throws IOException
	{
		writeUnescaped(name, Boolean.toString(bool));
	}

	@Override
	public void write(String name, byte[] data)
		throws IOException
	{
		startWrite();

		if(shouldOutputName())
		{
			writer.write('"');
			writeEscaped(name);
			writer.write('"');
			writer.write(':');
		}

		if(data == null)
		{
			writer.write("null");
			return;
		}

		writer.write('"');

		int i = 0;
		for(int n=data.length - 2; i<n; i+=3)
		{
			write(data, i, 3);
		}

		if(i < data.length)
		{
			write(data, i, data.length - i);
		}

		writer.write('"');
	}

	/**
	 * Write some BASE64 encoded bytes.
	 *
	 * @param data
	 * @param pos
	 * @param chars
	 * @param len
	 * @throws IOException
	 */
	private void write(byte[] data, int pos, int len)
		throws IOException
	{
		char[] chars = BASE64;

		int loc = (len > 0 ? (data[pos] << 24) >>> 8 : 0) |
			(len > 1 ? (data[pos+1] << 24) >>> 16 : 0) |
			(len > 2 ? (data[pos+2] << 24) >>> 24 : 0);

		switch(len)
		{
			case 3:
				writer.write(chars[loc >>> 18]);
				writer.write(chars[(loc >>> 12) & 0x3f]);
				writer.write(chars[(loc >>> 6) & 0x3f]);
				writer.write(chars[loc & 0x3f]);
				break;
			case 2:
				writer.write(chars[loc >>> 18]);
				writer.write(chars[(loc >>> 12) & 0x3f]);
				writer.write(chars[(loc >>> 6) & 0x3f]);
				writer.write('=');
				break;
			case 1:
				writer.write(chars[loc >>> 18]);
				writer.write(chars[(loc >>> 12) & 0x3f]);
				writer.write('=');
				writer.write('=');
		}
	}

	@Override
	public void writeNull(String name)
		throws IOException
	{
		write(name, (String) null);
	}

	@Override
	public void flush() throws IOException
	{
		writer.flush();
	}
}
23772
public SpannableStringBuilder insert(int where, CharSequence tb, int start, int end) {
        return replace(where, where, tb, start, end);
    }
348576
public final static void getXMLTag(final StringBuilder out, final StringBuilder in)
    {
        int pos = 1;
        if (in.charAt(1) == '/')
        {
            pos++;
        }
        while (Character.isLetterOrDigit(in.charAt(pos)))
        {
            out.append(in.charAt(pos++));
        }
    }
1132732
public static void tputs(Writer out, String str, Object... params) throws IOException {
        int index = 0;
        int length = str.length();
        int ifte = IFTE_NONE;
        boolean exec = true;
        Stack<Object> stack = new Stack<Object>();
        while (index < length) {
            char ch = str.charAt(index++);
            switch (ch) {
                case '\\':
                    ch = str.charAt(index++);
                    if (ch >= '0' && ch <= '9') {
                        throw new UnsupportedOperationException(); // todo
                    } else {
                        switch (ch) {
                            case 'e':
                            case 'E':
                                if (exec) {
                                    out.write(27); // escape
                                }
                                break;
                            case 'n':
                                out.write('\n');
                                break;
//                        case 'l':
//                            rawPrint('\l');
//                            break;
                            case 'r':
                                if (exec) {
                                    out.write('\r');
                                }
                                break;
                            case 't':
                                if (exec) {
                                    out.write('\t');
                                }
                                break;
                            case 'b':
                                if (exec) {
                                    out.write('\b');
                                }
                                break;
                            case 'f':
                                if (exec) {
                                    out.write('\f');
                                }
                                break;
                            case 's':
                                if (exec) {
                                    out.write(' ');
                                }
                                break;
                            case ':':
                            case '^':
                            case '\\':
                                if (exec) {
                                    out.write(ch);
                                }
                                break;
                            default:
                                throw new IllegalArgumentException();
                        }
                    }
                    break;
                case '^':
                    ch = str.charAt(index++);
                    if (exec) {
                        out.write(ch - '@');
                    }
                    break;
                case '%':
                    ch = str.charAt(index++);
                    switch (ch) {
                        case '%':
                            if (exec) {
                                out.write('%');
                            }
                            break;
                        case 'p':
                            ch = str.charAt(index++);
                            if (exec) {
                                stack.push(params[ch - '1']);
                            }
                            break;
                        case 'P':
                            ch = str.charAt(index++);
                            if (ch >= 'a' && ch <= 'z') {
                                if (exec) {
                                    dv[ch - 'a'] = stack.pop();
                                }
                            } else if (ch >= 'A' && ch <= 'Z') {
                                if (exec) {
                                    sv[ch - 'A'] = stack.pop();
                                }
                            } else {
                                throw new IllegalArgumentException();
                            }
                            break;
                        case 'g':
                            ch = str.charAt(index++);
                            if (ch >= 'a' && ch <= 'z') {
                                if (exec) {
                                    stack.push(dv[ch - 'a']);
                                }
                            } else if (ch >= 'A' && ch <= 'Z') {
                                if (exec) {
                                    stack.push(sv[ch - 'A']);
                                }
                            } else {
                                throw new IllegalArgumentException();
                            }
                            break;
                        case '\'':
                            ch = str.charAt(index++);
                            if (exec) {
                                stack.push((int) ch);
                            }
                            ch = str.charAt(index++);
                            if (ch != '\'') {
                                throw new IllegalArgumentException();
                            }
                            break;
                        case '{':
                            int start = index;
                            while (str.charAt(index++) != '}');
                            if (exec) {
                                int v = Integer.valueOf(str.substring(start, index - 1));
                                stack.push(v);
                            }
                            break;
                        case 'l':
                            if (exec) {
                                stack.push(stack.pop().toString().length());
                            }
                            break;
                        case '+':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 + v2);
                            }
                            break;
                        case '-':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 - v2);
                            }
                            break;
                        case '*':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 * v2);
                            }
                            break;
                        case '/':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 / v2);
                            }
                            break;
                        case 'm':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 % v2);
                            }
                            break;
                        case '&':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 & v2);
                            }
                            break;
                        case '|':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 | v2);
                            }
                            break;
                        case '^':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 ^ v2);
                            }
                            break;
                        case '=':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 == v2);
                            }
                            break;
                        case '>':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 > v2);
                            }
                            break;
                        case '<':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 < v2);
                            }
                            break;
                        case 'A':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 != 0 && v2 != 0);
                            }
                            break;
                        case '!':
                            if (exec) {
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 == 0);
                            }
                            break;
                        case '~':
                            if (exec) {
                                int v1 = toInteger(stack.pop());
                                stack.push(~v1);
                            }
                            break;
                        case 'O':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 != 0 || v2 != 0);
                            }
                            break;
                        case '?':
                            if (ifte != IFTE_NONE) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_IF;
                            }
                            break;
                        case 't':
                            if (ifte != IFTE_IF && ifte != IFTE_ELSE) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_THEN;
                            }
                            exec = toInteger(stack.pop()) != 0;
                            break;
                        case 'e':
                            if (ifte != IFTE_THEN) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_ELSE;
                            }
                            exec = !exec;
                            break;
                        case ';':
                            if (ifte == IFTE_NONE || ifte == IFTE_IF) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_NONE;
                            }
                            exec = true;
                            break;
                        case 'i':
                            if (params.length >= 1) {
                                params[0] = toInteger(params[0]) + 1;
                            }
                            if (params.length >= 2) {
                                params[1] = toInteger(params[1]) + 1;
                            }
                            break;
                        case 'd':
                            out.write(Integer.toString(toInteger(stack.pop())));
                            break;
                        default:
                            throw new UnsupportedOperationException();
                    }
                    break;
                case '$':
                    if (str.charAt(index) == '<') {
                        // We don't honour delays, just skip
                        while (str.charAt(index++) != '>');
                    } else {
                        if (exec) {
                            out.write(ch);
                        }
                    }
                    break;
                default:
                    if (exec) {
                        out.write(ch);
                    }
                    break;
            }
        }
    }
598945
public static String[] appendToAll(String append, String[] appendTo) {
        if (append == null) {
            throw new IllegalArgumentException("Method argument append must not be null.");
        }
        if (appendTo == null) {
            throw new IllegalArgumentException("Method argument to must not be null.");
        }

        String[] result = new String[appendTo.length];
        for (int i = 0; i  < appendTo.length; ++i) {
            result[i] = appendTo[i] == null ? null : appendTo[i] + append;
        }

        return result;
    }
534862
static CharOutput stringBuilderOutput(int initialSize) {
    final StringBuilder builder = new StringBuilder(initialSize);
    return new CharOutput() {

      @Override
      public void write(char c) {
        builder.append(c);
      }

      @Override
      public void flush() {}

      @Override
      public void close() {}

      @Override
      public String toString() {
        return builder.toString();
      }
    };
  }
1032346
public final static void appendHexEntity(final StringBuilder out, final char value)
    {
        out.append("&#x");
        out.append(Integer.toHexString(value));
        out.append(';');
    }
1055504
public void emit(final StringBuilder out, final Block root)
    {
        root.removeSurroundingEmptyLines();

        switch (root.type)
        {
        case RULER:
            this.config.decorator.horizontalRuler(out);
            return;
        case NONE:
        case XML:
            break;
        case HEADLINE:
            this.config.decorator.openHeadline(out, root.hlDepth);
            if (this.useExtensions && root.id != null)
            {
                out.append(" id=\"");
                Utils.appendCode(out, root.id, 0, root.id.length());
                out.append('"');
            }
            out.append('>');
            break;
        case PARAGRAPH:
            this.config.decorator.openParagraph(out);
            break;
        case CODE:
        case FENCED_CODE:
            if (this.config.codeBlockEmitter == null)
            {
                this.config.decorator.openCodeBlock(out);
            }
            break;
        case BLOCKQUOTE:
            this.config.decorator.openBlockquote(out);
            break;
        case UNORDERED_LIST:
            this.config.decorator.openUnorderedList(out);
            break;
        case ORDERED_LIST:
            this.config.decorator.openOrderedList(out);
            break;
        case LIST_ITEM:
            this.config.decorator.openListItem(out);
            if (this.useExtensions && root.id != null)
            {
                out.append(" id=\"");
                Utils.appendCode(out, root.id, 0, root.id.length());
                out.append('"');
            }
            out.append('>');
            break;
        }

        if (root.hasLines())
        {
            this.emitLines(out, root);
        }
        else
        {
            Block block = root.blocks;
            while (block != null)
            {
                this.emit(out, block);
                block = block.next;
            }
        }

        switch (root.type)
        {
        case RULER:
        case NONE:
        case XML:
            break;
        case HEADLINE:
            this.config.decorator.closeHeadline(out, root.hlDepth);
            break;
        case PARAGRAPH:
            this.config.decorator.closeParagraph(out);
            break;
        case CODE:
        case FENCED_CODE:
            if (this.config.codeBlockEmitter == null)
            {
                this.config.decorator.closeCodeBlock(out);
            }
            break;
        case BLOCKQUOTE:
            this.config.decorator.closeBlockquote(out);
            break;
        case UNORDERED_LIST:
            this.config.decorator.closeUnorderedList(out);
            break;
        case ORDERED_LIST:
            this.config.decorator.closeOrderedList(out);
            break;
        case LIST_ITEM:
            this.config.decorator.closeListItem(out);
            break;
        }
    }
545023
public void writeTo (ObjectOutputStream out)
        throws IOException
    {
        out.writeShort(_mask.length);
        out.write(_mask);
    }
271805
public static function fromString($input, $start = 0, $end = null)
	{
		return self::appendFromString(self::builder(), $input, $start, $end);
	}
590036
public static void emit(String src, JspWriter out) throws IOException {
        int end = src.length();
        int from = 0;
        for (int to = from; to < end; to++) {
            String escape = getEscape(src.charAt(to));
            if (escape != null) {
                if (to != from) {
                    out.write(src, from, to - from);
                }
                out.write(escape);
                from = to + 1;
            }
        }
        if (from != end) {
            out.write(src, from, end - from);
        }
    }