Logical.java:
package
com.lnn.spel.logical;
public class Logical {
private boolean andExp;
private boolean orExp;
private boolean notExp;
private boolean notGen;
public boolean isAndExp() {
return andExp;
}
public void setAndExp(boolean andExp) {
this.andExp = andExp;
}
public boolean isOrExp() {
return orExp;
}
public void setOrExp(boolean orExp) {
this.orExp = orExp;
}
public boolean isNotExp() {
return notExp;
}
public void setNotExp(boolean notExp) {
this.notExp = notExp;
}
public boolean isNotGen() {
return notGen;
}
public void setNotGen(boolean notGen) {
this.notGen = notGen;
}
}
logical.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="logical"
class = "com.lnn.spel.logical.Logical">
<property name="andExp"
value="#{true and true}"/>
<property name="notExp"
value="#{not false}"/>
<property name="notGen"
value="#{!false}"/>
<property name="orExp"
value="#{true or false}"/>
</bean>
</beans>
package
com.lnn.spel.logical;
import
org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[]
args) {
ApplicationContext
context = new ClassPathXmlApplicationContext("logical.xml");
Logical
logical = context.getBean("logical", Logical.class);
System.out.println(logical.isAndExp());
System.out.println(logical.isNotExp());
System.out.println(logical.isNotGen());
System.out.println(logical.isOrExp());
}
}
No comments:
Post a Comment