承接上文

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


.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. Hibernate4.x之映射关系--双向1-n

    双向1-n与双向n-1是完全相同的两种情形 双向1-n需要在1的一端可以访问n的一端,反之亦然. 域模型:从Order到Customer的多对一双向关联需要在Order类中定义一个Customer属性 ...

  2. SharePoint2010 自定义代码登录方法

    转:http://yysyb123.blog.163.com/blog/static/192050472011382421717/ SharePoint2010 自定义代码登录方法 (自定义Form验 ...

  3. log4net 将日志写入数据库

    asp.net利用log4net写入日志到SqlServer数据库,Log4net是一个开源的错误日志记录项目,易用性强,源自log4j,品质值得信赖. 下面就我的安装部署log4net到MS sql ...

  4. NGINX(四)配置解析

    前言 nginx配置解析是在初始化ngx_cycle_t数据结构时,首先解析core模块,然后core模块依次解析自己的子模块. 配置解析过程 nginx调用ngx_conf_parse函数进行配置文 ...

  5. poj2686-Traveling by Stagecoach(状压dp)

    题意: n张马票,m个城市,马票上有马数(决定速度),一张只能用一次,给出地图,求从城市a到b的最短时间. 分析:n值很小状态压缩 #include <map> #include < ...

  6. Leetcode OJ : Triangle 动态规划 python solution

    Total Accepted: 31557 Total Submissions: 116793     Given a triangle, find the minimum path sum from ...

  7. adb logcat调试中常用的命令介绍

    Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过 logcat 命 令来查看和使用. adb logcat 命令格式 : ad ...

  8. 【安全】requests和BeautifulSoup小试牛刀

    web安全的题,为了找key随手写的程序,无处安放,姑且贴上来. # -*- coding: UTF-8 -*- __author__ = 'weimw' import requests from B ...

  9. 怎么创建MongoDB数据库

    MongoDB didn’t provides any command to create “database“. Actually, you don’t need to create it manu ...

  10. POJ 3764 (异或+字典树)

    早就听过用字典树求异或最大值,然而没做过.发现一碰到异或的题就GG,而且因为以前做过的一道类似的题(事实上并不类似)限制了思路,蠢啊= =. 题意:一棵带权的树,求任意两点间路径异或的最大值. 题解: ...