1 /* Jackson JSON-processor. 2 * 3 * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi 4 */ 5 6 package com.fasterxml.jackson.core; 7 8 /** 9 * Enumeration that defines legal encodings that can be used 10 * for JSON content, based on list of allowed encodings from 11 * <a href="http://www.ietf.org/rfc/rfc4627.txt">JSON specification</a>. 12 *<p> 13 * Note: if application want to explicitly disregard Encoding 14 * limitations (to read in JSON encoded using an encoding not 15 * listed as allowed), they can use {@link java.io.Reader} / 16 * {@link java.io.Writer} instances as input 17 */ 18 public enum JsonEncoding { 19 UTF8("UTF-8", false, 8), // N/A for big-endian, really 20 UTF16_BE("UTF-16BE", true, 16), 21 UTF16_LE("UTF-16LE", false, 16), 22 UTF32_BE("UTF-32BE", true, 32), 23 UTF32_LE("UTF-32LE", false, 32) 24 ; 25 26 private final String _javaName; 27 28 private final boolean _bigEndian; 29 30 private final int _bits; 31 JsonEncoding(String javaName, boolean bigEndian, int bits)32 JsonEncoding(String javaName, boolean bigEndian, int bits) 33 { 34 _javaName = javaName; 35 _bigEndian = bigEndian; 36 _bits = bits; 37 } 38 39 /** 40 * Method for accessing encoding name that JDK will support. 41 * 42 * @return Matching encoding name that JDK will support. 43 */ getJavaName()44 public String getJavaName() { return _javaName; } 45 46 /** 47 * Whether encoding is big-endian (if encoding supports such 48 * notion). If no such distinction is made (as is the case for 49 * {@link #UTF8}), return value is undefined. 50 * 51 * @return True for big-endian encodings; false for little-endian 52 * (or if not applicable) 53 */ isBigEndian()54 public boolean isBigEndian() { return _bigEndian; } 55 bits()56 public int bits() { return _bits; } 57 } 58