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


Java DynaProperty类代码示例

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


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

示例1: copy

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
private void copy(final Directory directory, final Map<String, Object> metadata) {
    final TagDescriptor<?> descriptor = MetadataHelper.getDescriptor(directory);

    final LazyDynaClass directoryClass = new LazyDynaClass(directory.getName(), null, directory.getTags()
            .parallelStream()
            .map(t -> new DynaProperty(t.getTagName().replaceAll(NON_WORD_CHARS, ""), String.class))
            .toArray(DynaProperty[]::new));
    directoryClass.setReturnNull(true);

    final DynaBean directoryMetadata = new LazyDynaBean(directoryClass);
    directory.getTags().stream().forEach(t -> directoryMetadata.set(
            t.getTagName().replaceAll(NON_WORD_CHARS, ""),
            descriptor.getDescription(t.getTagType())
    ));
    metadata.put(directory.getName().replaceAll(NON_WORD_CHARS, ""), directoryMetadata);
}
 
开发者ID:edouardhue,项目名称:comeon,代码行数:17,代码来源:PictureReader.java

示例2: set

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * <p>Set the value of a simple property with the specified name.</p>
 *
 * @param name Name of the property whose value is to be set
 * @param value Value to which this property is to be set
 *
 * @exception ConversionException if the specified value cannot be
 *  converted to the type required for this property
 * @exception IllegalArgumentException if there is no property
 *  of the specified name
 * @exception NullPointerException if the type specified for the
 *  property is invalid
 * @exception NullPointerException if an attempt is made to set a
 *  primitive property to null
 */
public void set(String name, Object value) {

    DynaProperty descriptor = getDynaProperty(name);
    if (descriptor.getType() == null) {
        throw new NullPointerException
            ("The type for property " + name + " is invalid");
    }
    if (value == null) {
        if (descriptor.getType().isPrimitive()) {
            throw new NullPointerException
                ("Primitive value for '" + name + "'");
        }
    } else if (!isDynaAssignable(descriptor.getType(), value.getClass())) {
        throw new ConversionException
            ("Cannot assign value of type '" +
             value.getClass().getName() +
             "' to property '" + name + "' of type '" +
             descriptor.getType().getName() + "'");
    }
    dynaValues.put(name, value);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:DynaActionForm.java

示例3: toString

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * <p>Render a <code>String</code> representation of this object.</p>
 */
public String toString() {

    StringBuffer sb = new StringBuffer("DynaActionFormBean[name=");
    sb.append(name);
    DynaProperty props[] = getDynaProperties();
    if (props == null) {
        props = new DynaProperty[0];
    }
    for (int i = 0; i < props.length; i++) {
        sb.append(',');
        sb.append(props[i].getName());
        sb.append('/');
        sb.append(props[i].getType());
    }
    sb.append("]");
    return (sb.toString());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:DynaActionFormClass.java

示例4: initPrimaryKeys

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * Initializes the primary key and non primary key property arrays.
 */
protected void initPrimaryKeys()
{
    List           pkProps    = new ArrayList();
    List           nonPkProps = new ArrayList();
    DynaProperty[] properties = getDynaProperties();

    for (int idx = 0; idx < properties.length; idx++)
    {
        if (properties[idx] instanceof SqlDynaProperty)
        {
            SqlDynaProperty sqlProperty = (SqlDynaProperty)properties[idx];

            if (sqlProperty.isPrimaryKey())
            {
                pkProps.add(sqlProperty);
            }
            else
            {
                nonPkProps.add(sqlProperty);
            }
        }
    }
    _primaryKeyProperties    = (SqlDynaProperty[])pkProps.toArray(new SqlDynaProperty[pkProps.size()]);
    _nonPrimaryKeyProperties = (SqlDynaProperty[])nonPkProps.toArray(new SqlDynaProperty[nonPkProps.size()]);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:SqlDynaClass.java

示例5: toString

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public String toString()
{
    StringBuilder   result = new StringBuilder();
    DynaClass      type   = getDynaClass();
    DynaProperty[] props  = type.getDynaProperties();

    result.append(type.getName());
    result.append(": ");
    for (int idx = 0; idx < props.length; idx++)
    {
        if (idx > 0)
        {
            result.append(", ");
        }
        result.append(props[idx].getName());
        result.append(" = ");
        result.append(get(props[idx].getName()));
    }
    return result.toString();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:SqlDynaBean.java

示例6: getPropertyValue

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * Determines the value of the bean's property that has the given name. Depending on the
 * case-setting of the current builder, the case of teh name is considered or not. 
 * 
 * @param bean     The bean
 * @param propName The name of the property
 * @return The value
 */
protected Object getPropertyValue(DynaBean bean, String propName)
{
    if (getPlatform().isDelimitedIdentifierModeOn())
    {
        return bean.get(propName);
    }
    else
    {
        DynaProperty[] props = bean.getDynaClass().getDynaProperties();

        for (int idx = 0; idx < props.length; idx++)
        {
            if (propName.equalsIgnoreCase(props[idx].getName()))
            {
                return bean.get(props[idx].getName());
            }
        }
        throw new IllegalArgumentException("The bean has no property with the name "+propName);
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:TestAgainstLiveDatabaseBase.java

示例7: set

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * <p>Set the value of a simple property with the specified name.</p>
 *
 * @param name  Name of the property whose value is to be set
 * @param value Value to which this property is to be set
 * @throws ConversionException      if the specified value cannot be
 *                                  converted to the type required for
 *                                  this property
 * @throws IllegalArgumentException if there is no property of the
 *                                  specified name
 * @throws NullPointerException     if the type specified for the property
 *                                  is invalid
 * @throws NullPointerException     if an attempt is made to set a
 *                                  primitive property to null
 */
public void set(String name, Object value) {
    DynaProperty descriptor = getDynaProperty(name);

    if (descriptor.getType() == null) {
        throw new NullPointerException("The type for property " + name
            + " is invalid");
    }

    if (value == null) {
        if (descriptor.getType().isPrimitive()) {
            throw new NullPointerException("Primitive value for '" + name
                + "'");
        }
    } else if (!isDynaAssignable(descriptor.getType(), value.getClass())) {
        throw new ConversionException("Cannot assign value of type '"
            + value.getClass().getName() + "' to property '" + name
            + "' of type '" + descriptor.getType().getName() + "'");
    }

    dynaValues.put(name, value);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:37,代码来源:DynaActionForm.java

示例8: toString

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * <p>Render a <code>String</code> representation of this object.</p>
 *
 * @return The string representation of this instance.
 */
public String toString() {
    StringBuffer sb = new StringBuffer("DynaActionFormBean[name=");

    sb.append(name);

    DynaProperty[] props = getDynaProperties();

    if (props == null) {
        props = new DynaProperty[0];
    }

    for (int i = 0; i < props.length; i++) {
        sb.append(',');
        sb.append(props[i].getName());
        sb.append('/');
        sb.append(props[i].getType());
    }

    sb.append("]");

    return (sb.toString());
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:28,代码来源:DynaActionFormClass.java

示例9: testGetDescriptors

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * Positive test for getDynaPropertys().  Each property name listed in
 * <code>properties</code> should be returned exactly once.
 */
public void testGetDescriptors() {
    DynaProperty[] pd = dynaForm.getDynaClass().getDynaProperties();

    assertNotNull("Got descriptors", pd);

    int[] count = new int[properties.length];

    for (int i = 0; i < pd.length; i++) {
        String name = pd[i].getName();

        for (int j = 0; j < properties.length; j++) {
            if (name.equals(properties[j])) {
                count[j]++;
            }
        }
    }

    for (int j = 0; j < properties.length; j++) {
        if (count[j] < 0) {
            fail("Missing property " + properties[j]);
        } else if (count[j] > 1) {
            fail("Duplicate property " + properties[j]);
        }
    }
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:30,代码来源:TestDynaActionForm.java

示例10: getDynaProperty

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
@Override
public DynaProperty getDynaProperty(String aName) {
    if (name != null) {
        if (properties.isEmpty()) {
            if (delegate.hasMember(aName)) {
                Object oMember = delegate.getMember(aName);
                if (!(oMember instanceof JSObject) || !((JSObject) oMember).isFunction()) {
                    return new DynaProperty(aName);
                }
                return null;
            }
        } else {
            return properties.get(aName);
        }
    }
    throw new IllegalArgumentException("No property name specified");
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:18,代码来源:JSDynaClass.java

示例11: buildPropertyMap

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * build a map of business object with its specified property names and corresponding values
 * 
 * @param businessObject the given business object
 * @param the specified fields that need to be included in the return map
 * @return the map of business object with its property names and values
 */
public static Map<String, Object> buildPropertyMap(Object object, List<String> keyFields) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(object.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();
    Map<String, Object> propertyMap = new LinkedHashMap<String, Object>();

    for (DynaProperty property : properties) {
        String propertyName = property.getName();

        if (PropertyUtils.isReadable(object, propertyName) && keyFields.contains(propertyName)) {
            try {
                Object propertyValue = PropertyUtils.getProperty(object, propertyName);

                if (propertyValue != null && !StringUtils.isEmpty(propertyValue.toString())) {
                    propertyMap.put(propertyName, propertyValue);
                }
            }
            catch (Exception e) {
                LOG.info(e);
            }
        }
    }
    return propertyMap;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:31,代码来源:ObjectUtil.java

示例12: hasNullValueField

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * determine if the source object has a field with null as its value
 * 
 * @param sourceObject the source object
 */
public static boolean hasNullValueField(Object sourceObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(sourceObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();

    for (DynaProperty property : properties) {
        String propertyName = property.getName();

        if (PropertyUtils.isReadable(sourceObject, propertyName)) {
            try {
                Object propertyValue = PropertyUtils.getProperty(sourceObject, propertyName);
                if (propertyValue == null) {
                    return true;
                }
            }
            catch (Exception e) {
                LOG.info(e);
                return false;
            }
        }
    }
    return false;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:28,代码来源:ObjectUtil.java

示例13: buildPropertyMap

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
/**
 * This method builds a map of business object with its property names and values
 *
 * @param businessObject the given business object
 * @return the map of business object with its property names and values
 */
public static LinkedHashMap buildPropertyMap(Object businessObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(businessObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();
    LinkedHashMap propertyMap = new LinkedHashMap();

    try {
        for (int numOfProperty = 0; numOfProperty < properties.length; numOfProperty++) {
            String propertyName = properties[numOfProperty].getName();
            if (PropertyUtils.isWriteable(businessObject, propertyName)) {
                Object propertyValue = PropertyUtils.getProperty(businessObject, propertyName);
                propertyMap.put(propertyName, propertyValue);
            }
        }
    }
    catch (Exception e) {
        LOG.error("OJBUtility.buildPropertyMap()" + e);
    }
    return propertyMap;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:26,代码来源:OJBUtility.java

示例14: equals

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }

    if (obj == null) {
        return false;
    }

    if (!(obj instanceof MorphDynaBean)) {
        return false;
    }

    MorphDynaBean other = (MorphDynaBean) obj;
    EqualsBuilder builder = new EqualsBuilder().append(this.dynaClass, other.dynaClass);
    DynaProperty[] props = dynaClass.getDynaProperties();
    for (int i = 0; i < props.length; i++) {
        DynaProperty prop = props[i];
        builder.append(dynaValues.get(prop.getName()), dynaValues.get(prop.getName()));
    }
    return builder.isEquals();
}
 
开发者ID:aalmiray,项目名称:ezmorph,代码行数:23,代码来源:MorphDynaBean.java

示例15: get

import org.apache.commons.beanutils.DynaProperty; //导入依赖的package包/类
public Object get(String name, int index) {
    DynaProperty dynaProperty = getDynaProperty(name);

    Class type = dynaProperty.getType();
    if (!type.isArray() && !List.class.isAssignableFrom(type)) {
        throw new MorphException("Non-Indexed property name: " + name + " index: " + index);
    }

    Object value = dynaValues.get(name);

    if (value.getClass()
        .isArray()) {
        value = Array.get(value, index);
    } else if (value instanceof List) {
        value = ((List) value).get(index);
    }

    return value;
}
 
开发者ID:aalmiray,项目名称:ezmorph,代码行数:20,代码来源:MorphDynaBean.java


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