Package java.beans

Examples of java.beans.Statement


     * @param owner
     * @param value
     */
    public static boolean setAttributeValue(String propName, Object owner, Object value){
        try {
            Statement stmt = new Statement(owner, "set" + propName, new Object[]{value}); //$NON-NLS-1$
            stmt.execute();
            return true;
        } catch (Exception e) {
            return false;    }   
    }
View Full Code Here


            spl.invoke(obj, args);
            /*
             * Set the prefix that is added to each property change event from this class
             */
            Logger.getLogger("PropertyChange").debug("Property change Prefix >" + prefix + "<"); //$NON-NLS-1$ //$NON-NLS-2$
            Statement stmt = new Statement(obj, "setChangePrefix"new Object[] {prefix}); //$NON-NLS-1$
            stmt.execute();
            if ((obj instanceof DataValue) || (obj instanceof GenericNode))
                return;
            BeanInfo bi = Introspector.getBeanInfo(obj.getClass());

            /*
 
View Full Code Here

     * @param owner
     * @param value
     */
    public static boolean setAttributeValue(String propName, Object owner, Object value){
        try {
            Statement stmt = new Statement(owner, "set" + propName, new Object[]{value}); //$NON-NLS-1$
            stmt.execute();
            return true;
        } catch (Exception e) {
            return false;    }   
    }
View Full Code Here

            spl.invoke(obj, args);
            /*
             * Set the prefix that is added to each property change event from this class
             */
            Logger.getLogger("PropertyChange").debug("Property change Prefix >" + prefix + "<"); //$NON-NLS-1$ //$NON-NLS-2$
            Statement stmt = new Statement(obj, "setChangePrefix"new Object[] {prefix}); //$NON-NLS-1$
            stmt.execute();
            if ((obj instanceof DataValue) || (obj instanceof GenericNode))
                return;
            BeanInfo bi = Introspector.getBeanInfo(obj.getClass());

            /*
 
View Full Code Here

    protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
      java.util.Collection oldO = (java.util.Collection) oldInstance;
      java.util.Collection newO = (java.util.Collection) newInstance;

      if (newO.size() != 0) {
        out.writeStatement(new Statement(oldInstance, "clear", new Object[] {}));
      }
      for (Iterator i = oldO.iterator(); i.hasNext();) {
        out.writeStatement(new Statement(oldInstance, "add", new Object[] {i.next()}));
      }
    }
View Full Code Here

    protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
      java.util.Collection oldO = (java.util.Collection) oldInstance;
      java.util.Collection newO = (java.util.Collection) newInstance;

      if (newO.size() != 0) {
        out.writeStatement(new Statement(oldInstance, "clear", new Object[] {}));
      }
      for (Iterator i = oldO.iterator(); i.hasNext();) {
        out.writeStatement(new Statement(oldInstance, "add", new Object[] {i.next()}));
      }
    }
View Full Code Here

    protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
      java.util.Collection oldO = (java.util.Collection) oldInstance;
      java.util.Collection newO = (java.util.Collection) newInstance;

      if (newO.size() != 0) {
        out.writeStatement(new Statement(oldInstance, "clear", new Object[] {}));
      }
      for (Iterator i = oldO.iterator(); i.hasNext();) {
        out.writeStatement(new Statement(oldInstance, "add", new Object[] {i.next()}));
      }
    }
View Full Code Here

    @Override
    protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out) {
      Iterator ite = ((Collection) oldInstance).iterator();
      while (ite.hasNext()) {
        out.writeStatement(new Statement(oldInstance, "add", new Object[] {ite.next()}));
      }
    }
View Full Code Here

        MockBean4Owner_Target t = new MockBean4Owner_Target();
        MockBean4Owner_Owner o = new MockBean4Owner_Owner();
        t.setV(o);
        enc.setOwner(o);

        enc.writeStatement(new Statement(o, "loading", new Object[] {}));

        assertCodedXML(t, "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml",
                temp, enc);

    }
View Full Code Here

                        // Only write the property if it is not flagged as transient
                        Object transientVal = propDescriptors[i].getValue("transient");
                        if (transientVal == null || transientVal.equals(Boolean.FALSE))
                        {
                            xmlOut.writeStatement(
                                new Statement(oldInstance,
                                      propDescriptors[i].getWriteMethod().getName(),
                                      new Object [] {beanMap.getProperty(pk)}));
                        }
                    }
                }
                if (found == false)
                {
                    throw new ControlException("Unknown property in bean PropertyMap: " + pk);
                }
            }

            //
            // Get the bean context associated with the bean, and persist any nested controls
            //
            ControlBeanContext cbc = control.getControlBeanContext();
            if (cbc.size() != 0)
            {
                xmlOut.setPersistenceDelegate(ControlBeanContext.class,
                                              new ContextPersistenceDelegate());

                Iterator nestedIter = cbc.iterator();
                while (nestedIter.hasNext())
                {
                    Object bean = nestedIter.next();
                    if (bean instanceof ControlBean)
                    {
                        xmlOut.writeStatement(
                            new Statement(cbc, "add", new Object [] { bean } ));
                    }
                }
            }

            //
            // Restore any listeners associated with the control
            //
            EventSetDescriptor [] eventSetDescriptors = beanInfo.getEventSetDescriptors();
            for (int i = 0; i < eventSetDescriptors.length; i++)
            {
                EventSetDescriptor esd = eventSetDescriptors[i];
                Method listenersMethod = esd.getGetListenerMethod();
                String addListenerName = esd.getAddListenerMethod().getName();
                if (listenersMethod != null)
                {
                    //
                    // Get the list of listeners, and then add statements to incrementally
                    // add them in the same order
                    //
                    try
                    {
                        Object [] lstnrs = (Object [])listenersMethod.invoke(control,
                                                                             new Object []{});
                        for (int j = 0; j < lstnrs.length; j++)
                        {
                            //
                            // If this is a generated EventAdaptor class, then set the delegate
                            // explicitly
                            //
                            if (lstnrs[j] instanceof EventAdaptor)
                                xmlOut.setPersistenceDelegate(lstnrs[j].getClass(),
                                                              new AdaptorPersistenceDelegate());
                            xmlOut.writeStatement(
                                new Statement(control, addListenerName, new Object [] {lstnrs[j]}));
                        }
                    }
                    catch (Exception iae)
                    {
                        throw new ControlException("Unable to initialize listeners", iae);
                    }
                }
            }

            //
            // See if the control holds an implementation instance, if so, we need to include
            // it (and any nested controls or state) in the encoding stream
            //
            Object impl = control.getImplementation();
            if (impl != null)
            {

                //
                // Set the persistence delegate for the impl class to the Impl delegate,
                // set the current stream owner to the bean, and then write the implementation
                //
                Class implClass = impl.getClass();
                if (xmlOut.getPersistenceDelegate(implClass) instanceof DefaultPersistenceDelegate)
                    xmlOut.setPersistenceDelegate(implClass, new ImplPersistenceDelegate());

                //
                // HACK: This bit of hackery pushes the impl into the persistence stream
                // w/out actually requiring it be used as an argument elsewhere, since there
                // is no public API on the bean that takes an impl instance as an argument.
                //
                xmlOut.writeStatement(
                    new Statement(impl, "toString", null));
            }
        }
        finally
        {
            // Restore the previous encoding stream owner
View Full Code Here

TOP

Related Classes of java.beans.Statement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.