ConversionTestAction.java
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.conversion;
import org.apache.struts2.action.Action;
import org.apache.struts2.conversion.annotations.Conversion;
import org.apache.struts2.conversion.annotations.ConversionRule;
import org.apache.struts2.conversion.annotations.ConversionType;
import org.apache.struts2.conversion.annotations.TypeConversion;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
/**
* <code>ConversionTestAction</code>
*
* @author Rainer Hermanns
* @version $Id$
*/
@Conversion()
public class ConversionTestAction implements Action {
private String convertInt;
private String convertDouble;
private List users = null;
private HashMap keyValues = null;
public String getConvertInt() {
return convertInt;
}
@TypeConversion(type = ConversionType.APPLICATION)
public void setConvertInt( String convertInt ) {
this.convertInt = convertInt;
}
public String getConvertDouble() {
return convertDouble;
}
@TypeConversion(converter = "org.apache.struts2.util.XWorkBasicConverter")
public void setConvertDouble( String convertDouble ) {
this.convertDouble = convertDouble;
}
public List getUsers() {
return users;
}
@TypeConversion(rule = ConversionRule.COLLECTION, converterClass = String.class)
public void setUsers( List users ) {
this.users = users;
}
public HashMap getKeyValues() {
return keyValues;
}
@TypeConversion(rule = ConversionRule.MAP, converterClass = BigInteger.class)
public void setKeyValues( HashMap keyValues ) {
this.keyValues = keyValues;
}
/**
* Where the logic of the action is executed.
*
* @return a string representing the logical result of the execution.
* See constants in this interface for a list of standard result values.
* @throws Exception thrown if a system level exception occurs.
* Application level exceptions should be handled by returning
* an error value, such as Action.ERROR.
*/
@TypeConversion(type = ConversionType.APPLICATION, key = "java.util.Date")
public String execute() throws Exception {
return SUCCESS;
}
}