Ⅲ.spring的点点滴滴--赋值
承接上文
对象的赋值(调用方式都一样不再阐述)
.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的
java和Csharp的共同点
其中我们在标签里面还可以用ref | idref标签或者属性来通过id | name引用其他的对象,
许多标签的属性可以当作一个独立的标签,如下<entry key="myKey"> <value>hello</value></entry>在java中必须要有set字段的方法,Csharp可以省略
- 下一篇:Ⅳspring的点点滴滴--方法和事件
- 上一篇:Ⅱ.spring的点点滴滴--对象
- 本文链接地址:Ⅲ.spring的点点滴滴--赋值
Ⅲ.spring的点点滴滴--赋值的更多相关文章
- Ⅳspring的点点滴滴--方法和事件
承接上文 方法和事件 .net篇(环境为vs2012+Spring.Core.dll v1.31) public abstract class MethodDemo { protected abstr ...
- Ⅱ.spring的点点滴滴--对象
承接上文 对象的各种实例化 .net篇(环境为vs2012+Spring.Core.dll) 修改原来的PersonDao对象为 public class PersonDao : IPersonDao ...
- Ⅶ.spring的点点滴滴--自定义对象行为
承接上文 自定义对象行为 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class lifeCycle : Spring.Objects.Factory. ...
- Ⅰ.Spring的点点滴滴--序章
spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架 .net篇(环境为vs2012+Spring.Core.dll) 新建一个控制台 using Spring.Context; ...
- XI.spring的点点滴滴--IObjectFactoryPostProcessor(工厂后处理器)
承接上文 IObjectFactoryPostProcessor(工厂后处理器)) 前提是实现接口的对象注册给当前容器 直接继承的对象调用这个postProcessBeanFactory方法,参数为工 ...
- Ⅹ.spring的点点滴滴--IObjectPostProcessor(对象后处理器)
承接上文 IObjectPostProcessor(对象后处理器) 前提是实现接口的对象注册给当前容器 C#: 通过继承AbstractObjectFactory对象的AddObjectPostPro ...
- Ⅸ.spring的点点滴滴--IObjectFactory与IFactoryObject的杂谈
承接上文 ObjectFactory与IFactoryObject的杂谈 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class parent { pu ...
- Ⅷ.spring的点点滴滴--抽象对象和子对象
承接上文 抽象对象和子对象 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class parent { public string Name { get; ...
- Ⅵ.spring的点点滴滴--自定义类型转换器
承接上文 自定义类型转换器 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class CustomeConverter : TypeConverter{ ...
随机推荐
- git提交小结
git有工作区和暂存区的概念,工作区就是可以看到文件目录的地方,暂存区则是提交代码的地方 第一步,进入文件工作目录,终端输入命令 $ dir1/dir2: 第二步,查看哪些文件已经修改,输入命令 $ ...
- 浅析WCF与WebService、WPF与Silverlight 区别
由于在<Windows服务调用Quartz.net 实现消息调度>中,涉及到ASP.NET Web Service //WebServiceSoapClient client = new ...
- ASCII编码:Linux&Windows
我们的服务器为linux系统,日志中的字段通常会用不同分隔符来做分隔,在不同操作系统编码格式下查看也会有不同的体现,甚至会出现所谓的乱码.我在xshell5下常用的编码格式Unicode(UTF-8) ...
- SELinux的故障排除一例
刚刚采用Puppet部署了dokuwiki,不过配置完成后报错: DokuWiki Setup Error The datadir ('pages') at /pages is not found, ...
- C++ 继承之虚继承与普通继承的内存分布
仅供互相学习,请勿喷,有观点欢迎指出~ class A { virtual void aa(){}; }; class B : public virtual A { ]; //加入一个变量是为了看清楚 ...
- HW7.2
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- 挑战树莓派:谁才是Geek最爱的开发板?
树莓派(Raspberry Pi)是一块跟信用卡差不多大小的开发板,它的初衷是以低廉的硬件和开源软件扶持一些落后地区的电脑科学教育.由于它在性能和价格方面有一个很好的平衡点,所以很多硬件玩家也想买一个 ...
- JS 计算日期天数差
function dayDiffer(startDate,endDate){ console.info((endDate.getTime - startDate.getTime())/(24*60*6 ...
- Android实例-处理隐藏输入法后不再显示问题(XE8+小米2)
结果: 1.可以处理再次显示问题,但缺点是每个控件都要处理一次,累.哪位大神有好的处理方法,请M我. 实例代码: unit Unit1; interface uses System.SysUtils, ...
- flashback data archive (转)
闪回数据归档(Flashback Data Archive) 在Oracle 11g当中,对闪回技术再次进行了扩展,提供了一个全新的flashback方式,称之为闪回数据归档,本节我们将对闪回数据归档 ...