1 43 44 package org.jfree.xml.factory.objects; 45 46 51 public class CharacterObjectDescription extends AbstractObjectDescription { 52 53 56 public CharacterObjectDescription() { 57 super(Character .class); 58 setParameterDefinition("value", String .class); 59 } 60 61 66 public Object createObject() { 67 final String o = (String ) getParameter("value"); 68 if (o == null) { 69 return null; 70 } 71 if (o.length() > 0) { 72 return new Character (o.charAt(0)); 73 } 74 else { 75 return null; 76 } 77 } 78 79 86 public void setParameterFromObject(final Object o) throws ObjectFactoryException { 87 if (!(o instanceof Character )) { 88 throw new ObjectFactoryException("The given object is no java.lang.Character."); 89 } 90 91 setParameter("value", String.valueOf(o)); 92 } 93 94 101 public boolean equals(final Object o) { 102 if (this == o) { 103 return true; 104 } 105 if (!(o instanceof AbstractObjectDescription)) { 106 return false; 107 } 108 109 final AbstractObjectDescription abstractObjectDescription = (AbstractObjectDescription) o; 110 111 if (Character.TYPE.equals(abstractObjectDescription.getObjectClass())) { 112 return true; 113 } 114 if (Character .class.equals(abstractObjectDescription.getObjectClass())) { 115 return true; 116 } 117 return false; 118 } 119 120 125 public int hashCode() { 126 return getObjectClass().hashCode(); 127 } 128 129 } 130 | Popular Tags |