获取动态属性值

@param value
@param charset
@return
766857
@SuppressWarnings("unchecked")
    private byte[] getDynamicFieldByteValue(Object value, Charset charset) {
        switch (dynamicFieldType) {
            // 如果是打包剩余的所有Byte
            case allRestByte:
                return BytesUtil.objString2Byte((String) value, charset);
            // 如果是文件metadata
            case metadata:
                return MetadataMapper.toByte((Set<MetaData>) value, charset);
            default:
                return BytesUtil.objString2Byte((String) value, charset);
        }
    }
273596
public Charset setCharset(Charset charset) {
        Charset prev = this.charset.get();
        this.charset.set(charset);
        return prev;
    }
83644
public static final boolean isValid(final String value) {
        if (value == null) {
            return true;
        }
        final Locale locale;
        final int p = value.indexOf("__");
        if (p > -1) {
            locale = new Locale(value.substring(0, p), null, value.substring(p + 2));
        } else {
            final StringTokenizer tok = new StringTokenizer(value, "_");
            if (tok.countTokens() == 1) {
                locale = new Locale(value);
            } else if (tok.countTokens() == 2) {
                locale = new Locale(tok.nextToken(), tok.nextToken());
            } else if (tok.countTokens() == 3) {
                locale = new Locale(tok.nextToken(), tok.nextToken(), tok.nextToken());
            } else {
                return false;
            }
        }
        return LocaleConverter.validLocale(locale);
    }
877629
public static <T extends CharSequence> T validateChinese(T value, String errorMsg) throws ValidateException {
		if (false == isChinese(value)) {
			throw new ValidateException(errorMsg);
		}
		return value;
	}
275257
public static String getLetters(String value) {

    StringBuilder letters = new StringBuilder(value.length());

    for (char chr : value.toCharArray()) {
      if (Character.isLetter(chr)) {
        letters.append(chr);
      }
    }

    return letters.toString();
  }
1102917
public static String toUnicodeHex(int value) {
		final StringBuilder builder = new StringBuilder(6);

		builder.append("\\u");
		String hex = toHex(value);
		int len = hex.length();
		if (len < 4) {
			builder.append("0000", 0, 4 - len);// 不足4位补0
		}
		builder.append(hex);

		return builder.toString();
	}
119453
public static byte[] objString2Byte(String value, int max, Charset charset) {
        byte[] fullContentBytes = new byte[max];
        // 填充默认值
        Arrays.fill(fullContentBytes, (byte) 0);
        if (null == value) {
            return fullContentBytes;
        }
        // 获取byte
        byte[] realContent = value.getBytes(charset);
        int length;
        if (realContent.length <= max) {
            length = realContent.length;
        } else {
            length = max;
        }
        // 复制数值
        System.arraycopy(realContent, 0, fullContentBytes, 0, length);
        return fullContentBytes;
    }
755062
public static String[] chars(final String value) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        return value.split("");
    }
605153
public static String decode(String content, Charset charset) {
		if (null == charset) {
			charset = CharsetUtil.defaultCharset();
		}
		return decode(content, charset.name());
	}
259797
public String getString(String charset) {
    try {
      return new String(getBytes(), charset);
    }
    catch (UnsupportedEncodingException e) {
      throw new IllegalStateException(e.getMessage());
    }
  }
1301957
@SneakyThrows
    public static String urlDecode(final String value) {
        return URLDecoder.decode(value, StandardCharsets.UTF_8.name());
    }
1298294
public static int occurrencesOfChar(String string, final char value)
    {
        return StringIterate.countChar(string, new CharPredicate()
        {
            public boolean accept(char character)
            {
                return value == character;
            }
        });
    }
651536
@Override
    public void setCharacterEncoding(String charset) {
        if (null != this.outWriter || isCommitted()) {
            return;
        }
        if (null != charset) {
            this.encoding = connection.getEncodingUtils().stripQuotes(charset);
        }
        if (null != this.contentType) {
            int index = this.contentType.indexOf("charset=");
            StringBuilder sb = new StringBuilder();
            if (-1 != index) {
                sb.append(this.contentType.substring(0, index - 1).trim());
            } else {
                sb.append(this.contentType);
            }
            if (this.encoding != null) {
                sb.append(";charset=").append(this.encoding);
            }

            this.contentType = sb.toString();
            this.response.setHeader("Content-Type", this.contentType);
        }
    }
36314
public String encode(String value) {
    if (value == null) { return null; }
    StringBuilder buffer = new StringBuilder();
    buffer.append(Prefix);
    buffer.append(charset);
    buffer.append(Sep);
    buffer.append(getEncoding());
    buffer.append(Sep);
    buffer.append(new String(Base64.encode(value.getBytes(charset))));
    buffer.append(Postfix);
    return buffer.toString();
  }
897174
public static Action charset(final String charset) {
        return new Action(r -> {
            r.setCharacterEncoding(charset);
            return r;
        });
    }
723035
public Charset contentCharset() {
        String ct = contentType();
        if (ct != null) {
            int index = ct.indexOf("charset=");
            if (index != -1) {
                return Charset.forName(ct.substring(index + 8));
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
503810
public void set(String value)
    {
        char[] cha = value.toCharArray();
        for ( int i = 0; i < getN() &&  i < value.length(); i++ )
        {
            setChar(cha[i], i);
        }
    }