I have type-safe generic array copying!

Check this out. I get no warnings from this, and so far it seems to work fine, and it only takes twice the time of a normal array copy.
All you have to do is pass in a dummy array of the same type as your inputArray, which under normal circumstances is very doable. The dummy array does not need to have the same dimension as the input array, which lets you use this as a static method in a utility class without feeling the burning need to make it throw an exception.
It takes advantage of Collections' type-safe toArray() method.
     public static <T> T[] copyArray(T[] inputArray, T[] targetArray)
          return arrayToList(inputArray).toArray(targetArray);
     private static <T> ArrayList<T> arrayToList(T[] inputArray)
          ArrayList<T> returnValue = new ArrayList<T>();
          for(int i = 0; i < inputArray.length; i++)
               returnValue.add(inputArray);
          return returnValue;

And I like my tabs, thank you.Many people consider using tabs in code to be
amatuerish. I can't say I disagree. Tabs are
represented as different lengths depending on the
editor. If you are using Eclipse, you can set it to
insert a number of space when you hit tab instead of
inserting tabs.I like tabs because they are an abstraction of indentation levels, something you don't get with spaces (unless you use one space per level), and therefore it makes more sense to me to use them. I use editors with good tab sizes that are also adjustable. Plus, I just like them better. So there.

Similar Messages

  • Type Safe Collections

    Hello All,
    I want to have type safe collections. Today. when we do programming with collections it almost behaves like a scripting language with no data types. any thing which is an object goes in and comes out freely.
    what about having a Collection(vector, ArrayList) class which can contain objects of only one type.
    something like
    ArrayList<Integer> a = new ArrayList();
    regards,
    Abhishek.

    Here's my way of using generics in normal Java - not quite as good as a compile error - but it works, and gives you a runtime error on inserting an object of the wrong type.
    I did this when at Uni, hence all the funky comments (well, you can't expect the lecturers to actually read the code, can you?).
    Just something you may find useful:
    import java.util.*;
    ���An implementation of the Proxy pattern, designed to wrap any list, and make it accept
    ���objects of the specified type (subclasses are allowed) only, hence allowing a user of
    ���this class to 'trust' the Proxy list.
    public class TypeSafeList extends AbstractList implements Serializable
    ���protected List source;
    ���protected Class acceptable;
    ���/**
    ������@param list the list to assign.
    ������@exception java.lang.IllegalArgumentException if the list contains elements of a
    ������different type to that specified
    ���*/
    ���public TypeSafeList(List list,Class acceptable)
    ���{
    ������Iterator iterator = list.iterator();
    ������while( iterator.hasNext() )
    ���������if( !acceptable.isInstance( iterator.next() ) )
    ������������throw new IllegalArgumentException( list+" contains elements not of type "+acceptable);
    ������this.source=list;
    ������this.acceptable=acceptable;
    ���}
    ���/**
    ������Passes on the request to the underlying list. See java.util.List.
    ���*/
    ���public Object get(int index)
    ���{
    ������return source.get(index);
    ���}
    ���/**
    ������Passes on the request to the underlying list. See java.util.List.
    ���*/
    ���public int size()
    ���{
    ������return source.size();
    ���}
    ���/**
    ������Checks that the type of the parameter is valid, and then passes on the
    ������request to the underlying list. See java.util.List.
    ������
    ������@exception java.lang.IllegalArgumentException if the type of the parameter is
    ������invalid.
    ���*/
    ���public Object set(int index,Object element)
    ���{
    ������return source.set(index,checkType(element));
    ���}
    ���/**
    ������Passes on the request to the underlying list. See java.util.List.
    ���*/
    ���public Object remove(int index)
    ���{
    ������return source.remove(index);
    ���}
    ���/**
    ������Checks that the type of the parameter is valid, and then passes on the
    ������request to the underlying list. See java.util.List.
    ���*/���
    ���public void add(int index,Object object)
    ���{
    ������source.add(index,checkType(object));
    ���}
    ���/**
    ������Return the Class object this List is configured to accept.
    ���*/
    ���public Class getAcceptable()
    ���{
    ������return acceptable;
    ���}
    ���
    ���/**���
    ������Checks the validity of the parameter against the protected field 'acceptable'.
    ������@return object if object is valid.
    ������@exception java.lang.IllegalArgumentException if the argument is invalid.
    ���*/
    ���protected Object checkType(Object object) throws IllegalArgumentException
    ���{
    ������if (acceptable.isInstance(object))
    ���������return object;
    ������throw new IllegalArgumentException(object+" needs to be of type "+acceptable.getName());
    ���}
    }

  • Generics simply aren't type-safe?

    From http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf page 15:
    In particular, the language is designed to guarantee that if your entire application has been compiled without unchecked warnings using javac -source 1.5, it is type safe.
    However, I can create this:
    import java.util.*;
    public class TypeUnsafe
         static public <T extends Collection> void workaround(T a, T b)
              a.addAll(b);
         static public void main(String[] args)
              Collection<Integer> a = new ArrayList<Integer>();
              Collection<String> b = new ArrayList<String>();
              b.add("Bwahahaha");
              workaround(a, b);
              System.out.println(a.iterator().next().intValue()); // ClassCastException
    }There are no casts or particular trickery involved, and this compiles without warnings using javac -source 1.5. Yet I just added a String to a Collection<Integer>. Despite T being defined as extending a raw type, the usual unchecked warning when calling a method with parameterised arguments on a raw type is not given.
    On the positive side, it gives me a handy alternative to the NYI @SuppressWarnings :)
    I've searched bug parade and the forums, but haven't come across this particular problem... I've only recently started playing with generics, so perhaps I'm missing some subtlety that explains why people aren't jumping up and down and screaming about this.
    Sorry if this has been discussed before, and I'm not yet familiar enough with the terminology to have found it in my searches.

    Few thoughts:
    - The program kingguppy has presented is an example of program with false sense of security despite using generics - the generic program compiles even without a warning but in the end it throws ClassCastException. I hope that we won't find many generic programs with such characteric. I'd say that the program does not benefit of generics because there is no contract between container and containee as far as parameters of workaround() method are concerned. Actually, as Michael said, it uses raw type (Collection). If possible we should avoid using raw types in generic programs. By the way, do you know that raw types might be deprecated in the future?
    - Micheal also sugested that in case when there is a conversion from parameterized type to raw type the compiler should emit a warning. I agree with him. I hope that kingguppy will file a bug report and let us know what "generic gurus" think about it. Funny, if the workaround() method were designed as
    static public void notGenerifiedMethod(Collection a, Collection b) {
      a.addAll(b);
    }the compiler would actually emit an unchecked warning. Perhaps, it's sometimes better not to use generified methods.
    - The reason why I presented let's say a possible or different solution to the original problem is because in the end it matters only if we, developers, can produce a workable solution. The bosses don't like to hear that there are bugs... I hope you all know what I mean. Who knows, there might be a reader of this forum who will find it useful.
    Your thoughts are welcomed.
    Andrej

  • Problem in generic value copier class / reflection and generic classes

    Hello experts,
    I try to archive the following and am struggling for quite some time now. Can someone please give an assessment if this is possible:
    I am trying to write a generic data copy method. It searches for all (parameterless) getter methods in the source object that have a corresponding setter method (with same name but prefixed by "set" instead of "get" and with exactly one parameter) in the destination object.
    For each pair I found I do the following: If the param of the setter type (T2) is assignable from the return type of the getter (T1), I just assign the value. If the types are not compatible, I want to instantiate a new instance of T2, assign it via the setter, and invoke copyData recursively on the object I get from the getter (as source) and the newly created instance (as destination). The assumption is here, that the occurring source and destination objects are incompatible but have matching getter and setter names and at the leaves of the object tree, the types of the getters and setters are compatible so that the recursion ends.
    The core of the problem I am struggling with is the step where I instantiate the new destination object. If T2 is a non-generic type, this is straightforward. However, imagine T1 and T2 are parametrized collections: T1 is List<T3> and T2 is List<T4>. Then I need special handling of the collection. I can easily iterate over the elements of the source List and get the types of the elements, but I can not instantiate only a generic version of the destinatino List. Further I cannot create elements of T4 and add it to the list of T2 and go into recursion, since the information that the inner type of the destination list is T4 is not available at run-time.
    public class Source {
       T1 getA();
       setA(T1 x);
    public class Dest {
       T2 getA();
       setA(T2 x);
    public class BeanDataCopier {
       public static void copyData(Object source, Object destination) {
          for (Method getterMethod : sourceGetterMethods) {
             ... // find matching getter and setter names
             Class sourceParamT = [class of return value of the getter];
             Class destParamT = [class of single param of the setter];
             // special handling for collections -  I could use some help here
             // if types are not compatible
             Object destParam = destination.getClass().newInstance();
             Object sourceParam = source.[invoke getter method];
             copyData(sourceParam, destParam);
    // usage of the method
    Souce s = new Source(); // this is an example, I do not know the type of s at copying time
    Dest d = new Dest(); // the same is true for d
    // initialize s in a complicated way (actually JAX-B does this)
    // copy values of s to d
    BeanDataCopier.copyData(s, d);
    // now d should have copied values from s Can you provide me with any alternative approaches to implement this "duck typing" behaviour on copying properties?
    Best regards,
    Patrik
    PS: You might have guessed my overall use case: I am sending an object tree over a web service. On the server side, the web service operation has a deeply nested object structure as the return type. On the client side, these resulting object tree has instances not of the original classes, but of client classes generated by axis. The original and generated classes are of different types but have the identically named getter and setter methods (which again have incompatible parameter types that however have consistent names). On the client side, I want to simply create an object of the original class and have the values of the client object (including the whole object tree) copied into it.
    Edited by: Patrik_Spiess on Sep 3, 2008 5:09 AM

    As I understand your use case this is already supported by Axis with beanMapping [http://ws.apache.org/axis/java/user-guide.html#EncodingYourBeansTheBeanSerializer]
    - Roy

  • Describe non-generic array cast in JLS3 as being unchecked

    This method :
        static <T, U extends T> U[] cast(T[] a) { return (U[]) a; }will generate the warning: [unchecked] unchecked cast, found: T[], required: U[].
    And it should. Wouldn't it be appropriate if
        static Object[] cast(String[] a) { return (String[]) a; }would produce the same warning?
    If you do that, you could translate the declaration
      T[] at = new T[255]
      String[] as = new String[255]into
    Array<T> at = Array.<T>newInstance(255);
    Array<String> as = Array.<String>newInstance(String.class, 255);where java.lang.reflect.Array would be something like
    package java.lang.reflect.Array;
    public final class Array<T> implements Iterable<T> {
        public final int length;
        private Type memberType;
        private Array(Type memberType, int length) {
            this.memberType = memberType;
            this.length = length;
        public native T getMember(int i);
        public native void setMember(int i, T member);
        public native java.util.Iterator<T> iterator();
       public static <U> Array<U> newInstance(int length) {
           return new Array<U>(null, length);
       public static <U> Array<U> newInstance(Class<U> memberClass, int length) {
           return new Array<U>(memberClass, length);

    Sorry, I created a bad example. It should have been:
        static <T, U extends T> T[] cast(U[] a) { return (T[]) a; }and
        static Object[] cast(String[] a) { return (Object[]) a; }The point is that an array of String is different from an array of Object and casts between them is unsafe. Throwing an ArrayStoreException if the wrong type is assigned is just a workaround for lack generic types in pre-Tiger Java. Now that we will have generics, I think it would be appropriate if Java arrays would be treated as proper generic types. For those that are afraid of breaking backwards compatiblility, the erasure mechanism should be able to take care of that.

  • Array Copy Problem

    ARRAY COPY DOESN'T WORK. DO NOT ATTEMPT TO USE IT IN YOUR REPLY TO THIS TOPIC. array copy says that you need the same type of object in the arrays. I'm making a method in a class called SUPERARRAYUTIL where this isn't the case. They all extend from a class i made called SUPERARRAY (in javacase caps tho, i just like to use upper case), but that doesnt help me. I'm short on time and i want to post this right now, so i won have any code right away but here is how i'm gonna do it:
    1) Static method takes parameters superArray array, superArray newelements, and int start
    2) Make a temp array that would be big enough to fit array, and the newelements at postion start in array
    3) copy over array using a for loop, starting at 0 in temp.
    4) copy over newelements using a for loop, starting at start in temp.
    Then i will make non-static methods for superArrayUtil that will use the static methods in superArrayUtil. I will also make a method like System.arraycopy but will call a method called cut to trim the array of new elements and then call this arraycopy to copy it into the dest array, and then another non-static method for that method too.
    Basically i just need ideas or comments cause so far i ran into some weird problems or any suggestions if there's a better way to copy arrays in the general way of array1 into array2 at a starting position.

    Deo_Favente wrote:
    ARRAY COPY DOESN'T WORK.
    YES. YES IT DOES. WHY DO YOU THINK THAT IT DOESNT WORK? WHY DON'T YOU POST WHATEVER CODE THAT YOU DO HAVE THAT IS CAUSING YOU PROBLEMS AND THEN MAYBE WE COULD WORK WITH IT. I THINK THAT'S A BETTER IDEA PERSONALLY, AT LEAST OPPOSED TO WHAT YOU DID HERE._+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • My generic array creation problem.

    I'm getting a "generic array creation" error on lines 6 and 14. I've googled it and I'm still having a hard time. Most things I find on it are pretty complicated and as you can see mine's not, I'm in a beginners course. I'm basically writing a class with methods for dealing with a file of donors.
    Here's my code:
    public class DonorList <dlist>
        //Create empty list
        public DonorList()
            storage = new dlist [MAX];
            count = 0;
        //Capacity as specified
        public DonorList (int cap)
            MAX = cap;
            storage = new dlist [MAX];
            count = 0;
        public boolean isEmpty()
            return count == 0;
        public void clear()
            count = 0;
        //Returns number of elements
        public int size()
            return count;
        //Item at position k, position starts at zero
        public dlist get (int k)
            if (k >= 0 && k < count)
                return storage [k];
            return null;
        // e becomes item at position k
        public dlist set (int k, dlist e)
            dlist old = null;
            if (k > 0 && k < count)
                    old = storage [k];
                    storage [k] = e;
            return false;
        //Returns the position of e or -1 if not found.
        public int indexOf (dlist e)
            int k;
            for (k = 0; k < count; k++)
                if (e.equals(storage[k]))
                    return k;
            return -1;
        //Appends e at the end of the list. Returns false on failure.
        public boolean append (dlist e)
            if (count < MAX)
                storage [count] = e;
                count ++;
                return true;
            return false;
        //Adds e at position k. Returns false on failure.
        public boolean add (int k, dlist e)
            int j;
            if (count == MAX || k < 0 || k > count)
                return false;
            for ( j = count; j > k; j--)
                    storage [j] = storage [j-1];
                    storage [k] = e;
                    count ++;
                    return true;
            return false;
        private int MAX = 100;
        private dlist [] storage;
        private int count;
    }Any help as to why I am getting these errors is very much appreciated. Thanks.

    You cannot create an array of a generic, instead you need to create an array of the class the generic extends (in this case Object)
    You then have to cast the array to the generic type which will give you an unchecked warning which you can turn off with @SuppressWarning("unchecked") on the class.
    Generics and arrays don't always play nicely together and this is one case. ;-)

  • How can I check an object is an instance of any type within an array of related types?

    In LabVIEW, it's possible to check the runtime type of an object using To More Specific Class.vi. One usage of this would be to perform a safety check if some kind of class uses instances of another kind of class but is only able to handle a subset of that class' child types.
    For instance, let's say you had Beverage.lvclass, which represents an abstract type of product, and several subclasses: Coffee.lvclass, Tea.lvclass and Soda.lvclass.
    We also have a Person.lvclass which can drink beverages. A person also has preferences about the drinks they do or do not like:
    Attached is an implementation of this in LabVIEW.
    In Person.lvclass : Drink.vi, I have the following code. For whatever reason the wire appears broken in these snippets but it's all fine in the actual code.
    In Scenario.vi, I have the following code:
    What I'm finding is that no error is generated and instead I get "Yum, I love tea!", "Yum, I love coffee!" and "Yum, I love soda!". My guess is that To More Specific Class.vi casts to the static type of the "target class" input wire rather than its runtime type - and because I'm passing in elements from an array of types, the wire's static type is upcasted to the most specific type that is a superclass of the types in the array - which would be Beverage.lvclass. And so the cast is trying to determine if an object of static type Beverage.lvclass is an instance of Beverage.lvclass, which will of course be the case all the time.
    Is there any way to make LabVIEW check against the most specific runtype type of an object? As in, is there something I could do that, in this example case, would allow me to get the required behaviour of Joe throwing an error when he's made to drink soda? Or is this another limitation of LabVIEW that I'm going to have to live with?
    Solved!
    Go to Solution.
    Attachments:
    TypeCastingExample.zip ‏64 KB

    tst wrote:
    Your guess seems reasonable. I can't check right now, but there's a primitive called preserve run time type, which should do what you want.
    Cheers, that seems to have got it! I've never really looked at Preserve Run-Time Class before, but it seems to do the right thing.

  • What does it mean by "Deprecation of MBeanHome and Type-Safe Interfaces" ?

    The "Javadoc" for the type safe WebLogic MBean interfaces have this disclaimer;
    Deprecation of MBeanHome and Type-Safe Interfaces... This is a type-safe interface for a WebLogic Server MBean, which you can import into your client classes and access through weblogic.management.MBeanHome. As of 9.0, the MBeanHome interface and all type-safe interfaces for WebLogic Server MBeans are deprecated. Instead, client classes that interact with WebLogic Server MBeans should use standard JMX design patterns in which clients use the javax.management.MBeanServerConnection interface to discover MBeans, attributes, and attribute types at runtime.
    Link: http://otndnld.oracle.co.jp/document/products/wls/docs100/javadocs_mhome/weblogic/management/configuration/DomainMBean.html
    I don't understand what this means;
    1) Is all the WebLogic MBean interfaces in the "weblogic.management.configuration.*" deprecated?
    2) Is the usage of MBeanTypeService also deprecated. since it requires the an WebLogic MBean interface as input for it's getMBeanInfo method?
    3) If the WebLogic MBean interfaces will dispear, wil there be any reliable source for type information about WebLogic MBean since the information returned by MBeanTypeService.getMbeanInfo(), MBeanserver.getMbeanInfo() or WebLogicObjectName.getMbeanInfo() isn't consist in its naming schemes (tries to but..)?

    Hi,
    While scheduling background job, you can trigger the job based on existing job status as dependency or schedule the job based on the SAP Event.
    Dependency Job like first background job completes successfully then second followup job will executed other job will not triggered.
    Event Jobs: While importing data through transportation, some RDD* jobs automatically triggers. These are event based jobs.
    Regards,
    Ganesh
    ****Reward points if Helpful*****

  • UISelectMany :  must be of type List or Array (ERROR with rich:pickLisT )

    Hi
    I have a problem with my <rich:pickList> I can't display the items. When executing the application I got the following error:
    java.lang.IllegalArgumentException: ValueBinding for UISelectMany :  must be of type List or Array
            at org.richfaces.utils.PickListUtils.findUISelectManyConverter(PickListUtils.java:59)
            at org.richfaces.utils.PickListUtils.findUISelectManyConverterFailsafe(PickListUtils.java:79)as the error message the selectItems is not a List but it is I can't understand.
    I transmit to you my backing bean
    @Stateful
    @Name("adminAction")
    @Scope(ScopeType.SESSION)
    public class AdminActionBean implements AdminActionLocal {
    @In(required=false)
       private List<String> customersChoice;
    @Out(required=false)
       private List<String> companyNames;
    @Factory("companyNames")
       public void selectCompanyNames(){
           setCompanyNames((List<String>) getEm().createQuery("select c.companyName from Customer c")
                        .getResultList());
    //getter() and settter...... my .xhtml page
    <rich:pickList id="customersChoice" value="#{customersChoice}">
                        <f:selectItems  id="companyNames" value="#{companyNames}" />
              </rich:pickList>Have you got any Idea. thanks for help
    regards
    bibou

    You might look up the SelectItem, as the value parameter for a f:selectItems must be a List<SelectItem>. Each SelectItem has both a value and a label.
    Or, you could use Tomahawk's t:selectItems which uses a more dataList-style attribute set to allow you to have the value be any List, and you can select items in the List's node to be the Label and the Value of the select option.
    Look em up, they're useful.

  • What type of generic delta to use and what field?

    Dear BW Gurus,
    I am creating a generic datasource based on a view BSAK and BSIK (Accounts Payable tables). I am not able to determine what type of generic delta (numeric pointer, calender day or timestamp) should i use and what field in the table should it that be based on? All or any help is greatly appreciated.
    Thanks
    Raj

    CALDAY on field BLDAT (in both tables) seem an obvious candidate.
    Added - You will need help from functional people (or you can try it in ABAP forum) to determine which date field is updated with the system date when these tables are updated with SAP txns (some hint can be had by looking at the data)- the fields of interest would be -
    BUDAT
    BLDAT
    CPUDT
    It is almost certain that CALDAY is the only option you have for delta type, and one of these three fields will have to be chosen.
    Message was edited by: Ajay Das

  • Axis - Using type safe enumerations as parameters.

    I defined the following:
    interface A {
    foo(E x);
    where class E is a type safe enumeration (NOT a Java1.5 enum).
    When using java2wsdl | wsdl2java i get:
    interface A' {
    foo(String x);
    And then all the stubs and skeletons are implementing A' so I can't use my A. How can I stop axis from doing this?

    Hi,
    AFAIK, you can't. I'm not an expert though, so everything below may not be the best solution.
    The best way I have found for dealing with enums is to declare them as such in your schema, viz:
          <simpleType name="HoldStatus">
            <annotation>
              <documentation>The status of a hold.</documentation>
            </annotation>
            <restriction base="string">
              <enumeration value="INACTIVE"/>
              <enumeration value="ACTIVE"/>
            </restriction>
          </simpleType>Then, most WSDL->Java tools will do something sensible with this, making their own form of enum. I don't know about Axis, but Weblogic's wsdl2service does this.
    Then you still have to map between the generated enum and your one. This is the best solution I'm aware of, though.
    As far as running java2wsdl then wsdl2java - I'm not aware of any tools that will do 'round tripping' like this successfully. I'd be keen to hear of some if there are any though :-D
    -Tim

  • Generic arrays

    I want to make an array of LinkedLists of Doubles. I tried:
    LinkedList<Double> buckets = new LinkedList<Double>[n];which gave me an error because I'm creating a generic array. On the other hand, if I do
    LinkedList<Double> buckets = new LinkedList[n];I get a warning suggesting that the compiler was looking for the first version!
    How do I do this?

    McNepp wrote:
    It seems to be a common misconception that one has to
    resort to Reflection in order to create arrays
    of generic types.It is not a misconception. On the contrary. It depends on what the library writer is trying to achieve. If I understand Neal Gafter in his blog http://www.gafter.com/~neal dated from September 23rd titled Puzzling Through Erasure: answer section correctly - currently his site is unavailable but you could still find cached page through Google -, that it should be fine to use reflection. Using reflection is perfectly legal if the library writer wants to design the API in such way that the type parameters are not erased. Type parameters are stored inside of the class using class literals. He says that in this case "you can instantiate using reflection (tClass.newInstance()), create arrays (Array.newInstance), cast (Class.cast), and do instanceof tests (Class.isInstance), though with a slightly different syntax than you might prefer".
    I'm still learning generics and I might be wrong.
    Best regards,
    Andrej

  • Type-safe enum in CMP EJB field...

    Is it possible to use a type-safe enum like this in an EJB CMP field?
    I have tried to do that but although the code compiles I get errors.
    package dataBeansPkg;
    import java.io.Serializable;
    import java.io.ObjectStreamException;
    import java.util.HashMap;
    public final class Estado implements Serializable
    private static final String ACTIVODESC = "Activo";
    private static final String INACTIVODESC = "Inactivo";
    private static final String ELIMINADODESC = "Eliminado";
    private static final String BLOQUEADODESC = "Bloqueado";
    private static HashMap VALUES = new HashMap();
    private final String status;
    private final String descripcion;
    public static final Estado ACTIVO = new Estado("A", ACTIVODESC);
    public static final Estado INACTIVO = new Estado("I", INACTIVODESC);
    public static final Estado ELIMINADO = new Estado("E", ELIMINADODESC);
    public static final Estado BLOQUEADO = new Estado("B", BLOQUEADODESC);
    protected Estado()
    this.status = null;
    this.descripcion = null;
    protected Estado(String estado, String descripcion)
    this.status = estado;
    this.descripcion = descripcion;
    VALUES.put(estado, this);
    public String getValor() { return status; }
    public String getEstado() { return status; }
    public String getDescripcion() { return descripcion; }
    public String toString() { return getValor(); }
    public final boolean equals(Object o) { return super.equals(o); }
    public final int hashCode() { return super.hashCode(); }
    public static Estado find(String estado)
    if(VALUES.containsKey(estado)) {
    return (Estado)VALUES.get(estado);
    return null;
    public Object readResolve()
    Object result = find(status);
    if(result != null)
    return result;
    else
    return INACTIVO; // valor por omision
    Whenever I run a client using the bean with a field associated to this enum, I get...
    java.io.StreamCorruptedException: Caught EOFException while reading the stream header
    and
    Error loading state: java.io.StreamCorruptedException: Caught EOFException while reading the stream header
    Is it possible to use a type-safe enum as a field in an CMP bean?

    Yep... I think that's what I found. By using public methods in my enum class to map it's string member to the EJB field I was able to effectively use my enum in the EJB. The container does it work with a String but the EJB's clients only deal with a enum field. That's what I originally intended so, thanks for your response.

  • Do I have to get a hard copy of Snow Leopard for my iMac if I already have it for my MacBook?

    I have Leopard on my iMac, and Snow Leopard on my MacBook (both with all available updates)~I tried to use the Snow Leopard Install DVD from the MacBook to upgrade the iMac, but it said "Mac OS X 10.6 cannot be installed on this computer."  Why???  Do I have to get a hard copy of Snow Leopard for my iMac?  Are there different upgrades for the iMac vs. MacBook?
    I think I understand that once I have both computers on Snow Leopard, the Lion upgrade would be ONE upgrade for BOTH computers {I'm guessing I would need the client version for at home use}.  Also, once Lion was on one computer, would I just go into the Mac App store on the other one and download the upgrade on the other one?  But no additional fee would be charged?  Lastly, I read about the combo option that includes all updates to Lion since it's release~would that be the main Lion upgrade on the Mac App or would I have to search for it?
    Thanks for your help!

    The disc you used would have been the install disc that came with your Mac. These can only be used on that as they are made for that specific model.
    Make sure your machine meets requirements
    Macs with an Intel Core 2 Duo, Intel Core i3, Intel Core i5, Intel Core i7, or Xeon processor.)
    At least 2GB of RAM
    Mac OS X 10.6.6 or later (Mac OS X 10.6.8 is recommended)
    7 GB of free hard drive space is recommended
    Once you've purchased it would be a good idea to create a bootable DVD or USB
    http://www.macworld.com/article/161069/2011/07/make_a_bootable_lion_installer.ht ml
    But you can also go into the purchased section and download again

Maybe you are looking for

  • Creating code in AS3 to launch a PDF file?

    Hi, I am interested in creating a page on my website where visitors can download a pdf file. I have never done anything like this. Can anyone recommen a good tutorial or website tat has info regarding the code necessary to make this work in Flash AS3

  • Time issue on MacBook Pro

    Hi, I've had a problem with my mac for some time. Whenever I open or modify a file, the time shown is incorrect. The date is always correct, but the time shows 7:08pm for everything. The same occurs in Time Machine backups, iCal events and email from

  • Unable to open windows database files hosted on Lion Server

    I use Mac Mini as a server. With Snow Leopard Server I shared files hosted on Mac Mini and other PC computers on the network could use together Access and Quickbooks files. After upgrading to Lion Server no PC is able to open these database files. E.

  • Select * and Insert question

    I have my ResultSet and Query to get the data form an Oracle database. Would I use the same rs for an executeUpdate statement? Or how would I go about doing that? Basically I'm querying the database, getting the resultset, processing the data around,

  • ASA failover: secondary ASA disabled failover on its own

    Hi all I have a failover pair of ASA 5520 (Software Version 8.2(4)4) located in two different data centers. Because of a network issue the layer 2 connection between both locations has been interrupted for a couple of seconds and the ASAs went into s