Using a string variable to create an object

Hi, I just have a quick question. It is probably very simple but I can not seem to find an asnwer anywhere.
I have a class called Receive, from this class I derrive 12 difference other classes.
I also have a hashtable with a bunch of Object objects. At run time I get one of these objects according to some hastable key. So once I have this object I need to cast it to the right type (one of the above mentioned 12).
So I know I can find out which type this object is by doing this: object.getClass()
This returns a Class object. I then need to somehow use this class object to perform the cast. I tried everything and it doesnt seem to work. Then I thought well I can get the string name of the class : object.getClass().getName()
So I'm wandering if there is a way to use this string to cast my object. Or maybe there is another way.
I did see the cast() method in the Class api but I can't figure out the point of it since is returns an Object class object and not my class's object.

I took your advice and re factored the Receive class so it had all the functionality I needed except two methods which would then be overridden in the derived classes. What I had a hard time understanding is once an object of class say SpecialReceive extends Receive it can be referred to as Receive yet still maintain that it's a SpecialReceive.
What I mean is if I give a Receive object to some method and this method has no idea that this object is actually SpecialReceive and it calls a method say run() which gets overridden by the SpecialReceive. I thought that since this method has no idea what type of Receive this object is it will execute Receive's run(). But it actually does know what type of class it is and it executes the right run() method (the one that SpecialReceive overrides).
After I realized this there is no more need for casting.
Thanks everyone for your contributions.

Similar Messages

  • Convert String variable value  to an Object referece type

    Hi all,
    I want to know that if there any possible way to convert String variable value to a Object reference type in java. I'll explain by example if this is not clear.
    Let's think that there is a string variable name like,
    String name="HelloWorld";
    and there is a class name same to the variable value.
    class HelloWorld
    I am passing this string variable value to a method which is going to make a object of helloworld;
    new convertobj().convert("HelloWorld");
    class convertobj{
    public void convert(String name){
    // in hert it is going to create the object of HelloWorld;
    // HelloWorld hello=new HelloWorld(); just like this.
    now i want to do this from the name variable value.( name na=new name()) like wise.
    please let me know if there any possible way to do that.
    I am just passing the name of class by string variable then i wanted to make a instance of the class which come through the variable value.
    thanx.

    Either cast the object to a HelloWorld or use the reflection API (Google it) - with the reflection API you can discover what methods are available.
    Note: if you are planning to pass in various string arguments and instantiate a class which you expect to have a certain method... you should define an interface and have all of your classes that you will call in this way implement the interface (that way you're sure the class has a method of that name). You can then just cast the object to the interface type and call the method.
    John

  • Using PHP Data Services to create an object and accessing that objects data in an unbound way in AS

    Hello,
    I've been able to use the php data services and bind the results of a function to a component. However I am having a hard time figuring out the syntax to use the data services to create an object out of the results, and then use that object as an array of filenames to provide the current index of the filename to a new sound object.
    My problem is obviously in not being able to figure out the specific syntax, I have declared the service and and object of the services returned type and in the creationComplete() function I have assigned object.token = service.getData();
    I've tried various ways of then pulling that data out of the object, with no success.
    Can someone point me in the right direction?
    This code probably looks horrible because it doesn't work yet.
    - Joel
                import flash.media.Sound;
                import flash.media.SoundChannel;
                import mx.controls.Alert;
                var playing:Sound = new Sound();
                var channel:SoundChannel = new SoundChannel();
                var sndIndex:int=0;
                var skpTr:String;
                public function init():void{
                 mp3Array.token = mp3service.getData();
                 currentTrack(mp3Array.lastResult.filename); 
                     trace(mp3Array.lastResult.filename[sndIndex]);
                public function currentTrack(t:String):void{
                    playing = new Sound();
                    playing.load(new URLRequest("mp3/" +t));
                public function skip():void{
                    stop();
                    if (sndIndex != mp3Array.lastResult.length-1){
                        sndIndex++;
                        var skipTr:String=mp3Array.lastResult.filename[sndIndex].data;
                        currentTrack(skipTr);
                        play();
                    } else {
                        sndIndex=0;
                        skipTr=mp3Array.lastResult.filename[sndIndex].data;
                        currentTrack(skipTr);
                        play();
                public function stop():void{
                    channel.stop();
                public function play():void{
                    channel = playing.play();
        <fx:Declarations>
            <s:CallResponder id="mp3Array"/>
            <mp3services:Mp3Service id="mp3service" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>

    Hello Joel;
    In retrieving your data - what is your php returning to FB, an object, object array, an array?  Either way, I have a brief example below that an object(s) is being returned.  Pull the data from the lastResult in a ResultEvent.  The object instantiated in the resultEvent will contain your data and you can do what you want from there. 
    Also, I always use Network Monitor to see what data (if any) is being returned from the server, you can also see how it is being sent back.
    John
    private function init():void
         mp3Array.token = mp3service.getData();
         mp3Array.addEventListener(FaultEvent.FAULT, faultHandler);
         mp3Array.addEventListener(ResultEvent.RESULT, mp3Array_resultHandler);
    protected function faultHandler(event:FaultEvent):void
         Alert.show("There was a fault error!" + event.message, "Fault Error", Alert.OK);
    protected function mp3Array_resultHandler(event:ResultEvent):void
         // Not sure if your service is sending back an object or an array or ?
        var info:Object = mp3Array.lastResult;
         doSomeFunction(info)
    protected function doSomeFunction(data:Object):void
         trace(info.filename);

  • Using a string source to create a filestream

    is there any way 2 use a string source to create a filestream.
    eg string s= " JAVA ";
    now i want a filestream containg this string s.

    You could save the string to a file and then open it. However, that seems a stupid thing to need to do. Why do you need a FileStream rather than an InputStream?

  • Create object name using a String variable

    Hi,
    I�m making a jsp page and I need to add several objects to a vector. The vector's name is arrayGrupo, and the object is Grupo. The problem is that when I create the instance of the object, I cant �give him different names, so the add in the Vector will always be of the same object instance. Is there anyway to create an object name using a variable?
    Something like this:
    <% if (request.getParameter("grupoNome") != null ) {
                                       nomeG=request.getParameter("grupoNome");
                                       descG=request.getParameter("grupoDesc");
                                       int nG=arrayGrupo.getTamanho(); //size of the array
                                       String xpto=String.valueOf(nG);
                                       Grupo "xpto"= new Grupo(); //here is the problem
                                       xpto.setNomeGrupo(nomeG);
                                       xpto.setDescricao(descG);
                                       xpto.setIdgrupo(arrayGrupo.getTamanho()+1);
                                       arrayGrupo.addGrupo(xpto);
    }%>
    Thanks
    Rui Gon�alves

    I want to show a list of objects that are stored in a vector. But I also want to add objects to that vector. If I just want to add one object, I can use this code:
    <% if (request.getParameter("grupoNome") != null ) {
                                       nomeG=request.getParameter("grupoNome");
                                       descG=request.getParameter("grupoDesc");
                                       Grupo newGrupo = new Grupo(nomeG,descG,arrayGrupo.getTamanho()+1);
                                       arrayGrupo.addGrupo(newGrupo);
    %>
    What should I do if I want to add more than one object to the vector?
    I don�t know if I made myself clear but is quite hard to explain my problem.
    Thanks

  • Using a variable while creating an object

    I have 8 buttons called b0 to b8
    Button b0 = new Button (frame, 10, 10, 50, 50,"",'0');
    Button b1 = new Button (frame, 70, 10, 50, 50,"",'1');
    Button b2 = new Button (frame, 130, 10, 50, 50,"",'2');
    Button b3 = new Button (frame, 10, 70, 50, 50,"",'3');
    Button b4 = new Button (frame, 70, 70, 50, 50,"",'4');
    Button b5 = new Button (frame, 130, 70, 50, 50,"",'5');
    Button b6 = new Button (frame, 10, 130, 50, 50,"",'6');
    Button b7 = new Button (frame, 70, 130, 50, 50,"",'7');
    Button b8 = new Button (frame, 130, 130, 50, 50,"",'8');Rather then create them seperately a for loop would make more sense I think. Something like
    for (int i = 0; i < 9; i++) {
                    int x = (i % 3) * 60 + 10;
                    int y = (i / 3) * 60 + 10;
                    Button "b"+i = new Button (frame, x, y, 50, 50,"",i);
                }But I cant make this work, what am I doing wrong.
    Thanks

    Variable names don't mean much in Java. Certainly you can't do operations on them like
        Button "b"+iBut your buttons do form a sort of group or unit - they are geometrically related for one thing. What you need to do is create an object that represents this group.
    Try using an array.
    Declare an array of 9 buttons. Then you can use a for loop much like you have. But instead of talking about "b"+i, you would talk about b.
    Anything you were doing before with b2 you can still do - by referring to that Button as b[2].

  • Setting Prompt Directory path using a string variable?

    So when you define a Prompt you get the form P[promptname.wav] and all is good.  What we want to do is have that prompt name be retrieved from a prompt directory which is defined by a string.   So assume all your prompts have the same numbers like 1001.wav but the actual file is customized based on things like Sales/1001.wav and Marketing/1001.wav   and you want to have a StringValue DirectoryName set the Directory to Sales or Marketing.   The Script does not seem to support setting P["DirectoryName"/1001.wav] where Directory Name is a string variable.    Is there a solution to this other than changing the entire prompt to a string type and dropping the P[] data type entirely?   

    I am working with a similar issue.   It is simple enought to set the Prompt Directory but when it is a variable it seems to have different results.  The attached simple script is used to demonstrate Sam's recommendation.  The XML document is embedded in the script variable, so you dont need to create it.   So the script reaches into the XML document and pulls up the variable strDirectoryName and then adds "/" to it and then sets the strPromptDirectory.   I have done it three ways:  Hard coded, string value for prompt' and prompt data type resolved from string.  As you single step through the script you will find that all values populate appropriately, but only the hard coded play prompt actually plays the prompt.  The other two assemblies fail.  (Clearly it assumes the prompt 10001.wav is in the directory Generic/ if you want to try it).    Written in  Version 8.5 editor.  

  • Using a concastinated variable to indentify an object

    Hi,
    what I'm trying to do is loop through 81 jTextFields and disable them using concastinated variable names. I don't even know if this is possible.
    To clarify : I have 9 jPanes, (named Pane1 to Pane9). Each jPane has 9 jTextFields, (named a11 -> a19, a21 ->a29 ...... a91->a99).
    The code below is where I've got to and am having the problem. The compiler is not recognising TotalName as an object name for a jTextField
    public void TurnOffCells ()
            PaneNumber = 1;
            CellNumber = 1;
            while (PaneNumber<10)
                while (CellNumber<10)
                    PaneName = "Pane"+PaneNumber;
                    CellName = "a"+PaneNumber+CellNumber;
                    TotalName = PaneName+"."+CellName;
                    TotalName.setEnabled(false);
                    CellNumber++;
                PaneNumber++;
        }Please ignore my lack of convention correctness :)

    EoinM wrote:
    Hi,
    what I'm trying to do is loop through 81 jTextFields and disable them using concastinated variable names. I don't even know if this is possible.Concastinated?
    The code below is where I've got to and am having the problem. The compiler is not recognising TotalName as an object name for a jTextFieldThat's because you can't do it that way. Why don't you just put them all in a List and iterate over it?
    public void TurnOffCells ()
    PaneNumber = 1;
    CellNumber = 1;
    while (PaneNumber<10)
    while (CellNumber<10)
    PaneName = "Pane"+PaneNumber;
    CellName = "a"+PaneNumber+CellNumber;
    TotalName = PaneName+"."+CellName;
    TotalName.setEnabled(false);
    CellNumber++;
    PaneNumber++;
    }That code doesn't show what Object any of those variables are instances of. Are they Strings?
    Please ignore my lack of convention correctness :)No. That coupled with your lack of initialization statements makes it impossible to determine what you're trying to do with your code.
    Long story short, use a List (or a Map).

  • Newbie needs help with passing variables or creating flash object based on parameters

    Hello Community,
    I'm an amateur developer of Ms Access databases. In one of my applications I want to visualize the options available when reaching a certain score.
    What I'd like to get from this trial period, is a flash animation of a dartboard. Depending on an array of variables that provides the fill color (or reference thereof) the layers of the flash object will be dynamicly created, altered, or switched. The dartboard itself remains "static". I'm hoping to use 9 colors.
    I can manipulate the array any way needed. I can provide XML coding to pass the array variables. I'm just too new and untrained to incorporate this in a Edge animation or Dreamweaver.
    There is no need for interaction, once the object is created (ie no user feedback).
    Can someone point me in the right direction?
    thanks in advance,
    Jay from Stockholm

    Hi,
    I see you're using System.Data.OracleClient (which has been deprecated by MS) rather than Oracle.DataAccess.Client, but this works for me with Oracle's ODP, maybe it will help.
    Cheers,
    Greg
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    public class dataadapterfill
        public static void Main()
            using(OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl"))
                con.Open();
                using(OracleCommand cmd = new OracleCommand("select ename from emp where ename = :1", con))
                    cmd.Parameters.Add(new OracleParameter("myename", OracleDbType.Varchar2, 50)).Value = "KING";
                    OracleDataAdapter da = new OracleDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    foreach (DataRow row in ds.Tables[0].Rows)
                        Console.WriteLine("ename: {0}", row["ename"]);
    }

  • Using a string variable as a query SQL statement

    I want to construct a custom SQL statement in a string var, then use that var in the cfquery statement.  What is the proper syntax?  Here is my feeble attempt:
      <cffunction ...>
      <cfset var sql_txt="">
            <cfquery name="qSBJs" datasource="cfBAA_odbc">
                "#sql_txt#"
            </cfquery>
        <cfreturn qSBJs>
    I've tried using no " or # or just # or just " but nothing works.
    what about:
            <cfquery name="qSBJs" datasource="cfBAA_odbc" sql="#sql_txt#">
            </cfquery>
    nope.  I wish there was a sql property I could fill *before* the execution of the query.  Any suggestions?

    Hi Adam, and/or anyone who may have a few minutes to check this... I got the following code to work.  It calls the getSBJs function from Flash Builder 4.  I get the correct result set back.  Long table names are replaced with short abreviations.  Note that some local vars are declared but not used in the following example. I will use them in the future versions of this same code.  Since I will in the future, like a donkey, mindlessly use this same method for all my queries, it would be much appreciated if I could get a guru to check this code for:
    -Pure idiocy
    -Mild insanity
    -SQL injection vulnerability
    -Memory leakage
    -Scope dangers
    (ignore emoticons, see the underlying text)
        <cffunction name="AbrvTblNms" output="false" returntype="string" >
            <cfargument name="txt" type="string" required="true" />
            <cfset var qAbrvs="">
            <cfset var output_str="#ARGUMENTS.txt#">
            <cfquery name="qAbrvs" datasource="cfBAA_odbc" result="rsltAbrvs">
                SELECT TBL_NM, ABRV FROM BAA_TBL_ABRV ORDER BY 1
            </cfquery>
        <cfloop query="qAbrvs">
                <cfset output_str = Replace(output_str, '[' & qAbrvs.TBL_NM & ']', qAbrvs.ABRV, "ALL")>
        </cfloop>
            <cfreturn output_str>
        </cffunction>
        <!--- Fetch a list photo subjects whose records contain the given search word(s) --->
        <cffunction name="getSBJs" output="false" access="remote" returntype="any" >
            <cfargument name="srch_val" type="string" required="true" />
            <cfset var qSBJs="">
            <cfset var sql_txt="">
            <cfset var whr=""> 
            <cfset var b=False>
            <cfset var in_txt="">
            <cfset var fm_dt="">
            <cfset var to_dt="">
            <cfset var on_dt="">
            <cfset var pht="">
            <cfset var srch_str="">
            <cfset var srch_trm="">
            <!--- Transfer the srch_val to a local variable for further manipulation --->
            <cfset srch_str = "#ARGUMENTS.srch_val#">
            <!---
                An empty search term argument is handled by the BAA FlashBuilder front end.  We test for it again here,
                and substitute a dummy value, in case this function is called by something other than the intended
                FlashBuilder front end, and that front end doesn't protect us from an empty search term argument.
                Remember that we must still "hand back" a valid query structure to avoid causing a data type error
                in the calling function, so we search for a dummy value that will allow the query to proceed but is
                guaranteed to return an empty result set.  If the srch_val argument is not empty, transfer the value of
                the srch_str local variable to the srch_trm local variable.
            --->
            <cfif Not (Len(srch_str))>
                <cfset srch_str = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX">
            </cfif>
            <cfset srch_trm = "#srch_str#">
            <cfset sql_txt =
                "SELECT DISTINCT
                  [BAA_SBJ].SRC_SYS_NM, [BAA_SBJ].SRC_SYS_GUID, [BAA_SBJ].OBJ_GUID, [BAA_SBJ].SBJ_NM, [BAA_SBJ].SBJ_DOB, [BAA_SBJ].SBJ_ID, [BAA_SBJ].NOTE, [BAA_SBJ].CDT, [BAA_SBJ].CTM, [BAA_SBJ].CBY, [BAA_SBJ].MDT, [BAA_SBJ].MTM, [BAA_SBJ].MBY
                FROM
                  BAA_SBJ [BAA_SBJ]
                  LEFT JOIN BAA_SES [BAA_SES] ON [BAA_SES].PAR_GUID = [BAA_SBJ].OBJ_GUID
                  LEFT JOIN BAA_IMG [BAA_IMG] ON [BAA_IMG].PAR_GUID = [BAA_SES].OBJ_GUID
                WHERE [WHERE_CLAUSE] ORDER BY [BAA_SBJ].SBJ_NM">
            <cfset whr = "([BAA_SBJ].SBJ_NM CONTAINING TRIM( rm_srch_trm1 ) OR " &
                    "[BAA_SBJ].NOTE CONTAINING TRIM(:prm_srch_trm2 ) OR " &
                    "[BAA_SBJ].SBJ_DOB CONTAINING TRIM(:prm_srch_trm3 ) OR " &
                    "[BAA_SES].SES_TYP CONTAINING TRIM(:prm_srch_trm4 ) OR " &
                    "[BAA_SES].NOTE CONTAINING TRIM(:prm_srch_trm5 ) OR " &
                    "[BAA_IMG].NOTE CONTAINING TRIM(:prm_srch_trm6 ))">
            <cfset sql_txt = Replace(sql_txt,"[WHERE_CLAUSE]", "#whr#", "ALL")>
            <cfset sql_txt = AbrvTblNms(sql_txt)>
        <!--- Through experimentation, I learned that each occurance of a param must be uniquely named.
                  It would be very handy, if the param value was applied to *all* occurances of the param.
                        That way, I could get away with using one .addParam line instead of 6 --->
            <cfscript>
            queryService = new query();
            queryService.setDatasource("cfBAA_odbc");
            queryService.setName("qSBJs");
            queryService.setAttributes(sql="#sql_txt#");
            queryService.addParam(name="prm_srch_trm1", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm2", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm3", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm4", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm5", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm6", value="#srch_trm#", cfsqltype="VARCHAR");
            result = queryService.execute();
            qSBJs = result.getResult();
            </cfscript>       
            <!--- <cfquery name="qSBJs" datasource="cfBAA_odbc">
            </cffunction>
            </cfquery> --->
            <cfreturn qSBJs>
        </cffunction>
    THANKS TO ADAM AND DAN FOR HELPIMG ME GET THIS FAR!  Now, don't let me embarass you by doing something dum and giving you "credit", if you see me doing something dum above.  Thanks!

  • Setting SharePoint 2010 Form Fields Using Query String Variables

    Hi All,
    I have a requirement to populate sharepoint form field value with query string while uploading document to document library.
    While uploading the document to document library, I want to populate claim number available from query string in a pop up page i.e in my case EditForm.aspx, Located at
    http://servername:port/sitename/documentlibraryname/forms/EditForm.aspx.
    Additional Information:
    Created document library and added custom columns like claim number etc..
    Created a view to filter uploaded documents as per claim number.
    Server Details:
    Windows Server 2008 R2
    SharePoint 2010
    SQL Server 2008 R2
    I have written javascript for the same, but not sure where exactly to add the code in EditForm.aspx page.
    Any help on this would be greatly appreciated.
    Thanking you in advacne.
    Regards
    Seva

    if the NewForm.aspx contain a "New Item Form" or "Edit Item Form" you can populate the form field by doing the following:
    First for the data view create a parameter from query string and give it the claim_number query string name.
    now for the field Claim Number Convert it to normal ASP.NET TextBox example below for this
    Normal Field will be like this
    <SharePoint:formfield runat="server" id="ff5{$Pos}" ControlMode="Edit" FieldName="ClaimNumber" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff5',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ClaimNumber')}" />
    you will change it to
    <asp:TextBox runat="server" id="ff5{$Pos}" __designer:bind="{ddwrt:DataBind('i',concat('ff5',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ClaimNumber')}" />
    Now in the asp:TextBox you can add the "Text" Attribute and assign the created data view parameter to it example below
    <asp:TextBox runat="server" id="ff5{$Pos}" Text="{$Claim_Number}" __designer:bind="{ddwrt:DataBind('i',concat('ff5',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ClaimNumber')}" />
    Where {$Claim_Number} is your Query String Parameter.
    Now if you send the query string NewForm.aspx?Claim_Number=1232
    you should see the field populated
    This what I do usually to populate the fields
    How I Bought a Brand New $1.2 Million Home Using ONLY Affiliate Commissions
    I'm having the same problem.... allmost
    I have a querystring I wan't to parse into a form. But on editform, not newform. then the field gets populated, but on save, nothing happens.... It's just blank.... any ideas.?
    /Ulrich

  • Use String Variable in New Object Creation

    Thanks to those who review and respond. I am new to Java, so please be patient with my terminoloy mistakes and fumblings. I am reading in a file and I want to create a new object based on specific field (car for example). As you will notice I grab field 8 here label sIID.
    String sIID = dts.group(8);
    BTW this regex grouping works fine. The problem is seen when I try to use the sIID variable in my new object creation process.
    DateParse sIID = new DateParse();
    My IDE is reporting "Variable sIID is already defined in the scope"
    Is this possible? The assumption is that the sIID will have different value during the processing of the file. For example, car could mean truck, sedan, etc with operators like color, number of doors, mileage, top speed, etc.

    Thanks for the reply. I have include similar and much shorter code for the sake of brevity.
    My problems are centered around the x variable/object below. Ideally this would translate to three objects PersonA, PersonB, etc that I could reference later in the code as PersonA.newname if I wanted to. Hopefully this makes sense.
    public class TestingObjects {
      public static void main(String[] argv) {
           String [] names;
           names = new String[3];
           names[0] = "PersonA";
           names[1] = "PersonB";
           names[2] = "PersonC";
           for (String x:names) {
             PN x = new PN();  // <- Problem
             x.name = x;
             x.SayName();
            System.out.println(x.newname);
    public class PN {
           String name;
           String newname;
      public String SayName() {
           newname = "Name = " + name;
           System.out.println(name);
          return newname;
    }

  • No mapping at the fault address error while accessing the string variable

    Hi
    we have a application which runs fine on AIX and HP but is throwing error on SOLARIS.
    the application runs well (and use of string variables are also working fine ) till it hits Zone.cpp file
    where the string variable is not getting initialized and throws no mapping at the fault address
    the code snippet is as follows
    #include <string>
    #include <vector>
    const string ZONE_ATTR_TYPE_ZN("ZN");
    const string ZONE_ATTR_TYPE_FC("FC");
    const string ZONE_ATTR_TYPE_ST("ST");
    void Zone::AddAttributeValueAndCountryCode(const string &attributeValue,
                                                      Int attribSeq,
                                                      const string &countryCode,
                                                      ZoneSearchLocMap& zoneSearchLocMap)
         string key = "";
         if ((_attributeType == ZONE_ATTR_TYPE_FC) ||
              (_attributeType == ZONE_ATTR_TYPE_CT))
              key = _attributeType+DELIM+attributeValue;
    we are running it on
    CC: Sun C++ 5.9 SunOS_sparc Patch 124863-04 2008/04/16
    compiled with these option
    -g0 -xspace -KPIC -D_XPG5 -m32 -xarch=sparcvis -mt -DNCURSES -DEXC_HANDLING -DRW_NO_BOOL
    and the created the execuatble with these option
    -i -z rescan -g0 -xspace -mt -D_XPG5 -m32 -xarch=sparcvis -mt -DNCURSES -DEXC_HANDLING -DRW_NO_BOOL -lpthread -lsocket -lnsl -ldl -lposix4 -lCrun -lCstd -lc -lm -lnsl -lsocket
    the dbx output
    t@1 (l@1) program terminated by signal SEGV (no mapping at the fault address)
    where -h
    Current function is Zone::AddAttributeValueAndCountryCode
    56 if ((_attributeType == ZONE_ATTR_TYPE_FC) ||
    (dbx) where -h
    current thread: t@1
    =>[1] Zone::AddAttributeValueAndCountryCode(this = 0x194c088, attributeValue = CLASS, attribSeq = 1, countryCode = CLASS, zoneSearchLocMap = CLASS), line 56 in "Zone.cpp"
    [2] ZoneLoader::Load(trans = CLASS, zoneList = CLASS, prZoneList = CLASS, zoneSearchLocMap = STRUCT, planningCompany = 0x1890f20), line 90 in "ZoneLoader.cpp"
    [3] ZoneManager::ZoneManager(this = 0x1933e28, shipperId = 1000, consDBConnection = CLASS), line 24 in "ZoneManager.cpp"

    I see you are compiling with -KPIC. Is the code going into a shared library?
    Run "ldd" on all the C++ shared libraries you create, and on the main program. You should see a dependency on /usr/lib/libCrun.so.1 and /usr/lib/libCstd.so.1, and no dependency on any other libCrun or libCstd.
    Do you have a particular reason for using -D_XPG5? Changing the Unix version presented by the system headers in /usr/include can sometimes create incompatibilities with the C++ headers and runtime libraries that are intended for the default Unix version.
    Are all of the object files created with the same options, especially the -mt option?
    If none of the above considerations raise any red flags, you might have run into a bug in the compiler or the C++ runtime libraries, or you might have a bug in your code that by accident does not show up in other environments.
    There is no way to evaluate whether you have a compiler or runtime library bug without a test case that demonstrates the problem.
    You might have heap or other data corruption in your program due to invalid pointer use, use of an uninitialized variable, reading or writing outside the bounds of an object, double deletion of an object, use of an object after it has been deleted. You might also have an MT programming error where a critical region is not properly guarded, or where a shared variable is not declared volatile.
    By accident, data can be read or written incorrectly, or a data-race condition can exist, but without causing program failure. A program containing these errors can appear to run successfully on one platform and fail on another, or on the same platform under other conditions.
    Running the program under dbx with Run-Time Checking enabled will show many of these errors.
    The Thread Analyzer can find data race conditions.
    If you think you have found a problem with the compiler or libraries, please file a bug report at
    [http://bugs.sun.com]
    with a test case that can be compiled and run to show the problem.

  • Function that returns N values, without using a string

    Hi, how can i make a function that returns several valures (that hasn't a exact number of returned values, it could return 3 values, or 7) without using a string?
    When i need to return several values from a function, i put the values inside a varchar like thus 'XXX,YYY,ZZZ' and so on. Don't know if this has a poor performance.
    If you can supply simple examples for what im asking, i would be nice.
    (without using a string)

    Can i create the type objects inside a package? If i
    can, they will be local to the package, right?Yes, you're right.
    Pipeline returns a row or several?You can use pipelined function in the same way you use table:
    SELECT * FROM TABLE(pipelined_funct(agr1, agr2));
    It returns results as separate rows.

  • Can I Execute a function whose name is stored in a string variable?

    Can I execute a function whose name is stored in a string variable?
    Like
    Depending on the condition I will stroed the name of the function in a string variable. Then using that string variable i want to execute the function.
    String str=��
    iVal an int can take ne value
    Switch(iVal)
    Case 1:
    str=�test1()�;
    Case 2:
    str=�test2()�;
    I want whatever function name is in str to be executed.
    ----------------------------------------------------------------------------------

    For just executing a method or two, reflection might be easier than beanshell (or it might not). For executing entire scripts, beanshell will be preferable over reflection.
    (I assume beanshell uses reflection under the hood, but I've never bothered to peek.)

Maybe you are looking for