POFing Enums... InstantiationException

I'm getting this exception
Exception in thread "Thread-1" (Wrapped) java.io.IOException: An exception occurred instantiating a PortableObject user type from a POF stream: type-id=10015, class-name=oms.grid.SendingType, exception=
java.lang.InstantiationException: oms.grid.SendingType
        at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:265)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ConverterFromBinary.convert(PartitionedCache.CDB:4)
        at com.tangosol.util.ConverterCollections$ConverterInvocableMap.invoke(ConverterCollections.java:2281)
        at com.tangosol.util.ConverterCollections$ConverterNamedCache.invoke(ConverterCollections.java:2747)
        at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.invoke(PartitionedCache.CDB:11)
        at com.tangosol.coherence.component.util.SafeNamedCache.invoke(SafeNamedCache.CDB:1)
        at coup.QueueReader.run(QueueReader.java:105)
        at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: An exception occurred instantiating a PortableObject user type from a POF stream: type-id=10015, class-name=oms.grid.SendingType, exception=java.lang.InstantiationException: oms.grid.SendingType
        at com.tangosol.io.pof.PortableObjectSerializer.deserialize(PortableObjectSerializer.java:122)
        at com.tangosol.io.pof.PofBufferReader.readAsObject(PofBufferReader.java:3306)
        at com.tangosol.io.pof.PofBufferReader.readAsObjectArray(PofBufferReader.java:3350)
        at com.tangosol.io.pof.PofBufferReader.readAsObject(PofBufferReader.java:2924)
        at com.tangosol.io.pof.PofBufferReader.readObject(PofBufferReader.java:2603)
        at com.tangosol.io.pof.ConfigurablePofContext.deserialize(ConfigurablePofContext.java:358)
        at com.tangosol.util.ExternalizableHelper.deserializeInternal(ExternalizableHelper.java:2745)
        at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:261)
        ... 7 moremy SendingType.java file looks like
package oms.grid;
import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import com.tangosol.io.pof.PortableObject;
import java.io.IOException;
public enum SendingType implements PortableObject {
    NEW_ORDER,
    CANCEL,
    REPLACE,
    IGNORE;
    public void readExternal(PofReader reader) throws IOException {
    public void writeExternal(PofWriter writer) throws IOException {
}probably I'm making this too difficult, right?
Thanks,
Andrew

We just use a generic serializer for all enums:
public class EnumSerializer implements PofSerializer {
     @SuppressWarnings({ "rawtypes" })
     private final Class<Enum> type;
     private final Object[] enumValues;
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public EnumSerializer(int typeId, Class<Enum> type) {
          try {
               this.type = type;
               enumValues = EnumSet.allOf(type).toArray();
          } catch(Throwable t) {
               t.printStackTrace();
               throw new RuntimeException(t);
    @Override
    public Object deserialize(PofReader in) throws IOException {
         try {
              final int ordinal = in.readInt(0);
              try {
                   return enumValues[ordinal];
              } catch(ArrayIndexOutOfBoundsException e) {
                   throw new IOException(String.format("An error ocurred trying to deserialize enum [%s]: ordinal %d is not a valid value.", type.getName(), ordinal), e);
        } finally {
            in.readRemainder();
    @SuppressWarnings({ "rawtypes" })
    @Override
    public void serialize(PofWriter out, Object obj) throws IOException {
         Enum e = (Enum) obj;
        out.writeInt(0, e.ordinal());
        out.writeRemainder(null);
}Regards, Paul

Similar Messages

  • Enum type is retrieving me a null reference

    Hi, i have a very strange bug in my code that is messing me up.
    I defined two enum types in separated files like this:
    public enum Section {
         SectionA, SectionN;
    public enum Subsection {
        SubA(1, SectionA), SubN(2, SectionN);
        private Section sec;
        private int num;
        Subsection (int num, Section sec) {
            this.num = num;
            this.sec = sec;    // Here is the problem
    }Well, the problem is that in the line with the comment I'm recieving a null reference and I think that is not possible. Is that a compiler bug?

    I'm no getting any error message, let me show you my code:
    The problematic enum type.
    public enum Subseccion {
        ALUMNOS_ALTA(1, AltaAlumnos.class, "Alta", Privilegio.ALTA_ALUMNOS, Seccion.ALUMNOS),
        ALUMNOS_BUSCAR(2, BuscarAlumno.class, "Buscar", Privilegio.BUSCAR_ALUMNOS, Seccion.ALUMNOS),
        ALUMNOS_EDITAR(3, EditarAlumno.class, "Editar", Privilegio.EDITAR_ALUMNOS, Seccion.ALUMNOS),
        PERSONAL_ALTA(1, AltaPersonal.class, "Alta", Privilegio.ALTA_PROFESORES, Seccion.PERSONAL),
        PERSONAL_BUSCAR(2, BuscarPersonal.class, "Buscar", Privilegio.PERSONAL_BUSCAR, Seccion.PERSONAL),
        PERSONAL_EDITAR(3, EditarPersonal.class, "Editar", Privilegio.PERSONAL_EDITAR, Seccion.PERSONAL),
        MATERIAS(1, Materias.class, "Materias", Privilegio.ASIGNATURAS, Seccion.CURSOS),
        CURSOS(2, Cursos.class, "Cursos", Privilegio.CURSOS, Seccion.CURSOS),
        GRUPOS(3, Grupos.class, "Grupos", Privilegio.GRUPOS, Seccion.CURSOS),
        ASIGNAR_GRUPOS(4, AlumnosSalones.class, "Asignar Grupos", Privilegio.ASIGNAR_GRUPOS, Seccion.CURSOS);
        private final Class<? extends JPanel> panel;
        private final String texto;
        private final Seccion pa;  // La secci�n a la que pertenece
        private final Privilegio priv;   
        private final int importancia;
        Subseccion(int importa, Class<? extends JPanel> panel, String texto, Privilegio priv, Seccion fad) {
            this.panel = panel;
            this.texto = texto;
            if (fad == null)
                System.err.println("A NULL REFERENCE");   // Always happen
            pa = fad;
            this.priv = priv;
            this.importancia = importa;
        public int getImportancia() {
            return importancia;
         * Regresa el Panel construido que corresponde a la secci�n.
         * @param d El Objeto de base de datos que se usar� para crear el Panel.
         * @param ven El Objeto de ventana que se usar� para crear el Panel.
        public JPanel getPanelInstance(BaseDeDatosE d, VentanaPrincipal ven)
            throws InstantiationException, NoSuchMethodException, IllegalAccessException,
                    java.lang.reflect.InvocationTargetException {
            // Construyo el panel si es que hay uno asociado
            Constructor<? extends JPanel> cons = panel.getConstructor(BaseDeDatosE.class, VentanaPrincipal.class);
            JPanel panel = cons.newInstance(d, ven);
            return panel;
         * Devuelve el privilegio asociado a esta secci�n.
        public Privilegio getPrivilegio() {
            return priv;
         * Pone el "bot�n" en RollOver.
         * @param btn El "bot�n"
        public void setEstadoRollOver(JPanel btn) {
         * Pone el "bot�n" en estado presionado.
         * @param btn El "bot�n"
        public void setEstadoPresionado(JPanel btn) {
         * Devuelve la secci�n a la que pertenece.
        public Seccion getSec() {
            return pa;
         * Pone el "bot�n" en estado normal.
         * @param btn El "bot�n"
        public void setEstadoNormal(JPanel btn) {
    The enum type that is getting null.
    public enum Seccion {
        ALUMNOS(null, "/alumno", "Alumnos",
                new Subseccion[] {Subseccion.ALUMNOS_BUSCAR, Subseccion.ALUMNOS_ALTA, Subseccion.ALUMNOS_EDITAR},
                null),
        PERSONAL(null, "/profesor", "Personal",
                 new Subseccion[] {Subseccion.PERSONAL_BUSCAR, Subseccion.PERSONAL_ALTA, Subseccion.PERSONAL_EDITAR},
                 null),
        CURSOS(null, "/cursos", "Cursos",
               new Subseccion[] {Subseccion.CURSOS, Subseccion.GRUPOS, Subseccion.MATERIAS, Subseccion.ASIGNAR_GRUPOS},
               null),
        CURSOS_CALIFICAR(CalificarCursos.class, "/default", "Calificar Cursos", null, Privilegio.CALIFICAR_CURSOS),
        ASISTENCIA(Asistencia.class, "/default", "Asistencia", null, Privilegio.ASISTENCIA);
        private final Class<? extends JPanel> panel;
        private final String prefijoImagen;
        private final Subseccion[] subs;  // Las subseciones de esta secci�n
        private final String etiqueta;  // El texto que va a llevar el icono
        private final Privilegio priv;
        Seccion (Class<? extends JPanel> panel, String prefijoImagen, String etiqueta, Subseccion[] subs, Privilegio priv) {
            this.panel = panel;
            this.prefijoImagen = prefijoImagen;
            this.subs = subs;
            this.etiqueta = etiqueta;
            this.priv = priv;
         * Regresa el Panel construido que corresponde a la secci�n.
         * @param d El Objeto de base de datos que se usar� para crear el Panel.
         * @param ven El Objeto de ventana que se usar� para crear el Panel.
         * @return <code>null</code> Si no tiene un panel asociado.
        public JPanel getPanelInstance(BaseDeDatosE d, VentanaPrincipal ven)
            throws InstantiationException, NoSuchMethodException, IllegalAccessException,
                    java.lang.reflect.InvocationTargetException {
            if (panel != null) {
                // Construyo el panel si es que hay uno asociado
                Constructor<? extends JPanel> cons = panel.getConstructor(BaseDeDatosE.class, VentanaPrincipal.class);
                JPanel panel = cons.newInstance(d, ven);
                return panel;
            return null;
         * Devuelve el privilegio asociado a esta secci�n.
         * @return <code>null</code> Si no existe un privilegio asociado.
        public Privilegio getPrivilegio() {
            return priv;
         * Pone el icono de estado RollOver.
         * @param etiq El JLabel asociado a esta secci�n
        public void setIconoRollOver(JLabel etiq) {
            etiq.setIcon( new ImageIcon( getClass().getResource(prefijoImagen + "BtnOver.jpg") ) );
         * Pone el icono de estado Presionado.
         * @param etiq El JLabel asociado a esta secci�n
        public void setIconoPresionado(JLabel etiq) {
            etiq.setIcon( new ImageIcon( getClass().getResource(prefijoImagen + "Btn.jpg") ) );
         * Pone el icono de estado Normal.
         * @param etiq El JLabel asociado a esta secci�n
        public void setIconoNormal(JLabel etiq) {
            etiq.setIcon( new ImageIcon( getClass().getResource(prefijoImagen + "BtnBco.jpg") ) );           
         * Obtiene un arreglo con las subsecciones disponibles, en primer lugar la que
         * se deber�a mostrar por defecto.
         * @return <code>null</code> Si no tiene subsecciones asociadas.
        public Subseccion[] getSubsecciones() {
            return subs;
         * Le pone el texto a la etiqueta que muestra el icono de la secci�n.
        public void setTextoIcono(JLabel etiq) {
            etiq.setText(etiqueta);
    }And if you do
    Subseccion.ALUMNOS_ALTA;The message "NULL REFERENCE" is printed.

  • PersistenceDelegate for typesafe enum pattern

    I've converted my code over from using int constants to the typesafe enum pattern in Effective Java. Unfortunately, the pattern only goes into serialization using Serializable and does not go into how to write a proper PersistenceDelegate that parallels the safety precautions of the Serializable enum. I've tried to do a direct mirroring of the readResolve() method given in the book inside of the intiatiate method of my PersistenceDelegate, but the XMLEncoder keeps rejecting the output and I get an InstantiationException, which shouldn't happen since the method call should not instantiate any new instances since the enums are static.
    class PositionBiasModePersistenceDelegate extends PersistenceDelegate {
        protected Expression instantiate(Object oldInstance, Encoder out) {
            PositionBiasMode mode = (PositionBiasMode) oldInstance;
            return new Expression(mode, PositionBiasMode.VALUES, "get", new Object[] {new Integer(PositionBiasMode.VALUES.indexOf(mode))});
    public abstract class PositionBiasMode {
        private final String name;
        private static int nextOrdinal = 0;
        private final int ordinal = nextOrdinal++;
        /** Creates a new instance of PreferredPositionMode */
        private PositionBiasMode(String name) {
            this.name = name;
        public String toString() {
            return name;
        public abstract boolean complies(PositionBias pb);
        public static final PositionBiasMode IGNORE = new PositionBiasMode("Ignore") {
            public boolean complies(PositionBias pb) {
                return true;
        public static final PositionBiasMode FRONT = new PositionBiasMode("Front") {
            public boolean complies(PositionBias pb) {
                return pb.hasBias() && pb.getPositionBias() < 0 ? false : true;
        public static final PositionBiasMode BACK = new PositionBiasMode("Back") {
            public boolean complies(PositionBias pb) {
                return pb.hasBias() && pb.getPositionBias() >= 0 ? false : true;
        private static final PositionBiasMode[] PRIVATE_VALUES = {IGNORE, FRONT, BACK};
        public static final List VALUES = Collections.unmodifiableList(Arrays.asList(PRIVATE_VALUES));
    }

    Yeah I tried this too. I think the instantiation exception is something to do with it trying to recreate the MyEnum.VALUES List. I don't understand enough about the process to know how to fix that though.
    The approach I eventually went for was to add a couple of things to the enum class as follows:
    // add to MyEnum class:
    public static final PersistenceDelegate PERSISTENCE = new PersistenceDelegate()
         protected boolean mutatesTo(Object oldInstance, Object newInstance)
              return (MyEnum)oldInstance == (MyEnum)newInstance;
         protected Expression instantiate(Object oldInstance, Encoder out)
              MyEnum enum = (MyEnum)oldInstance;
              return new Expression(enum, new MyEnum.Factory(), "forOrdinal", new Object[]{new Integer(enum.ordinal)});
    public static final class Factory
         public MyEnum forOrdinal(int ordinal)
              return PRIVATE_VALUES[ordinal];
    // usage:
    XMLEncoder enc = new XMLEncoder(...);
    enc.setPersistenceDelegate(MyEnum.class, MyEnum.PERSISTENCE);Not entirely sure it's the ideal approach but maybe it'll work for you. Cheers.

  • OC4J Application Server - InstantiationException

    Error : java.lang.InstantiationException: Error initializing ejb-modules: message-destination-mapping tag with missing 'location' attribute
    HI All,
    Hope someone can help me with the following error. I've got a ear file which deploys 100% correct, and the application can run successfully after deploying. But if I stop and start the container, then i get the following exception, the container starts up but the application does not start successfully.
    Oracle Container start-up exception:
    09/05/11 09:17:15 Start process
    Listening for transport dt_socket at address: 8688
    0.000: [GC [PSYoungGen: 43776K->4394K(51008K)] 43776K->4394K(517056K), 0.0290830 secs]
    3.295: [GC [PSYoungGen: 48170K->7220K(51008K)] 48170K->8371K(517056K), 0.0499300 secs]
    6.817: [GC [PSYoungGen: 50996K->7218K(51008K)] 52147K->13636K(517056K), 0.0504670 secs]
    09/05/11 09:17:28 WARNING: Application.setConfig Application: stf-7.0.1 is in failed state as initialization failed.
    java.lang.InstantiationException: Error initializing ejb-modules: message-destination-mapping tag with missing 'location' attribute
    09/05/11 09:17:29 Oracle Containers for J2EE 10g (10.1.3.2.0) initialized
    29.062: [GC [PSYoungGen: 50994K->7226K(51008K)] 57412K->15785K(517056K), 0.0436860 secs]
    32.675: [GC [PSYoungGen: 51002K->7228K(50880K)] 59561K->16729K(516928K), 0.0346460 secs]
    We use jdk1.5, Ejb3 and Oracle 10.1.3
    We use message driven beans, for which we create an ejb-jar.xml that looks as follow:
    Start
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
         <!-- OC4J EJB-JAR.XML for UDSWSConServices -->
         <display-name>vss-ejb</display-name>
         <enterprise-beans>
              <message-driven>
                   <display-name>VSSAdvancedQueueBatchBeanMDB</display-name>
                   <ejb-name>VSSAdvancedQueueBatchBean</ejb-name>
                   <ejb-class>
                        za.globed.varsite.hebs.bsi.services.ejb.VSSAdvancedQueueBatchBean
                   </ejb-class>
                   <transaction-type>Bean</transaction-type>
                   <message-destination-type>
                        javax.jms.Queue
                   </message-destination-type>
                   <message-destination-link>
                        jms/batchQueue
                   </message-destination-link>
                   <activation-config>
                        <activation-config-property>
                             <activation-config-property-name>
                                  acknowledgeMode
                             </activation-config-property-name>
                             <activation-config-property-value>
                                  Auto-acknowledge
                             </activation-config-property-value>
                        </activation-config-property>
                        <activation-config-property>
                             <activation-config-property-name>
                                  destinationType
                             </activation-config-property-name>
                             <activation-config-property-value>
                                  javax.jms.Queue
                             </activation-config-property-value>
                        </activation-config-property>
                        <activation-config-property>
                             <activation-config-property-name>
                                  subscriptionDurability
                             </activation-config-property-name>
                             <activation-config-property-value>
                                  NonDurable
                             </activation-config-property-value>
                        </activation-config-property>
                        <activation-config-property>
                             <activation-config-property-name>
                                  messageSelector
                             </activation-config-property-name>
                             <activation-config-property-value>
                                  Destination =
                                  'za.globed.varsite.hebs.bsi.services.VSSAdvancedQueueBatchBean'
                             </activation-config-property-value>
                        </activation-config-property>
                   </activation-config>
              </message-driven>
         </enterprise-beans>
         <assembly-descriptor>
              <container-transaction>
                   <method>
                        <ejb-name>VSSAdvancedQueueBatchBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <trans-attribute>Supports</trans-attribute>
              </container-transaction>
              <message-destination>
                   <display-name>
                        Destination for VSSAdvancedQueueBatchBean
                   </display-name>
                   <message-destination-name>
                        jms/batchQueue
                   </message-destination-name>
              </message-destination>
         </assembly-descriptor>
    </ejb-jar>
    -- end --
    Any help or suggestions would be much appreciated.
    Thanks
    Nina

    I would advise you to use the latest version - 10.1.3.5 - i remember some issues with 10.1.3.4.
    For certifications see here:
    http://www.oracle.com/technetwork/middleware/ias/downloads/oracle-soa-certification-101310-097492.html
    You have two options to bypass the check:
    * Use ignore : runinstaller -ignoresysprereqs
    http://onlineappsdba.com/index.php/2008/11/24/upgrade-oracle-application-server-to-10134-10g-r3-patchset-4/
    * Or change in the installers file that lists the allowed versions - you can search for the numbers listed in your error dialog

  • APEX application or page url  - How to use enum string to replace ID number

    URL to a APEX page is format as ***/f?p=APPLICATION_ID:PAGE_ID:... . Here the APPLIACTION_ID and PAGE_ID are numbers.
    My Question is: Is there a way to replace the numbers by using strings? For example: can I have a URL like /f?p=MY_APPLICATION:MY_PAGE1: ... ? Juts like ENUM in other languages, MY_APPLICATION actually just represent the application id but much more readable since it is a string with a name the user may familar.
    Please help.
    Thank you.

    You can assign an alphanumeric alias to applications and pages using their respective attribute edit forms in the Application Builder. Then you can construct links that use those aliases instead of the IDs. These aliases will generally be preserved in the URL visible in the browser, but not in all cases. You have to deliberately use the aliases in any branch definitions, list item targets, etc. Note that application aliases must be unique within a workspace. Please see the User's Guide for more info.
    Scott

  • Why "null" value is impossible in "switch(val) {case null: }"  for enums?

    I'm wondering why Java 5.0 does not allow null values
    as options in switch statement:
    If type E is "enum" then the following language construction is
    not allowed:
    E val;
    switch(val) {
       case A:
         break;
       case B:
           break;
       case null:   // this is not allowed
            break;
    }Can somebody explain me why Java does not support it? I beleave that
    some serious reasons were for that.
    As we know enum types can have "null" values and in case I use nulls
    for my enumerations the code with "switch" statement becomes quite urgly because it is necessary to handle 2 separate execution paths:
    null and not null.
    Thanks

    I really don�t know too much about 1.5, but I can tell you that for 1.4 the switch receives as a parameter an int or anything that can be casted automatically to an int. Therefore you can�t never use null cause int, char, short, byte can�t never take as a value null.

  • How to get I32 enum text out of a control (i/p terminal config, active edge of DAQmx vis)

    Hi,
     I am using DAQmx VIs create channel.vi and sample clock.vi, they have inputs (input terminal configuration) and (active edge) both are I32 and have enum looking drop down options. i want to use those text values to put into my excel file, but they give out numeric codes related to respective option. is it possible to get the text as it is.
    it is not an enum but I32 which looks like enum..
    plz help..
    Thanks
    Solved!
    Go to Solution.

    Note: This assumes that you have an actual control on the VI. If you have a
    block diagram constant, then that won't actually work. In this case to get the actual text you need to pick from list of text items. To further complicate things, the actual values that are generated are not sequential. You can use either a case structure or a 2-step lookup.
    Attachments:
    Example_VI.png ‏7 KB

  • Using static .values() method of Enum in Generic Class

    Hi *,
    I tried to do the following:
    public class AClass<E extends Enum<E> >  {
         public AClass() {
              E[] values = E.values(); // this DOESN'T work
              for (E e : values) { /* do something */ }
    }This is not possible. But how can I access all Enum constants if I use
    an Enum type parameter in a Generic class?
    Thanks for your help ;-) Stephan

    Here's a possible workaround. The generic class isn't adding much in this case; I originally wrote it as a static method that you simply passed the class to:
    public class Test21
      public static enum TestEnum { A, B, C };
      public static class AClass<E extends Enum<E>>
        private Class<E> clazz;
        public AClass(Class<E> _clazz)
        {  clazz = _clazz;  }
        public Class<E> getClazz()
        {  return clazz;  }
        public void printConstants()
          for (E e : clazz.getEnumConstants())
            System.out.println(e.toString());
      public static void main(String[] argv)
        AClass<TestEnum> a = new AClass<TestEnum>(TestEnum.class);
        a.printConstants();
    }

  • Sun's demo using enum doesn't seem to work for me

    I'm trying to run a demo from the Sun website, http://java.sun.com/docs/books/tutorial/java/nutsandbolts/switch.html, which includes the enum statement:
    public class SwitchEnumDemo {
        public enum Month { JANUARY, FEBRUARY, MARCH, APRIL,
                            MAY, JUNE, JULY, AUGUST, SEPTEMBER,
                            OCTOBER, NOVEMBER, DECEMBER }
        public static void main(String[] args) {
            Month month = Month.FEBRUARY;
            int year = 2000;
            int numDays = 0;
            switch (month) {
                case JANUARY:
                    // etc etc ...
            System.out.println("Number of Days = " + numDays);
    }However, copying-and-pasting the code into NetBeans, I get an error on the enum declaration stating: '';' expected. Warning: as of release 1.5, 'enum' is a keyword and may not be used as an identifier'. Well... I know that. Isn't that why I'm using it in the first place? Or am I confused?
    I'm using NeBeans 5.0 on Java 1.5.0_06.
    Any advice?
    Question 2: Once I get this thing working, is there any way I can get the month as an input from the user, without needing a long block stating
    if (input = "January") month = Month.JANUARY;
    else if (input = "Feburary") month = Month.FEBURARY;
      //etc etcThat is, can the string representation of a month be somehow kept within the enumerated Month itself, and that be used to check the user's input?
    Thanks for any advice!

    However, copying-and-pasting the code into NetBeans,
    I get an error on the enum declaration stating:
    '';' expected. Warning: as of release 1.5, 'enum'
    is a keyword and may not be used as an
    identifier'. Well... I know that. Isn't
    that why I'm using it in the first place? Or am I
    confused?
    I'm using NeBeans 5.0 on Java 1.5.0_06.I can't say for sure about that; it seems very odd. However, I do know that my IDE will warn me about those sorts of things if I configure my project for pre-1.5 operation. It allows me to say a project is for Java 1.4 even if I'm using a 1.5 JVM and will mention things like that so that forward compatibility can be considered. I don't suppose this could be the case with your situation?
    You might want to search for all instances of "enum" in your code, though, because it's hard to imagine the one instance which appears in the snippet you posted causing problems.
    Question 2: Once I get this thing working, is there
    any way I can get the month as an input from the
    user, without needing a long block stating{snip}
    Well, in this case you can just do
    for (Month m : Month.values())
        if (m.toString().equalsIgnoreCase(input))
            month = m;
            break;
    }or you can build a Map<String,Month> if you're looking for case-sensitive comparison.
    In general, however, you can put pretty much anything into an enum:
    public enum SomeEnum
        A(0),
        B(0),
        C(1),
        D(0),
        E(2);
        private int value;
        SomeEnum(int value)
            this.value = value;
        public int getValue()
            return value;
    // the following is perfectly legal
    SomeEnum e = methodThatReturnsSomeEnum();
    System.out.println(e.getValue());and you could use that to put some form of identifier in the enumeration object. I have a class around here somewhere which uses an enum to enumerate the operators in an expression parser; the Operator enum constructor accepts an int specifying the operator precedence.

  • Importing  Through DTW : "Invalid ItemName'M'  in Enum 'BO Gender Types

    Dear Members,
    I am trying to import in a Business Partner,the contact person in which the gender and date of birth is to be imported.?its showing an error named "Invalid Item Name'M'  in Enum 'BO Gender Types 65171.
    Can anyone help me in this regard to import through template.
    Thanks ,
    Venkatesh.R

    Hi sudha,
    Thanks a lot,one of my issues has been solved,can you tell me how to import similarly for date of birth.
    Regards,
    Venkatesh.R

  • Just checking on another odd feature: Typedef enum Property Node "Value" not reflecting changes in the Typedef?

    Just encountered this odd behavior in LV 2011 which I reduced to the following example:
    - create a new VI and drop an enum control on te FP.
    - make this control a typedef and open the corresponding typedef
    - create a "case 1" item and a "case 2" item
    - save the typedef (I used the name Typedef Control 1) and CLOSE it (this is to allow updating of the original control).
    - drop a case structure on the diagram and connect the enum to it:
    So far so good. Now create a "Value" Property node for the enum and use it instead of the terminal:
    If I now go back to the typedef and add a "case 3" item, save the typedef and close it, the control is updated, but the Property node is not.
    How do I know that? For one, the Case Structure contextual menu does not offer to create a case for every value. Also, if I add a "case 3" case manually, it turns red.
    Luckily, the magic Ctrl-R key stroke actually does solve this problem.
    Tested in LV 2011.

    By Ctrl-R trick do you simply mean running the VI?  That is one way to force a recompile, but if you hold down Ctrl while pressing the run button you can recompile without running.  This should not be "dangerous" in any situation.
    As you have drawn your example, I see no reason not to use a local in that situation (ok, maybe for vanity).  Still, I view the behavior you describe as a bug, and it should certainly be fixed for the benefit of local haters out there.  You have to be a little careful where you draw the line between what gets handled in real time and what gets handled only at compile time.

  • Looking for an alternative to an enum (or any non trivial type)

    Hi. I am making a class to manage geometric points, as in [x, y, z]. some languages, such as scripting language 'adobe actionscript' support certain special values such as NaN (or 'not a number'), and I can do things such as
    var _some_var:Number = Number.NaN;
    the previous sentence is something like assigning null to a pointer. NaN is not a valid value, so I can not operate with a var that has nan as a value.
    I want to do something like that in my class, but I can not use a number value and then say, 'this value is never gonna happen by itself, so if the var has that value is because is in nan state. for any value that I choose, if is a valid value, will be enough
    to consider it as an invalid alternative. instead of that, the vars are handled in pairs, so for each numeric coordinate, such as x, there is also a bool that says if the numeric value is defined
    in each point, there are the x, y and z coordinates, plus defx, defy and defz.
    the constructor is something like
    point() {
    x= 0;
    y= 0;
    z= 0;
    defx = false;
    defy=false;
    defz=false
    and since all vars are private, I use accessors such as
    setX(double _x) {
    x = _x;
    defX = true;
    so how do I assign a NaN to a var that has already a value?, or, how do I set the var 'defX' to false again?
    since setX(_some_value) is the same as x = _some_value, the idea would be that I could write something like
    setX(NaN), and that would 'undefine' X.
    since I can overload functions, and create functions with different prototypes for different types of values, even though the functions are called the same way, that's what I am doing.
    I had two choices: the first one is (copy paste from my file)
    //#ifndef _nan
    //#define _nan
    //#define NaN "NaN"
    //#endif
    not the one I chose because it does not seem better than my second choice (that's why it appears as a comment), or does not solve the problem I have with the choices I have thought so far:
    (in file 'especiales.h')
    #ifndef _especiales
    #define _especiales
    enum EEspecial {NaN};
    #endif
    and in the file for the point definition (as inline functions)
    void setX(double _x) {
                    x = _x;
                    defX = true;
            void setX(EEspecial _e) {
                    if (_e == NaN)
                        defX = false;
                    else
                        throw coordIndefException();
            double getX();
            bool definidoX() {return defX;}
    it works, it does not throw an error or there are no syntax problems; but there is a problem in my head. In the previous sentences there are two functions, one that takes a numeric value and sets it in x, and sets x as defined. on that receives not a numeric
    value but a special value, that if it turn out to be nan, will unset the x var, and set it as undefined.I checked it with these simple lines:
        geometriaPunto _ensayo;
       try {
            _ensayo.setX(NaN);
            cout << _ensayo.getX() << "\n";
        } catch (exception _e) {
            cout << _e.what() << "\n";
    this works fine. if I place a 0 in setX, it will print 0. if I place a NaN in the parenthesis, it will write the exception name. This works fine. But as far as I know, all basic var types, and all enums, also have implicit conversions to numeric values.
    so even though it works here, as I understand, telling it setX(0) is the same as setX(NaN) (which would be the implicit conversion of NaN, since is the first value in the enum). none of those are double (because I did not wrote it as setX(0.0) ), so my guess
    is that even though it works here, it was just luck, and some other c compile may understand it different, since there is not much difference between function_name(int) or function_name(enum_type)
    what would be the best way, most clear way to overload 'setX()' so it does accept a type that can not be confused with a numeric value, yet it does not make my code way more obscure and does not create ambiguity?
    tnx

    this is the last post I will make on this thread, as I find your answers useless and I already have what I need, but concerning your answers:
    "You said it worked for you in your 'adobe actionscript' code - why wouldn't the same technique work in C++ code? Number.NaN is a Number value, and it doesn't prevent you from doing operations in a var that holds that value - but that didn't
    seem to concern you before."
    have you ever worked with actionscript or did you just post because you had to post anything. yes, I can assign NaN to a numeric var in actionscript, just like I can assign null to a pointer. null is a value (0), if I add something to a var that has null,
    it will not have null anymore, if the compiler or the executable don't verify this behavior that should throw an exception. In actionscript, if a var has nan and I add something to it, it will still have nan, because nan is not a value, is a state, and probably
    actionscriopt also handles numeric vars with some other types of vars, to make these kind of validations. If I add 1 to garbage, I will still have garbage, and if I choose a random value to be chosen as nan, I or anybody else can not assure this value will
    not be the result of a valid operation
    2. "Is your question about C#, and not C++? If it is, you are in the wrong forum."
    why do you ask, did you see the previous sentences written in c#, or do you still have to answer crap if you don't answer something related to the question. if somebody has been writing things in other languages (including java or the same actionscript,
    which support that kind of behavior for properties and accessors), seems logic that I want to maintain that programing style, which will help somebody who also has been writing in those languages and then tries to read this new source, written in c++

  • How to use in enums in multiple places?

    How does one use an enum set in multiple places in a vi?
    I have resorted to just copying an existing one when I need the same set of enum values in a different spot, but doing it this way will be a big hassle if/when I want to add items to the enum, because I would have to locate every copy of the enum and update them idividually.
    Is it possible?

    It's not so much the "custom control" part as it is the typedef part. A typedef enforces the datatype for all its instances, including constants, so changing it will propogate through your entire code. To create it the easiest way is to create a front panel enum control and then right click it and select Advanced>>Customize. You can then change it into a typedef and save it under any name you want.
    From this point on, you can simply use that typedef in your code.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
    Try to take over the world!

  • How do I make one enum depend on the selection of another?

    Suppose I have 5 enums, say A, B, C, D, E. Each has entries different from the others. I'd like to have a 2nd enum with the entries "A,B,C,D,E". When the user selects one of the 2nd enum entries, I'd like the user to be presented with the corresponding enum from the group of 5.
    The context is this: the 2nd enum has entries like "Status Register" and "Event Register", and 3 others. Each register has different bits, like "motion complete" and "forward limit". I'd like the user to be able to select the register in one enum, and show that register's bit names in the other enum.
    -Jeff

    You could also use Rings as the controls on th efront panel. When the user selects the group programmatically change the value of the ring. You would need to keep track of the current group selection so that when you actually use the value from the ring you can typecast it back to the correct ENUM type and value.
    Another option would be to show/hide the controls based on the group selection.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How can I establish an enum typedef for use with state machines and action engines?

    Hey all--
    I have an action engine with several instances.  Any time that I add a method to the engine, I have to modify all of the calling code to update the constant that determines the method being called.  There must be a smarter way to address this problem but my LV experience is insufficient to identify it.  Can any of you wiz-bangs tell me if it is possible to make a type def (I can do this) and use it with each instance of the action engine call so that changing any instance also updates the typedef?
    Thanks.

    Take your enumerator.  If it is not a control (ie constant), change it to a control.
    Under File Menu, select New > Custom Control.
    Move (or copy) your Enum Control to the Custom Control.  Change the Control to Strict Type Def (the selection to the right of the wrench).  Save it.
    (EDIT: ** OOps, the picture shows the wrong one.. sorry**)
    Copy that new Strict Type Def control to your code.
    See images below.
    OR.. If you're using LV8.x, and using a project, I would recomment that you do it from within your project explorer.  Simply insert a new "Control".  The rest of the steps are similar, except that you can insert it from your project. 
    R
    Message Edited by JoeLabView on 07-08-2008 06:47 PM
    Attachments:
    TypeDef.PNG ‏33 KB

Maybe you are looking for