Declaring an object with a string

Is there a way to declare a data object (at runtime) from a
string descriptor? For example, lets say I load a text file that
contains the following string: "{name:"bob", age:42,
location:"earth"}". Is there a way to then have Flash parse the
string and interpret it as an Object object in memory?
Thanks!

This may be just what I need, thanks for the tip!
I've set up a quick test though, and I'm having some
problems. My code is as follows:
import JSON;
var str:String = "{'var1':'hello world'}";
var obj:Object = JSON.parse(str);
trace(obj.var1);
All that I'm getting is an "[object Object]" trace in my
output window (upon JSON.parse() calling). Scripts following the
parse command do not run (ie: the trace action). And, if I try to
access the obj object later (I was checking it upon a button
press), then Flash is reporting that obj is undefined. Do you have
any insight on this?
Thanks for your help!!

Similar Messages

  • Comparing Collection object with a string

    Hi everyone,
    There is my problem: I have a program that generate all possible combinations of a certain number of letters for example: -ABC- will gives A, B, C, AB, AC, BC, ABC. Everything is fine at this point. But then the user can input a string like "AB" and I have to tell him if this string is contained in the generated set. My set is in a Collection, but when I used : LetterCombination.Contains(TextString), it returns always false. Even if I know that the string is contained in the set.
    Here is the code to generate the set:
    public class Recursion
         Collection LetterCombination;
    /*String Letters is the letters which I have to generate the combination, and
    the LetterNumber is the number of letters contained in my string.*/
         public Recursion(Set ItemLetters, String Letters, int LetterNumbers)
              ItemLetters = new TreeSet();
    String[] Token = Letters.split(" ");
    /*Adding the letters in the TreeSet*/
    for (int i = 0; i < LetterNumbers; i++)
         ItemLetters.add(Token);
    LetterCombination = BuildLetterSet(ItemLetters);
    private Collection BuildLetterSet(Set ItemLetters)
    Set NotUsedYet = new TreeSet();
    Set thisPowerSet = new TreeSet();
    Collection Letterresult = new ArrayList();
    NotUsedYet.addAll(ItemLetters);
    BuildByRecursion(NotUsedYet, thisPowerSet, Letterresult);
    return Letterresult;
    private void BuildByRecursion(Set notUsedYet, Set thisPowerSet, Collection result)
    if(notUsedYet.isEmpty())
    if(!thisPowerSet.isEmpty())
    Set copy = new TreeSet();
    copy.addAll(thisPowerSet);
    result.add(copy);
    return;
    Object item = notUsedYet.iterator().next();
    notUsedYet.remove(item);
    BuildByRecursion(notUsedYet, thisPowerSet, result);
    thisPowerSet.add(item);
    BuildByRecursion(notUsedYet, thisPowerSet, result);
    thisPowerSet.remove(item);
    notUsedYet.add(item);
    And if I print out the LetterCombination collection, it gives me:
    [C]
    [B, C]
    [A]
    [A, C]
    [A, B]
    [A, B, C]
    Which are the good combination needed. But I really don't understand how to compare this collection with the string entered by the user.
    I'm really lost. can somebody help me! Thanks in advance...

    You don't show where you call this constructor, or what your arguments are:
    public Recursion(Set ItemLetters, String Letters, int LetterNumbers)
       ItemLetters = new TreeSet();
       String[] Token = Letters.split(" ");
       /*Adding the letters in the TreeSet*/
       for (int i = 0; i < LetterNumbers; i++)
          ItemLetters.add(Token[ i ]);
       LetterCombination = BuildLetterSet(ItemLetters);
    }But, the constructor doesn't make sense, anyway. itemLetters is immediately set to a new TreeSet, so whatever you passed in (if anything) for the first argument is unchanged by the constructor (and the new TreeSet is lost when you finish the constructor). Also, you split your input Letters on space, but rely on LetterNumbers for the length of the split array (which may or may not be accurate). Why not do a 'for' loop testing for "i < Token.length", and eliminate LetterNumbers parameter? Your input for the second parameter to this constructor would have to be "A B C D" (some letters delimited by spaces). Your constructor only needs one parameter--that String.
    The capitalization of your variables doesn't follow standard coding conventions. Your code is hard to read without the "code" formatting tags (see "Formatting Tips"/ [ code ] button above message posting box).

  • Naming an object with a string.

    Is it possible to make on object that is named with a String?
    so you make a string String a = "Hello";
    and then you make an object that is called Hello.
    Does anyone know?
    thx, SJG

    AFAIK, no. But depending on what you want to do, there are various ways of storing a String on the basis of another string received at runtime.
    A HashMap, for example, could use the String "Hello" as a key to get at another string:
    HashMap map = new HashMap();
    String inputA = "hello";
    String inputB = "to be stored";
    map.put(inputA, inputB);
    System.out.println(map.get(inputA));Perhaps that might be useful to you?

  • Problem with web service that returns an object with a String that have som

    Hi everybody:
    I have a problem with a web service I am doing, I have made a web service that returns a collection of objects, the objects have a set of properties, there is one property that is a String,this property consists in a text fragment that could have some characters that are considered special in XML like &, <, >, " and that's why when I execute the service from a client an exception is thrown:
    {code}
    Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is com.ctc.wstx.exc.WstxParsingException: Expected a text token, got START_ELEMENT.
    at [row,col {unknown-source}]: [9,646]
    org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is com.ctc.wstx.exc.WstxParsingException: Expected a text token, got START_ELEMENT.
    at [row,col {unknown-source}]: [9,646]
    at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
    at org.codehaus.xfire.client.Client.onReceive(Client.java:410)
    at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
    at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
    at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
    at org.codehaus.xfire.client.Client.invoke(Client.java:336)
    at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
    at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
    at $Proxy0.search(Unknown Source)
    at cu.co.cenatav.webservices.client.Client.main(Client.java:26)
    {code}
    I know that this is happening because special characters are sent by the soap message but I don't know how to solve this problem.
    How could I avoid this exception ?
    I hope you can help me.
    Regards.
    Ariel

    Hi,
    BPEL and BPEL PM do not have a good support for SOAPENC-Array: it would be very difficult to create such an array in BPEL or to receive it and manipulate it.
    The (unfortunately very intrusive) work around is to change the WSDL of the service to use a XML type defined using XML schema. This is all the more painful that JDev 9.0.4 does not have strong support for complex types.
    In general though, I would highly recommend this best practice:
    1) Start by define the WSDL contract first
    2) Then generate the server side skeleton to implement it
    3) Use BPEL as the client to this contract.
    By starting with the contract first, you make sure that 1) your interfaces are clean and coarse grained.
    2) things like java objects, sessions, etc to not leak through the interface (which would be the worst thing that could happen because it would closely link the client and the server.
    Sorry for not being more helpful. This will get radically cleaner in Oracle AS 10.1.3.
    Edwin

  • URL object with https string throws malformed url exception: unknown protocol: https

    In WebLogic I am trying to connect to an HTTPS url by passing that url
    string into the contructor for URL object. This throws a Malformed URL
    Exception : unknown protocol: https.
    When i run this same block of code outside of weblogic (in a stand-alone
    app), it runs perfectly. (not exceptions when creating the URL object).
    why do i get this exception in weblogic?
    could weblogic be loading its own URL class rather than the java.net.URL
    class (which supports ssl)? if so how do i override that classloading?
    is there a weblogic security "feature" that prevents opening an ssl
    connection?
    thanks for any help
    mike
    [email protected]

    You need to modify your weblogic.policy file to allow you to change the
    the property java.protocol.handler.pkgs ... and any other properties
    that you may probably change using JSSE (for example:
    javax.net.ssl.trustStore for storing certificates of servers that you
    want to connect to from WLS )
    Regards,
    John Salvo
    Michael Harrison wrote:
    >
    thanks for the help dennis, but still get the "unknown protocol https".
    the URL object sees that the URLStreamHandler ==null and get the value for
    java.protocol.handler.pkgs (which should be
    com.sun.net.ssl.internal.www.protocol) then it tries to load that class. i
    believe that the GetPropertyAction("java.protocol.handler.pkgs","") is not
    returning com.sun.net.ssl.internal.www.protocol. therefore the class is not
    getting loaded
    i think that my classpath is set up properly for classpath and
    weblogic_classpath so i think that i me calling
    System.setProperty("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol"); is not effective.
    do you know anyway i can trouble shoot this.
    thanks
    mike
    Dennis O'Neill <[email protected]> wrote in message
    news:39d23c28$[email protected]..
    Https is an add-in so to speak. Try this before you create your url:
    System.setProperty ("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol");
    // add the default security provider (again, in JSSE1.0.1)
    int iap = java.security.Security.addProvider(new
    com.sun.net.ssl.internal.ssl.Provider() );
    dennis

  • Instantiating Object with NDS

    I'm having no success in instantiating object with NDS. Does anyone know whether is possible?
    I can hard code a statement as follows:
    pkg1.gs_nt(gs_nt.LAST) := NEW SomeObject_ot('x');
    where pkg1 is a package with the gs_nt variable declared in the spec. (global scope). The var. gs_nt is a nested table of SomeObject_ot type.
    When I try to use the same approach using NDS I get error messages at compile time:
    PLS-000103: Encountered the symbol "" - When I try to use the SomeObject_ot in a USING clause to set the value of a placeholder. In other words, it doesn't do the substitution.
    PLS-00382: expression is of wrong type - when I try to concatenate the object with a string.
    Based on the above, I've concluded that NDS can't be used to instantiate object types.
    Is thsi conclusion correct? Does anyone have a solution?

    Does this do what you need?
    SQL> create or replace type SomeObject is Object (
      2         val varchar2(10)
      3  ) ;
      4  /
    Type created.
    SQL>
    SQL> create or replace type SomeObject_nt is table of SomeObject ;
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE pkg1 IS
      2      gs_nt someobject_nt;
      3      PROCEDURE initialize(p_var IN VARCHAR2,
      4                           p_obj IN VARCHAR2);
      5  END;
      6  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY pkg1 IS
      2      PROCEDURE initialize(p_var IN VARCHAR2,
      3                           p_obj IN VARCHAR2) IS
      4          str VARCHAR2(4000);
      5      BEGIN
      6          str := 'begin ' ||
      7                 '  ' || p_var ||'.EXTEND ; '||
      8                 '  ' || p_var || '(' || p_var ||'.LAST) := NEW ' || p_obj || '(:val) ; ' ||
      9                 'end ;';
    10          dbms_output.put_line('Count=' || pkg1.gs_nt.COUNT);
    11          EXECUTE IMMEDIATE str
    12              USING 'String';
    13          dbms_output.put_line('Count=' || pkg1.gs_nt.COUNT || ' pkg1.gs_nt(1).val='||pkg1.gs_nt(1).val);
    14      END;
    15  BEGIN
    16    gs_nt := SomeObject_nt() ;
    17  END;
    18  /
    Package body created.
    SQL> set serveroutput on size 100000
    SQL> exec pkg1.initialize(p_var => 'pkg1.gs_nt',p_obj => 'SomeObject') ;
    Count=0
    Count=1 pkg1.gs_nt(1).val=String
    PL/SQL procedure successfully completed.
    SQL>

  • Encryt with a String

    Hi all
    This is the first time that I'm trying to use de cryto api, but my purpose is to encrip a object with a String of my, and then serialize it.
    I've found the following example on the net:
    try {
    // Generate a temporary key. In practice, you would save this key.
    // See also e464 Encrypting with DES Using a Pass Phrase.
    SecretKey key = KeyGenerator.getInstance("DES").generateKey();
    // Prepare the encrypter
    Cipher ecipher = Cipher.getInstance("DES");
    ecipher.init(Cipher.ENCRYPT_MODE, key);
    // Seal (encrypt) the object
    SealedObject so = new SealedObject(new MySecretClass(), ecipher);
    // Get the algorithm used to seal the object
    String algoName = so.getAlgorithm(); // DES
    // Prepare the decrypter
    Cipher dcipher = Cipher.getInstance("DES");
    dcipher.init(Cipher.DECRYPT_MODE, key);
    // Unseal (decrypt) the class
    MySecretClass o = (MySecretClass)so.getObject(dcipher);
    } catch (java.io.IOException e) {
    } catch (ClassNotFoundException e) {
    } catch (javax.crypto.IllegalBlockSizeException e) {
    } catch (javax.crypto.BadPaddingException e) {
    } catch (javax.crypto.NoSuchPaddingException e) {
    } catch (java.security.NoSuchAlgorithmException e) {
    } catch (java.security.InvalidKeyException e) {
    But i like to use it with my own key (String object), anyone knows which changes need to be performed?

    This is my standard DES example -
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.security.*;
    import sun.misc.*;
    public class DESEncryptDataString
        static public class EncryptionException extends Exception
            private EncryptionException(String text, Exception chain)
                super(text, chain);
        public DESEncryptDataString(byte[] keyBytes, byte[] ivBytes, String characterEncoding) throws EncryptionException
            assert (keyBytes != null) && (keyBytes.length == 8);
            assert (ivBytes != null) && (ivBytes.length == 8);
            assert (characterEncoding != null);
            try
                SecretKey key1 = new SecretKeySpec(keyBytes, "DES");
                // To demonstrate that the least significant bit is the parity bit and can be ignored.
                keyBytes[0] ^=0x01;
                SecretKey key2 = new SecretKeySpec(keyBytes, "DES");
                IvParameterSpec iv = new IvParameterSpec(ivBytes);
                this.characterEncoding = characterEncoding;
                this.encryptCipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
                this.encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key1, iv);
                this.decryptCipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
                this.decryptCipher.init(javax.crypto.Cipher.DECRYPT_MODE, key2, iv);
            catch (Exception e)
                throw new EncryptionException("Problem constucting " + this.getClass().getName(), e);
        synchronized public byte[] encrypt(String dataString) throws EncryptionException
            assert dataString != null;
            try
                byte[] dataStringBytes = dataString.getBytes(characterEncoding);
                byte[] encryptedDataStringBytes = encryptCipher.doFinal(dataStringBytes);
                return encryptedDataStringBytes;
            catch (Exception e)
                throw new EncryptionException("Problem encrypting string", e);
        synchronized public String decrypt(byte[] encryptedDataStringBytes) throws EncryptionException
            assert encryptedDataStringBytes != null;
            try
                byte[] dataStringBytes = this.decryptCipher.doFinal(encryptedDataStringBytes);
                String dataString = new String(dataStringBytes, characterEncoding);
                return dataString;
            catch (Exception e)
                throw new EncryptionException("Problem decrypting string", e);
        public static void main(String[] args)
            try
                // Make sure SUN are a valid provider
                Security.addProvider(new com.sun.crypto.provider.SunJCE());
                // The DES Key - any 8 bytes will do though beware of weak keys.
                // This could be read from a file.
                final byte[] keyBytes = "01234567".getBytes("ASCII");
                // IV For CBC mode
                // Again, could be read from a file.
                final byte[] IVBytes = "ABCDEFGH".getBytes("ASCII");
                // Data string encrypt agent that assumes the data string is only ASCII characters
                DESEncryptDataString dataStringEncryptAgent = new DESEncryptDataString(keyBytes, IVBytes, "UTF-8");
                // Get the data string to encrypt from the command line
                String dataString = (args.length == 0)? "The quick brown fox jumps over the lazy dog." : args[0];
                System.out.println("Data string ....................[" + dataString + "]");
                byte[] encryptedDataStringBytes = dataStringEncryptAgent.encrypt(dataString);
                BASE64Encoder base64Encoder = new BASE64Encoder();
                System.out.println("Encoded encrypted data string ..[" + base64Encoder.encode(encryptedDataStringBytes) + "]");
                String recoveredDataString = dataStringEncryptAgent.decrypt(encryptedDataStringBytes);
                System.out.println("Recovered data string ..........[" + recoveredDataString + "]");
            catch (Exception e)
                e.printStackTrace(System.out);
        private String characterEncoding;
        private Cipher encryptCipher;
        private Cipher decryptCipher;
    }Please note, DO NOT TRY TO CONVERT THE ENCRYPTED DATA TO A STRING USING
    String encryptedDataAsString = new String(encryptedDataStringBytes)
    as not all bytes and byte sequences can be recovered from teh resulting String. The result depends on the encoding.
    If you need a String representation then use Base64 or Hex encoding.

  • Creating object with names from a String Array

    Hi all,
    This might be a stupid question .. I have the following method:
         public OptionInputPanel(Option newO, String [] parameter){
              super(new BorderLayout());
              o = newO;
              for (int i = 0; i < parameter.length; i++){
                   testB = BorderFactory.createTitledBorder(parameter);
                   JFormattedTextField parameter[i] = new JFormattedTextField(); // problem
    as you can see I would like to name my text fields with the strings that I have in the parameters array so that I can get their values later on. How can I do it?
    Thanks for help
    Stan

                   JFormattedTextField parameter[i] = new JFormattedTextField(); // problemYou are declare an array of size i, and assigning a single JFormattedTextField to it.
         public OptionInputPanel(Option newO, String [] parameter){
              super(new BorderLayout());
              o = newO;
              JFormattedTextField params[ i ] = new JFormattedTextField();
              for (int i = 0; i < parameter.length; i++){
                   testB = BorderFactory.createTitledBorder(parameter[ i ]);
                   param[ i ] = new JFormattedTextField(parameter[ i ]);
    Resources for Beginners
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java. This one has been getting a lot of very positive comments lately.

  • (261718088) Q: Can you use xm:multiple with Objects other than String?

    Q: Can you use xm:multiple with Objects other than Strings?
    <br>
    A: You bet. Attached find a text file with some code from the example I showed
    today, a version of the multipleSayHiTo() method that has a parameter of an Array
    of Person objects rather than a parameter of an Array of Strings. The code within
    the text file comes from the Greeting.jws file (the Greeting Web Service).
    [multiple.txt]

    So you are saying that the recovery discs I made do include the copy of windows that was originally installed?
    Absolutely! They will restore the hard disk to its original out-of-the-box contents. Follow the instructions in the section Restoring from recovery DVDs/media, which begins on p. 73 of the User's Guide.
       Satellite A660 Series User’s Guide
    maybe i can make a deal with wd to have them swap this drive out for the BEKT instead...
    That would be a good idea in any case.
    As I said, the 10-fc12-045d error would not be due to the drive's being AFT, but more likely the discs are not being read properly. New discs can be obtained from Toshiba. Scroll down to Get Recovery Media here
    -Jerry

  • How to encrypt with a string as input,but not a key object

    As far as I know,when encrypt or decrypt ,a key must first be got,and the key is first generate by a tool or from SecurityRandom,that means I can not generate the same key with the same input.Does there is a method which can generate a same with the same input string?
    There is a need to transfer file between to site,and the customer wish to encrypt these files during transfering,and they want to store a string into each database at each site,when sending and receiving files,get the string from the database to encrypt or decrypt the file,they alse want to have a control of the string,they can change the string randomly if they wish as long as long keep each string is equal,how to realize this?

    I think what you are looking for is a password based encryption (PBE). An example of using the same is mentioned in JCE reference guide. Below is the relevant code/docs from the rference guide.
    Using Password-Based Encryption
    In this example, we prompt the user for a password from which we derive an encryption key.
    It would seem logical to collect and store the password in an object of type java.lang.String. However, here's the caveat: Objects of type String are immutable, i.e., there are no methods defined that allow you to change (overwrite) or zero out the contents of a String after usage. This feature makes String objects unsuitable for storing security sensitive information such as user passwords. You should always collect and store security sensitive information in a char array instead.
    For that reason, the javax.crypto.spec.PBEKeySpec class takes (and returns) a password as a char array.
    The following method is an example of how to collect a user password as a char array:
         * Reads user password from given input stream.
        public char[] readPasswd(InputStream in) throws IOException {
            char[] lineBuffer;
            char[] buf;
            int i;
            buf = lineBuffer = new char[128];
            int room = buf.length;
            int offset = 0;
            int c;
    loop:   while (true) {
                switch (c = in.read()) {
                  case -1:
                  case '\n':
                    break loop;
                  case '\r':
                    int c2 = in.read();
                    if ((c2 != '\n') && (c2 != -1)) {
                        if (!(in instanceof PushbackInputStream)) {
                            in = new PushbackInputStream(in);
                        ((PushbackInputStream)in).unread(c2);
                    } else
                        break loop;
                  default:
                    if (--room < 0) {
                        buf = new char[offset + 128];
                        room = buf.length - offset - 1;
                        System.arraycopy(lineBuffer, 0, buf, 0, offset);
                        Arrays.fill(lineBuffer, ' ');
                        lineBuffer = buf;
                    buf[offset++] = (char) c;
                    break;
            if (offset == 0) {
                return null;
            char[] ret = new char[offset];
            System.arraycopy(buf, 0, ret, 0, offset);
            Arrays.fill(buf, ' ');
            return ret;
        }In order to use Password-Based Encryption (PBE) as defined in PKCS #5, we have to specify a salt and an iteration count. The same salt and iteration count that are used for encryption must be used for decryption:
        PBEKeySpec pbeKeySpec;
        PBEParameterSpec pbeParamSpec;
        SecretKeyFactory keyFac;
        // Salt
        byte[] salt = {
            (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
            (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
        // Iteration count
        int count = 20;
        // Create PBE parameter set
        pbeParamSpec = new PBEParameterSpec(salt, count);
        // Prompt user for encryption password.
        // Collect user password as char array (using the
        // "readPasswd" method from above), and convert
        // it into a SecretKey object, using a PBE key
        // factory.
        System.out.print("Enter encryption password:  ");
        System.out.flush();
        pbeKeySpec = new PBEKeySpec(readPasswd(System.in));
        keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
        // Initialize PBE Cipher with key and parameters
        pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
        // Our cleartext
        byte[] cleartext = "This is another example".getBytes();
        // Encrypt the cleartext
        byte[] ciphertext = pbeCipher.doFinal(cleartext);Hope this helps
    Sai Pullabhotla

  • Create an object with the name passed in as a string argument to a method

    Hi,
    I am sorry if it's too trivial for this forum , but I am stuck with the following requirements.
    I have a method
    void abc(String object_name, String key, String value)
    method abc should first check if there exists in memory a hashmap object with the name passed in as argument object_name.
    If yes ..just put the key and value there.
    if not , then create the hashmap object called <object_name> and insert the key/value there.
    Can anybody help me in the first step i.e, how to check if an object exists with the name passed in and if not then create it.
    Will getInstance method be of any help?
    Thanks in advance for your response.
    -Sub-java

    Dear Cotton.m,
    Thanks for your suggesstion. I will remember that.
    But somehow I have a strong belief that you still need to consult dictionary for exact meaning of the words like "upset" , "frustration" etc. Not knowing something in a language , that too as a beginner, does not yield frustration, but increases curiosity. And people like petes1234 are there to diminish that appetite.
    To clarify above, let me compare jverd's reply to my doubt with petes1234's.
    jverd said it cannot be done and suggested a work around (It was perfect and worked for me) While petes1234 , having no work in hand probably, started analysis of newbies mistakes.
    jverd solved my problem by saying that it cannot be done. petes1234 acted as a worthless critic in my opinion and now joined cotton.m.
    Finally, this is a java forum and I do not want to discuss human characteristics here for sure.
    My apologies if I had a wrong concept or if I chose a wrong forum to ask, where people like petes1234 or Cotton.m show their geekdom by pointing out "shortfalls" rather than clearing that by perfect examples and words.
    Again take it easy and Cotton.m , please do not use this forum to figure out others' frustration but be a little more focussed on solving others "Java related" problems :)
    -Sub-java

  • New Local Move Request fails with error "Multiple objects with Guid hex octet string were found."

    I can find nothing searching online.  Trying to move the last user mailbox from one server to another, but it fails with this error.  I have checked all mailboxes for the same GUID but can't locate it anywhere.  Anybody have some suggestions?

    Does anyone know if there is a way to perform a search based on mailbox GUID?  Maybe I could find all objects with the same and it could lead me in the right direction.
    Hi,
    To find the object that belongs to a GUID, you can refer to this blog.
    http://blogs.technet.com/b/ehlro/archive/2010/04/22/how-to-find-the-object-that-belongs-to-a-guid.aspx
    Best Regards.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Lynn-Li
    TechNet Community Support

  • New object (with string)

    Hello,
    I have a function which is getting as an input a string variable and needs to create an new object that has the same name as the input string.
    How can I do it?
    thanks

    Hello,
    I have a function which is getting as an input a
    string variable and needs to create an new object
    that has the same name as the input string.
    How can I do it?For me the main question is why you want to do this? What difference is the name of the as long as you can find the object. I wonder if there is a better way of implementing what it is you want to do.
    For instance, would tying your object to the string via HashMap be a better solution?
    Do you have any sample code or pseudocode showing what you want to do?
    Message was edited by:
    petes1234

  • Setting the name of a new object from a string

    Is there anyway I can set the object name of a newly created
    object from a string?
    eg.
    (the code below generates a compile time error on the
    variable declaration)
    public function addText(newTxt:String, txt:String,
    format:TextFormat):void {
    var
    this[newTxt]:TextField = new TextField();
    this[newTxt].autoSize = TextFieldAutoSize.LEFT;
    this[newTxt].background = true;
    this[newTxt].border = true;
    this[newTxt].defaultTextFormat = format;
    this[newTxt].text = txt;
    addChild(this[newTxt]);
    called using>
    addText("mytxt", "test text", format);
    I could then reference the object later on without using
    array notation using mytxt.border = false; for example
    There are many a time when I want to set the name of a new
    object from a string.
    In this example I have a function that adds a new text object
    to a sprite.
    The problem is, if I call the function more than once then
    two textfield objects will exist, both with the same name. (either
    that or the old one will be overwritten).
    I need a way of setting the name of the textfield object from
    a string.
    using
    var this[newTxt]:TextField = new TextField()
    does not work, If I take the "var" keyword away it thinks it
    a property of the class not an object.
    resulting in >
    ReferenceError: Error #1056: Cannot create property newTxt on
    Box.
    There must be a way somehow to declare a variable that has
    the name that it will take represented in a string.
    Any help would be most welcome
    Thanks

    Using:
    var this[newTxt]:TextField = new TextField()
    is the right approach.
    You can either incrment an instance variable so that the name
    is unique:
    newTxt = "MyName" + _globalCounter;
    var this[newTxt]:TextField = new TextField();
    globalCounter ++;
    Or store the references in an array:
    _globalArray.push(new TextField());
    Tracy

  • So how do you declare an object?

    Okay I have a program I'm trying to build that lets me navigate between menus...
    Main Menu starts up:
    (Unimportant)
    Then it takes me to another Menu.
    When this is over I want to go back:
       System.out.println("Select: ");
            System.out.println("1: to Return to the main menu");
            System.out.println("or");
            System.out.println("0 to Exit");
         if(input.nextInt()==1){
             main(); // <-- error here
         else if(input.nextInt()==0){
             System.exit(0);
            }   It doesnt find the main method because I didn't declare it as an object at the top...
    How do I do that?
    Edited by: tark_theshark on Mar 30, 2008 5:24 AM

    Nah, this has nothing to do with declaring an object, and you really don't want to do this. What you really want to do is to have a loop of some kind, say a while loop and have the loop repeat until the user presses "0". Something like so:
        public static void main(String[] args)
            boolean done = false;
            while (!done)
                if(input.nextInt() == 0)
                    done = true;
        }Edited by: Encephalopathic on Mar 30, 2008 6:27 AM

Maybe you are looking for

  • How to copy text from Excel to a text field in the form?

    Hi All, I want to copy a text from Excel or Word file and paste it in a text field in the form, How? I tried to use ctrl+c for copy and ctrl+v for paste but it doesn't work!

  • Print issue with personas

    Hi Friends, I have front-end printing set   according to the instructions in note 771683. Essentially you print to a PDF file which appears in a pop-up window, from where you can save or print as you would with and other PDF file displayed in a web b

  • How to develop JMS Java Application.

    Now,I develop Java Application(J2SE stand alone) to send JMS for JMS Adapter(sender) verification. But fatal exception is displayed when I execute Java application. Error is rellated to following code. InitialContext context = new InitialContext(prop

  • Assets: Unable to post to the assigned Cost Center in Asset Master

    When I do the Depreciation Run, the cost center that gets hit is the Cost Center specified on the Cost Element (associated with the Depreciation Expenses account). Never does the Cost Center specified on the Asset Master gets picked. In case I do not

  • Reporting in Abap

    Hi, Is there any format available or developed at your end for giving a requirement to abapers for creating a functional related report in ABAP?