Setting data type of an object at run time

This is something of an advanced problem, so I hope there's
someone out there who can speak to this. I apologize for the length
of the post, I'm just trying to be clear about a rather unclear
conundrum. --
We all use arrays to hold collections of things. As you know,
an array is its self a type (Array) and so there is no way to
declare, for instance, an array of MovieClips or an array of
Strings. Heres what happens: lets pretend that we have 3 movie
clips clip1_mc, clip2_mc, and clip3_mc, and an Array called
anArray. so we can legally do this. anArray.push( clip1_mc );
anArray.push( clip2_mc ); anArray.push( clip3_mc );. An array of
size 3. Now the code: trace( typeof anArray[0] ); will output
"object." This can be a problem. If you try this: var
newClip:MovieClip = anArray[0]; you get a type mismatch from the
compiler. "Found Object where MovieClip is required." It
necessitates this: var newClip:MovieClip = MovieClip( anArray[0] );
Bummer no?
Ok. So fast forward. Lets assume a class List that uses an
array to hold the items in the list. So the class uses the Array
class in "composition." So you have methods like insert( ); and
retrieve(). Retriece() returns an item from an index in the array.
Because of the aforementioned problem, no matter what type the
thing was going into the list it comes out with type Object because
the retrieve function must return an item of some type, the only
option is to declare the return type of the retrieve() function as
Object. Lets say you know that this is a list of Strings. You could
write the retrieve()'s code like: return String( returnItem ); And
type the object "on the way out" .. but what if you want the list
to work with any type object, you would have to have a variable to
hold the desired type of objects in the list. And then as the
objects are being returned, you'd cast them to the type stored in
that variable. I guess that you'd pass the type to the constructor
of the List: var aList:List = new List( "AddressCard" ); -- That
should declare a List (Array) of AddressCards.
Is there a way to do this? have the type specified in casting
be dynamic?
And the flip-side of that is detecting the name of the class
of an object instance. The thing here would be to try to derive a
String from the name of the constructor function. (which is always
the class name) In actionscript 3 there is a service package--
mx.util -- I think, that has a function to return the qualified
class name of an object. But is there a jimmy rig for this in AS2?
My actual project does not use an Array to implement List. (
or Stack ) It uses a structure called a "linked list" - which is a
whole other topic, but same problem as with Arrays is also present
in the linked list versions and so requires the same solution. If
one is willing to type things explicitly when assigning an item in
the list to a variable of some type, this thing is quite excellent.
But I don't like it. I have the package with docs, code, sample
fla's, diagrams and everything that I would encourage people to
download, look at, try and whatever and then come back here with
any thoughts on it. There is a component with Flash professional
that is a list like structure, but it's so general that it crosses
the line into bloat. Ie: if you are using a list as a stack, you
only need getTop() and pop() and push() not all the other (12 or
so) methods in the class. Mine are patterned after structures from
the C++ standard template library. And the code style is C++, but I
think it's actually easier to read that way.
the files:
http://www.null.bz/ADL_Lib/ADT_Lib.zip
Thanks in advance, for your efforts! I really appreciate all
of it, helpful or not.

First reactions:
>>var newClip:MovieClip = MovieClip( anArray[0] );
Even though you must use a cast to prevent the compile time
error, you don't get an error on this line because the compiler
skips typechecking for values accessed with the [] operator.
>>Is there a way to do this? have the type specified in
casting be dynamic?
Nope. You must effectively type check all objects used
through array elements yourself.
Reading on...

Similar Messages

  • Findind Data type of a variable in Run Time

    Hi Experts,
        I am trying to find the data type of variable in runtime with "DESCRIBE FIELD" statement.
        but it always shows data type C by default. i have written this code.....
        DATA: w_value TYPE d.
        DESCRIBE FIELD p_value TYPE w_value.
       My requirement is that if  i pass a variable of any type(like date, time , char, Integer , Decimal etc.) from selection screen i  will   give the correct data type of variable.
    Please let me know how to acheive this problem.
    Regards,
    Shri

    Hey Raj,
    In this code it always ask a date type variable.
    Still my problem i snot getting solve.
    check the below one which might give u a fair idea
    DATA: Desc_object         TYPE ref to cl_abap_typedescr.
    Parameters:   p_char           TYPE char10 ,
                  p_date           TYPE d,
                  p_int            type i.
    Field-symbols : <any_type> type any.
    START-OF-SELECTION.
      If p_char is not initial.
         assign p_char to <any_type>.
      elseIf p_date is not initial.
         assign p_date to <any_type>.
      elseif p_int is not initial.
         assign p_int to <any_type>.
      endif.
    IF <any_type>  is assigned.
      desc_object = cl_abap_typedescr=>describe_by_data( <any_type> ).
      WRITE: / desc_object->absolute_name.
      WRITE: / desc_object->type_kind.
    ENDIF.
    The Catch lies in assigning the variables to field symbol. I think you already have that part of code
    Edited by: A J Raj on Dec 9, 2009 7:12 PM

  • Reference data types in interface objects?

    How do you create reference data type based on data type in interface object??

    First create the reference DT1 in IR then create a new data type DT2 and if you want to create a reference to DT1 then in  the editor select Type (3rd coloum) as the DT1 which you can get by double click on Type and then you select "search help" and select DT1 from the list.
    Cheer's

  • Help!!! create & destroy CORBA object at run time

    I am develop an program using CORBA (Java IDL and JDK 1.3 on Win 98 OS) that involved login-logout mechanism. Someone can login into my program, by access HTML file from the server machine that contained an applet, via browser (NN 6).
    (the client and server run on same machine)
    If somebody login, says Mr.X, and make mistakes by type an invalid password, my program still (can) work by opening a wrong account/record belong to other people who (login and) logout last time before Mr.X login. It is a wrong result.
    I know the reason why this could be happen, its all because Java IDL support the CORBA transient object type. This transient object has the same lifetime as the execution of the server process that creates it. And it cause a problem for me.
    According to the explanation above, i have some questions :
    1. How to create, access, and destroy (delete) any CORBA object on demand (at run time) without have to shut down the server (process), in order to release any data/record hold by the CORBA object ?
    2. If Java IDL cannot create and destroy a CORBA object on demand (at run time), how do I solve my problem above ?
    If Java IDL cannot delete any CORBA object at run time, can it just delete any value (refresh data) that the object hold so any new data can be add again ?
    3. if i run my program on 2 different machine, it result an error : COMM_FAILURE minor code 1398079490. How do I fix it ? any solution for this error ?
    i really need any help, this program is my final project
    i will appreciate any help and answers
    thanks in advance
    Marsel Hober

    I'm using the POA implementation in java 1.4, but the api docs
    aren't very helpful in terms of what all the various policy
    values really do. I've got a servant that gets created by a
    request on a different object, and needs to stay around until
    the client tells it to go away. All the material that I've found
    on how to use CORBA in Java is either pre-POA, or doesn't
    cover any kind of management policies like servant retention.
    Can someone tell me how to do this, or am I stuck trying to
    wade through the CORBA 2.3 spec and hoping that I can
    figure out how the stuff really works in Java?

  • Mapping with Scd operator set to type 2 reading source records two times

    Mapping with Scd operator set to type 2 reading source records two times.Records selected count being displayed at the end of execution is double the source record count.This possibly is affecting the performance of the mapping.
    Is this a bug in scd type 2 operagtor in OWB 11gR2.How to rectify this umwamted double loop through the source data selectiom?

    Hi Roelant,
    I think it is important to be aware that although Paris - 10gR2 - is not actually buggy (in this respect!), it is really quite idiosyncratic in exactly how it processes SCDs.
    I followed up on your and Mark's comments, and did an in depth analysis of this topic. It is at http://www.donnapkelly.pwp.blueyonder.co.uk/documents/OWB_10gR2_SCD.pdf
    My conclusions are perhaps of interest to anyone considering doing SCD processing with Paris.
    I'll be doing a follow-up this weekend, and publishing a sort of 'how-to-do-it' guide.
    Cheers,
    Donna
    Message was edited to add the words: "in this respect"

  • How to build sql query for view object at run time

    Hi,
    I have a LOV on my form that is created from a view object.
    View object is read-only and is created from a SQL query.
    SQL query consists of few input parameters and table joins.
    My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
    Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
    Thanks
    Srikanth Addanki

    As I understand you want to change the query at run time.
    If this is what you want, you can use setQuery Method then use executeQuery.
    http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_

  • How to get class name of a object in run time, from its accessible context.

    Hi,
    I need to get the class name of a java object in run-time, given the AccessibleContext of that object.
    I gone through the AccessibleContext api documentation. but there is not way to get the class name for a java object using its AccessibleContext object.
    Do any one have any idea how to get the class name of an java object, given its accessible object Accessible.
    Thanks
    Timberlake

    816311 wrote:
    Please try to provide a solution for my requirement and avoid evaluating a requirement.
    I am a curious guyit's great to be curious. however, in this situation, the requirement makes no sense in the given context. so, in an effort to be helpful, the people on this forum are asking you the reason behind the requirement. the reason we do this is because we have experience answering questions on this forum and, more often than not, requirements which don't make sense are the result of misunderstandings or confusion on the part of the person making the requirement. if we can figure out why you want to do what you want to do, we may be able to point you in a direction which makes more sense.

  • Swing objects loaded run time but i want validate those so how do i vadidat

    Swing objects loaded run time but i want validate those so how do i vadidate run objects

    Validate what? (Is this the same Chandra that just left TDA?)
    Message was edited by:
    bsampieri

  • JSP, Data Web Bean, BC4J: Setting the where clause of a View Object at run time

    Hi,
    I am trying to develop a data web bean in which the where clause of a View Object will be set at run time and the results of the query then displayed.
    My BC4J components are located in one project while the coding for the data web bean is in another project. I used the following code bu t it does not work. Could you please let me know what I am doing wrong?
    public void populateOSTable(int P_EmpId)
    String m_whereString = "EmpView.EMP_ID = " + P_EmpId;
    String m_OrderBy = "EmpView.EMP_NAME";
    oracle.jbo.ApplicationModule appModule = null;
    ViewObject vo = appModule.findApplicationModule("EMPBC.EMPAppModule").findViewObject("EMPBC.EMPView");
    vo.setWhereClause(m_whereString);
    vo.setOrderByClause(m_OrderBy);
    vo.executeQuery();
    vo.next();
    String empName numAttrs = vo.getAttribute(EmpName);
    System.out.println(empName);
    Thanks.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JDev Team (Laura):
    Here is how I have usually done mine:
    1. In the JSP, use a RowsetNavigator bean to set the where clause and execute the query.
    2. Use a custom web bean to process the results of the query (print to HTML).
    for example:
    <jsp:useBean class="oracle.jbo.html.databeans.RowsetNavigator" id="rsn" scope="request" >
    <%
    // get the parameter from the find form
    String p = request.getParameter("p");
    String s = request.getParameter("s");
    // store the information for reference later
    session.putValue("p", p);
    session.putValue("s", s);
    // initialize the app module and view object
    rsn.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    // set the where clause string
    String theclause = "presname = '" + p + "' AND slideno=" + s;
    // set the where clause for the VO
    rsn.getRowSet().getViewObject().setWhereClause(theclause);
    rsn.getRowSet().getViewObject().executeQuery();
    rsn.getRowSet().first();
    %>
    </jsp:useBean>
    <jsp:useBean class="wt_bc.walkthruBean" id="wtb" scope="request" >
    <%
    // initialize the app module and VO
    wtb.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    wtb.render();
    %>
    In this case, the render method of my custom web bean mostly gets some session variables, and prints various content depending on the session variable values.
    Hope this helps.
    </jsp:useBean><HR></BLOCKQUOTE>
    Laura can you give the code of your walkthru bean? i wna't to initialize a viewobject, set the where clause and give that viewobject back to initialize my navigatorbar.
    Nathalie
    null

  • BC4j-- unable to set date type attribute in a row

    when i m set a attribute which is of date type in row of a view.
    it is giving me error " cannot create object of date type"
    i'll apreciate the answer to this problem
    thanx

    <%
    SimpleDateFormat databaseFormat = new SimpleDateFormat();
    SimpleDateFormat viewFormat = new SimpleDateFormat();
    databaseFormat.applyPattern("yyyy-MM-dd");
    viewFormat.applyPattern("MM/dd/yyyy");
    // to convert &#8220;MM/dd/yyyy&#8221; to &#8220;yyyy-MM-dd&#8221; for updating database
    String date_view=&#8221;12/31/2001&#8221;;
    String date_db=new String(databaseFormat.format(viewFormat.parse
    (date_view)));
    ...setAttribute(column_name,date_db);
    %>

  • Set data type property

    Hi all.
    I'm on devsuite 10g.
    Is there a way to set the data type property of an item at runtime???
    Thanks all for the collaboration,
    Fabrizio

    You can't it's a design time only construct

  • Counting Data types inside compiled objects...

    Hi Gurus,
    My requirment is that for any user,we create 'n' no of Functions/Procs/Packages,etc.Now, all these objects will have data-types defined in them.Can i get an overall count of data-types used in a particular user...(going inside the code and checking the data types it has & the count like
    For User : Scott
    COUNT(*) DATA_TYPES
    10 NUMBER
    4521 VARCHAR2
    239 XMLTYPE..
    etc..
    Hope some one helps...

    Query and Count using the dictionary view ALL_ARGUMENTS

  • Basic Data Types as Class Objects

    Consider the following code using the java.lang.reflect.Method
    Class c = Class.forName("java.util.Date");
    // get all methods in Date
    Method[] c_classes = c.getMethods();
    // get the UTC method - UTC(int year, int month, int date, int hrs, int min, int sec)
    Method m = c_classes[0];
    // get the parameters (all int)
    Class[] p = m.getParameterTypes();
    This gives a Class array of basic data types (in this case int) - in debug the variable is of type "class" with value "0x16d9220:class(int)"
    How do you create a Class object of a basic data type from scratch? I've tried Class.forName("int") and get an exception.
    Cheers
    Gareth

    You could use the class literals.
    Class[] primitiveTypes = {
    boolean.class,
    byte.class,
    char.class,
    double.class,
    float.class,
    int.class,
    long.class,
    short.class,
    Cheers, that's exactly what I needed.
    Gareth

  • Data type of Souce Object Vs BW Object

    Hi All,
    Our Source system is Oracle system.We have a field 'delivered date' (Database type is 'DATE' and Type in DDIC is 'DATS').
    for example: 20.09.2005 08:17:15
    Our requirement is to display this data as it is in BW report on ODS.
    Shall go for BW infoObject with data type 'CHAR' ? does it lead to any issues while loading from oracle to BW as source data type is 'DATS' and BW Object  data type is 'CHAR'?
    Is necessary to maiantain same data types here?
    If dont go with data type 'CHAR', it is not possible to display date and time together.
    I have tested with flat file and it works fine.
    Thanks

    Hi,
    Thanks for your reply.Thats what i had thought of doing.we need not represent it as Date as its combination of date and time.This is the only way to get it i guess.(defining 'CHAR' infoObject and mapping to 'DATS' of source field ).
    Any other possibilities?
    Thanks

  • Mixing ESR Data type and XSD Objects

    Dear PI forum users,
    I have created some XSD containing complex types and thus "acting" as data types.
    I would like to use such a complex type defined in XSD in an ESR Data type object.
    But when I use the search help in the type column, i can only see other data types objects and not complex types defined in External definition objects.
    Do you know if what I want to do is possible and how ?
    Thanks a lot.
    Jean-Charles

    Hi,
    i can only see other data types objects and not complex types defined in External definition objects.
    This is because only datatypes are shown in the search help. It is not possible to reference an external definition in a data type.
    What you can do is:
    1.) Recreate the complex types found your external definition as a data type, and reference it in your main data type
    or
    2.) Encode the data types into your external definition (cleaner)
    Hope this helps,

Maybe you are looking for

  • Listen to Audio File in PDF with Reader 9.3.1

    I have a pdf with a mp3 file in it but can't play it I looked to see if the multimedia.api was on and it says it is any ideas?                                                                                                                            

  • How can I copy the kindle format books on my iPad to my Linux PC.?

    My iPad battery is dying/dead.  How can I copy the kindle format books on my iPad to my Linux PC?  Because i understand they'll be lost when i get Apple to 'fix' my battery.

  • How do I Validate a Successful Migration?

    What are the steps to follow to validate a successful migration in sharepoint.

  • Overcoming error message 150:30

    I have CS4 and recently needed to re-install Mac OS 10.10.2 and all applications. Now can not run CS4 and receive error message 150.30. Any suggestions? I do not have a superdrive so can not re-install CS4 form original disks.

  • MPE Utilization report vs In Session monitoring

    I have MPE 2.1.1.2. We have 25 voice ports and 20 Web ports. Today when I go look at the utilization report for voice it says 100% scheduled and 10% utilized. At the same time I look at the in session monitoring and count 15 ports in use for voice. I