浏览 1882 次
锁定老帖子 主题:赋值运算符的疑问
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2012-02-16
代码如下: //省略了部分代码 public static int DEFAULT_PARSER_FEATURE; 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; } // 这里是调用方法 public static final Object parse(String text, int features) { //.. } public enum Feature { AutoCloseSource, AllowComment, AllowUnQuotedFieldNames, AllowSingleQuotes ; private Feature(){ mask = (1 << ordinal()); } private final int mask; public final int getMask() { return mask; } public static boolean isEnabled(int features, Feature feature) { return (features & feature.getMask()) != 0; } public static int config(int features, Feature feature, boolean state) { if (state) { features |= feature.getMask(); } else { features &= ~feature.getMask(); } return features; } } 在什么场景使用这类赋值运算符? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |