Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » SimpleAnyType
SimpleAnyType [message #48988] Fri, 18 January 2008 19:38 Go to next message
Philipp Kutter is currently offline Philipp KutterFriend
Messages: 306
Registered: July 2009
Senior Member
Hi.
Ed Merks told me to use

SimpleAnyType

to wrap any value, independent whether it is an object or a data type.

Does OCL support the treatment of instances of SimpleAnyType in a
convenient way?

This would be huge!

Best, Philipp

-------- Original Message --------
Subject: Re: Wrapper for arbitrary values or objects
Date: Fri, 18 Jan 2008 10:35:22 -0500
From: Ed Merks <merks@ca.ibm.com>
Organization: EclipseCorner
Newsgroups: eclipse.tools.emf
References: <fmqgel$rv9$1@build.eclipse.org>

Phillip,

An instance of SimpleAnyType is an EObject and can have its
setInstanceType be called to reference any EDataType and then setValue
or setRawValue can be used to set an instance of that type or a literal
representation of an instance of that type so in that way it acts as a
wrapper. This is what's created when a serialized instance uses
xsi:type="..." where "..." refers to an EDataType rather than an EClass...


Philipp W. Kutter wrote:
> Hi.
> Has anyone an idea what is the most elegant solution for a
> wrapper for values of some EDataYype, and objects of some EClass?
>
> We need to define an EStructuralFeature which can point both to any
> EObject, or any of EInt, EBoolean, EString, e.t.c.
>
> Creating a class
>
> Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
> EInt*, ...)
>
> is obvious, but then the OCL expressions over this get very ugly.
>
> Best, Philipp
Re: SimpleAnyType [message #49021 is a reply to message #48988] Fri, 18 January 2008 20:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Philipp,

The SimpleAnyType has a demand-created EClass, if I'm not mistaken, right?
With demand-created features corresponding to the elements and attributes
found in the XML?

In that case, OCL's usual introspection mechanism will find the metadata
that it needs to figure out what you're trying to tell it.

Of course, I haven't actually tried this ... why don't you?

Cheers,

Christian


Philipp W. Kutter wrote:

> Hi.
> Ed Merks told me to use
>
> SimpleAnyType
>
> to wrap any value, independent whether it is an object or a data type.
>
> Does OCL support the treatment of instances of SimpleAnyType in a
> convenient way?
>
> This would be huge!
>
> Best, Philipp
>
> -------- Original Message --------
> Subject: Re: Wrapper for arbitrary values or objects
> Date: Fri, 18 Jan 2008 10:35:22 -0500
> From: Ed Merks <merks@ca.ibm.com>
> Organization: EclipseCorner
> Newsgroups: eclipse.tools.emf
> References: <fmqgel$rv9$1@build.eclipse.org>
>
> Phillip,
>
> An instance of SimpleAnyType is an EObject and can have its
> setInstanceType be called to reference any EDataType and then setValue
> or setRawValue can be used to set an instance of that type or a literal
> representation of an instance of that type so in that way it acts as a
> wrapper. This is what's created when a serialized instance uses
> xsi:type="..." where "..." refers to an EDataType rather than an EClass...
>
>
> Philipp W. Kutter wrote:
> > Hi.
> > Has anyone an idea what is the most elegant solution for a
> > wrapper for values of some EDataYype, and objects of some EClass?
> >
> > We need to define an EStructuralFeature which can point both to any
> > EObject, or any of EInt, EBoolean, EString, e.t.c.
> >
> > Creating a class
> >
> > Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
> > EInt*, ...)
> >
> > is obvious, but then the OCL expressions over this get very ugly.
> >
> > Best, Philipp
Re: SimpleAnyType [message #49050 is a reply to message #49021] Fri, 18 January 2008 21:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------070204060005080907020609
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Christian,

It's like this. You'd create an instance and then you can set it's
instance type to any EDataType. After that you can set the raw value
which must be a literal of the data type or the value which must be an
instance of the data type. In all cases the value is recorded in the
mixed text feature of the parent AnyType. No demand created metadata
need be involved. I suppose the only tricky thing is that the value
returned by getValue must be an instance of the type returned by
getInstanceType. I'm not sure what type of specialized support, if any,
this would need.

package org.eclipse.emf.ecore.xml.type;


import org.eclipse.emf.ecore.EDataType;


/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Simple Any
Type</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue <em>Raw
Value</em>}</li>
* <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
<em>Value</em>}</li>
* <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
<em>Instance Type</em>}</li>
* </ul>
* </p>
*
* @see org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe()
* @model extendedMetaData="name='simpleAnyType' kind='simple'"
* @generated
*/
public interface SimpleAnyType extends AnyType
{
/**
* Returns the value of the '<em><b>Raw Value</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Raw Value</em>' attribute.
* @see #setRawValue(String)
* @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_RawValue()
* @model dataType="org.eclipse.emf.ecore.xml.type.String"
transient="true" volatile="true" derived="true"
* extendedMetaData="name=':3' kind='simple'"
* @generated
*/
String getRawValue();

/**
* Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue <em>Raw
Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Raw Value</em>' attribute.
* @see #getRawValue()
* @generated
*/
void setRawValue(String value);

/**
* Returns the value of the '<em><b>Value</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Value</em>' attribute.
* @see #setValue(Object)
* @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_Value()
* @model dataType="org.eclipse.emf.ecore.xml.type.AnySimpleType"
transient="true" volatile="true" derived="true"
* extendedMetaData="name=':4' kind='simple'"
* @generated
*/
Object getValue();

/**
* Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
<em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Value</em>' attribute.
* @see #getValue()
* @generated
*/
void setValue(Object value);

/**
* Returns the value of the '<em><b>Instance Type</b></em>' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Instance Type</em>' reference.
* @see #setInstanceType(EDataType)
* @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_InstanceType()
* @model resolveProxies="false" required="true"
* extendedMetaData="name=':5' kind='simple'"
* @generated
*/
EDataType getInstanceType();

/**
* Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
<em>Instance Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Instance Type</em>'
reference.
* @see #getInstanceType()
* @generated
*/
void setInstanceType(EDataType value);

} // SimpleAnyType


Christian W. Damus wrote:
> Hi, Philipp,
>
> The SimpleAnyType has a demand-created EClass, if I'm not mistaken, right?
> With demand-created features corresponding to the elements and attributes
> found in the XML?
>
> In that case, OCL's usual introspection mechanism will find the metadata
> that it needs to figure out what you're trying to tell it.
>
> Of course, I haven't actually tried this ... why don't you?
>
> Cheers,
>
> Christian
>
>
> Philipp W. Kutter wrote:
>
>
>> Hi.
>> Ed Merks told me to use
>>
>> SimpleAnyType
>>
>> to wrap any value, independent whether it is an object or a data type.
>>
>> Does OCL support the treatment of instances of SimpleAnyType in a
>> convenient way?
>>
>> This would be huge!
>>
>> Best, Philipp
>>
>> -------- Original Message --------
>> Subject: Re: Wrapper for arbitrary values or objects
>> Date: Fri, 18 Jan 2008 10:35:22 -0500
>> From: Ed Merks <merks@ca.ibm.com>
>> Organization: EclipseCorner
>> Newsgroups: eclipse.tools.emf
>> References: <fmqgel$rv9$1@build.eclipse.org>
>>
>> Phillip,
>>
>> An instance of SimpleAnyType is an EObject and can have its
>> setInstanceType be called to reference any EDataType and then setValue
>> or setRawValue can be used to set an instance of that type or a literal
>> representation of an instance of that type so in that way it acts as a
>> wrapper. This is what's created when a serialized instance uses
>> xsi:type="..." where "..." refers to an EDataType rather than an EClass...
>>
>>
>> Philipp W. Kutter wrote:
>> > Hi.
>> > Has anyone an idea what is the most elegant solution for a
>> > wrapper for values of some EDataYype, and objects of some EClass?
>> >
>> > We need to define an EStructuralFeature which can point both to any
>> > EObject, or any of EInt, EBoolean, EString, e.t.c.
>> >
>> > Creating a class
>> >
>> > Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
>> > EInt*, ...)
>> >
>> > is obvious, but then the OCL expressions over this get very ugly.
>> >
>> > Best, Philipp
>>
>
>


--------------070204060005080907020609
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">
Christian,<br>
<br>
It's like this.&nbsp; You'd create an instance and then you can set it's
instance type to any EDataType.&nbsp; After that you can set the raw value
which must be a literal of the data type or the value which must be an
instance of the data type.&nbsp; In all cases the value is recorded in the
mixed text feature of the parent AnyType.&nbsp; No demand created metadata
need be involved. I suppose the only tricky thing is that the value
returned by getValue must be an instance of the type returned by
getInstanceType.&nbsp; I'm not sure what type of specialized support, if
any, this would need.<small><br>
</small>
<blockquote><small>package org.eclipse.emf.ecore.xml.type;</small><br>
<br>
<br>
<small>import org.eclipse.emf.ecore.EDataType;</small><br>
<br>
<br>
<small>/**</small><br>
<small>&nbsp;* &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;* A representation of the model object
'&lt;em&gt;&lt;b&gt;Simple Any Type&lt;/b&gt;&lt;/em&gt;'.</small><br>
<small>&nbsp;* &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;*</small><br>
<small>&nbsp;* &lt;p&gt;</small><br>
<small>&nbsp;* The following features are supported:</small><br>
<small>&nbsp;* &lt;ul&gt;</small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue &lt;em&gt;Raw
Value&lt;/em&gt;}&lt;/li&gt;</small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
&lt;em&gt;Value&lt;/em&gt;}&lt;/li&g t; </small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
&lt;em&gt;Instance Type&lt;/em&gt;}&lt;/li&gt;</small><br>
<small>&nbsp;* &lt;/ul&gt;</small><br>
<small>&nbsp;* &lt;/p&gt;</small><br>
<small>&nbsp;*</small><br>
<small>&nbsp;* @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe() </small><br>
<small>&nbsp;* @model extendedMetaData="name='simpleAnyType' kind='simple'"</small><br>
<small>&nbsp;* @generated</small><br>
<small>&nbsp;*/</small><br>
<small>public interface SimpleAnyType extends AnyType</small><br>
<small>{</small><br>
<small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Returns the value of the '&lt;em&gt;&lt;b&gt;Raw
Value&lt;/b&gt;&lt;/em&gt;' attribute.</small><br>
<small>&nbsp;&nbsp; * &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * @return the value of the '&lt;em&gt;Raw Value&lt;/em&gt;'
attribute.</small><br>
<small>&nbsp;&nbsp; * @see #setRawValue(String)</small><br>
<small>&nbsp;&nbsp; * @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_RawValue() </small><br>
<small>&nbsp;&nbsp; * @model dataType="org.eclipse.emf.ecore.xml.type.String"
transient="true" volatile="true" derived="true"</small><br>
<small>&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp; extendedMetaData="name=':3' kind='simple'"</small><br>
<small>&nbsp;&nbsp; * @generated</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; String getRawValue();</small><br>
<br>
<small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue &lt;em&gt;Raw
Value&lt;/em&gt;}' attribute.</small><br>
<small>&nbsp;&nbsp; * &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * @param value the new value of the '&lt;em&gt;Raw
Value&lt;/em&gt;' attribute.</small><br>
<small>&nbsp;&nbsp; * @see #getRawValue()</small><br>
<small>&nbsp;&nbsp; * @generated</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; void setRawValue(String value);</small><br>
<br>
<small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Returns the value of the
'&lt;em&gt;&lt;b&gt;Value&lt;/b&gt;& amp;lt;/em&gt;' attribute.</small><br>
<small>&nbsp;&nbsp; * &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * @return the value of the '&lt;em&gt;Value&lt;/em&gt;'
attribute.</small><br>
<small>&nbsp;&nbsp; * @see #setValue(Object)</small><br>
<small>&nbsp;&nbsp; * @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_Value() </small><br>
<small>&nbsp;&nbsp; * @model
dataType="org.eclipse.emf.ecore.xml.type.AnySimpleType"
transient="true" volatile="true" derived="true"</small><br>
<small>&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp; extendedMetaData="name=':4' kind='simple'"</small><br>
<small>&nbsp;&nbsp; * @generated</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; Object getValue();</small><br>
<br>
<small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
&lt;em&gt;Value&lt;/em&gt;}' attribute.</small><br>
<small>&nbsp;&nbsp; * &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * @param value the new value of the
'&lt;em&gt;Value&lt;/em&gt;' attribute.</small><br>
<small>&nbsp;&nbsp; * @see #getValue()</small><br>
<small>&nbsp;&nbsp; * @generated</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; void setValue(Object value);</small><br>
<br>
<small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Returns the value of the '&lt;em&gt;&lt;b&gt;Instance
Type&lt;/b&gt;&lt;/em&gt;' reference.</small><br>
<small>&nbsp;&nbsp; * &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * @return the value of the '&lt;em&gt;Instance
Type&lt;/em&gt;' reference.</small><br>
<small>&nbsp;&nbsp; * @see #setInstanceType(EDataType)</small><br>
<small>&nbsp;&nbsp; * @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_InstanceType() </small><br>
<small>&nbsp;&nbsp; * @model resolveProxies="false" required="true"</small><br>
<small>&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp; extendedMetaData="name=':5' kind='simple'"</small><br>
<small>&nbsp;&nbsp; * @generated</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; EDataType getInstanceType();</small><br>
<br>
<small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
&lt;em&gt;Instance Type&lt;/em&gt;}' reference.</small><br>
<small>&nbsp;&nbsp; * &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * @param value the new value of the '&lt;em&gt;Instance
Type&lt;/em&gt;' reference.</small><br>
<small>&nbsp;&nbsp; * @see #getInstanceType()</small><br>
<small>&nbsp;&nbsp; * @generated</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; void setInstanceType(EDataType value);</small><br>
<br>
<small>} // SimpleAnyType</small><br>
</blockquote>
<br>
Christian W. Damus wrote:
<blockquote cite="mid:fmr217$a7n$1@build.eclipse.org" type="cite">
<pre wrap="">Hi, Philipp,

The SimpleAnyType has a demand-created EClass, if I'm not mistaken, right?
With demand-created features corresponding to the elements and attributes
found in the XML?

In that case, OCL's usual introspection mechanism will find the metadata
that it needs to figure out what you're trying to tell it.

Of course, I haven't actually tried this ... why don't you?

Cheers,

Christian


Philipp W. Kutter wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Hi.
Ed Merks told me to use

SimpleAnyType

to wrap any value, independent whether it is an object or a data type.

Does OCL support the treatment of instances of SimpleAnyType in a
convenient way?

This would be huge!

Best, Philipp

-------- Original Message --------
Subject: Re: Wrapper for arbitrary values or objects
Date: Fri, 18 Jan 2008 10:35:22 -0500
From: Ed Merks <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a>
Organization: EclipseCorner
Newsgroups: eclipse.tools.emf
References: <a class="moz-txt-link-rfc2396E" href="mailto:fmqgel$rv9$1@build.eclipse.org">&lt;fmqgel$rv9$1@build.eclipse.org&gt;</a>

Phillip,

An instance of SimpleAnyType is an EObject and can have its
setInstanceType be called to reference any EDataType and then setValue
or setRawValue can be used to set an instance of that type or a literal
representation of an instance of that type so in that way it acts as a
wrapper. This is what's created when a serialized instance uses
xsi:type="..." where "..." refers to an EDataType rather than an EClass...


Philipp W. Kutter wrote:
&gt; Hi.
&gt; Has anyone an idea what is the most elegant solution for a
&gt; wrapper for values of some EDataYype, and objects of some EClass?
&gt;
&gt; We need to define an EStructuralFeature which can point both to any
&gt; EObject, or any of EInt, EBoolean, EString, e.t.c.
&gt;
&gt; Creating a class
&gt;
&gt; Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
&gt; EInt*, ...)
&gt;
&gt; is obvious, but then the OCL expressions over this get very ugly.
&gt;
&gt; Best, Philipp
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>

--------------070204060005080907020609--
Re: SimpleAnyType [message #49082 is a reply to message #49050] Fri, 18 January 2008 22:13 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Ed,

Ah! I see. I wasn't quite grokking the significance of the "Simple" part
of the name. Naturally, a SimpleAnyType wouldn't have structure.

All of this feels to me like an XSD-ism, not a modeling concept. I wouldn't
expect this to have any meaning in OCL. The closest equivalent in OCL
would be declaring a property of type OclAny. The value can be anything at
all, except a collection. Unless, of course, the property has
multiplicity, in which case the value is a collection of anything at all,
except a collection.

:-)

I would expect that the SimpleAnyType is already interepreted by MDT OCL as
OclAny, because this is the default type for anything that we don't
understand (don't have a type mapping for). This makes sense to me, but
probably doesn't help Philipp.

Cheers,

Christian


Ed Merks wrote:

> Christian,
>
> It's like this. You'd create an instance and then you can set it's
> instance type to any EDataType. After that you can set the raw value
> which must be a literal of the data type or the value which must be an
> instance of the data type. In all cases the value is recorded in the
> mixed text feature of the parent AnyType. No demand created metadata
> need be involved. I suppose the only tricky thing is that the value
> returned by getValue must be an instance of the type returned by
> getInstanceType. I'm not sure what type of specialized support, if any,
> this would need.

-----8<-----
Previous Topic:[Announce] MDT OCL 1.2.0 I200801162020 is available
Next Topic:Cardinality constraint for non-navigable associations ?
Goto Forum:
  


Current Time: Wed Apr 24 16:38:43 GMT 2024

Powered by FUDForum. Page generated in 0.04919 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top