Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean myParseBool(String s)
- {
- return s.equals("1");
- }
- public String myPrintBool(boolean b)
- {
- return b ? "1" : "0";
- }
- import javax.xml.bind.annotation.adapters.XmlAdapter;
- public class BooleanAdapter extends XmlAdapter<Integer, Boolean>
- {
- @Override
- public Boolean unmarshal( Integer s )
- {
- return s == null ? null : s == 1;
- }
- @Override
- public Integer marshal( Boolean c )
- {
- return c == null ? null : c ? 1 : 0;
- }
- }
- @XmlElement( name = "enabled" )
- @XmlJavaTypeAdapter( BooleanAdapter.class )
- public Boolean getEnabled()
- {
- return enabled;
- }
Add Comment
Please, Sign In to add comment