org.apache.openjpa.meta
Class AccessCode

java.lang.Object
  extended by 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 Summary
    static int EMPTY
               
    static int EXPLICIT
               
    static int FIELD
               
    static int MIXED
               
    static int PROPERTY
               
    static int UNKNOWN
               
     
    Constructor Summary
    AccessCode()
               
     
    Method Summary
    static int getMixedCode(int cCode, int fCode)
               
    static boolean isCompatibleSuper(int subCode, int superCode)
              Affirms if the sub class access type is compatible with super class access style.
    static boolean isEmpty(ClassMetaData meta)
               
    static boolean isEmpty(int code)
               
    static boolean isExplicit(int code)
               
    static boolean isField(ClassMetaData meta)
               
    static boolean isField(FieldMetaData meta)
               
    static boolean isField(int code)
               
    static boolean isMixed(int code)
              Affirms if the given code designates that members can use both FIELD and PROPERTY based access.
    static boolean isProperty(ClassMetaData meta)
               
    static boolean isProperty(FieldMetaData meta)
               
    static boolean isProperty(int code)
               
    static boolean isUnknown(ClassMetaData meta)
               
    static boolean isUnknown(FieldMetaData meta)
               
    static boolean isUnknown(int code)
               
    static boolean isValidClassCode(int code)
              Affirms if the given code is valid.
    static boolean isValidFieldCode(int code)
               
    static int mergeFieldCode(ClassMetaData meta, FieldMetaData fmd, int fCode)
               
    static int mergeFieldCode(int cCode, int fCode)
              Merges the field access type with the class access type provided such merge is valid.
    static String toClassString(int code)
               
    static int toFieldCode(int code)
               
    static String toFieldString(int code)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    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 Detail

    AccessCode

    public AccessCode()
    Method Detail

    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:
    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)


    Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.