|
|
|
|
Re: generate Integer type from schema attribute [message #419209 is a reply to message #419206] |
Mon, 12 May 2008 23:11 |
Will Horn Messages: 265 Registered: July 2009 |
Senior Member |
|
|
Yeah, that is true. In my experience, though, for databinding purposes
it seems easier to deal with Objects and null than with isSetX. But I
am still getting the hang of databinding...
Ed Merks wrote:
> Will,
>
> Most people don't want to use wrapper types anyway. They take a lot
> more storage. The "Object" versions of the data types are provided
> purely to support nillable where it's obvious that the data is supposed
> to include an additional value representing nil which is different from
> just the absence of a value...
>
>
> Will Horn wrote:
>> Okay. It is not a big issue. There is also xs:integer which maps to
>> BigInteger if an object is really necessary.
>>
>> However, I am curious - there is no way to use the IntObject EDataType
>> unless you have an element with type xs:int and xs:nillable="true"?
>>
>> -Will
>>
>> Ed Merks wrote:
>>> Will,
>>>
>>> You'd really have to defineda new simple type and specify its
>>> ecore:instanceClassName to be java.lang.Integer. For primitive
>>> types, it seems better to make use the fact that the feature
>>> unsettable and isSetX == false can be used to detect if the feature
>>> is missing.
>>>
>>>
>>> Will Horn wrote:
>>>> From
>>>> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
>>>>
>>>> the only schema type that maps to Integer is xs:int with
>>>> nillable="true". This is only possible for elements since
>>>> attributes don't use the nillable property.
>>>>
>>>> I am wondering if there is a way to map an optional xs:int attribute
>>>> in xsd to an Integer in the Java code where a missing attribute in a
>>>> document would correspond to null. This would seem analogous to
>>>> how a missing optional xs:string attribute corresponds to a null
>>>> String object.
>>>>
>>>> I have a feeling it's possible, just haven't found the right trick ;o)
>>>>
>>>> -Will
|
|
|
Re: generate Integer type from schema attribute [message #419213 is a reply to message #419209] |
Tue, 13 May 2008 01:47 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Will,
Yes, the whole concept of unsettable along with isSet and unset does
tend to bend people's minds a bit... But if you need to deal with large
amounts of data, wrapper objects can be a bit of a space killer
Will Horn wrote:
> Yeah, that is true. In my experience, though, for databinding
> purposes it seems easier to deal with Objects and null than with
> isSetX. But I am still getting the hang of databinding...
>
> Ed Merks wrote:
>> Will,
>>
>> Most people don't want to use wrapper types anyway. They take a lot
>> more storage. The "Object" versions of the data types are provided
>> purely to support nillable where it's obvious that the data is
>> supposed to include an additional value representing nil which is
>> different from just the absence of a value...
>>
>>
>> Will Horn wrote:
>>> Okay. It is not a big issue. There is also xs:integer which maps
>>> to BigInteger if an object is really necessary.
>>>
>>> However, I am curious - there is no way to use the IntObject
>>> EDataType unless you have an element with type xs:int and
>>> xs:nillable="true"?
>>>
>>> -Will
>>>
>>> Ed Merks wrote:
>>>> Will,
>>>>
>>>> You'd really have to defineda new simple type and specify its
>>>> ecore:instanceClassName to be java.lang.Integer. For primitive
>>>> types, it seems better to make use the fact that the feature
>>>> unsettable and isSetX == false can be used to detect if the feature
>>>> is missing.
>>>>
>>>>
>>>> Will Horn wrote:
>>>>> From
>>>>> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
>>>>>
>>>>> the only schema type that maps to Integer is xs:int with
>>>>> nillable="true". This is only possible for elements since
>>>>> attributes don't use the nillable property.
>>>>>
>>>>> I am wondering if there is a way to map an optional xs:int
>>>>> attribute in xsd to an Integer in the Java code where a missing
>>>>> attribute in a document would correspond to null. This would
>>>>> seem analogous to how a missing optional xs:string attribute
>>>>> corresponds to a null String object.
>>>>>
>>>>> I have a feeling it's possible, just haven't found the right trick
>>>>> ;o)
>>>>>
>>>>> -Will
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.05255 seconds