जेएक्सबी ट्रेट्स खाली int एक्सएमएल एट्रिब्यूट 0 के रूप में खाली है, जो मेरे साथ ठीक है, लेकिन मुझे इसे शून्य के रूप में स्टोर करने की आवश्यकता है। ऐसा लगता है कि मैं कस्टम कॉन्फ़िगरेशन में DataConverterImpl क्लास को नहीं बदल सकता। क्या किया जा सकता है अगर बिल्कुल?जेएक्सबी ट्रेट्स इंटेल एक्सएमएल एट्रिब्यूट 0
@XmlAttribute(name = "Count")
protected Integer passengerCount;
एक्सएमएल के दौरान
parseInt()
सूर्य (Oracle) जो कोड के नीचे है से DataConverterImpl.class
से कहा जाता है को पार्स, अपने नेवे जा रहा:
<xs:attribute name="Count" type="Integer0to999" use="optional">
<xs:simpleType name="Integer0to999">
<xs:annotation>
<xs:documentation xml:lang="en">Used for Integer values, from 0 to 999 inclusive</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="999"/>
</xs:restriction>
</xs:simpleType>
xjc स्कीमा संकलन के बाद मैं निम्नलिखित के साथ वर्ग मिला इस कोड से शून्य प्राप्त करने के लिए:
public static int _parseInt(CharSequence s) {
int len = s.length();
int sign = 1;
int r = 0;
for(int i=0; i<len; i++) {
char ch = s.charAt(i);
if(WhiteSpaceProcessor.isWhiteSpace(ch)) {
// skip whitespace
} else
if('0'<=ch && ch<='9') {
r = r*10 + (ch-'0');
} else
if(ch=='-') {
sign = -1;
} else
if(ch=='+') {
; // noop
} else
throw new NumberFormatException("Not a number: "+s);
}
return r*sign;
}