Scans the next character from the input stream, adding it to the
converter.

@param converter the byte-to-character converter
@param is the form's input stream
@param ch the next character
961398
private static void readChar(ByteToChar converter, 
                               CharReader is,
                               int ch, boolean isTop)
    throws IOException
  {
    if (ch == '+') {
      if (isTop)
        converter.addByte(' ');
      else
        converter.addChar(' ');
    }
    else if (ch == '%') {
      int ch1 = is.next();

      if (ch1 == 'u') {
        ch1 = is.next();
        int ch2 = is.next();
        int ch3 = is.next();
        int ch4 = is.next();

        converter.addChar((char) ((toHex(ch1) << 12) +
                                  (toHex(ch2) << 8) + 
                                  (toHex(ch3) << 4) + 
                                  (toHex(ch4))));
      }
      else {
        int ch2 = is.next();
        
        converter.addByte(((toHex(ch1) << 4) + toHex(ch2)));
      }
    }
    else if (isTop) {
      converter.addByte((byte) ch);
    }
    else {
      converter.addChar((char) ch);
    }
  }
528122
public void addConverter(ValueConverter<?, ?> converter) {

    getInitializationState().requireNotInitilized();
    if (this.converters == null) {
      this.converters = new ArrayList<>();
    }
    this.converters.add(converter);
  }
1146113
public static StreamEncoder forEncoder(WritableByteChannel ch,
                                           CharsetEncoder enc,
                                           int minBufferCap)
    {
        return new StreamEncoder(ch, enc, minBufferCap);
    }
162884
private final void _appendCharacterEscape(char ch, int escCode)
        throws IOException, JsonGenerationException
    {
        if (escCode >= 0) { // \\N (2 char)
            if ((_outputTail + 2) > _outputEnd) {
                _flushBuffer();
            }
            _outputBuffer[_outputTail++] = '\\';
            _outputBuffer[_outputTail++] = (char) escCode;
            return;
        }
        if (escCode != CharacterEscapes.ESCAPE_CUSTOM) { // std, \\uXXXX
            if ((_outputTail + 2) > _outputEnd) {
                _flushBuffer();
            }
            int ptr = _outputTail;
            char[] buf = _outputBuffer;
            buf[ptr++] = '\\';
            buf[ptr++] = 'u';
            // We know it's a control char, so only the last 2 chars are non-0
            if (ch > 0xFF) { // beyond 8 bytes
                int hi = (ch >> 8) & 0xFF;
                buf[ptr++] = HEX_CHARS[hi >> 4];
                buf[ptr++] = HEX_CHARS[hi & 0xF];
                ch &= 0xFF;
            } else {
                buf[ptr++] = '0';
                buf[ptr++] = '0';
            }
            buf[ptr++] = HEX_CHARS[ch >> 4];
            buf[ptr] = HEX_CHARS[ch & 0xF];
            _outputTail = ptr;
            return;
        }
    }
286083
private boolean isSockJsSpecialChar(char ch) {
        return ch <= '\u001F'
                || ch >= '\u200C' && ch <= '\u200F'
                || ch >= '\u2028' && ch <= '\u202F'
                || ch >= '\u2060' && ch <= '\u206F'
                || ch >= '\uFFF0'
                || ch >= '\uD800' && ch <= '\uDFFF';
    }
644137
public static final int readAll(ReadableByteChannel ch, ByteBuffer dst) throws IOException
    {
        int count = 0;
        while (dst.hasRemaining())
        {
            int rc = ch.read(dst);
            if (rc == -1)
            {
                if (count > 0)
                {
                    return count;
                }
                return -1;
            }
            count += rc;
        }
        return count;
    }
949862
public void init(Converter converter, Converter convAlternate, Converter convCheckmark)
    {
        super.init(converter, convAlternate);
        m_convCheckmark = convCheckmark;
    }
1075944
public boolean handleCharacter(int ch) {

		if (this.rtfParser.isImport()) {
			if (buffer.length() > 254)
				writeBuffer();
		}
		//if(data == null) data = new ByteBuffer();
		if (dataOS == null) {
			dataOS = new ByteArrayOutputStream();
		}
		switch (dataFormat) {
		case FORMAT_HEXADECIMAL:
			hexChars.append((char) ch);
			if (hexChars.length() == 2) {
				try {
					dataOS.write((char) Integer.parseInt(hexChars.toString(),
							16));
				} catch (NumberFormatException e) {
					e.printStackTrace();
				}
				hexChars = new StringBuffer();
			}
			break;
		case FORMAT_BINARY:
			if (dataOS == null) {
				dataOS = new ByteArrayOutputStream();
			}
			// HGS - FIX ME IF PROBLEM!
			dataOS.write((char) (ch));
			// PNG signature should be.
			//			   (decimal)              137  80  78  71  13  10  26  10
			//			   (hexadecimal)           89  50  4e  47  0d  0a  1a  0a
			//			   (ASCII C notation)    \211   P   N   G  \r  \n \032 \n

			binaryLength--;
			if (binaryLength == 0) {
				dataFormat = FORMAT_HEXADECIMAL;
			}
			break;
		}

		return true;
	}
812622
public static String applyFromInputStream(InputStream is) throws ConverterException {		
		String xml = converters.get(0).convertFromInputStream(is, false);						
		xml = applyFromSecond(xml);
		if (conversionDone()) {
			return converters.get(converters.size()-1).changeVersion(xml);
		} else {
			return xml;
		}
	}
377827
public static char getFirstLetter(char ch) {
		if (ch >= 'a' && ch <= 'z') {
			return ch;
		}
		if (ch >= 'A' && ch <= 'Z') {
			return Character.toLowerCase(ch);
		}
		final byte[] bys = String.valueOf(ch).getBytes(CharsetUtil.CHARSET_GBK);
		if (bys.length == 1) {
			return ch;
		}
		int count = (bys[0] + 256) * 256 + bys[1] + 256;
		if (count < 45217) {
			return ch;
		} else if (count < 45253) {
			return 'a';
		} else if (count < 45761) {
			return 'b';
		} else if (count < 46318) {
			return 'c';
		} else if (count < 46826) {
			return 'd';
		} else if (count < 47010) {
			return 'e';
		} else if (count < 47297) {
			return 'f';
		} else if (count < 47614) {
			return 'g';
		} else if (count < 48119) {
			return 'h';
		} else if (count < 49062) {
			return 'j';
		} else if (count < 49324) {
			return 'k';
		} else if (count < 49896) {
			return 'l';
		} else if (count < 50371) {
			return 'm';
		} else if (count < 50614) {
			return 'n';
		} else if (count < 50622) {
			return 'o';
		} else if (count < 50906) {
			return 'p';
		} else if (count < 51387) {
			return 'q';
		} else if (count < 51446) {
			return 'r';
		} else if (count < 52218) {
			return 's';
		} else if (count < 52698) {
			return 't';
		} else if (count < 52980) {
			return 'w';
		} else if (count < 53689) {
			return 'x';
		} else if (count < 54481) {
			return 'y';
		} else if (count < 55290) {
			return 'z';
		}
		return ch;
	}
478549
@Override
    public void addConverter(Class<?> from, Class<?> to, Converter converter) {
        Map toMap = fromMap.get(from);
        if (toMap == null) {
            toMap = new HashMap<Class<?>, Map<Class<?>, Converter>>();
            fromMap.put(from, toMap);
        }
        toMap.put(to, converter);
    }
508273
public <FT> void registerConverter(Class<FT> clazz, Converter<FT, ?> converter) {
		converterMap.put(clazz, converter);
	}
7849
public static boolean isBaseChar(int ch)
   {
      return (0x0041 <= ch && ch <= 0x005A) || (0x0061 <= ch && ch <= 0x007A) || (0x00C0 <= ch && ch <= 0x00D6)
         || (0x00D8 <= ch && ch <= 0x00F6) || (0x00F8 <= ch && ch <= 0x00FF) || (0x0100 <= ch && ch <= 0x0131)
         || (0x0134 <= ch && ch <= 0x013E) || (0x0141 <= ch && ch <= 0x0148) || (0x014A <= ch && ch <= 0x017E)
         || (0x0180 <= ch && ch <= 0x01C3) || (0x01CD <= ch && ch <= 0x01F0) || (0x01F4 <= ch && ch <= 0x01F5)
         || (0x01FA <= ch && ch <= 0x0217) || (0x0250 <= ch && ch <= 0x02A8) || (0x02BB <= ch && ch <= 0x02C1)
         || 0x0386 == ch || (0x0388 <= ch && ch <= 0x038A) || 0x038C == ch || (0x038E <= ch && ch <= 0x03A1)
         || (0x03A3 <= ch && ch <= 0x03CE) || (0x03D0 <= ch && ch <= 0x03D6) || 0x03DA == ch || 0x03DC == ch
         || 0x03DE == ch || 0x03E0 == ch || (0x03E2 <= ch && ch <= 0x03F3) || (0x0401 <= ch && ch <= 0x040C)
         || (0x040E <= ch && ch <= 0x044F) || (0x0451 <= ch && ch <= 0x045C) || (0x045E <= ch && ch <= 0x0481)
         || (0x0490 <= ch && ch <= 0x04C4) || (0x04C7 <= ch && ch <= 0x04C8) || (0x04CB <= ch && ch <= 0x04CC)
         || (0x04D0 <= ch && ch <= 0x04EB) || (0x04EE <= ch && ch <= 0x04F5) || (0x04F8 <= ch && ch <= 0x04F9)
         || (0x0531 <= ch && ch <= 0x0556) || 0x0559 == ch || (0x0561 <= ch && ch <= 0x0586)
         || (0x05D0 <= ch && ch <= 0x05EA) || (0x05F0 <= ch && ch <= 0x05F2) || (0x0621 <= ch && ch <= 0x063A)
         || (0x0641 <= ch && ch <= 0x064A) || (0x0671 <= ch && ch <= 0x06B7) || (0x06BA <= ch && ch <= 0x06BE)
         || (0x06C0 <= ch && ch <= 0x06CE) || (0x06D0 <= ch && ch <= 0x06D3) || 0x06D5 == ch
         || (0x06E5 <= ch && ch <= 0x06E6) || (0x0905 <= ch && ch <= 0x0939) || 0x093D == ch
         || (0x0958 <= ch && ch <= 0x0961) || (0x0985 <= ch && ch <= 0x098C) || (0x098F <= ch && ch <= 0x0990)
         || (0x0993 <= ch && ch <= 0x09A8) || (0x09AA <= ch && ch <= 0x09B0) || 0x09B2 == ch
         || (0x09B6 <= ch && ch <= 0x09B9) || (0x09DC <= ch && ch <= 0x09DD) || (0x09DF <= ch && ch <= 0x09E1)
         || (0x09F0 <= ch && ch <= 0x09F1) || (0x0A05 <= ch && ch <= 0x0A0A) || (0x0A0F <= ch && ch <= 0x0A10)
         || (0x0A13 <= ch && ch <= 0x0A28) || (0x0A2A <= ch && ch <= 0x0A30) || (0x0A32 <= ch && ch <= 0x0A33)
         || (0x0A35 <= ch && ch <= 0x0A36) || (0x0A38 <= ch && ch <= 0x0A39) || (0x0A59 <= ch && ch <= 0x0A5C)
         || 0x0A5E == ch || (0x0A72 <= ch && ch <= 0x0A74) || (0x0A85 <= ch && ch <= 0x0A8B) || 0x0A8D == ch
         || (0x0A8F <= ch && ch <= 0x0A91) || (0x0A93 <= ch && ch <= 0x0AA8) || (0x0AAA <= ch && ch <= 0x0AB0)
         || (0x0AB2 <= ch && ch <= 0x0AB3) || (0x0AB5 <= ch && ch <= 0x0AB9) || 0x0ABD == ch || 0x0AE0 == ch
         || (0x0B05 <= ch && ch <= 0x0B0C) || (0x0B0F <= ch && ch <= 0x0B10) || (0x0B13 <= ch && ch <= 0x0B28)
         || (0x0B2A <= ch && ch <= 0x0B30) || (0x0B32 <= ch && ch <= 0x0B33) || (0x0B36 <= ch && ch <= 0x0B39)
         || 0x0B3D == ch || (0x0B5C <= ch && ch <= 0x0B5D) || (0x0B5F <= ch && ch <= 0x0B61)
         || (0x0B85 <= ch && ch <= 0x0B8A) || (0x0B8E <= ch && ch <= 0x0B90) || (0x0B92 <= ch && ch <= 0x0B95)
         || (0x0B99 <= ch && ch <= 0x0B9A) || 0x0B9C == ch || (0x0B9E <= ch && ch <= 0x0B9F)
         || (0x0BA3 <= ch && ch <= 0x0BA4) || (0x0BA8 <= ch && ch <= 0x0BAA) || (0x0BAE <= ch && ch <= 0x0BB5)
         || (0x0BB7 <= ch && ch <= 0x0BB9) || (0x0C05 <= ch && ch <= 0x0C0C) || (0x0C0E <= ch && ch <= 0x0C10)
         || (0x0C12 <= ch && ch <= 0x0C28) || (0x0C2A <= ch && ch <= 0x0C33) || (0x0C35 <= ch && ch <= 0x0C39)
         || (0x0C60 <= ch && ch <= 0x0C61) || (0x0C85 <= ch && ch <= 0x0C8C) || (0x0C8E <= ch && ch <= 0x0C90)
         || (0x0C92 <= ch && ch <= 0x0CA8) || (0x0CAA <= ch && ch <= 0x0CB3) || (0x0CB5 <= ch && ch <= 0x0CB9)
         || 0x0CDE == ch || (0x0CE0 <= ch && ch <= 0x0CE1) || (0x0D05 <= ch && ch <= 0x0D0C)
         || (0x0D0E <= ch && ch <= 0x0D10) || (0x0D12 <= ch && ch <= 0x0D28) || (0x0D2A <= ch && ch <= 0x0D39)
         || (0x0D60 <= ch && ch <= 0x0D61) || (0x0E01 <= ch && ch <= 0x0E2E) || 0x0E30 == ch
         || (0x0E32 <= ch && ch <= 0x0E33) || (0x0E40 <= ch && ch <= 0x0E45) || (0x0E81 <= ch && ch <= 0x0E82)
         || 0x0E84 == ch || (0x0E87 <= ch && ch <= 0x0E88) || 0x0E8A == ch || 0x0E8D == ch
         || (0x0E94 <= ch && ch <= 0x0E97) || (0x0E99 <= ch && ch <= 0x0E9F) || (0x0EA1 <= ch && ch <= 0x0EA3)
         || 0x0EA5 == ch || 0x0EA7 == ch || (0x0EAA <= ch && ch <= 0x0EAB) || (0x0EAD <= ch && ch <= 0x0EAE)
         || 0x0EB0 == ch || (0x0EB2 <= ch && ch <= 0x0EB3) || 0x0EBD == ch || (0x0EC0 <= ch && ch <= 0x0EC4)
         || (0x0F40 <= ch && ch <= 0x0F47) || (0x0F49 <= ch && ch <= 0x0F69) || (0x10A0 <= ch && ch <= 0x10C5)
         || (0x10D0 <= ch && ch <= 0x10F6) || 0x1100 == ch || (0x1102 <= ch && ch <= 0x1103)
         || (0x1105 <= ch && ch <= 0x1107) || 0x1109 == ch || (0x110B <= ch && ch <= 0x110C)
         || (0x110E <= ch && ch <= 0x1112) || 0x113C == ch || 0x113E == ch || 0x1140 == ch || 0x114C == ch
         || 0x114E == ch || 0x1150 == ch || (0x1154 <= ch && ch <= 0x1155) || 0x1159 == ch
         || (0x115F <= ch && ch <= 0x1161) || 0x1163 == ch || 0x1165 == ch || 0x1167 == ch || 0x1169 == ch
         || (0x116D <= ch && ch <= 0x116E) || (0x1172 <= ch && ch <= 0x1173) || 0x1175 == ch || 0x119E == ch
         || 0x11A8 == ch || 0x11AB == ch || (0x11AE <= ch && ch <= 0x11AF) || (0x11B7 <= ch && ch <= 0x11B8)
         || 0x11BA == ch || (0x11BC <= ch && ch <= 0x11C2) || 0x11EB == ch || 0x11F0 == ch || 0x11F9 == ch
         || (0x1E00 <= ch && ch <= 0x1E9B) || (0x1EA0 <= ch && ch <= 0x1EF9) || (0x1F00 <= ch && ch <= 0x1F15)
         || (0x1F18 <= ch && ch <= 0x1F1D) || (0x1F20 <= ch && ch <= 0x1F45) || (0x1F48 <= ch && ch <= 0x1F4D)
         || (0x1F50 <= ch && ch <= 0x1F57) || 0x1F59 == ch || 0x1F5B == ch || 0x1F5D == ch
         || (0x1F5F <= ch && ch <= 0x1F7D) || (0x1F80 <= ch && ch <= 0x1FB4) || (0x1FB6 <= ch && ch <= 0x1FBC)
         || 0x1FBE == ch || (0x1FC2 <= ch && ch <= 0x1FC4) || (0x1FC6 <= ch && ch <= 0x1FCC)
         || (0x1FD0 <= ch && ch <= 0x1FD3) || (0x1FD6 <= ch && ch <= 0x1FDB) || (0x1FE0 <= ch && ch <= 0x1FEC)
         || (0x1FF2 <= ch && ch <= 0x1FF4) || (0x1FF6 <= ch && ch <= 0x1FFC) || 0x2126 == ch
         || (0x212A <= ch && ch <= 0x212B) || 0x212E == ch || (0x2180 <= ch && ch <= 0x2182)
         || (0x3041 <= ch && ch <= 0x3094) || (0x30A1 <= ch && ch <= 0x30FA) || (0x3105 <= ch && ch <= 0x312C)
         || (0xAC00 <= ch && ch <= 0xD7A3);
   }
152204
public void addConverterComponent(ValueConverter<?, ?> converter) {

    if (converter instanceof AbstractRecursiveValueConverter) {
      ((AbstractRecursiveValueConverter<?, ?>) converter).setComposedValueConverter(this);
    }
    if (converter instanceof AbstractComponent) {
      ((AbstractComponent) converter).initialize();
    }
    addConverter(converter);
  }
1119158
public void append(final char ch) {
        final int newlen = this.len + 1;
        if (newlen > this.array.length) {
            expand(newlen);
        }
        this.array[this.len] = ch;
        this.len = newlen;
    }
480024
public static <K, V> Map<K, V> parse(@Nullable String input, Converter<K> keyConverter, Converter<V> valueConverter) {
    Map<K, V> map = new LinkedHashMap<>();
    if (input != null) {
      FieldParser reader = new FieldParser(input);
      boolean end = false;
      while (!end) {
        String key = reader.nextKey();
        if (key == null) {
          end = true;
        } else {
          String val = StringUtils.defaultString(reader.nextVal(), "");
          map.put(keyConverter.parse(key), valueConverter.parse(val));
        }
      }
    }
    return map;
  }
1328525
final public void write(char ch)
  {
    Writer out = this.out;
    if (out == null)
      return;
    
    try {
      out.write(ch);
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
    }
  }