/*
(non-Javadoc)
@see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
774832
@Override
    public void characters(char[] ch, int start, int length) throws SAXException {
        String text = new String(ch, start, length);
        if (this.isName) {
            this.name = text;
            this.isName = false;
        } else if (this.isState) {
            this.state = text;
            this.isState = false;
        } else if (this.isNp) {
            this.np = Integer.parseInt(text);
            this.isNp = false;
        } else if (this.isProperties) {
            this.properties = text;
            this.isProperties = false;
        } else if (this.isNtype) {
            this.ntype = text;
            this.isNtype = false;
        } else if (this.isStatus) {
            this.status = text;
            this.isStatus = false;
        } else if (this.isJobs) {
            jobs = text;
            this.isJobs = false;
        }
    }
474720
public void characters(char ch[], int start, int length)
			throws SAXException {
		String arg0 = new String(ch);
		arg0 = arg0.substring(start, start + length);
//		System.out.println(arg0);

		if (arg0.startsWith("\n"))
			return;

		this.processValue(arg0);
	}
429672
@Override
    public void characters(char[] ch, int start, int length)
        throws SAXException {
        if (vIsOpen) {
            value.append(ch, start, length);
        }
        if (fIsOpen) {
            formula.append(ch, start, length);
        }
        if (hfIsOpen) {
            headerFooter.append(ch, start, length);
        }
    }
1098215
private void outputString(String s) throws SAXException {
        handler.characters(s.toCharArray(), 0, s.length());
    }
1350245
private int stringHexChar() throws JsonParserException {
    // GWT-compatible Character.digit(char, int)
    int c = "0123456789abcdef0123456789ABCDEF".indexOf(advanceChar()) % 16;
    if (c == -1)
      throw createParseException(null, "Expected unicode hex escape character", false);
    return c;
  }
947655
private static char[] chars(byte[] bytes) {
        char[] chars = new char[bytes.length];
        for (int i = 0; i < bytes.length; i++) {
            int pos = bytes[i] & 0xff;
            chars[i] = (char) pos;
        }
        return chars;
    }
433589
public static String generate(final int chars) {
        final SecureRandom secureRandom = new SecureRandom();
        final char[] buff = new char[chars];
        for (int i = 0; i < chars; ++i) {
            if (i % 10 == 0) {
                secureRandom.setSeed(secureRandom.nextLong());
            }
            buff[i] = VALID_CHARACTERS[secureRandom.nextInt(VALID_CHARACTERS.length)];
        }
        return new String(buff);
    }
1280031
public char[] readChars (int length) throws KryoException {
		char[] array = new char[length];
		if (optional(length << 1) == length << 1) {
			byte[] buffer = this.buffer;
			int p = this.position;
			for (int i = 0; i < length; i++, p += 2)
				array[i] = (char)((buffer[p] & 0xFF) | ((buffer[p + 1] & 0xFF)) << 8);
			position = p;
		} else {
			for (int i = 0; i < length; i++)
				array[i] = readChar();
		}
		return array;
	}
1043238
private void parseCharRef(boolean doFlush) throws SAXException, IOException {
        int value = 0;
        char c;

        if (tryRead('x')) {
            loop1: while (true) {
                c = readCh();
                if (c == ';') {
                    break loop1;
                } else {
                    int n = Character.digit(c, 16);
                    if (n == -1) {
                        fatal("illegal character in character reference", c,
                                null);
                        break loop1;
                    }
                    value *= 16;
                    value += n;
                }
            }
        } else {
            loop2: while (true) {
                c = readCh();
                if (c == ';') {
                    break loop2;
                } else {
                    int n = Character.digit(c, 10);
                    if (n == -1) {
                        fatal("illegal character in character reference", c,
                                null);
                        break loop2;
                    }
                    value *= 10;
                    value += c - '0';
                }
            }
        }

        // check for character refs being legal XML
        if (((value < 0x0020) && !((value == '\n') || (value == '\t') || (value == '\r')))
                || ((value >= 0xD800) && (value <= 0xDFFF))
                || (value == 0xFFFE)
                || (value == 0xFFFF) || (value > 0x0010ffff)) {
            fatal("illegal XML character reference U+"
                    + Integer.toHexString(value));
        } else if ((value >= 0x007F) && (value <= 0x009F)) // 2006-11-13 hsivonen
        {
            handler.warn("Character reference expands to a control character: U+00"
                    + Integer.toHexString(value) + ".");
        }
        if (isPrivateUse(value)) {
            warnAboutPrivateUseChar();
        }

        // Check for surrogates: 00000000 0000xxxx yyyyyyyy zzzzzzzz
        // (1101|10xx|xxyy|yyyy + 1101|11yy|zzzz|zzzz:
        if (value <= 0x0000ffff) {
            // no surrogates needed
            dataBufferAppend((char) value);
        } else if (value <= 0x0010ffff) {
            value -= 0x10000;
            // > 16 bits, surrogate needed
            dataBufferAppend((char) (0xd800 | (value >> 10)));
            dataBufferAppend((char) (0xdc00 | (value & 0x0003ff)));
        } else {
            // too big for surrogate
            fatal("character reference " + value + " is too large for UTF-16",
                    Integer.valueOf(value).toString(), null);
        }
        if (doFlush) {
            dataBufferFlush();
        }
    }
710095
@SuppressWarnings("unchecked")
    public static List<Character> getAt(char[] array, Collection indices) {
        return primitiveArrayGet(array, indices);
    }
855108
@SuppressWarnings("deprecation")
    @Override
    public void characters(char[] ch, int start, int length)
            throws SAXException {
        if (alreadyComplainedAboutThisRun) {
            return;
        }
        if (atStartOfRun) {
            char c = ch[start];
            if (pos == 1) {
                // there's a single high surrogate in buf
                if (isComposingChar(UCharacter.getCodePoint(buf[0], c))) {
                    warn("Text run starts with a composing character.");
                }
                atStartOfRun = false;
            } else {
                if (length == 1 && UCharacter.isHighSurrogate(c)) {
                    buf[0] = c;
                    pos = 1;
                    return;
                } else {
                    if (UCharacter.isHighSurrogate(c)) {
                        if (isComposingChar(UCharacter.getCodePoint(c,
                                ch[start + 1]))) {
                            warn("Text run starts with a composing character.");
                        }
                    } else {
                        if (isComposingCharOrSurrogate(c)) {
                            warn("Text run starts with a composing character.");
                        }
                    }
                    atStartOfRun = false;
                }
            }
        }
        int i = start;
        int stop = start + length;
        if (pos > 0) {
            // there's stuff in buf
            while (i < stop && isComposingCharOrSurrogate(ch[i])) {
                i++;
            }
            appendToBuf(ch, start, i);
            if (i == stop) {
                return;
            } else {
                if (!Normalizer.isNormalized(buf, 0, pos, Normalizer.NFC, 0)) {
                    errAboutTextRun();
                }
                pos = 0;
            }
        }
        if (i < stop) {
            start = i;
            i = stop - 1;
            while (i > start && isComposingCharOrSurrogate(ch[i])) {
                i--;
            }
            if (i > start
                    && !Normalizer.isNormalized(ch, start, i, Normalizer.NFC, 0)) {
                errAboutTextRun();
            }
            appendToBuf(ch, i, stop);
        }
    }
1076942
public char getChar(String key) {
        String s = getString(key);
        if (s == null || s.trim().length() == 0) {
            return (char) 0;
        } else {
            return s.charAt(0);
        }
    }
567703
@Override
    public void ignorableWhitespace( char[] chars, int start, int length )
        throws SAXException
    {
        characters( chars, start, length );
    }
824435
public static String escapeXML(final char[] chars, final int offset, final int length) {
        final StringBuilder escaped = new StringBuilder();

        final int end = offset + length;
        for (int i = offset; i < end; ++i) {
            final char c = chars[i];

            switch (c) {
            case '\'':
                escaped.append("&apos;");
                break;
            case '\"':
                escaped.append("&quot;");
                break;
            case '<':
                escaped.append("&lt;");
                break;
            case '>':
                escaped.append("&gt;");
                break;
            case '&':
                escaped.append("&amp;");
                break;
            default:
                escaped.append(c);
            }
        }

        return escaped.toString();
    }
507426
public static CharPredicate among(final String chars) {
    return new CharPredicate() {
      @Override public boolean isChar(char c) {
        return chars.indexOf(c) >= 0;
      }
      @Override public String toString() {
        return '[' + chars + ']';
      }
    };
  }
1114341
private static char[] mapChar (byte[] digits) {
		char[] result = new char[digits.length];

		for (int i=0; i<digits.length; i++)
			result[i] = mapChar(digits[i]);

		return result;
	}
116886
public static Character readCharacter(String value, Character defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Character.valueOf((char)Integer.parseInt(value));
	}