本文整理匯總了Java中org.seasar.framework.beans.PropertyDesc.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java PropertyDesc.setValue方法的具體用法?Java PropertyDesc.setValue怎麽用?Java PropertyDesc.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.seasar.framework.beans.PropertyDesc
的用法示例。
在下文中一共展示了PropertyDesc.setValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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);
}
示例4: updateTimestampIfNeed
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
protected void updateTimestampIfNeed(Object bean) {
if (getTimestamp() != null) {
PropertyDesc pd = getBeanMetaData().getTimestampPropertyType()
.getPropertyDesc();
pd.setValue(bean, getTimestamp());
}
}
示例5: updateVersionNoIfNeed
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
protected void updateVersionNoIfNeed(Object bean) {
if (getVersionNo() != null) {
PropertyDesc pd = getBeanMetaData().getVersionNoPropertyType()
.getPropertyDesc();
pd.setValue(bean, getVersionNo());
}
}
示例6: setupRelationKeyValue
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
protected void setupRelationKeyValue(RelationRowCreationResource res) {
final RelationPropertyType rpt = res.getRelationPropertyType();
final BeanMetaData bmd = rpt.getBeanMetaData();
for (int i = 0; i < rpt.getKeySize(); ++i) {
final String columnName = rpt.getMyKey(i) + res.getBaseSuffix();
if (!res.containsColumnName(columnName)) {
continue;
}
if (!res.hasRowInstance()) {
res.setRow(newRelationRow(rpt));
}
if (!res.containsRelKeyValueIfExists(columnName)) {
continue;
}
final Object value = res.extractRelKeyValue(columnName);
if (value == null) {
continue;
}
final String yourKey = rpt.getYourKey(i);
final PropertyType pt = bmd.getPropertyTypeByColumnName(yourKey);
final PropertyDesc pd = pt.getPropertyDesc();
pd.setValue(res.getRow(), value);
continue;
}
}
示例7: registerValue
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
protected void registerValue(ResultSet rs, Object row, PropertyType pt,
String name) throws SQLException {
final ValueType valueType = pt.getValueType();
final Object value = valueType.getValue(rs, name);
final PropertyDesc pd = pt.getPropertyDesc();
pd.setValue(row, value);
}
示例8: testAutoSelectSqlByDto3
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
public void testAutoSelectSqlByDto3() throws Exception {
DaoMetaData dmd = createDaoMetaData(getDaoClass("Employee3Dao"));
SelectDynamicCommand cmd = (SelectDynamicCommand) dmd
.getSqlCommand("getEmployees");
assertNotNull("1", cmd);
System.out.println(cmd.getSql());
Object dto = getBean("Employee3");
BeanDesc desc = BeanDescFactory.getBeanDesc(dto.getClass());
PropertyDesc propertyDesc = desc.getPropertyDesc("manager");
propertyDesc.setValue(dto, (new Short((short) 7902)));
List employees = (List) cmd.execute(new Object[] { dto });
System.out.println(employees);
assertTrue("2", employees.size() > 0);
}
示例9: put
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
public Object put(Object key, Object value) {
PropertyDesc pd = beanDesc.getPropertyDesc(key.toString());
pd.setValue(bean, value);
return null;
}
示例10: 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());
}
}
示例11: 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());
}
}
示例12: setProperty
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
protected static void setProperty(IdentifierGenerator generator,
String propertyName, String value) {
BeanDesc beanDesc = BeanDescFactory.getBeanDesc(generator.getClass());
PropertyDesc pd = beanDesc.getPropertyDesc(propertyName);
pd.setValue(generator, value);
}
示例13: handle
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
/**
* @see org.seasar.extension.jdbc.ResultSetHandler#handle(java.sql.ResultSet)
*/
public Object handle(ResultSet rs) throws SQLException {
// Set<String(columnName)>
final Set columnNames = createColumnNames(rs.getMetaData());
// Map<String(columnName), PropertyType>
Map propertyCache = null;// [DAO-118] (2007/08/26)
// Map<String(relationNoSuffix), Map<String(columnName), PropertyType>>
Map relationPropertyCache = null;// [DAO-118] (2007/08/25)
final List list = new ArrayList();
final int relSize = getBeanMetaData().getRelationPropertyTypeSize();
final RelationRowCache relRowCache = new RelationRowCache(relSize);
while (rs.next()) {
// Lazy initialization because if the result is zero, the cache is
// unused.
if (propertyCache == null) {
propertyCache = createPropertyCache(columnNames);
}
if (relationPropertyCache == null) {
relationPropertyCache = createRelationPropertyCache(columnNames);
}
// Create row instance of base table by row property cache.
final Object row = createRow(rs, propertyCache);
for (int i = 0; i < relSize; ++i) {
RelationPropertyType rpt = getBeanMetaData()
.getRelationPropertyType(i);
if (rpt == null) {
continue;
}
Object relationRow = null;
Map relKeyValues = new HashMap();
// TODO 1レコード目でnullが返るなら、2レコード目以降は不要では?
RelationKey relKey = createRelationKey(rs, rpt, columnNames,
relKeyValues);
if (relKey != null) {
relationRow = relRowCache.getRelationRow(i, relKey);
if (relationRow == null) {
relationRow = createRelationRow(rs, rpt, columnNames,
relKeyValues, relationPropertyCache);
relRowCache.addRelationRow(i, relKey, relationRow);
}
}
if (relationRow != null) {
PropertyDesc pd = rpt.getPropertyDesc();
pd.setValue(row, relationRow);
postCreateRow(relationRow);
}
}
postCreateRow(row);
list.add(row);
}
return list;
}
示例14: handle
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
/**
* @see org.seasar.extension.jdbc.ResultSetHandler#handle(java.sql.ResultSet)
*/
public Object handle(ResultSet resultSet) throws SQLException {
if (resultSet.next()) {
// Set<String(columnName)>
final Set columnNames = createColumnNames(resultSet.getMetaData());// [DAO-118]
// (2007/08/26)
// Map<String(columnName), PropertyType>
Map propertyCache = createPropertyCache(columnNames);// [DAO-118]
// (2007/08/25)
// Map<String(relationNoSuffix), Set<PropertyType>>
final Map relationPropertyCache = createRelationPropertyCache(columnNames);// [DAO-118]
// (2007/08/26)
final Object row = createRow(resultSet, propertyCache);
for (int i = 0; i < getBeanMetaData().getRelationPropertyTypeSize(); ++i) {
RelationPropertyType rpt = getBeanMetaData()
.getRelationPropertyType(i);
if (rpt == null) {
continue;
}
Map relKeyValues = new HashMap();
RelationKey relKey = createRelationKey(resultSet, rpt,
columnNames, relKeyValues);
Object relationRow = null;
if (relKey != null) {
relationRow = createRelationRow(resultSet, rpt,
columnNames, relKeyValues, relationPropertyCache);
}
if (relationRow != null) {
PropertyDesc pd = rpt.getPropertyDesc();
pd.setValue(row, relationRow);
postCreateRow(relationRow);
}
}
postCreateRow(row);
if (resultSet.next()) {
handleNotSingleResult();
}
return row;
} else {
return null;
}
}
示例15: registerRelationValidValue
import org.seasar.framework.beans.PropertyDesc; //導入方法依賴的package包/類
protected void registerRelationValidValue(RelationRowCreationResource res,
PropertyType pt, Object value) throws SQLException {
res.incrementValidValueCount();
final PropertyDesc pd = pt.getPropertyDesc();
pd.setValue(res.getRow(), value);
}