承接上文

对象的赋值(调用方式都一样不再阐述)


.net篇(环境为vs2012+Spring.Core.dll v1.31

public class PropertyDemo{
public System.Collections.ArrayList PropertyList { get; set; }
public System.Collections.Specialized.HybridDictionary PropertyDictionary { get; set; }
public System.Collections.Specialized.NameValueCollection PropertyNameValue { get; set; }
public Spring.Collections.Set PropertySet { get; set; }
public System.Collections.Generic.List<string> PropertyStrList { get; set; }
public System.Collections.Generic.Dictionary<string, string> PropertyStrDictionary { get; set; }
public string this[int index] {
get { return (string)PropertyList[index]; }
set { PropertyList[index] = value; }
}
public string this[string keyName] {
get { return (string)PropertyDictionary[keyName]; }
set { PropertyDictionary.Add(keyName, value); }
}
public DateTime PropertyTime { get; set; }
}
 <object name="PropertyDemo" type="SpringBase.PropertyDemo,SpringBase">
<property name="PropertyList">
<list>
<value>a list element followed by a reference</value>
</list>
</property>
<property name="PropertyDictionary">
<dictionary>
<entry key="a string => string entry" value="just some string"/>
</dictionary>
</property>
<property name="PropertyNameValue">
<name-values>
<add key="HarryPotter" value="The magic property"/>
<add key="JerrySeinfeld" value="The funny (to Americans) property"/>
</name-values>
</property>
<property name="PropertySet">
<set>
<value>just some string</value>
</set>
</property>
<property name="PropertyStrList">
<list element-type="string">
<value>a</value>
<value>b</value>
<value>c</value>
</list>
</property>
<property name="PropertyStrDictionary">
<dictionary key-type="string" value-type="string">
<entry key="zero">
<value>jerry</value>
</entry>
<entry key="one">
<value>Month</value>
</entry>
<entry key="two">
<value>Nikola Tesla</value>
</entry>
<entry key="three">
<value>DateTime.Today</value>
</entry>
</dictionary>
</property>
<property name="[0]" value="Master Shake"/>
<property name="['one']" value="uno"/>
<property name="PropertyTime" expression="DateTime.Today + 7"/>
</object>

上面的标签和csharp的类型需要对应或者用基类也可以,
expression是表达式运行的时候会自动换行为响应的值,key-type设置是泛型属性key的类型,
key-value设置是泛型属性值的类型,属性索引老版本可能不是这样的设置的


java篇(环境为Maven+Jdk1.7+IntelliJ IDEA 12.1.4

package springdemo;
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
public class PropertyDemo {
private ArrayList propertyList;
public ArrayList getPropertyList() {
return propertyList;
}
public void setPropertyList(ArrayList propertyList) {
this.propertyList = propertyList;
}
private Map propertyDictionary;
public Map getPropertyDictionary() {
return propertyDictionary;
}
public void setPropertyDictionary(Map propertyDictionary) {
this.propertyDictionary = propertyDictionary;
}
private Set propertySet;
public Set getPropertySet() {
return propertySet;
}
public void setPropertySet(Set propertySet) {
this.propertySet = propertySet;
}
private Properties propertyprops;
public Properties getPropertyprops() {
return propertyprops;
}
public void setPropertyprops(Properties propertyprops) {
this.propertyprops = propertyprops;
}
}
 <bean id="PropertyDemo" class="springdemo.PropertyDemo">
<property name="propertyList">
<list>
<value>a list element followed by a reference</value>
</list>
</property>
<property name="propertyDictionary">
<map>
<entry key="a string => string entry" value="just some string"/>
</map>
</property>
<property name="propertySet">
<set>
<value>just some string</value>
</set>
</property>
<property name="propertyprops">
<props>
<prop key="db">172.0.0.1</prop>
<prop key="name">myself</prop>
</props>
</property>
</bean>

不知道java东西少还是什么只有这些,因为java是伪泛型也不支持属性索引器,
因为没有文档都是参考c# 探索出java


javaCsharp的共同点

其中我们在标签里面还可以用ref | idref标签或者属性来通过id | name引用其他的对象,
许多标签的属性可以当作一个独立的标签,如下

<entry key="myKey"> <value>hello</value></entry>

java中必须要有set字段的方法,Csharp可以省略


Ⅲ.spring的点点滴滴--赋值的更多相关文章

  1. Ⅳspring的点点滴滴--方法和事件

    承接上文 方法和事件 .net篇(环境为vs2012+Spring.Core.dll v1.31) public abstract class MethodDemo { protected abstr ...

  2. Ⅱ.spring的点点滴滴--对象

    承接上文 对象的各种实例化 .net篇(环境为vs2012+Spring.Core.dll) 修改原来的PersonDao对象为 public class PersonDao : IPersonDao ...

  3. Ⅶ.spring的点点滴滴--自定义对象行为

    承接上文 自定义对象行为 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class lifeCycle : Spring.Objects.Factory. ...

  4. Ⅰ.Spring的点点滴滴--序章

    spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架 .net篇(环境为vs2012+Spring.Core.dll) 新建一个控制台 using Spring.Context; ...

  5. XI.spring的点点滴滴--IObjectFactoryPostProcessor(工厂后处理器)

    承接上文 IObjectFactoryPostProcessor(工厂后处理器)) 前提是实现接口的对象注册给当前容器 直接继承的对象调用这个postProcessBeanFactory方法,参数为工 ...

  6. Ⅹ.spring的点点滴滴--IObjectPostProcessor(对象后处理器)

    承接上文 IObjectPostProcessor(对象后处理器) 前提是实现接口的对象注册给当前容器 C#: 通过继承AbstractObjectFactory对象的AddObjectPostPro ...

  7. Ⅸ.spring的点点滴滴--IObjectFactory与IFactoryObject的杂谈

    承接上文 ObjectFactory与IFactoryObject的杂谈 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class parent { pu ...

  8. Ⅷ.spring的点点滴滴--抽象对象和子对象

    承接上文 抽象对象和子对象 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class parent { public string Name { get; ...

  9. Ⅵ.spring的点点滴滴--自定义类型转换器

    承接上文 自定义类型转换器 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class CustomeConverter : TypeConverter{ ...

随机推荐

  1. Android学习系列(1)--为App签名(为apk签名)

    写博客是一种快乐,前提是你有所写,与人分享,是另一种快乐,前提是你有舞台展示,博客园就是这样的舞台.这篇文章是android开发人员的必备知识,是我特别为大家整理和总结的,不求完美,但是有用. 1.签 ...

  2. pt-table-checksum 主从复制一致性检查

    1. pt-table-checksum介绍 http://www.percona.com/doc/percona-toolkit/2.2/pt-table-checksum.html pt-tabl ...

  3. Android中Bitmap和Drawable,等相关内容

    一.相关概念 1.Drawable就是一个可画的对象,其可能是一张位图(BitmapDrawable),也可能是一个图形(ShapeDrawable),还有可能是一个图层(LayerDrawable) ...

  4. Java HashMap存储问题

    public static boolean isIsomorphic(String s, String t) { Map map1 = new HashMap<>(); Map map2 ...

  5. php中的字符串和正则表达式

    一.字符串类型的特点 1.PHP是弱类型语言,其他数据类型一般都可以直接应用于字符串函数操作. 1: <?php //输出345 //输出345 //先查找hello常量,若没找到,将hello ...

  6. 卡特兰数 BZOJ3907 网格 NOIP2003 栈

    卡特兰数 卡特兰数2 卡特兰数:主要是求排列组合问题 1:括号化矩阵连乘,问多少种方案 2:走方格,不能过对角线,问多少种方案 3:凸边型,划分成三角形 4:1到n的序列进栈,有多少种出栈方案 NOI ...

  7. HTML5学习之FileReader接口

    http://blog.csdn.net/zk437092645/article/details/8745647 用来把文件读入内存,并且读取文件中的数据.FileReader接口提供了一个异步API ...

  8. 【转载】locate命令的使用

    [说明]转载自 http://www.cnblogs.com/flysnail/archive/2012/05/16/2504266.html 使用locate命令,遇到了这样的情况:当前目录下有一个 ...

  9. HDU-4618 Palindrome Sub-Array 暴力枚举

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4618 直接暴力枚举中心点,在中间如果求不出最大值直接跳过优化下... //STATUS:C++_AC_ ...

  10. STL学习系列一:STL(标准模板库)理论基础

    STL(Standard Template Library,标准模板库)是惠普实验室开发的一系列软件的统称.现然主要出现在C++中,但在被引入C++之前该技术就已经存在了很长的一段时间. STL的从广 ...