I have a class which constructor takes a Jakarta enums. I'm trying to find how I can easily inject it via an Spring XML aplicationContext.
For example :
The enum :
public class MyEnum extends org.apache.commons.lang.enums.Enum {
public static final MyEnum MY_FIRST_VALUE = new MyEnum("MyFirstValue");
public static final MyEnum ...
public enum myEnum {
VAL1(10), VAL2(20), VAL3("hai") {
public Object getValue() {
return this.strVal;
}
public String showMsg() {
return "This is your msg!";
}
};
String strVal;
Integer intVal;
public Object getValue() {
return this.intVal;
}
private myEnum(int i) {
th...
Could someone please point me toward a cleaner method to generate a random enum member. This works but seems ugly.
Thanks!
public T RandomEnum<T>()
{
string[] items = Enum.GetNames(typeof( T ));
Random r = new Random();
string e = items[r.Next(0, items.Length - 1)];
return (T)Enum.Parse(typeof (T), e, true);
}
...
Hi, I was wondering in C++ if I have an enum can I access the value at the second index? For example I have
enum Test{hi, bye};
if I want 'hi', can I do something like Test[0], thanks.
...
Hi
I have an enumeration of delivery status codes. And when I save delivery data to the database they are stored with a foreign key to a table containing the same data (i.e. the same delivery codes)
What is the best strategy for keeping an enumeration in synch with data in a database?
Do you just remember to add to the enumeration wh...
Hi,
I am wondering how you would approach this problem
I have two Taxrates that can apply to my products. I specifically want to avoid persisting the Taxrates into the database while still being able to change them in a central place (like Taxrate from 20% to 19% etc).
so I decided it would be great to have them just compiled into my ...
This is my code:
internal enum WindowsMessagesFlags {
WM_EXITSIZEMOVE = 0x00000232,
WM_DISPLAYCHANGE = 0x0000007e,
WM_MOVING = 0x00000216,
}
protected override void WndProc(ref Message m) {
switch(m.Msg) {
case (int)WindowsMessagesFlags.WM_DISPLAYCHANGE:
FixWindowSnapping();
break;
...
I've heard some people saying that enums are evil and shouldn't be used in web services because of the mismatches that could occur between the server and the client if some values are assigned, or if the enum is marked with the Flags attribute. They also said that web services exposing enums are harder to maintain but couldn't really giv...
For those who like a good WPF binding challenge:
I have a nearly functional example of two-way binding a checkbox to an individual bit of a flags enumeration (thanks Ian Oakes, original MSDN post). The problem though is that the binding behaves as if it is one way (UI to DataContext, not vice versa). So effectively the check box does ...
I have an enum
public enum FileExtentions {
mp3,
mpeg
}
And I have a FileInfo of which I want to check if the extension is in the previous enum.
I was hoping I could do a
FileExtensions.Any(e=>e.ToString().Equals(file.Extension));
But that would have been too awesome.
Any ideas?
...
One thing I really like about AS3 over AS2 is how much more compile-time type-checking it adds. However, it seems to be somewhat lacking in that there is no type-checked enumeration structure available. What's a good (best / accepted) way to do custom enumerated types in AS3?
...
Following up this question: "Database enums - pros and cons", I'd like to know which database systems support enumeration data types, and a bit of detail on how they do it (e.g. what is stored internally, what are the limits, query syntax implications, indexing implications, ...).
Discussion of use cases or the pros and cons should take...
Suppose you're maintaining an API that was originally released years ago (before java gained enum support) and it defines a class with enumeration values as ints:
public class VitaminType {
public static final int RETINOL = 0;
public static final int THIAMIN = 1;
public static final int RIBOFLAVIN = 2;
}
Over the years the API has ...
Hello
Apache XMLBeans can be used to generate Java classes and interfaces from XML Schema Definition files (XSD). It also generates Enums based on StringEnumAbstractBase and StringEnumAbstractBase.Table to represent domain values. They are handy for entering only valid values. However, I want to get all those values to generate a JCombo...
We were having a debate if enums should have uninitialized values. For example. We have
public enum TimeOfDayType
{
Morning
Afternoon
Evening
}
or
public enum TimeOfDayType
{
None
Morning
Afternoon
Evening
}
I think that there shouldn't be any none but then you have to default to some valid value on initi...
Fun with enums in C#. Take one generic list that is created to store some Enum that you had defined previously and add few items in it. Iterate with foreach or GetEnumerator<T>() but specify some other enum then the original and see what happens. I was expecting InvalidCastException or something like that but it perfectly works :).
...
I have an existing database of a film rental system. Each film has a has a rating attribute. In SQL they used a constraint to limit the allowed values of this attribute.
CONSTRAINT film_rating_check CHECK
((((((((rating)::text = ''::text) OR
((rating)::text = 'G'::text)) OR
((rating)::text = 'PG'::text)) OR
...
Hi,
I want to pass an enum value as command parameter in WPF, something like this -
<Button x:Name="uxSearchButton" Command="{Binding Path=SearchMembersCommand}"
CommandParameter="SearchPageType.First" Content="Search"></Button>
SearchPageType is an enum and this is to know from which button search command is invoked.
Is th...
I have some tables that represent various types. They usually just consist of an ID (int), and a name. Ideally I would have this in an enum. Is there a way to map a table like this onto an enum?
EDIT: How would I handle it if there were extra fields other than an ID and Name?
...
I'm creating a set of enum values, but I need each enum value to be 64 bits wide. If I recall correctly, an enum is generally the same size as an int; but I thought I read somewhere that (at least in GCC) the compiler can make the enum any width they need to be to hold their values. So, is it possible to have an enum that is 64 bits wide...