下面这段代码是啥意思,求指导

9527-abc 发布于 2017/09/26 17:54
阅读 697
收藏 1

【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”

com.alibaba.fastjson.JSON类中的一段代码,求大神指导这个是啥意思

 public abstract class JSON implements JSONStreamAware, JSONAware {

    //.....

  //这个static下面的代码是干啥的?
  static {
        int features = 0;
        features |= Feature.AutoCloseSource.getMask();
        features |= Feature.InternFieldNames.getMask();
        features |= Feature.UseBigDecimal.getMask();
        features |= Feature.AllowUnQuotedFieldNames.getMask();
        features |= Feature.AllowSingleQuotes.getMask();
        features |= Feature.AllowArbitraryCommas.getMask();
        features |= Feature.SortFeidFastMatch.getMask();
        features |= Feature.IgnoreNotMatch.getMask();
        DEFAULT_PARSER_FEATURE = features;
    }

 

加载中
1
温安适
温安适
|= // 按位或操作

经过上边的操作  features 的二进制值就表示了上述所有状态,这个是节省空间,快速判断当前特性的操作。

温安适
温安适
回复 @夜辰 : 原理类似
9527-abc
9527-abc
和linux那个权限可读可写可执行同一类型的么?
0
yehun
yehun

默认转换的属性, |=按位或赋值

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部