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


Java PropertyDesc类代码示例

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


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

示例1: createFormBeanConfig

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * アクションフォーム設定を作成します。
 * 
 * @param actionMapping
 *            アクションマッピング
 * @return アクションフォーム設定
 */
protected S2FormBeanConfig createFormBeanConfig(
        S2ActionMapping actionMapping) {

    S2FormBeanConfig formConfig = createFormBeanConfig();
    formConfig.setName(actionMapping.getName());
    ActionFormWrapperClass wrapperClass = createActionFormWrapperClass(actionMapping);
    BeanDesc beanDesc = actionMapping.getActionFormBeanDesc();
    for (int i = 0; i < beanDesc.getPropertyDescSize(); i++) {
        PropertyDesc pd = beanDesc.getPropertyDesc(i);
        if (pd.isReadable()) {
            S2DynaProperty property = createDynaProperty(pd);
            wrapperClass.addDynaProperty(property);
        }
    }
    formConfig.setDynaClass(wrapperClass);
    return formConfig;
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:25,代码来源:ActionCustomizer.java

示例2: getSimpleProperty

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * 単純なプロパティの値を返します。
 * 
 * @param bean
 *            JavaBeans
 * @param name
 *            プロパティ名
 * @return プロパティの値
 */
protected Object getSimpleProperty(Object bean, String name) {
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return null;
    }
    PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isReadable()) {
        return null;
    }
    Object value = pd.getValue(bean);
    if (value == null) {
        if (!ModifierUtil.isAbstract(pd.getPropertyType())) {
            value = ClassUtil.newInstance(pd.getPropertyType());
            if (pd.isWritable()) {
                pd.setValue(bean, value);
            }
        } else if (Map.class.isAssignableFrom(pd.getPropertyType())) {
            value = new HashMap<String, Object>();
            if (pd.isWritable()) {
                pd.setValue(bean, value);
            }
        }
    }
    return value;
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:35,代码来源:S2RequestProcessor.java

示例3: createBeanPropertyTypes

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
public PropertyType[] createBeanPropertyTypes(String tableName) {
    List list = new ArrayList();
    BeanDesc beanDesc = getBeanDesc();
    Set columns = getColumns(tableName);
    boolean found = false;
    for (int i = 0; i < beanDesc.getPropertyDescSize(); ++i) {
        PropertyDesc pd = beanDesc.getPropertyDesc(i);
        if (isRelation(pd)) {
            continue;
        }
        PropertyType pt = createPropertyType(pd);
        if (isPrimaryKey(pd)) {
            pt.setPrimaryKey(true);
            found = true;
        }
        setupColumnName(pt, columns);
        setupPersistent(pt, columns);
        list.add(pt);
    }
    PropertyType[] propertyTypes = (PropertyType[]) list
            .toArray(new PropertyType[list.size()]);
    if (!found) {
        setupPrimaryKey(propertyTypes, tableName);
    }
    return propertyTypes;
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:27,代码来源:PropertyTypeFactoryImpl.java

示例4: testGetGeneratedValueTx

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
public void testGetGeneratedValueTx() throws Exception {
    BasicUpdateHandler updateHandler = new BasicUpdateHandler(
            getDataSource(),
            "insert into identitytable(id_name) values('hoge')");
    updateHandler.execute(null);
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(Hoge.class);
    PropertyDesc propertyDesc = beanDesc.getPropertyDesc("id");
    PropertyType propertyType = new PropertyTypeImpl(propertyDesc,
            ValueTypes.getValueType(int.class));
    IdentityIdentifierGenerator generator = new IdentityIdentifierGenerator(
            propertyType, new HSQL());
    Hoge hoge = new Hoge();
    generator.setIdentifier(hoge, getDataSource());
    System.out.println(hoge.getId());
    assertTrue("1", hoge.getId() >= 0);
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:17,代码来源:IdentityIdentifierGeneratorTest.java

示例5: testGenerate_allocationSizeTx

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
public void testGenerate_allocationSizeTx() throws Exception {
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(Hoge.class);
    PropertyDesc propertyDesc = beanDesc.getPropertyDesc("id");
    PropertyType propertyType = new PropertyTypeImpl(propertyDesc,
            ValueTypes.getValueType(int.class));
    SequenceIdentifierGenerator generator = new SequenceIdentifierGenerator(
            propertyType, new HSQL());
    generator.setSequenceName("myseq2");
    generator.setAllocationSize(10L);
    Hoge hoge = new Hoge();
    generator.setIdentifier(hoge, getDataSource());
    System.out.println(hoge.getId());
    assertTrue(hoge.getId() > 0);
    int prev = hoge.getId();
    for (int i = 0; i < 31; i++) {
        generator.setIdentifier(hoge, getDataSource());
        System.out.println(hoge.getId());
        assertTrue(hoge.getId() > prev);
        prev = hoge.getId();
    }
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:22,代码来源:SequenceIdentifierGeneratorTest.java

示例6: testCreateIdentifierGenerator

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
public void testCreateIdentifierGenerator() throws Exception {
    Dbms dbms = new HSQL();
    Hoge hoge = new Hoge();
    hoge.setId(1);
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(Hoge.class);
    PropertyDesc propertyDesc = beanDesc.getPropertyDesc("id");
    PropertyType propertyType = new PropertyTypeImpl(propertyDesc,
            ValueTypes.getValueType(int.class));
    IdentifierGenerator generator = IdentifierGeneratorFactory
            .createIdentifierGenerator(propertyType, dbms, null);
    assertEquals("1", AssignedIdentifierGenerator.class, generator
            .getClass());
    generator = IdentifierGeneratorFactory.createIdentifierGenerator(
            propertyType, dbms, "identity");
    assertEquals("2", IdentityIdentifierGenerator.class, generator
            .getClass());
    generator = IdentifierGeneratorFactory.createIdentifierGenerator(
            propertyType, dbms, "sequence, sequenceName = myseq");
    assertEquals("3", "myseq", ((SequenceIdentifierGenerator) generator)
            .getSequenceName());
    generator = IdentifierGeneratorFactory.createIdentifierGenerator(
            propertyType, dbms,
            "sequence, sequenceName = myseq, allocationSize = 10");
    assertEquals("4", 10, ((SequenceIdentifierGenerator) generator)
            .getAllocationSize());
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:27,代码来源:IdentifierGeneratorFactoryTest.java

示例7: entrySet

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
public Set entrySet() {
    Set set = new HashSet<Entry>();
    int size = beanDesc.getPropertyDescSize();
    for (int i = 0; i < size; i++) {
        PropertyDesc pd = beanDesc.getPropertyDesc(i);
        set.add(new BeanEntry(bean, pd));
    }
    return set;
}
 
开发者ID:kawasima,项目名称:sa-compojure,代码行数:10,代码来源:BeanWrapper.java

示例8: keySet

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
public Set keySet() {
    Set<String> set = new HashSet<String>();
    int size = beanDesc.getPropertyDescSize();
    for (int i = 0; i < size; i++) {
        PropertyDesc pd = beanDesc.getPropertyDesc(i);
        set.add(pd.getPropertyName());
    }
    return set;
}
 
开发者ID:kawasima,项目名称:sa-compojure,代码行数:10,代码来源:BeanWrapper.java

示例9: isExportableProperty

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * リクエストに設定可能なプロパティかどうかを返します。
 * 
 * @param propertyDesc
 *            プロパティ記述
 * @return リクエストに設定可能かどうか
 */
protected boolean isExportableProperty(PropertyDesc propertyDesc) {
    return !propertyDesc.getPropertyType().getName().startsWith(
            "javax.servlet")
            && !propertyDesc.getPropertyName().equals("requestScope")
            && !propertyDesc.getPropertyName().equals("sessionScope")
            && !propertyDesc.getPropertyName().equals("appplicationScope");
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:15,代码来源:S2RequestProcessor.java

示例10: setSimpleProperty

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * 単純なプロパティの値を設定します。
 * 
 * @param bean
 *            JavaBeans
 * @param name
 *            パラメータ名
 * @param value
 *            パラメータの値
 * @throws ServletException
 *             何か例外が発生した場合。
 */
@SuppressWarnings("unchecked")
protected void setSimpleProperty(Object bean, String name, Object value) {
    if (bean instanceof Map) {
        setMapProperty((Map) bean, name, value);
        return;
    }
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return;
    }
    PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isWritable()) {
        return;
    }
    if (pd.getPropertyType().isArray()) {
        pd.setValue(bean, value);
    } else if (List.class.isAssignableFrom(pd.getPropertyType())) {
        List<String> list = ModifierUtil.isAbstract(pd.getPropertyType()) ? new ArrayList<String>()
                : (List<String>) ClassUtil
                        .newInstance(pd.getPropertyType());
        list.addAll(Arrays.asList((String[]) value));
        pd.setValue(bean, list);
    } else if (value == null) {
        pd.setValue(bean, null);
    } else if (value instanceof String[]) {
        String[] values = (String[]) value;
        pd.setValue(bean, values.length > 0 ? values[0] : null);
    } else {
        pd.setValue(bean, value);
    }
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:44,代码来源:S2RequestProcessor.java

示例11: testGetValue

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * @throws Exception
 */
public void testGetValue() throws Exception {
    BbbAction action = new BbbAction();
    action.hoge = "aaa";
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(BbbAction.class);
    PropertyDesc pd = beanDesc.getPropertyDesc("hoge");
    S2DynaProperty property = new S2DynaProperty(pd);
    assertEquals("aaa", property.getValue(action));
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:12,代码来源:S2DynaPropertyTest.java

示例12: testGetValue_wrapper

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * @throws Exception
 */
public void testGetValue_wrapper() throws Exception {
    BbbAction action = new BbbAction();
    action.hogeList = Arrays.asList("1");
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(BbbAction.class);
    PropertyDesc pd = beanDesc.getPropertyDesc("hogeList");
    S2DynaProperty property = new S2DynaProperty(pd);
    Object value = property.getValue(action);
    assertEquals(ListWrapper.class, value.getClass());
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:13,代码来源:S2DynaPropertyTest.java

示例13: setIdentifier

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
protected void setIdentifier(Object bean, Object value) {
    if (propertyType == null) {
        throw new EmptyRuntimeException("propertyType");
    }
    PropertyDesc pd = propertyType.getPropertyDesc();
    pd.setValue(bean, value);
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:8,代码来源:AbstractIdentifierGenerator.java

示例14: isWritable

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * プロパティが書き込み可能な場合<code>true</code>を返します。
 * 
 * @param propertyDesc プロパティ記述
 * @return プロパティが書き込み可能な場合<code>true</code>、そうでない場合<code>false</code>
 */
public static boolean isWritable(PropertyDesc propertyDesc) {
    if (isWritableMethod != null) {
        Boolean b = (Boolean) MethodUtil.invoke(isWritableMethod,
                propertyDesc, null);
        return b.booleanValue();
    }
    return propertyDesc.hasWriteMethod();
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:15,代码来源:PropertyDescUtil.java

示例15: isReadable

import org.seasar.framework.beans.PropertyDesc; //导入依赖的package包/类
/**
 * プロパティが読み取り可能な場合<code>true</code>を返します。
 * 
 * @param propertyDesc プロパティ記述
 * @return プロパティが読み取り可能な場合<code>true</code>、そうでない場合<code>false</code>
 */
public static boolean isReadable(PropertyDesc propertyDesc) {
    if (isReadableMethod != null) {
        Boolean b = (Boolean) MethodUtil.invoke(isReadableMethod,
                propertyDesc, null);
        return b.booleanValue();
    }
    return propertyDesc.hasReadMethod();
}
 
开发者ID:seasarorg,项目名称:s2dao,代码行数:15,代码来源:PropertyDescUtil.java


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