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


Java PropertyDesc.getPropertyName方法代码示例

本文整理汇总了Java中org.seasar.framework.beans.PropertyDesc.getPropertyName方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyDesc.getPropertyName方法的具体用法?Java PropertyDesc.getPropertyName怎么用?Java PropertyDesc.getPropertyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.seasar.framework.beans.PropertyDesc的用法示例。


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

示例1: combineProperties

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
/**
 * setterを拡張し、
 * (1)スーパークラスの同メソッドを呼び、
 * (2)modifiedPropertiesフィールドへsetterが呼ばれたことを記録します。
 */
private void combineProperties(final CtClass enhancedCtClass)
        throws CannotCompileException {
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(targetClass);
    final int propertyDescSize = beanDesc.getPropertyDescSize();
    for (int i = 0; i < propertyDescSize; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        if (!pd.hasWriteMethod() || !pd.hasReadMethod()) {
            continue;
        }
        final String propertyName = pd.getPropertyName();
        if (propertyName.equalsIgnoreCase(versionNoPropertyName)) {
            continue;
        }
        if (propertyName.equalsIgnoreCase(timestampPropertyName)) {
            continue;
        }

        final String setterName = pd.getWriteMethod().getName();
        final String getterName = pd.getReadMethod().getName();
        final String propertyClassName = ClassUtil
                .getSimpleClassName(pd.getPropertyType());
        final String oldName = propertyName + "Old";
        final String s = "public void " + setterName + "("
                + propertyClassName + " " + propertyName + ")"
                + " { final " + propertyClassName + " " + oldName
                + " = super." + getterName + "(); " + "super."
                + setterName + "(" + propertyName + "); " + "if (!"
                + EqualsUtil.class.getName() + ".equals(" + oldName
                + ", " + propertyName + ")) "
                + modifiedPropertiesFieldName + ".add(\""
                + propertyName + "\"); }";
        //System.out.println(s);
        final CtMethod m = CtNewMethod.make(s, enhancedCtClass);
        enhancedCtClass.addMethod(m);
    }
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:42,代码来源:BeanEnhancerImpl.java

示例2: createRelationPropertyType

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
protected RelationPropertyType createRelationPropertyType(
        PropertyDesc propertyDesc) {

    String[] myKeys = new String[0];
    String[] yourKeys = new String[0];
    int relno = beanAnnotationReader.getRelationNo(propertyDesc);
    String relkeys = beanAnnotationReader.getRelationKey(propertyDesc);
    if (relkeys != null) {
        StringTokenizer st = new StringTokenizer(relkeys, " \t\n\r\f,");
        List myKeyList = new ArrayList();
        List yourKeyList = new ArrayList();
        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            int index = token.indexOf(':');
            if (index > 0) {
                myKeyList.add(token.substring(0, index));
                yourKeyList.add(token.substring(index + 1));
            } else {
                myKeyList.add(token);
                yourKeyList.add(token);
            }
        }
        myKeys = (String[]) myKeyList.toArray(new String[myKeyList.size()]);
        yourKeys = (String[]) yourKeyList.toArray(new String[yourKeyList
                .size()]);
    }
    final BeanMetaData beanMetaData = createRelationBeanMetaData(propertyDesc
            .getPropertyType());
    PropertyDesc enhancedPd = null;
    if (beanEnhancer.isEnhancedClass(beanMetaData.getBeanClass())) {
        enhancedPd = new PropertyDescImpl(propertyDesc.getPropertyName(),
                beanMetaData.getBeanClass(), propertyDesc.getReadMethod(),
                propertyDesc.getWriteMethod(), getBeanDesc());
    } else {
        enhancedPd = propertyDesc;
    }
    final RelationPropertyType rpt = new RelationPropertyTypeImpl(
            enhancedPd, relno, myKeys, yourKeys, beanMetaData);
    return rpt;
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:41,代码来源:RelationPropertyTypeFactoryImpl.java

示例3: getColumnName

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
/**
 * カラム名を返します。
 * 
 * @param propertyDesc {@link PropertyDesc}
 * @return カラム名
 */
protected String getColumnName(PropertyDesc propertyDesc) {
    String propertyName = propertyDesc.getPropertyName();
    String defaultName = fromPropertyNameToColumnName(propertyName);
    String name = beanAnnotationReader.getColumnAnnotation(propertyDesc);
    return name != null ? name : defaultName;
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:13,代码来源:AbstractPropertyTypeFactory.java

示例4: getIndexedProperty

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
/**
 * インデックス化されたプロパティの値を返します。
 * 
 * @param bean
 *            JavaBeans
 * @param name
 *            名前
 * @param indexes
 *            インデックスの配列
 * @return インデックス化されたプロパティの値
 * 
 */
@SuppressWarnings("unchecked")
protected Object getIndexedProperty(Object bean, String name, int[] indexes) {
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return null;
    }
    PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isReadable()) {
        return null;
    }
    if (pd.getPropertyType().isArray()) {
        Object array = pd.getValue(bean);
        Class<?> elementType = getArrayElementType(pd.getPropertyType(),
                indexes.length);
        if (array == null) {
            int[] newIndexes = new int[indexes.length];
            newIndexes[0] = indexes[0] + 1;
            array = Array.newInstance(elementType, newIndexes);
        }
        array = expand(array, indexes, elementType);
        pd.setValue(bean, array);
        return getArrayValue(array, indexes, elementType);
    } else if (List.class.isAssignableFrom(pd.getPropertyType())) {
        List list = (List) pd.getValue(bean);
        if (list == null) {
            list = new ArrayList(Math.max(50, indexes[0]));
            pd.setValue(bean, list);
        }
        ParameterizedClassDesc pcd = pd.getParameterizedClassDesc();
        for (int i = 0; i < indexes.length; i++) {
            if (pcd == null || !pcd.isParameterizedClass()
                    || !List.class.isAssignableFrom(pcd.getRawClass())) {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j <= i; j++) {
                    sb.append("[").append(indexes[j]).append("]");
                }
                throw new NoParameterizedListRuntimeException(
                        getRealClass(beanDesc.getBeanClass()), pd
                                .getPropertyName()
                                + sb);
            }
            int size = list.size();
            pcd = pcd.getArguments()[0];
            for (int j = size; j <= indexes[i]; j++) {
                if (i == indexes.length - 1) {
                    list.add(ClassUtil.newInstance(convertClass(pcd
                            .getRawClass())));
                } else {
                    list.add(new ArrayList());
                }
            }
            if (i < indexes.length - 1) {
                list = (List) list.get(indexes[i]);
            }
        }
        return list.get(indexes[indexes.length - 1]);
    } else {
        throw new IndexedPropertyNotListArrayRuntimeException(
                getRealClass(beanDesc.getBeanClass()), pd.getPropertyName());
    }
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:74,代码来源:S2RequestProcessor.java

示例5: setIndexedProperty

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
/**
 * インデックス化されたプロパティの値を設定します。
 * 
 * @param bean
 *            JavaBeans
 * @param name
 *            名前
 * @param indexes
 *            インデックスの配列
 * @param value
 *            値
 */
@SuppressWarnings("unchecked")
protected void setIndexedProperty(Object bean, String name, int[] indexes,
        Object value) {
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return;
    }
    PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isWritable()) {
        return;
    }
    if (value.getClass().isArray() && Array.getLength(value) > 0) {
        value = Array.get(value, 0);
    }
    if (pd.getPropertyType().isArray()) {
        Object array = pd.getValue(bean);
        Class<?> elementType = getArrayElementType(pd.getPropertyType(),
                indexes.length);
        if (array == null) {
            int[] newIndexes = new int[indexes.length];
            newIndexes[0] = indexes[0] + 1;
            array = Array.newInstance(elementType, newIndexes);
        }
        array = expand(array, indexes, elementType);
        pd.setValue(bean, array);
        setArrayValue(array, indexes, value);
    } else if (List.class.isAssignableFrom(pd.getPropertyType())) {
        List list = (List) pd.getValue(bean);
        if (list == null) {
            list = new ArrayList(Math.max(50, indexes[0]));
            pd.setValue(bean, list);
        }
        ParameterizedClassDesc pcd = pd.getParameterizedClassDesc();
        for (int i = 0; i < indexes.length; i++) {
            if (pcd == null || !pcd.isParameterizedClass()
                    || !List.class.isAssignableFrom(pcd.getRawClass())) {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j <= i; j++) {
                    sb.append("[").append(indexes[j]).append("]");
                }
                throw new NoParameterizedListRuntimeException(
                        getRealClass(beanDesc.getBeanClass()), pd
                                .getPropertyName()
                                + sb);
            }
            int size = list.size();
            pcd = pcd.getArguments()[0];
            for (int j = size; j <= indexes[i]; j++) {
                if (i == indexes.length - 1) {
                    list.add(ClassUtil.newInstance(convertClass(pcd
                            .getRawClass())));
                } else {
                    list.add(new ArrayList());
                }
            }
            if (i < indexes.length - 1) {
                list = (List) list.get(indexes[i]);
            }
        }
        list.set(indexes[indexes.length - 1], value);
    } else {
        throw new IndexedPropertyNotListArrayRuntimeException(
                getRealClass(beanDesc.getBeanClass()), pd.getPropertyName());
    }
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:78,代码来源:S2RequestProcessor.java

示例6: getColumnAnnotation

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
public String getColumnAnnotation(PropertyDesc pd) {
    String propertyName = pd.getPropertyName();
    String columnNameKey = propertyName + COLUMN_SUFFIX;
    return getField(columnNameKey);
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:6,代码来源:FieldBeanAnnotationReader.java

示例7: getRelationKey

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
public String getRelationKey(PropertyDesc pd) {
    String propertyName = pd.getPropertyName();
    String relkeysKey = propertyName + RELKEYS_SUFFIX;
    return getField(relkeysKey);
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:6,代码来源:FieldBeanAnnotationReader.java

示例8: getRelationNo

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
public int getRelationNo(PropertyDesc pd) {
    String relnoKey = pd.getPropertyName() + RELNO_SUFFIX;
    Field field = beanDesc.getField(relnoKey);
    return FieldUtil.getInt(field, null);
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:6,代码来源:FieldBeanAnnotationReader.java

示例9: hasRelationNo

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
public boolean hasRelationNo(PropertyDesc pd) {
    String relnoKey = pd.getPropertyName() + RELNO_SUFFIX;
    return beanDesc.hasField(relnoKey);
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:5,代码来源:FieldBeanAnnotationReader.java

示例10: getValueType

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
public String getValueType(PropertyDesc pd) {
    String valueTypeKey = pd.getPropertyName() + VALUE_TYPE_SUFFIX;
    return getField(valueTypeKey);
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:5,代码来源:FieldBeanAnnotationReader.java

示例11: S2DynaProperty

import org.seasar.framework.beans.PropertyDesc; //导入方法依赖的package包/类
/**
 * インスタンスを構築します。
 * 
 * @param propertyDesc
 *            プロパティ記述
 */
public S2DynaProperty(PropertyDesc propertyDesc) {
    super(propertyDesc.getPropertyName(), propertyDesc.getPropertyType());
    this.propertyDesc = propertyDesc;
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:11,代码来源:S2DynaProperty.java


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