Can you listen for a string value to change?

Is there any easy way to see if a string changes value? I have a public static string in one instance of a class that I wish to be notified when it changes. An object of another class will have the listener.
Edited by: sarcasteak on Dec 8, 2009 1:40 PM

jverd wrote:
sarcasteak wrote:
jverd wrote:
sarcasteak wrote:
In the class that has the value, I create a new ObservableValue object and in the constructor I pass it the string. Now whenever I update the value I assume I do ov.setValue(search), so then the class that wants to get this value would implement observer.. but how does it get access to the ov instance?It registers itself as an observer. Did you read up on Observer/Observable?An observer for just that one instance of the ObvservableValue?Yes.
The problem is that I am not sure how to access the value from the secondary class.Your Observer must have an update() method. You understand that you have to implement the Observer interface, right? And you understand that to do so, you have to provide that method right? Have you looked at that method's signature? It provides you a reference to the Observable. You just cast it to whatever your class is and call the get method for the property you're interested in.
I understand that I need to add the observer, but I am not sure how I can do that if the secondary class(object) isn't being instantiated in the same object that passes the value.I have no idea what you mean by the last half of that sentence.
Have you tried maybe googling for java observer observable pattern? I'm sure there are plenty of examples available.Thanks, but I just ended up taking the easy way out and using an eclipse preference to pass values back and forth, not ideal since the values change so much.

Similar Messages

  • Can You Listen FOR while AS does something else too?

    Play and control the playing of a QT movie while also listening with Speech recognitionServer to some word from the user.
    i heard AS cant multithread.......

    An AppleScript doesn't multithread, but there can be multiple scripts running. In any given script it also depends on any results or user interface items used, since targeted applications will be doing their things separately.

  • How can you listen to music and play a game at the same time?

    How can you listen to music and play a game at the same time?
    I am playing music, by starting the Crash Baandicoot Nitro Kart 3D game it shuts off the music playing. Is there a way around this?
    It seems like this should be possible.
    Message was edited by: RuthlessVengeance
    Message was edited by: RuthlessVengeance

    Select the music play list you want to listen to and start it playing. Go back to the home screen and start the app you want to use, music will stop. Press the home button two time quickly and it will bring up a simple control for controling the music. This works for me with all of the apps I have purchased including games. Just a note you can pull up the same music control if the iPod is a sleep and locked by pressing the button three times quickly.
    Mike

  • How can you listen to music without headphones?

    How can you listen to music without headphones?

    - Try cleaning out/blowing out the headphone jack. Try inserting/removing the plug a dozen times or so.
    Try the following to rule out a software problem
    - Reset the iPod. Nothing will be lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup
    - Restore to factory settings/new iPod.
    - Make an appointment at the Genius Bar of an Apple store. Seems you have a bad headphone jack.
    Apple Retail Store - Genius Bar
    Apple will exchange your iPod for a refurbished one for this price. They do not fix yours.
    Apple - iPod Repair price
    A third-party place like the following will replace the jack for less. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Replace the jack yourself
    iPod Touch Repair – iFixit

  • Can't listen for connections - Operation not supported

    Hi,
    We have install OSB Client on HP-UX 11i V2 HP rx5670 Server as per Oracle Secure backup Installation Guide.
    But we are getting following error message. Please help us to solve the issue:
    2010/12/29.10:23:02 can't listen for connections - Operation not supported
    # /sbin/init.d/OracleBackup start
    Starting Oracle Secure Backup services daemon.
    2010/12/29.10:23:27 can't listen for connections - Operation not supported
    Thanks
    Khairul/Bangladesh

    Have a look at the observiced.log file to see if that has any more detail, this is in /usr/tmp.
    I would check to see if there is something else on the system that is using TCP port 400 or 10000. On Solaris I've seen the webmin installation using port 10000. Both those ports need to be free for OSB to be able to start.
    With OSB stopped, you can "telnet <hostname> 400" and "telnet <hostname> 10000" to see if it connects. If it does then something is listening on that port.
    You should be able to do "netstat -na" as well, to show you listening ports.
    Rich

  • Is there any native method for converting String value to Hungarian notat..

    Hello. there.
    This might be very simple question. but I'm just curious about this.
    I am wondering if Java API offer the any native method for converting uppercased string value to lowercase which obey the Hungarian notation.
    What I'm going to do is using Reflection for excuting RFC function on SAP. I was found it is very similar to JDBC Programming.
    Please refer to blow codes.
    //mTable
    JCoTable mTable = function.getTableParameterList().getTable(rtnTblNm);
        for (int i = 0; i < mTable.getNumRows(); i++) {
         mTable.setRow(i);
         HashMap tmpData = new HashMap ();
              for (int j=0; j < mTable.getNumColumns(); j++) {
                     // I want to set key String [userNo] instead of  [USER_NO] here.
              tmpData.put(mTable.getMetaData().getName(j).toLowerCase(), mTable.getString(j));
              result.add(tmpData);
    } Basically, The idea was from ibatis framework [com.ibatis.common.beans.classInfo] dropcase();
    Any idea would be very helpful for me. Thank you.
    Edited by: hosung.seo on Aug 30, 2009 10:42 PM
    Edited by: hosung.seo on Aug 30, 2009 10:50 PM

    ejp wrote:
    Hungarian notation is a representation of logical/arithmetic expressions in postfix form. Not what you're talking about.
    So your title is very confusing to the people here who know what it means, which is probably all of them, because people read threads based on their title.From now on, I will pay more attention when I post an question.
    If the titile as " +Is there any native method for converting String value to camelcase?"+ would be easier to what i'm pointing at.
    As I mentioned in above sorce code, converting [USER_NO] to [userNo] isn't relevant Hungarian notation. yes, it was ambiguous. Agree! :)
    But some answer wasn't fit to converting case or recognizing "underscore" delimiter. I was expecting toCamelCase() such as blew. Thanks.
        public static String toCamelCase(String name) {
            String lowerName = name.toLowerCase();
            String[] pieces = lowerName.split("_");
            if (pieces.length == 1) {
                return lowerName;
            StringBuffer result = new StringBuffer(pieces[0]);
            for (int i = 1; i < pieces.length; i++) {
                result.append(Character.toUpperCase(pieces.charAt(0)));
    result.append(pieces[i].substring(1));
    return result.toString();

  • How can you trim the contact field value without cloudconnector?

    How can you trim the contact field value without cloudconnector?

    You can add your contacts to segments, while right-clicking on the criteria you have added in segments, you will see the option for Merge, Intersect & Trim.
    See the attached URL, it might help you .
    Merge, Intersect, Trim

  • How many devices can you use for your itunes account?

    how many devices can you use for your itunes account?

    PT wrote:
    Macistotle wrote:
    Unless you have DRM still haunting your tunes ... Then you can only use those songs on 5 devices. Otherwise, connect as many as you like (as stated above).
    No, you can sync your DRM tracks to an unlimited number of iPods (but only authorized to play on 5 different computers/user accounts)
    Patrick
    So I can sync two iPods to my iTunes account and sync the same digital copy movies that come with some o' my DVDs to both ipods? Do movies make a difference really, DRM-Wise? Thanks in advance.

  • HT204387 can you listen to music with your ipod touch 4g and a bluetooth handsfree device

    can you listen to music with your ipod touch 4g and a bluetooth handsfree device

    Yes if the BT device supports the profiles supported by the iPod. See:
    iOS: Supported Bluetooth profiles
    The A2DP provide is used with speaker and headphones
    The Hands Free profiles (HFP) is typically used with headset (headphones and mic).

  • TS3212 can you listen to purchased music on android phone?

    Can you listen to purchased itunes on an android phone?

    How do I do that. I very recently purchased an album and songs from my desk top.  When I use my Ipa
    Pad, it plays but when I use my Gallaxy cell phone, I don't know it works.  I am so frustrated.  HELP

  • Can you listen to the radio without internet on the ipod touch?

    Can you listen to the radio without internet on the ipod touch? (like the nano?)

    RainyRain958 you are just BSs. There is no cellular iPod. Here is the comparison
    http://www.apple.com/ipod/compare-ipod-models/
    You can get iPads that have a cellular radio
    RainyRain958 wrote:
    They sell 5G iPods that are all the same, except that you have cellular. Go to the iPod model comparison page on Apple's website-- the cellular iPod is labeled Wi-Fi + Cellular.

  • Can you listen to AM radio with I pod?

    Can you listen to FM and AM radio on an I pod?

    No.
    You can listen to internet radio

  • Can you listen to music without the headphones?

    Can you listen to music on the iPod Classic without the headphones?

    The Classic does not have an internal speaker, so either you need to:
    plug in headphones
    connect the iPod to an amplifier and speakers (from the headphone socket)
    connect it to an iPod Dock cable and plug that into an amplifier
    Place the iPod into the Dock on something that has a Dock connector and amplifier built in.

  • Can you ask for a specific time for your package to be delivered

    can you ask for a specific time for your package to be delivered

    You can only arrange that with the shipper after your package is shipped (and before it is deliverd.) When the package is shipped Apple usually emails the tracking information.

  • How to use execute immediate for character string value 300

    how to use execute immediate for character string value > 300 , the parameter for this would be passed.
    Case 1: When length = 300
    declare
    str1 varchar2(20) := 'select * from dual';
    str2 varchar2(20) := ' union ';
    result varchar2(300);
    begin
    result := str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || ' ';
    dbms_output.put_line('length : '|| length(result));
    execute immediate result;
    end;
    /SQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
    length : 300
    PL/SQL procedure successfully completed.
    Case 2: When length > 300 ( 301)
    SQL> set serveroutput on size 2000;
    declare
    str1 varchar2(20) := 'select * from dual';
    str2 varchar2(20) := ' union ';
    result varchar2(300);
    begin
    result := str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || str2 ||
    str1 || ' ';
    dbms_output.put_line('length : '|| length(result));
    execute immediate result;
    end;
    /SQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
    declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 6

    result varchar2(300);Answer shouldn't be here ? In the greater variable ?
    Nicolas.

Maybe you are looking for