Home » Modeling » EMF » AnySimpleType
|
Re: AnySimpleType [message #426774 is a reply to message #426767] |
Tue, 20 January 2009 11:32 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
David,
Comments below.
David Michonneau wrote:
> Hi,
>
> Is it possible to use AnySimpleType without having a model generated from an
> xsd, but from an .ecore file?
>
Yes.
> I'd like to have an EMap of String, SimpleAnyType,
Notice that you've changed the wording here from AnySimpleType to
SimpleAnyType? They're two different things and you'll get exactly
which one you choose. AnySimpleType is an EDataType and given that it
supports a value of any type, it's instance type name is
java.lang.Object, so what you see below should be expected.
SimpleAnyType is an EClass that's used to wrap a value of any type along
with an indication of what type of value is being wrapped. If that's
what you want, you'll need "value" to be an EReference of type
SimpleAnyType.
> but the generation
> removes any trace of SimpleAnyType in the generated code:
>
> ecore:
> EStringToEAnyTypeMapEntry
> -key: String
> -value:AnySimpleType
>
> MyModel
> ref(0..*) props: EStringToEAnyTypeMapEntry
>
> generates
>
> MyModel
> ..
> EMap<String,Object> getProps();
>
> Thanks,
>
> David
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: AnySimpleType [message #426776 is a reply to message #426774] |
Tue, 20 January 2009 11:55 |
David Michonneau Messages: 85 Registered: July 2009 |
Member |
|
|
So what is the difference between AnySimpleType and Object? Do I get
automatic serialization for AnySimpleType? But for what types of objects
exactly? In other words what feature do I get with AnySimpleType, that I
can't get with Object?
Regarding the SimpleAnyType one, is there some examples that show how to set
/get a String or a Date into/from it? I am not sure to understand the
AnyType class it extends, and the rawValue method. Is setting the
instanceType mandatory, or is it automatically done when I set a value?
Last question: do I need to set any extendedmetadata option for
serialization? Or is this only needed if my model was in an xsd?
Thanks,
David
"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:gl4cnl$43f$1@build.eclipse.org...
> David,
>
> Comments below.
>
> David Michonneau wrote:
>> Hi,
>>
>> Is it possible to use AnySimpleType without having a model generated from
>> an xsd, but from an .ecore file?
>>
> Yes.
>> I'd like to have an EMap of String, SimpleAnyType,
> Notice that you've changed the wording here from AnySimpleType to
> SimpleAnyType? They're two different things and you'll get exactly which
> one you choose. AnySimpleType is an EDataType and given that it supports
> a value of any type, it's instance type name is java.lang.Object, so what
> you see below should be expected. SimpleAnyType is an EClass that's used
> to wrap a value of any type along with an indication of what type of value
> is being wrapped. If that's what you want, you'll need "value" to be an
> EReference of type SimpleAnyType.
>> but the generation removes any trace of SimpleAnyType in the generated
>> code:
>>
>> ecore:
>> EStringToEAnyTypeMapEntry
>> -key: String
>> -value:AnySimpleType
>>
>> MyModel
>> ref(0..*) props: EStringToEAnyTypeMapEntry
>>
>> generates
>>
>> MyModel
>> ..
>> EMap<String,Object> getProps();
>>
>> Thanks,
>>
>> David
>>
>>
|
|
|
Re: AnySimpleType [message #426780 is a reply to message #426776] |
Tue, 20 January 2009 12:08 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------060308020508040803000704
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
David,
Comments below.
David Michonneau wrote:
> So what is the difference between AnySimpleType and Object?
AnySimpleType is an EDataType and an EDataType is always a wrapper for
some Java type. Can you think of any other Java type that allows any value?
> Do I get
> automatic serialization for AnySimpleType?
Yes, but not one that you'll like very much. It basically calls
toString on the value, and when you read it back it, it will just be a
String.
> But for what types of objects
> exactly? In other words what feature do I get with AnySimpleType, that I
> can't get with Object?
>
Nothing. At least EJavaObject using java.io.Serializeable to produce a
serializaton. Although it's not human readable, it does preserve the
type of the object.
> Regarding the SimpleAnyType one, is there some examples that show how to set
> /get a String or a Date into/from it? I am not sure to understand the
> AnyType class it extends, and the rawValue method. Is setting the
> instanceType mandatory, or is it automatically done when I set a value?
>
Yes, you *must *set the instance type and that determines how the value
is converted to and from the raw (string) value. When serialized, the
instance type is written out as an xsi:type referring to the EDataType
and thereby preserves the type information.
> Last question: do I need to set any extendedmetadata option for
> serialization?
I think so yes. Otherwise I don't think the xsi:type referring to a
non-EClass is supported.
> Or is this only needed if my model was in an xsd?
>
I think it's needed to support this schema-centric types of behaviors...
> Thanks,
>
> David
>
> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
> news:gl4cnl$43f$1@build.eclipse.org...
>
>> David,
>>
>> Comments below.
>>
>> David Michonneau wrote:
>>
>>> Hi,
>>>
>>> Is it possible to use AnySimpleType without having a model generated from
>>> an xsd, but from an .ecore file?
>>>
>>>
>> Yes.
>>
>>> I'd like to have an EMap of String, SimpleAnyType,
>>>
>> Notice that you've changed the wording here from AnySimpleType to
>> SimpleAnyType? They're two different things and you'll get exactly which
>> one you choose. AnySimpleType is an EDataType and given that it supports
>> a value of any type, it's instance type name is java.lang.Object, so what
>> you see below should be expected. SimpleAnyType is an EClass that's used
>> to wrap a value of any type along with an indication of what type of value
>> is being wrapped. If that's what you want, you'll need "value" to be an
>> EReference of type SimpleAnyType.
>>
>>> but the generation removes any trace of SimpleAnyType in the generated
>>> code:
>>>
>>> ecore:
>>> EStringToEAnyTypeMapEntry
>>> -key: String
>>> -value:AnySimpleType
>>>
>>> MyModel
>>> ref(0..*) props: EStringToEAnyTypeMapEntry
>>>
>>> generates
>>>
>>> MyModel
>>> ..
>>> EMap<String,Object> getProps();
>>>
>>> Thanks,
>>>
>>> David
>>>
>>>
>>>
>
>
>
--------------060308020508040803000704
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
David,<br>
<br>
Comments below.<br>
<br>
David Michonneau wrote:
<blockquote cite="mid:gl4e38$eir$1@build.eclipse.org" type="cite">
<pre wrap="">So what is the difference between AnySimpleType and Object?</pre>
</blockquote>
AnySimpleType is an EDataType and an EDataType is always a wrapper for
some Java type. Can you think of any other Java type that allows any
value?<br>
<blockquote cite="mid:gl4e38$eir$1@build.eclipse.org" type="cite">
<pre wrap=""> Do I get
automatic serialization for AnySimpleType? </pre>
</blockquote>
Yes, but not one that you'll like very much. It basically calls
toString on the value, and when you read it back it, it will just be a
String.<br>
<blockquote cite="mid:gl4e38$eir$1@build.eclipse.org" type="cite">
<pre wrap="">But for what types of objects
exactly? In other words what feature do I get with AnySimpleType, that I
can't get with Object?
</pre>
</blockquote>
Nothing. At least EJavaObject using java.io.Serializeable to produce a
serializaton. Although it's not human readable, it does preserve the
type of the object.<br>
<blockquote cite="mid:gl4e38$eir$1@build.eclipse.org" type="cite">
<pre wrap="">
Regarding the SimpleAnyType one, is there some examples that show how to set
/get a String or a Date into/from it? I am not sure to understand the
AnyType class it extends, and the rawValue method. Is setting the
instanceType mandatory, or is it automatically done when I set a value?
</pre>
</blockquote>
Yes, you <b>must </b>set the instance type and that determines how
the value is converted to and from the raw (string) value. When
serialized, the instance type is written out as an xsi:type referring
to the EDataType and thereby preserves the type information.<br>
<blockquote cite="mid:gl4e38$eir$1@build.eclipse.org" type="cite">
<pre wrap="">
Last question: do I need to set any extendedmetadata option for
serialization?</pre>
</blockquote>
I think so yes. Otherwise I don't think the xsi:type referring to a
non-EClass is supported.<br>
<blockquote cite="mid:gl4e38$eir$1@build.eclipse.org" type="cite">
<pre wrap=""> Or is this only needed if my model was in an xsd?
</pre>
</blockquote>
I think it's needed to support this schema-centric types of behaviors...<br>
<blockquote cite="mid:gl4e38$eir$1@build.eclipse.org" type="cite">
<pre wrap="">
Thanks,
David
"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:Ed.Merks@gmail.com"><Ed.Merks@gmail.com></a> wrote in message
<a class="moz-txt-link-freetext" href="news:gl4cnl$43f$1@build.eclipse.org">news:gl4cnl$43f$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,
Comments below.
David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
Is it possible to use AnySimpleType without having a model generated from
an xsd, but from an .ecore file?
</pre>
</blockquote>
<pre wrap="">Yes.
</pre>
<blockquote type="cite">
<pre wrap="">I'd like to have an EMap of String, SimpleAnyType,
</pre>
</blockquote>
<pre wrap="">Notice that you've changed the wording here from AnySimpleType to
SimpleAnyType? They're two different things and you'll get exactly which
one you choose. AnySimpleType is an EDataType and given that it supports
a value of any type, it's instance type name is java.lang.Object, so what
you see below should be expected. SimpleAnyType is an EClass that's used
to wrap a value of any type along with an indication of what type of value
is being wrapped. If that's what you want, you'll need "value" to be an
EReference of type SimpleAnyType.
</pre>
<blockquote type="cite">
<pre wrap=""> but the generation removes any trace of SimpleAnyType in the generated
code:
ecore:
EStringToEAnyTypeMapEntry
-key: String
-value:AnySimpleType
MyModel
ref(0..*) props: EStringToEAnyTypeMapEntry
generates
MyModel
...
EMap<String,Object> getProps();
Thanks,
David
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>
--------------060308020508040803000704--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Fri Apr 26 14:06:36 GMT 2024
Powered by FUDForum. Page generated in 0.03673 seconds
|