/** * Mark all transient fields in {@code targetClass} as @Transient for the * XML serialization. * * Fields marked with java transient keyword do not work becase the * XMLEncoder does not take these into account. This helper marks the fields * marked with transient keyword as transient also for the XMLDecoder. * * @param targetClass the class */ @SuppressWarnings("rawtypes") public static void remarkTransientFields(Class targetClass) { try { BeanInfo info; info = Introspector.getBeanInfo(targetClass); PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors(); for (Field f : targetClass.getDeclaredFields()) { if (Modifier.isTransient(f.getModifiers())) { for (int i = 0; i < propertyDescriptors.length; ++i) { if (propertyDescriptors[i].getName().equals(f.getName())) { propertyDescriptors[i].setValue("transient", Boolean.TRUE); } } } } } catch (IntrospectionException ex) { LOGGER.log(Level.WARNING, "An exception ocurred during remarking transient fields:", ex); } }
/** * See {@link java.beans.FeatureDescriptor}. */ public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) { target.setExpert(source.isExpert()); target.setHidden(source.isHidden()); target.setPreferred(source.isPreferred()); target.setName(source.getName()); target.setShortDescription(source.getShortDescription()); target.setDisplayName(source.getDisplayName()); // Copy all attributes (emulating behavior of private FeatureDescriptor#addTable) Enumeration<String> keys = source.attributeNames(); while (keys.hasMoreElements()) { String key = keys.nextElement(); target.setValue(key, source.getValue(key)); } // See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor) target.setPropertyEditorClass(source.getPropertyEditorClass()); target.setBound(source.isBound()); target.setConstrained(source.isConstrained()); }
/** * See {@link java.beans.FeatureDescriptor}. */ public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) { target.setExpert(source.isExpert()); target.setHidden(source.isHidden()); target.setPreferred(source.isPreferred()); target.setName(source.getName()); target.setShortDescription(source.getShortDescription()); target.setDisplayName(source.getDisplayName()); // Copy all attributes (emulating behavior of private FeatureDescriptor#addTable) Enumeration<String> keys = source.attributeNames(); while (keys.hasMoreElements()) { String key = keys.nextElement(); target.setValue(key, source.getValue(key)); } // See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor) target.setPropertyEditorClass(source.getPropertyEditorClass()); target.setBound(source.isBound()); target.setConstrained(source.isConstrained()); }
public void setValue(String key, Object val) { descriptor.setValue(key, val); }
public synchronized void setValue(String attributeName, Object value) { if( propertyDescriptor==null )return; propertyDescriptor.setValue(attributeName, value); }
@Override public void setValue(String attributeName, Object value) { this.property.setValue(attributeName, value); }
public void setValue(String key, Object val) { descriptor.setValue(key, val); }
public void setValue(String key, Object val) { descriptor.setValue(key, val); }
protected void setCategory(String categoryName, String... propertyNames) { for (String propertyName : propertyNames) { PropertyDescriptor pd = properties.get(propertyName); if (pd != null) { pd.setValue("category", categoryName); } else { LOG.log(Level.WARNING, "Failed to set category for property '" + propertyName + "'. No such property was found"); } } }
protected void setCategory(String categoryName, String... propertyNames) { for (String propertyName : propertyNames) { PropertyDescriptor pd = properties.get(propertyName); if (pd != null) { pd.setValue("category", categoryName); } else { LOG.log(Level.WARNING, "Failed to set category for property '" + propertyName + "'. No such property was found"); } } }
protected void setCategory(String categoryName, String... propertyNames) { for (String propertyName : propertyNames) { PropertyDescriptor pd = properties.get(propertyName); if (pd != null) { pd.setValue("category", categoryName); } else { LOG.log(Level.WARNING, "Failed to set category for property '" + propertyName + "'. No such property was found"); } } }
public BboxBeanInfo() throws IntrospectionException { props[0] = new PropertyDescriptor("x", Bbox.class); props[1] = new PropertyDescriptor("y", Bbox.class); props[2] = new PropertyDescriptor("width", Bbox.class); props[3] = new PropertyDescriptor("height", Bbox.class); props[4] = new PropertyDescriptor("maxX", Bbox.class); props[4].setValue("transient", Boolean.TRUE); props[5] = new PropertyDescriptor("maxY", Bbox.class); props[5].setValue("transient", Boolean.TRUE); }
public static final void markTransientProperty(String name,Class<?> classe) throws IntrospectionException { BeanInfo info = Introspector.getBeanInfo(classe); PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors(); for (int i = 0; i < propertyDescriptors.length; ++i) { PropertyDescriptor pd = propertyDescriptors[i]; if (pd.getName().equals(name)) { pd.setValue("transient", Boolean.TRUE); } } }
public static final void markTransientProperty(String name,Class<?> classe) throws IntrospectionException { BeanInfo info = Introspector.getBeanInfo(classe); PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors(); for (int i = 0; i < propertyDescriptors.length; ++i) { PropertyDescriptor pd = propertyDescriptors[i]; if (pd.getName().equals(name)) { pd.setValue("transient", Boolean.TRUE); } } }
public SyncTimerBeanInfo() { super(SyncTimer.class); createPropertyGroup("grouping", new String[] { "groupSize", "timeoutInMs" }); PropertyDescriptor p = property("groupSize"); p.setValue(NOT_UNDEFINED, Boolean.TRUE); p.setValue(DEFAULT, Integer.valueOf(0)); p = property("timeoutInMs"); p.setValue(NOT_UNDEFINED, Boolean.TRUE); p.setValue(DEFAULT, Long.valueOf(0)); }
public ConstantThroughputTimerBeanInfo() { super(ConstantThroughputTimer.class); createPropertyGroup("delay", //$NON-NLS-1$ new String[] { "throughput", //$NON-NLS-1$ "calcMode" }); //$NON-NLS-1$ PropertyDescriptor p = property("throughput"); //$NON-NLS-1$ p.setValue(NOT_UNDEFINED, Boolean.TRUE); p.setValue(DEFAULT, Double.valueOf(0.0)); p = property("calcMode", ConstantThroughputTimer.Mode.class); //$NON-NLS-1$ p.setValue(DEFAULT, Integer.valueOf(ConstantThroughputTimer.Mode.ThisThreadOnly.ordinal())); p.setValue(NOT_UNDEFINED, Boolean.TRUE); // must be defined }
protected final PropertyDescriptor createPropertyDescriptor(String valueName, String resourceKey, int priority) { try { PropertyDescriptor propertyDescriptor = new PropertyDescriptor(valueName, beanClass); propertyDescriptor.setValue("label", resourceManager.getString(resourceKey)); propertyDescriptor.setValue("priority", new Integer(priority)); return propertyDescriptor; } catch (IntrospectionException e) { return null; } }