Class AccessCode

java.lang.Object
org.apache.openjpa.meta.AccessCode

public class AccessCode extends Object
Represents access styles for members of a class and field through a 5-bit integer.
The bits designate following aspects of access style being used at class level:
  • Bit position 0 (UNKNOWN): generally 0. All bits as zero represent that no access style has been set. 1 denotes that the class has no property at all and its access can not be determined.
  • Bit position 1 (FIELD): Field based access is default
  • Bit position 2 (PROPERTY): Property based access is default
  • Bit position 3 (EXPLICIT): whether explicit or implicit Explicit access style allows members to use mixed access style, implicit access style does not
  • Bit position 4 (MIXED): whether all members are using the same access style or not. Can only be set if EXPLICT bit is set. If set, then bit 1 or 2 denotes what is the default.
    The same bits designate following aspects of access style being used at field level:
  • Bit position 0 (UNKNOWN): always 0. All bits as zero represent that no access style has been set.
  • Bit position 1 (FIELD): Field based access is default
  • Bit position 2 (PROPERTY): Property based access is default
  • Bit position 3 (EXPLICIT): whether the access is explicit or implicit
  • Bit position 4 (MIXED): not used

    Validation Rules for the bits:

  • 1. Only one of the position 1 (FIELD) and 2 (PROPERTY) can be set. A single bit is not used for legacy reason to cope with the access constants used in ClassMetaData which this class now refactors to address new behaviors specified in JPA 2.0 specification.
  • 2. if position 3 (EXPLICIT) is set then one of position 1 (FIELD) and 2 (PROPERTY) must be set.
  • 3. If position 4 (MIXED) is set then the set position of either FIELD or PROPERTY designates the default access of the member.
  • Since:
    2.0.0
    Author:
    Pinaki Poddar
    • Field Details

      • UNKNOWN

        public static int UNKNOWN
      • EMPTY

        public static int EMPTY
      • FIELD

        public static int FIELD
      • PROPERTY

        public static int PROPERTY
      • EXPLICIT

        public static int EXPLICIT
      • MIXED

        public static int MIXED
    • Constructor Details

      • AccessCode

        public AccessCode()
    • Method Details

      • isValidClassCode

        public static boolean isValidClassCode(int code)
        Affirms if the given code is valid.
      • isValidFieldCode

        public static boolean isValidFieldCode(int code)
      • isMixed

        public static boolean isMixed(int code)
        Affirms if the given code designates that members can use both FIELD and PROPERTY based access.
      • isExplicit

        public static boolean isExplicit(int code)
      • isProperty

        public static boolean isProperty(int code)
      • isField

        public static boolean isField(int code)
      • isUnknown

        public static boolean isUnknown(int code)
      • isEmpty

        public static boolean isEmpty(int code)
      • isField

        public static boolean isField(ClassMetaData meta)
      • isProperty

        public static boolean isProperty(ClassMetaData meta)
      • isUnknown

        public static boolean isUnknown(ClassMetaData meta)
      • isEmpty

        public static boolean isEmpty(ClassMetaData meta)
      • isField

        public static boolean isField(FieldMetaData meta)
      • isProperty

        public static boolean isProperty(FieldMetaData meta)
      • isUnknown

        public static boolean isUnknown(FieldMetaData meta)
      • isCompatibleSuper

        public static boolean isCompatibleSuper(int subCode, int superCode)
        Affirms if the sub class access type is compatible with super class access style.
      • mergeFieldCode

        public static int mergeFieldCode(ClassMetaData meta, FieldMetaData fmd, int fCode)
      • mergeFieldCode

        public static int mergeFieldCode(int cCode, int fCode)
        Merges the field access type with the class access type provided such merge is valid.
        Returns:
        the modified class access code.
        Throws:
        IllegalStateException - if the given codes are not compatible
      • getMixedCode

        public static int getMixedCode(int cCode, int fCode)
      • toFieldCode

        public static int toFieldCode(int code)
      • toFieldString

        public static String toFieldString(int code)
      • toClassString

        public static String toClassString(int code)