Here's what we're really trying to achieve. We have a concept of a person and
would like to have a variety of different types or roles and the ability to
embody one or more. Our gut approach would be to have an int field coupled with
static final variables named in such a way to clearly indicate which types mean
what. We would use a bitwise or to decode the value and tell us which type of
person this is. For example we'd like to right the following code:
| type_code | set('misc','info','helper')
public static final int TYPE_CODE_MISC = 1;
public static final int TYPE_CODE_INFO = 2;
public static final int TYPE_CODE_HELPER = 4;
if ((getTypeCode() & Person.TYPE_CODE_MISC) == Person.TYPE_CODE_MISC)
This would return a yeah or nay if the asked about type_code was found in
the value.
What we're looking for is a way to name the static variables with meaningful
(read rememberable) names. It doesn't matter whether this is backed by a single
integer values in the database or the ability to extract the set values into a
list containing the values of the type_code for this record. We nust want to be
able to able to decode it without it having to look like this:
if ((getTypeCode() & PersonTypes.VALUE_1) == PersonTypes.VALUE_1)
We could find no way to indicate in the schema what the values or names of the
static int variables were. Let us know if this is any clearer.
Cheers,
Tim & Ben
"Ebersole, Steven" wrote:
> Was there a reason you did not want to simply load the column value into the
> object and then simply perform the bitwise manipulations there?
>
> ********************************************
> Steve Ebersole
> IT Integration Engineer
> Vignette Corporation
> 512.741.4195
>
> Visit http://www.vignette.com
>
> ********************************************
>
> -----Original Message-----
> From: Timothy Ruppert [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 6:48 AM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] Mysql set type - Resend - if I need to rephrase
> please let me know
>
> We are just trying to generate a field that reflects a type_code on an
> entity object where the type_code could hold multiple values decoded via
>
> a bitwise or. For example, a person may have a type_code field and the
> individual person may be one or many types. One approach would be to
> define final ints and perform a bitwise or on the values:
> final int MISC_TYPE = 1;
> final int HELPER_TYPE = 2;
> final int IN_CHARGE_TYPE = 4;
> . . .
>
> We also tried an enumeration, but we couldn't find a way to reflect the
> database set concept in this framework. The attributeGroup concept
> appeared to be a little closer at first glance, but didn't handle the
> individual field as a set either.
>
> Our attempts resulted in a types.PersonType class with an instance of
> PersonType as VALUE_1 and the int occupying VALUE_1_TYPE = 1; etc for
> the other enum values.
>
> I'm sure this has been done plenty of times - can someone please share??
>
> Cheers,
> Tim Ruppert && Ben Cox
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev