DescriptorSupport.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:jdk8u-jdk 作者:
/**
 * Constructor taking field names and field values.  Neither array
 * can be null.
 *
 * @param fieldNames String array of field names.  No elements of
 * this array can be null.
 * @param fieldValues Object array of the corresponding field
 * values.  Elements of the array can be null. The
 * <code>fieldValue</code> must be valid for the
 * <code>fieldName</code> (as defined in method {@link #isValid
 * isValid})
 *
 * <p>Note: array sizes of parameters should match. If both arrays
 * are empty, then an empty descriptor is created.</p>
 *
 * @exception RuntimeOperationsException for illegal value for
 * field Names or field Values.  The array lengths must be equal.
 * If the descriptor construction fails for any reason, this
 * exception will be thrown.
 *
 */
public DescriptorSupport(String[] fieldNames, Object[] fieldValues)
        throws RuntimeOperationsException {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
        MODELMBEAN_LOGGER.logp(Level.FINEST,
                DescriptorSupport.class.getName(),
                "Descriptor(fieldNames,fieldObjects)", "Constructor");
    }

    if ((fieldNames == null) || (fieldValues == null) ||
        (fieldNames.length != fieldValues.length)) {
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
            MODELMBEAN_LOGGER.logp(Level.FINEST,
                    DescriptorSupport.class.getName(),
                    "Descriptor(fieldNames,fieldObjects)",
                    "Illegal arguments");
        }

        final String msg =
            "Null or invalid fieldNames or fieldValues";
        final RuntimeException iae = new IllegalArgumentException(msg);
        throw new RuntimeOperationsException(iae, msg);
    }

    /* populate internal structure with fields */
    init(null);
    for (int i=0; i < fieldNames.length; i++) {
        // setField will throw an exception if a fieldName is be null.
        // the fieldName and fieldValue will be validated in setField.
        setField(fieldNames[i], fieldValues[i]);
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
        MODELMBEAN_LOGGER.logp(Level.FINEST,
                DescriptorSupport.class.getName(),
                "Descriptor(fieldNames,fieldObjects)", "Exit");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号