/** * Extract the stored value type. * * @return the previously stored value type. * * @throws BAD_OPERATION if the Any contains something different. * * @see org.omg.CORBA.portable.ValueBase */ public Serializable extract_Value() throws BAD_OPERATION { try { if (has instanceof ValueBaseHolder) return ((ValueBaseHolder) has).value; else { // Normally, ValueBase holder must be an instance of the // ValueBaseHolder. However some IDL compilers probably // have a bug, do not deriving this way. The the only // way to access the wrapped value is via reflection. Field f = has.getClass().getField("value"); return (Serializable) f.get(has); } } catch (Exception ex) { BAD_OPERATION bad = new BAD_OPERATION("Value type expected"); bad.minor = Minor.Any; bad.initCause(ex); throw bad; } }
/** {@inheritDoc} */ public Serializable get_val() throws TypeMismatch { try { return ((ValueBaseHolder) holder).value; } catch (ClassCastException cex) { TypeMismatch m = new TypeMismatch(); m.initCause(cex); throw m; } }
/** {@inheritDoc} */ public void insert_val(Serializable a_x) throws InvalidValue, TypeMismatch { try { ((ValueBaseHolder) holder).value = a_x; valueChanged(); } catch (ClassCastException cex) { TypeMismatch t = new TypeMismatch(); t.initCause(cex); throw t; } }