当前位置: 首页>>代码示例>>Java>>正文


Java BeanInfo类代码示例

本文整理汇总了Java中java.beans.BeanInfo的典型用法代码示例。如果您正苦于以下问题:Java BeanInfo类的具体用法?Java BeanInfo怎么用?Java BeanInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BeanInfo类属于java.beans包,在下文中一共展示了BeanInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBeanInfo

import java.beans.BeanInfo; //导入依赖的package包/类
private static BeanInfo getBeanInfo(Boolean mark, Class type) {
    System.out.println("test=" + mark + " for " + type);
    BeanInfo info;
    try {
        info = Introspector.getBeanInfo(type);
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
    if (info == null) {
        throw new Error("could not find BeanInfo for " + type);
    }
    if (mark != info.getBeanDescriptor().getValue("test")) {
        throw new Error("could not find marked BeanInfo for " + type);
    }
    return info;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Test4520754.java

示例2: writeResponseResult

import java.beans.BeanInfo; //导入依赖的package包/类
@Override
protected void writeResponseResult(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServiceException {

	String className = request.getParameter("className");
	String large = request.getParameter("large");

	if (className == null || !className.startsWith("com.twinsoft.convertigo.beans"))
		throw new ServiceException("Must provide className parameter", null);

	try {
		BeanInfo bi = CachedIntrospector.getBeanInfo(GenericUtils.<Class<? extends DatabaseObject>>cast(Class.forName(className)));
		int iconType = large != null && large.equals("true") ? BeanInfo.ICON_COLOR_32x32 : BeanInfo.ICON_COLOR_16x16;
		IOUtils.copy(bi.getBeanDescriptor().getBeanClass().getResourceAsStream(MySimpleBeanInfo.getIconName(bi, iconType)), response.getOutputStream());
	} catch (Exception e) {
		throw new ServiceException("Icon unreachable", e);
	}

	Engine.logAdmin.info("The image has been exported");
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:21,代码来源:GetIcon.java

示例3: fromObject

import java.beans.BeanInfo; //导入依赖的package包/类
private static List<ReflectionInfo> fromObject(Integer index, Object obj) throws IntrospectionException {
    if (obj == null || obj.getClass().getName().startsWith("java.lang") // NOI18N
            || obj.getClass().getName().startsWith("java.math")) { // NOI18N
        // Let the default handle this
        return Collections.singletonList(new ReflectionInfo(index, null));
    } else {
        BeanInfo bi = Introspector.getBeanInfo(obj.getClass(), Object.class);
        List<ReflectionInfo> result = new ArrayList<>();
        for (PropertyDescriptor pd : bi.getPropertyDescriptors()) {
            result.add(new ReflectionInfo(index, pd.getName()));
        }
        if (result.isEmpty()) {
            return Collections.singletonList(new ReflectionInfo(index, null));
        } else {
            return result;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ReflectionInfo.java

示例4: checkListeners

import java.beans.BeanInfo; //导入依赖的package包/类
private void checkListeners() {
	BeanInfo beanInfo = null;
	try {
		beanInfo = Introspector.getBeanInfo( getClass(), Object.class );
		internalCheckListeners( beanInfo );
	}
	catch( IntrospectionException t ) {
		throw new HibernateException( "Unable to validate listener config", t );
	}
	finally {
		if ( beanInfo != null ) {
			// release the jdk internal caches everytime to ensure this
			// plays nicely with destroyable class-loaders
			Introspector.flushFromCaches( getClass() );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:Cloneable.java

示例5: setParameterValue

import java.beans.BeanInfo; //导入依赖的package包/类
/**
 * Sets the value for a specified parameter for this resource.
 *
 * @param paramaterName the name for the parameter
 * @param parameterValue the value the parameter will receive
 */
@Override
public void setParameterValue(String paramaterName, Object parameterValue)
            throws ResourceInstantiationException{
  // get the beaninfo for the resource bean, excluding data about Object
  BeanInfo resBeanInf = null;
  try {
    resBeanInf = getBeanInfo(this.getClass());
  } catch(Exception e) {
    throw new ResourceInstantiationException(
      "Couldn't get bean info for resource " + this.getClass().getName()
      + Strings.getNl() + "Introspector exception was: " + e
    );
  }
  setParameterValue(this, resBeanInf, paramaterName, parameterValue);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:22,代码来源:AbstractResource.java

示例6: RootClassInfo

import java.beans.BeanInfo; //导入依赖的package包/类
private RootClassInfo(String className, List<String> warnings) {
    super();
    this.className = className;
    this.warnings = warnings;

    if (className == null) {
        return;
    }
    
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(className);
    String nameWithoutGenerics = fqjt.getFullyQualifiedNameWithoutTypeParameters();
    if (!nameWithoutGenerics.equals(className)) {
        genericMode = true;
    }

    try {
        Class<?> clazz = ObjectFactory.externalClassForName(nameWithoutGenerics);
        BeanInfo bi = Introspector.getBeanInfo(clazz);
        propertyDescriptors = bi.getPropertyDescriptors();
    } catch (Exception e) {
        propertyDescriptors = null;
        warnings.add(getString("Warning.20", className)); //$NON-NLS-1$
    }
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:25,代码来源:RootClassInfo.java

示例7: getListCellRendererComponent

import java.beans.BeanInfo; //导入依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Node node = Visualizer.findNode(value);
    thumbImage = node.getIcon(BeanInfo.ICON_COLOR_32x32);
    this.selected = isSelected;
    label.setOpaque(selected);
    if (selected) {
      label.setBackground(UIManager.getColor("List.selectionBackground"));
      label.setForeground(UIManager.getColor("List.selectionForeground"));
    } else {
      label.setBackground(UIManager.getColor("Label.background"));
      label.setForeground(UIManager.getColor("Label.foreground"));
    }
    this.focused = cellHasFocus;
    this.label.setText(node.getDisplayName());

    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:IconPanel.java

示例8: main

import java.beans.BeanInfo; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
        PropertyDescriptor[] pds = i.getPropertyDescriptors();

        Checker.checkEq("number of properties", pds.length, 1);
        PropertyDescriptor p = pds[0];
        Checker.checkEq("property description", p.getShortDescription(), "CHILD");

        Checker.checkEq("isBound",  p.isBound(),  false);
        Checker.checkEq("isExpert", p.isExpert(), false);
        Checker.checkEq("isHidden", p.isHidden(), false);
        Checker.checkEq("isPreferred", p.isPreferred(), false);
        Checker.checkEq("required", p.getValue("required"), false);
        Checker.checkEq("visualUpdate", p.getValue("visualUpdate"), false);

        Checker.checkEnumEq("enumerationValues", p.getValue("enumerationValues"),
            new Object[]{"BOTTOM", 3, "javax.swing.SwingConstants.BOTTOM"});
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:OverridePropertyInfoTest.java

示例9: main

import java.beans.BeanInfo; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
        Checker.checkEq("description",
            i.getBeanDescriptor().getShortDescription(), "CHILD");

        PropertyDescriptor[] pds = i.getPropertyDescriptors();
        Checker.checkEq("number of properties", pds.length, 1);
        PropertyDescriptor p = pds[0];

        Checker.checkEq("property description", p.getShortDescription(), "CHILDPROPERTY");
        Checker.checkEq("isBound",  p.isBound(),  childFlag);
        Checker.checkEq("isExpert", p.isExpert(), childFlag);
        Checker.checkEq("isHidden", p.isHidden(), childFlag);
        Checker.checkEq("isPreferred", p.isPreferred(), childFlag);
        Checker.checkEq("required", p.getValue("required"), childFlag);
        Checker.checkEq("visualUpdate", p.getValue("visualUpdate"), childFlag);

        Checker.checkEnumEq("enumerationValues", p.getValue("enumerationValues"),
            new Object[]{"BOTTOM", 3, "javax.swing.SwingConstants.BOTTOM"});
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:OverrideUserDefPropertyInfoTest.java

示例10: _setPropertySetters

import java.beans.BeanInfo; //导入依赖的package包/类
private void _setPropertySetters(Class<?> klass, List<Object> props)
  throws IntrospectionException
{
  BeanInfo beanInfo = Introspector.getBeanInfo(klass);
  PropertyDescriptor[] descs = beanInfo.getPropertyDescriptors();
  for(int i=0, sz=props.size(); i<sz; i++)
  {
    String name = (String)props.get(i);
    PropertyDescriptor desc = _getDescriptor(descs, name);
    if (desc == null)
    {
      throw new IllegalArgumentException("property:"+name+" not found on:"
        +klass);
    }
    Method setter = desc.getWriteMethod();
    if (setter == null)
    {
      throw new IllegalArgumentException("No way to set property:"+name+" on:"
        +klass);
    }
    props.set(i, setter);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:24,代码来源:TableBuilder.java

示例11: resolveParamProperties

import java.beans.BeanInfo; //导入依赖的package包/类
private void resolveParamProperties() throws IntrospectionException{
    List<ArgDefEntry<RequestParamDefinition>> reqParamDefs = new LinkedList<>();

    BeanInfo beanInfo = Introspector.getBeanInfo(argType);
    PropertyDescriptor[] propDescs = beanInfo.getPropertyDescriptors();

    for (PropertyDescriptor propDesc : propDescs) {
        //            TypeDescriptor propTypeDesc;
        //            propTypeDesc = beanWrapper.getPropertyTypeDescriptor(propDesc.getName());


        //            RequestParam reqParamAnno = propTypeDesc.getAnnotation(RequestParam.class);
        RequestParam reqParamAnno = propDesc.getPropertyType().getAnnotation(RequestParam.class);
        if (reqParamAnno == null) {
            // 忽略未标注 RequestParam 的属性;
            continue;
        }
        RequestParamDefinition reqParamDef = RequestParamDefinition.resolveDefinition(reqParamAnno);
        ArgDefEntry<RequestParamDefinition> defEntry = new ArgDefEntry<>(reqParamDefs.size(), propDesc.getPropertyType(),
                reqParamDef);
        reqParamDefs.add(defEntry);
        propNames.add(propDesc.getName());
    }
    paramResolver = RequestParamResolvers.createParamResolver(reqParamDefs);
}
 
开发者ID:bubicn,项目名称:bubichain-sdk-java,代码行数:26,代码来源:PojoPropertiesConverter.java

示例12: createDataItems

import java.beans.BeanInfo; //导入依赖的package包/类
/**
 * create data items from the properties
 */
protected void createDataItems ( final Class<?> targetClazz )
{
    try
    {
        final BeanInfo bi = Introspector.getBeanInfo ( targetClazz );
        for ( final PropertyDescriptor pd : bi.getPropertyDescriptors () )
        {
            final DataItem item = createItem ( pd, targetClazz );
            this.items.put ( pd.getName (), item );

            final Map<String, Variant> itemAttributes = new HashMap<String, Variant> ();
            fillAttributes ( pd, itemAttributes );
            this.attributes.put ( pd.getName (), itemAttributes );

            initAttribute ( pd );
        }
    }
    catch ( final IntrospectionException e )
    {
        logger.info ( "Failed to read initial item", e );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:AbstractObjectExporter.java

示例13: bean2MapNull

import java.beans.BeanInfo; //导入依赖的package包/类
/**
 * 将对象转为Map,为null的字段跳过,同时保持有序
 * @param bean
 * @return
 * @throws IntrospectionException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Map bean2MapNull(Object bean) throws IntrospectionException,
		IllegalAccessException, InvocationTargetException {
	Class type = bean.getClass();
	Map returnMap = new TreeMap();
	BeanInfo beanInfo = Introspector.getBeanInfo(type);
	PropertyDescriptor[] propertyDescriptors = beanInfo
			.getPropertyDescriptors();
	for (int i = 0; i < propertyDescriptors.length; i++) {
		PropertyDescriptor descriptor = propertyDescriptors[i];
		String propertyName = descriptor.getName();
		if (!propertyName.equals("class")) {
			Method readMethod = descriptor.getReadMethod();
			Object result = readMethod.invoke(bean, new Object[0]);
			if (result != null) {
				returnMap.put(propertyName, result);
			} else {
				//没有值的字段直接跳过
			}
		}
	}
	return returnMap;
}
 
开发者ID:iminto,项目名称:zooadmin,代码行数:32,代码来源:BeanMapUtil.java

示例14: transBean2Map

import java.beans.BeanInfo; //导入依赖的package包/类
public static Map<String, Object> transBean2Map(Object obj) {
	Map<String, Object> map = newHashMap();
	if (obj == null) {
		return map;
	}
	try {
		BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
		PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
		for (PropertyDescriptor property : propertyDescriptors) {
			String key = property.getName();
			// 过滤class属性
			if (!key.equals("class")) {
				// 得到property对应的getter方法
				Method getter = property.getReadMethod();
				Object value = getter.invoke(obj);
				map.put(key, value);
			}
		}
	} catch (Exception e) {
		System.out.println("transBean2Map Error " + e);
	}
	return map;
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:24,代码来源:InstanceUtil.java

示例15: configureMenuItem

import java.beans.BeanInfo; //导入依赖的package包/类
private void configureMenuItem (JMenuItem item, String containerCtx, String action, ActionProvider provider, Map context) {
//        System.err.println("ConfigureMenuItem: " + containerCtx + "/" + action);
        item.setName(action);
        item.putClientProperty(KEY_ACTION, action);
        item.putClientProperty(KEY_CONTAINERCONTEXT, containerCtx);
        item.putClientProperty(KEY_CREATOR, this);
        item.setText(
            provider.getDisplayName(action, containerCtx));
        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = context == null ? ActionProvider.STATE_ENABLED | ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, context);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; 
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
        //Intentionally use enabled property
        item.setVisible(enabled);
        item.setMnemonic(provider.getMnemonic(action, containerCtx));
        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbstractContextMenuFactory.java


注:本文中的java.beans.BeanInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。