PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/com/alibaba/fastjson/parser/Feature.java

https://bitbucket.org/xiejuntao/xdesktop
Java | 106 lines | 35 code | 14 blank | 57 comment | 3 complexity | 28b42508f65a0feb6d573240dcd649d7 MD5 | raw file
  1. /*
  2. * Copyright 1999-2101 Alibaba Group.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.alibaba.fastjson.parser;
  17. /**
  18. * @author wenshao<szujobs@hotmail.com>
  19. */
  20. public enum Feature {
  21. /**
  22. *
  23. */
  24. AutoCloseSource,
  25. /**
  26. *
  27. */
  28. AllowComment,
  29. /**
  30. *
  31. */
  32. AllowUnQuotedFieldNames,
  33. /**
  34. *
  35. */
  36. AllowSingleQuotes,
  37. /**
  38. *
  39. */
  40. InternFieldNames,
  41. /**
  42. *
  43. */
  44. AllowISO8601DateFormat,
  45. /**
  46. * {"a":1,,,"b":2}
  47. */
  48. AllowArbitraryCommas,
  49. /**
  50. *
  51. */
  52. UseBigDecimal,
  53. /**
  54. * @since 1.1.2
  55. */
  56. IgnoreNotMatch,
  57. /**
  58. * @since 1.1.3
  59. */
  60. SortFeidFastMatch,
  61. /**
  62. * @since 1.1.3
  63. */
  64. DisableASM,
  65. /**
  66. * @since 1.1.7
  67. */
  68. DisableCircularReferenceDetect,
  69. /**
  70. * @since 1.1.10
  71. */
  72. InitStringFieldAsEmpty
  73. ;
  74. private Feature(){
  75. mask = (1 << ordinal());
  76. }
  77. private final int mask;
  78. public final int getMask() {
  79. return mask;
  80. }
  81. public static boolean isEnabled(int features, Feature feature) {
  82. return (features & feature.getMask()) != 0;
  83. }
  84. public static int config(int features, Feature feature, boolean state) {
  85. if (state) {
  86. features |= feature.getMask();
  87. } else {
  88. features &= ~feature.getMask();
  89. }
  90. return features;
  91. }
  92. }