Ⅲ.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{ ...
随机推荐
- Spring配置bean的详细知识
在Spring中配置bean的一些细节.具体信息请参考下面的代码及注释 applicationContext.xml文件 <?xml version="1.0" encodi ...
- HDU 5622 KK's Chemical DP
题意:bc round 71(中文题面) 分析(官方题解): 根据药品之间的相互关系,我们可以构建一张图,我们对相互会发生反应的药品连边 这个图的特征,是一个环加上一些“树”(可能有多个联通块) 一个 ...
- 一个HR给应届毕业生的面试建议 后悔看到的太晚了 (转)
开始之前务必记住: 黄金法则:80/20---你要承担起80%的谈话而面试官只会说20%. 白金法则:你必须试着控制面试的节奏和话题. 钻石法则:对于没有把握的问题,抛回给面试 ...
- [原]Java面试题-将字符串中数字提取出来排序后输出
[Title][原]Java面试题-将字符串中数字提取出来排序后输出 [Date]2013-09-15 [Abstract]很简单的面试题,要求现场在纸上写出来. [Keywords]面试.Java. ...
- Nullable问题
在代码中经常遇到int? 其实int?是Nullable<int>的简写方式. int到int?转化 int? i=null; int j=0; i=j; int?到int转化 ; int ...
- dataStructure@ Check whether a given graph is Bipartite or not
Check whether a given graph is Bipartite or not A Bipartite Graph is a graph whose vertices can be d ...
- HDU3966-Aragorn's Story(树链剖分)
第一道树链剖分. 早就想学..一直懒.. 感觉还是比较简单的. 主要是要套其他数据结构,线段树大概还好,平衡树之类的肯定就跪了. http://blog.csdn.net/acdreamers/art ...
- (转)java读取数据库表信息,子段
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sq ...
- Xcode8 创建NSManageObject subclass方法
更新iOS8之后发现coredata也做了一些改变,创建本地的时候一脸懵逼,最后发现: 喜极而泣不能自已,(-.-!)
- hbase运维
NoSQL现在风生水起,hbase的使用也越来越广,但目前几乎所有的NoSQL产品在运维上都没法和DB相提并论,在这篇blog中来总结下我们在运维hbase时的一些问题以及解决的方法,也希望得到更多h ...