org.springframework.beans.propertyeditors.PropertiesEditorの使い方

1.IntegerEditorクラス
import org.springframework.beans.propertyeditors.PropertiesEditor;
public class IntegerEditor extends PropertiesEditor {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (text == null || text.equals(“")) {
text = “0";
}
setValue(Integer.parseInt(text));
}

@Override
public String getAsText() {
return getValue().toString();
}
}

2.FloatEditorクラス
import org.springframework.beans.propertyeditors.PropertiesEditor;

public class FloatEditor extends PropertiesEditor {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (text == null || text.equals(“")) {
text = “0";
}
setValue(Float.parseFloat(text));
}

@Override
public String getAsText() {
return getValue().toString();
}
}

3.LongEditorクラス
import org.springframework.beans.propertyeditors.PropertiesEditor;
public class LongEditor extends PropertiesEditor {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (text == null || text.equals(“")) {
text = “0";
}
setValue(Long.parseLong(text));
}

@Override
public String getAsText() {
return getValue().toString();
}
}

Java

Posted by arkgame