java类java.beans.Beans的实例源码

PropertySupport.java 文件源码 项目:incubator-netbeans 阅读 18 收藏 0 点赞 0 评论 0
public void setValue(T val)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (setter == null) {
        throw new IllegalAccessException();
    }

    Object valideInstance = Beans.getInstanceOf(instance, setter.getDeclaringClass());

    try {
        setter.invoke(valideInstance, val);
    } catch (IllegalAccessException ex) {
        try {
            setter.setAccessible(true);
            setter.invoke(valideInstance, val);
        } finally {
            setter.setAccessible(false);
        }
    }
}
IndexedPropertySupport.java 文件源码 项目:incubator-netbeans 阅读 18 收藏 0 点赞 0 评论 0
public void setValue(T val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canWrite()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, setter.getDeclaringClass());

    Object value = val;
    if (
        (val != null) && (setter.getParameterTypes()[0].getComponentType().isPrimitive()) &&
            (!val.getClass().getComponentType().isPrimitive())
    ) {
        value = Utilities.toPrimitiveArray((Object[]) val);
    }

    setter.invoke(validInstance, value);
}
MVMapElement.java 文件源码 项目:Pogamut3 阅读 15 收藏 0 点赞 0 评论 0
MVMapElement(TLDataObject dataObject) {
    // Hack
    if (Beans.isDesignTime()) {
        Beans.setDesignTime(false);
    }
    this.dataObject = dataObject;

    glPanel = new TLMapGLPanel(dataObject.getDatabase().getMap(), dataObject.getDatabase());

    slider = new TLSlider(dataObject.getDatabase());

    elementPanel = new JPanel(new BorderLayout());
    elementPanel.add(glPanel, BorderLayout.CENTER);
    elementPanel.add(slider, BorderLayout.PAGE_END);

    ActionMap map = new ActionMap();
    map.put("save", SystemAction.get(SaveAction.class));
    elementPanel.setActionMap(map);

    lookupContent = new InstanceContent();
    lookup = new ProxyLookup(dataObject.getLookup(), new AbstractLookup(lookupContent));
}
CommandInfo.java 文件源码 项目:javify 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Returns the instantiated bean.
 * If the bean implements <code>CommandObject</code>, its
 * <code>setCommandContext</code> method will be called.
 * @param dh the data handler describing the command data
 * @param loader the class loader used to instantiate the bean
 */
public Object getCommandObject(DataHandler dh, ClassLoader loader)
  throws IOException, ClassNotFoundException
{
  Object object = Beans.instantiate(loader, className);
  if (object != null)
    {
      if (object instanceof CommandObject)
        {
          CommandObject command = (CommandObject)object;
          command.setCommandContext(verb, dh);
        }
      else if (dh != null && (object instanceof Externalizable))
        {
          InputStream in = dh.getInputStream();
          if (in != null)
            {
              Externalizable externalizable = (Externalizable)object;
              externalizable.readExternal(new ObjectInputStream(in));
            }
        }
    }
  return object;
}
BeanInstance.java 文件源码 项目:repo.kmeanspp.silhouette_score 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Adds all beans to the supplied component
 * 
 * @param container a <code>JComponent</code> value
 */
public static void addAllBeansToContainer(JComponent container,
  Integer... tab) {
  int index = 0;
  if (tab.length > 0) {
    index = tab[0].intValue();
  }

  Vector<Object> components = null;
  if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
    components = TABBED_COMPONENTS.get(index);
  }

  if (container != null) {
    if (components != null) {
      for (int i = 0; i < components.size(); i++) {
        BeanInstance tempInstance = (BeanInstance) components.elementAt(i);
        Object tempBean = tempInstance.getBean();
        if (Beans.isInstanceOf(tempBean, JComponent.class)) {
          container.add((JComponent) tempBean);
        }
      }
    }
    container.revalidate();
  }
}
BeanInstance.java 文件源码 项目:repo.kmeanspp.silhouette_score 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Adds the supplied collection of beans to the end of the list of collections
 * and to the JComponent container (if not null)
 * 
 * @param beanInstances the vector of bean instances to add
 * @param container
 */
public static void addBeanInstances(Vector<Object> beanInstances,
  JComponent container) {
  // reset(container);

  if (container != null) {
    for (int i = 0; i < beanInstances.size(); i++) {
      Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
      if (Beans.isInstanceOf(bean, JComponent.class)) {
        container.add((JComponent) bean);
      }
    }
    container.revalidate();
    container.repaint();
  }

  TABBED_COMPONENTS.add(beanInstances);
}
BeanInstance.java 文件源码 项目:repo.kmeanspp.silhouette_score 阅读 15 收藏 0 点赞 0 评论 0
/**
 * Creates a new <code>BeanInstance</code> instance given the fully qualified
 * name of the bean
 * 
 * @param container a <code>JComponent</code> to add the bean to
 * @param beanName the fully qualified name of the bean
 * @param x the x coordinate of the bean
 * @param y th y coordinate of the bean
 */
public BeanInstance(JComponent container, String beanName, int x, int y,
  Integer... tab) {
  m_x = x;
  m_y = y;

  // try and instantiate the named component
  try {
    m_bean = Beans.instantiate(null, beanName);
  } catch (Exception ex) {
    ex.printStackTrace();
    return;
  }

  addBean(container, tab);
}
BeanInstance.java 文件源码 项目:repo.kmeanspp.silhouette_score 阅读 16 收藏 0 点赞 0 评论 0
public static void appendBeans(JComponent container, Vector<Object> beans,
  int tab) {
  if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
    Vector<Object> components = TABBED_COMPONENTS.get(tab);
    //

    for (int i = 0; i < beans.size(); i++) {
      components.add(beans.get(i));
      if (container != null) {
        Object bean = ((BeanInstance) beans.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
    }

    if (container != null) {
      container.revalidate();
      container.repaint();
    }
  }
}
CommandInfo.java 文件源码 项目:jvm-stm 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Returns the instantiated bean.
 * If the bean implements <code>CommandObject</code>, its
 * <code>setCommandContext</code> method will be called.
 * @param dh the data handler describing the command data
 * @param loader the class loader used to instantiate the bean
 */
public Object getCommandObject(DataHandler dh, ClassLoader loader)
  throws IOException, ClassNotFoundException
{
  Object object = Beans.instantiate(loader, className);
  if (object != null)
    {
      if (object instanceof CommandObject)
        {
          CommandObject command = (CommandObject)object;
          command.setCommandContext(verb, dh);
        }
      else if (dh != null && (object instanceof Externalizable))
        {
          InputStream in = dh.getInputStream();
          if (in != null)
            {
              Externalizable externalizable = (Externalizable)object;
              externalizable.readExternal(new ObjectInputStream(in));
            }
        }
    }
  return object;
}
BeanInstance.java 文件源码 项目:autoweka 阅读 16 收藏 0 点赞 0 评论 0
/**
  * Adds all beans to the supplied component
  *
  * @param container a <code>JComponent</code> value
  */
 public static void addAllBeansToContainer(JComponent container, Integer... tab) {
   int index = 0;
   if (tab.length > 0) {
     index = tab[0].intValue();
   }

   Vector components = null;
   if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
     components = TABBED_COMPONENTS.get(index);
   }

   if (container != null) {
     if (components != null) {
for (int i = 0; i < components.size(); i++) {
  BeanInstance tempInstance = (BeanInstance)components.elementAt(i);
  Object tempBean = tempInstance.getBean();
  if (Beans.isInstanceOf(tempBean, JComponent.class)) {
    container.add((JComponent)tempBean);
  }
}
     }
     container.revalidate();
   }
 }
BeanInstance.java 文件源码 项目:autoweka 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Adds the supplied collection of beans to the end of the list
 * of collections and to the JComponent container (if not null)
 * 
 * @param beanInstances the vector of bean instances to add
 * @param container
 */
public static void addBeanInstances(Vector beanInstances, JComponent container) {
  // reset(container);

  if (container != null) {
    for (int i = 0; i < beanInstances.size(); i++) {
      Object bean = ((BeanInstance)beanInstances.elementAt(i)).getBean();
      if (Beans.isInstanceOf(bean, JComponent.class)) {
        container.add((JComponent)bean);
      }
    }
    container.revalidate();
    container.repaint();
  }

  TABBED_COMPONENTS.add(beanInstances);    
}
BeanInstance.java 文件源码 项目:autoweka 阅读 17 收藏 0 点赞 0 评论 0
public static void appendBeans(JComponent container, Vector beans, int tab) {
  if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
    Vector components = TABBED_COMPONENTS.get(tab);
    //

    for (int i = 0; i < beans.size(); i++) {
      components.add(beans.get(i));
      if (container != null) {
        Object bean = ((BeanInstance)beans.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent)bean);
        }
      }        
    }

    if (container != null) {
      container.revalidate();
      container.repaint();
    }      
  }
}
BeanInstance.java 文件源码 项目:umple 阅读 14 收藏 0 点赞 0 评论 0
/**
 * Adds all beans to the supplied component
 * 
 * @param container a <code>JComponent</code> value
 */
public static void addAllBeansToContainer(JComponent container,
  Integer... tab) {
  int index = 0;
  if (tab.length > 0) {
    index = tab[0].intValue();
  }

  Vector<Object> components = null;
  if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
    components = TABBED_COMPONENTS.get(index);
  }

  if (container != null) {
    if (components != null) {
      for (int i = 0; i < components.size(); i++) {
        BeanInstance tempInstance = (BeanInstance) components.elementAt(i);
        Object tempBean = tempInstance.getBean();
        if (Beans.isInstanceOf(tempBean, JComponent.class)) {
          container.add((JComponent) tempBean);
        }
      }
    }
    container.revalidate();
  }
}
BeanInstance.java 文件源码 项目:umple 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Adds the supplied collection of beans to the end of the list of collections
 * and to the JComponent container (if not null)
 * 
 * @param beanInstances the vector of bean instances to add
 * @param container
 */
public static void addBeanInstances(Vector<Object> beanInstances,
  JComponent container) {
  // reset(container);

  if (container != null) {
    for (int i = 0; i < beanInstances.size(); i++) {
      Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
      if (Beans.isInstanceOf(bean, JComponent.class)) {
        container.add((JComponent) bean);
      }
    }
    container.revalidate();
    container.repaint();
  }

  TABBED_COMPONENTS.add(beanInstances);
}
BeanInstance.java 文件源码 项目:umple 阅读 14 收藏 0 点赞 0 评论 0
/**
 * Creates a new <code>BeanInstance</code> instance given the fully qualified
 * name of the bean
 * 
 * @param container a <code>JComponent</code> to add the bean to
 * @param beanName the fully qualified name of the bean
 * @param x the x coordinate of the bean
 * @param y th y coordinate of the bean
 */
public BeanInstance(JComponent container, String beanName, int x, int y,
  Integer... tab) {
  m_x = x;
  m_y = y;

  // try and instantiate the named component
  try {
    m_bean = Beans.instantiate(null, beanName);
  } catch (Exception ex) {
    ex.printStackTrace();
    return;
  }

  addBean(container, tab);
}
BeanInstance.java 文件源码 项目:umple 阅读 16 收藏 0 点赞 0 评论 0
public static void appendBeans(JComponent container, Vector<Object> beans,
  int tab) {
  if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
    Vector<Object> components = TABBED_COMPONENTS.get(tab);
    //

    for (int i = 0; i < beans.size(); i++) {
      components.add(beans.get(i));
      if (container != null) {
        Object bean = ((BeanInstance) beans.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
    }

    if (container != null) {
      container.revalidate();
      container.repaint();
    }
  }
}
SavePanel.java 文件源码 项目:dhcalc 阅读 57 收藏 0 点赞 0 评论 0
@Override
public void onLoad() {
    tabPanel.selectTab(0);

    if (!Beans.isDesignTime()) {
        Storage s = Storage.getLocalStorageIfSupported();

        if (s != null) {

            for (int i = 0; i < s.getLength(); i++) {
                String key = s.key(i);

                if ((key != null) && key.startsWith(STORAGE_KEY)) {
                    String name = key.substring(STORAGE_KEY.length());
                    storageList.addItem(name, key);
                }
            }
        }
    }
}
JarInfo.java 文件源码 项目:passage 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Get a new Bean instance given its name
 */
public Object getInstance(String name) {
    try {
        return Beans.instantiate(null, name);
    } catch (Throwable th) {
        if (com.bbn.openmap.util.Debug.debugging("beanbox")) {
            System.err.println(th);
            th.printStackTrace();
            if (name.indexOf('\\') >= 0) {
                System.err.println("    Note that file names in manifests must use forward "
                        + "slashes \"/\" \n    rather than back-slashes \"\\\"");
            }
        }
        return null;
    }
}
BeanInstance.java 文件源码 项目:jbossBA 阅读 16 收藏 0 点赞 0 评论 0
/**
  * Describe <code>setBeanInstances</code> method here.
  *
  * @param beanInstances a <code>Vector</code> value
  * @param container a <code>JComponent</code> value
  */
 public static void setBeanInstances(Vector beanInstances, 
                  JComponent container) {
   reset(container);

   if (container != null) {
     for (int i = 0; i < beanInstances.size(); i++) {
Object bean = ((BeanInstance)beanInstances.elementAt(i)).getBean();
if (Beans.isInstanceOf(bean, JComponent.class)) {
  container.add((JComponent)bean);
}
     }
     container.revalidate();
     container.repaint();
   }
   COMPONENTS = beanInstances;
 }
CommandInfo.java 文件源码 项目:JamVM-PH 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Returns the instantiated bean.
 * If the bean implements <code>CommandObject</code>, its
 * <code>setCommandContext</code> method will be called.
 * @param dh the data handler describing the command data
 * @param loader the class loader used to instantiate the bean
 */
public Object getCommandObject(DataHandler dh, ClassLoader loader)
  throws IOException, ClassNotFoundException
{
  Object object = Beans.instantiate(loader, className);
  if (object != null)
    {
      if (object instanceof CommandObject)
        {
          CommandObject command = (CommandObject)object;
          command.setCommandContext(verb, dh);
        }
      else if (dh != null && (object instanceof Externalizable))
        {
          InputStream in = dh.getInputStream();
          if (in != null)
            {
              Externalizable externalizable = (Externalizable)object;
              externalizable.readExternal(new ObjectInputStream(in));
            }
        }
    }
  return object;
}
LoadingDialog.java 文件源码 项目:mychart 阅读 27 收藏 0 点赞 0 评论 0
@PostConstruct
protected void init() throws IOException {
    dialog = new JDialog(mainWindow != null ? mainWindow.getFrame() : null, true);
    dialog.setUndecorated(true);
    dialog.setPreferredSize(new Dimension(200, 230));
    dialog.setResizable(false);
    dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    dialog.setLocationRelativeTo(mainWindow != null ? mainWindow.getFrame() : null);

    dialog.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.VK_ESCAPE) {
                dialog.setVisible(false);
            }
        }
    });

    JLabel imagemLabel = new JLabel();
    imagemLabel.setIcon(Beans.isDesignTime() ? null : images.loading());
    dialog.getContentPane().add(imagemLabel, BorderLayout.CENTER);

    dialog.pack();
}
CommandInfo.java 文件源码 项目:classpath 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Returns the instantiated bean.
 * If the bean implements <code>CommandObject</code>, its
 * <code>setCommandContext</code> method will be called.
 * @param dh the data handler describing the command data
 * @param loader the class loader used to instantiate the bean
 */
public Object getCommandObject(DataHandler dh, ClassLoader loader)
  throws IOException, ClassNotFoundException
{
  Object object = Beans.instantiate(loader, className);
  if (object != null)
    {
      if (object instanceof CommandObject)
        {
          CommandObject command = (CommandObject)object;
          command.setCommandContext(verb, dh);
        }
      else if (dh != null && (object instanceof Externalizable))
        {
          InputStream in = dh.getInputStream();
          if (in != null)
            {
              Externalizable externalizable = (Externalizable)object;
              externalizable.readExternal(new ObjectInputStream(in));
            }
        }
    }
  return object;
}
ManifestSection.java 文件源码 项目:incubator-netbeans 阅读 25 收藏 0 点赞 0 评论 0
/** Create a fresh instance.
 * @return the instance
 * @exception Exception if there is an error
 */
protected final Object createInstance() throws Exception {
    if (! isDefaultInstance()) {
        try {
            Object o = Beans.instantiate(getClassLoader(), className);
            clazz = o.getClass();
            if (! getSectionClass().isAssignableFrom(clazz)) {
                throw new ClassCastException("Class " + clazz.getName() + " is not a subclass of " + getSuperclass().getName()); // NOI18N
            }
            return o;
        } catch (ClassNotFoundException cnfe) {
            Exceptions.attachMessage(cnfe,
                                     "Loader for ClassNotFoundException: " +
                                     getClassLoader());
            throw cnfe;
        } catch (LinkageError le) {
            throw new ClassNotFoundException(le.toString(), le);
        }
    } else {
        getSectionClass(); // might throw some exceptions
        if (SharedClassObject.class.isAssignableFrom(clazz)) {
            return SharedClassObject.findObject(clazz.asSubclass(SharedClassObject.class), true);
        } else {
            return clazz.newInstance();
        }
    }
}
PropertySupport.java 文件源码 项目:incubator-netbeans 阅读 27 收藏 0 点赞 0 评论 0
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (getter == null) {
        throw new IllegalAccessException();
    }

    Object valideInstance = Beans.getInstanceOf(instance, getter.getDeclaringClass());

    try {
        try {
            return cast(getValueType(), getter.invoke(valideInstance));
        } catch (IllegalAccessException ex) {
            try {
                getter.setAccessible(true);

                return cast(getValueType(), getter.invoke(valideInstance));
            } finally {
                getter.setAccessible(false);
            }
        }
    } catch (IllegalArgumentException iae) {
        //Provide a better message for debugging
        StringBuffer sb = new StringBuffer("Attempted to invoke method ");
        sb.append(getter.getName());
        sb.append(" from class ");
        sb.append(getter.getDeclaringClass().getName());
        sb.append(" on an instance of ");
        sb.append(valideInstance.getClass().getName());
        sb.append(" Problem:");
        sb.append(iae.getMessage());
        throw (IllegalArgumentException) new IllegalArgumentException(sb.toString()).initCause(iae);
    }
}
BeanNode.java 文件源码 项目:incubator-netbeans 阅读 19 收藏 0 点赞 0 评论 0
/** Detaches all listeners from the bean and destroys it.
* @throws IOException if there was a problem
*/
@Override
public void destroy() throws IOException {
    if (removePCLMethod != null) {
        try {
            Object o = Beans.getInstanceOf(bean, removePCLMethod.getDeclaringClass());
            removePCLMethod.invoke(o, new Object[] { propertyChangeListener });
        } catch (Exception e) {
            NodeOp.exception(e);
        }
    }

    super.destroy();
}
IndexedPropertySupport.java 文件源码 项目:incubator-netbeans 阅读 17 收藏 0 点赞 0 评论 0
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canRead()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, getter.getDeclaringClass());

    return PropertySupport.cast(getValueType(), getter.invoke(validInstance));
}
IndexedPropertySupport.java 文件源码 项目:incubator-netbeans 阅读 15 收藏 0 点赞 0 评论 0
public E getIndexedValue(int index)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canIndexedRead()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, indexedGetter.getDeclaringClass());

    return PropertySupport.cast(getElementType(), indexedGetter.invoke(validInstance, index));
}
IndexedPropertySupport.java 文件源码 项目:incubator-netbeans 阅读 17 收藏 0 点赞 0 评论 0
public void setIndexedValue(int index, E val)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canIndexedWrite()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, indexedSetter.getDeclaringClass());
    indexedSetter.invoke(validInstance, new Object[] { new Integer(index), val });
}
MapGLPanel.java 文件源码 项目:Pogamut3 阅读 76 收藏 0 点赞 0 评论 0
/**
 * Create a panel for 
 * @param caps
 * @param map
 * @param log
 */
protected MapGLPanel(GLCapabilities caps, IUnrealMap map, Logger log) {
    super(caps);

    if (Beans.isDesignTime()) {
        Beans.setDesignTime(false);
    }

    this.map = map;
    this.logger = log;

    Location mapFocus = new Location(
            map.getBox().getCenterX(),
            map.getBox().getCenterY(),
            map.getBox().getCenterZ());
    // Stuff for controlling viewpoint in map
    mapViewpoint = new MapViewpoint();
    mapController = new MapController(this, mapViewpoint, mapFocus);
    mapController.registerListeners();

    // Create renderers
    mapRenderer = new MapRenderer(map, lastGLName++);
    agentRenderes = new GLRendererCollection<IRenderableUTAgent>();
    environmentRenderer = new EnvironmentRenderer(mapViewpoint, agentRenderes, mapRenderer);

    // Add listener so this level is rendered
    this.addGLEventListener(environmentRenderer);

    // Listen for changes in viewpoint
    mapViewpoint.addViewpointListener(this);

    // Set initial position of view + thanks to listener display
    mapViewpoint.setFromViewedBox(map.getBox());

}
TrinidadConverterHandler.java 文件源码 项目:myfaces-trinidad 阅读 14 收藏 0 点赞 0 评论 0
@Override
protected MetaRuleset createMetaRuleset(Class type)
{
  MetaRuleset m = super.createMetaRuleset(type);
  // Trinidad-2014 : Converters may have id specified in the tld, but it isn't supported
  if (Beans.isDesignTime())
    m.ignore("id");
  m.addRule(StringArrayPropertyTagRule.Instance);
  m.addRule(ValueExpressionTagRule.Instance);
  m.addRule(LocalePropertyTagRule.Instance);
  m.addRule (TimezonePropertyTagRule.Instance);
  return m;
}


问题


面经


文章

微信
公众号

扫码关注公众号