承接上文

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


.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. nopcommerce商城系统--源代码结构和架构

    这个文档是让开发者了解nopcommerce解决方案结构的指南.这是新的nopcommerce开发者学习nopcommerce代码的相关文档.首先,nopCommerce源代码是很容易得到的.它是一个 ...

  2. Ext入门学习系列(四)面板控件

    第四章 使用面板 上节学习了Ext复杂对话框,更进一步了解了Ext的运行机制.本章重点来了解Ext所有控件的基础——面板控件. 一.Ext的面板是什么? 同样先来看看几个效果: 基本面板,点击右上角小 ...

  3. Go语言项目的错误和异常管理 via 达达

    Go语言项目的错误和异常管理 最近连续遇到朋友问我项目里错误和异常管理的事情,之前也多次跟团队强调过错误和异常管理的一些概念,所以趁今天有动力就赶紧写一篇Go语言项目错误和异常管理的经验分享. 首先我 ...

  4. ASCII编码:Linux&Windows

    我们的服务器为linux系统,日志中的字段通常会用不同分隔符来做分隔,在不同操作系统编码格式下查看也会有不同的体现,甚至会出现所谓的乱码.我在xshell5下常用的编码格式Unicode(UTF-8) ...

  5. <转>MySQL性能优化的最佳20+条经验

    http://coolshell.cn/articles/1846.html 今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心 ...

  6. 关于java环境配置的问题

    在以前刚开始接触Java环境配置问题的时候,配置了一大串的字符串,所有的路径全部在一个path变量里面,特别冗杂. 由于这两天重新再装了一个版本的JDK结果出现毛病了,就只有重新配置该环境变量,结果又 ...

  7. C: Answers to “The C programming language, Edition 2”

    <The C programming language> Edition 2的习题答案地址: http://users.powernet.co.uk/eton/kandr2/index.h ...

  8. HDU-4648 Magic Pen 6 简单题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4648 求遍前缀和,然后扫描标记下就可以了... //STATUS:C++_AC_453MS_1792K ...

  9. POJ1038 - Bugs Integrated, Inc.(状态压缩DP)

    题目大意 要求你在N*M大小的主板上嵌入2*3大小的芯片,不能够在损坏的格子放置,问最多能够嵌入多少块芯片? 题解 妈蛋,这道题折腾了好久,黑书上的讲解看了好几遍才稍微有点眉目(智商捉急),接着看了网 ...

  10. Swift对面向对象提供了良好的支持,下面介绍几个其独有的特性。

    Swift对面向对象提供了良好的支持,下面介绍几个其独有的特性. 懒加载属性 Swift在语言层面上提供了类中懒加载属性的支持,使用lazy作为关键字: class Renderer { lazy v ...