Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/beans/SimpleBeanInfo.java
38829 views
/*1* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans;2627import java.awt.Image;28import java.awt.Toolkit;29import java.awt.image.ImageProducer;30import java.net.URL;3132/**33* This is a support class to make it easier for people to provide34* BeanInfo classes.35* <p>36* It defaults to providing "noop" information, and can be selectively37* overriden to provide more explicit information on chosen topics.38* When the introspector sees the "noop" values, it will apply low39* level introspection and design patterns to automatically analyze40* the target bean.41*/4243public class SimpleBeanInfo implements BeanInfo {4445/**46* Deny knowledge about the class and customizer of the bean.47* You can override this if you wish to provide explicit info.48*/49public BeanDescriptor getBeanDescriptor() {50return null;51}5253/**54* Deny knowledge of properties. You can override this55* if you wish to provide explicit property info.56*/57public PropertyDescriptor[] getPropertyDescriptors() {58return null;59}6061/**62* Deny knowledge of a default property. You can override this63* if you wish to define a default property for the bean.64*/65public int getDefaultPropertyIndex() {66return -1;67}6869/**70* Deny knowledge of event sets. You can override this71* if you wish to provide explicit event set info.72*/73public EventSetDescriptor[] getEventSetDescriptors() {74return null;75}7677/**78* Deny knowledge of a default event. You can override this79* if you wish to define a default event for the bean.80*/81public int getDefaultEventIndex() {82return -1;83}8485/**86* Deny knowledge of methods. You can override this87* if you wish to provide explicit method info.88*/89public MethodDescriptor[] getMethodDescriptors() {90return null;91}9293/**94* Claim there are no other relevant BeanInfo objects. You95* may override this if you want to (for example) return a96* BeanInfo for a base class.97*/98public BeanInfo[] getAdditionalBeanInfo() {99return null;100}101102/**103* Claim there are no icons available. You can override104* this if you want to provide icons for your bean.105*/106public Image getIcon(int iconKind) {107return null;108}109110/**111* This is a utility method to help in loading icon images.112* It takes the name of a resource file associated with the113* current object's class file and loads an image object114* from that file. Typically images will be GIFs.115* <p>116* @param resourceName A pathname relative to the directory117* holding the class file of the current class. For example,118* "wombat.gif".119* @return an image object. May be null if the load failed.120*/121public Image loadImage(final String resourceName) {122try {123final URL url = getClass().getResource(resourceName);124if (url != null) {125final ImageProducer ip = (ImageProducer) url.getContent();126if (ip != null) {127return Toolkit.getDefaultToolkit().createImage(ip);128}129}130} catch (final Exception ignored) {131}132return null;133}134}135136137