Undocumented String feature

Hey
Take a look at this code and tell me where this is dosumentet i jdk.
          // display the result from the search, the most frequent first.
          // The string s is f.eks. /MyDocuments/test.html;Title_of_document
          // put the url and the title in a hashtable
          urls = new Hashtable();
          for (int k = int_tbl.length-1; k>=0;k--){
               String s = str_tbl[k];
               int slash = s.lastIndexOf(";");
               String kvasiUrl = s.substring(slash + 1,s.length());
               String ss = s.substring(0,slash);
               String OKUrl = new String(ss.toCharArray());
               urls.put(kvasiUrl, OKUrl);
               textArea.append(kvasiUrl+"\n");
          }//end for
          // set the current position to the first document in the list.
          textArea.setCaretPosition(1);
     }//end search
     // display the document in the browser, the target variable in the showDocument()
     // method is the target variable for html
     public void mouseClicked(MouseEvent evt){
//System.out.println(textArea.getSelectedText());
          if (!(textArea.getSelectedText().equals(""))){
               try{
                    String t = textArea.getSelectedText();
                    String s = (String)urls.get(t);
                    String mmm = getCodeBase().toString()+s;
                    String s3 = new String(mmm.toCharArray());
                    String s2 = new String(getCodeBase().toString()+s);
                    URL url = new URL(s3);
                    getAppletContext().showDocument(url,"_blank");
                    // This will result in the following c:\User\Myloginname\NULL
                    // the null part represents the variable s
                    // the former part is the codebase
                    // but a System.out.println(url.toString()) will print
                    // c:\User\Myloginname\MyDocuments\test.html
               }catch(MalformedURLException ext){
                    ext.printStackTrace();
               }//end try catch
          }//end if
     }//end mouseClicked
I have heard erlier that the String concat often can cause problem and the solution is to make a new string with the toCharArray or getBytes in the constructor, but this does not help in this situation. Thats why I've tried with both the s2 and s3 string.
Have anyone else encountered this problem??Or read something about it that can help me?
TheLaw

It would help if you wrote a simplified version of the program instead of trying to debug the most complicated possible code. You had some useful debugging code there but it's commented out.
In fact it is impossible to debug this code because it's impossible to tell what's selected in the text area. But whatever it is, it doesn't match anything that was used earlier as a key to the hashtable. So the urls.get() method returns null, which is what you are seeing. I don't see any control that requires the user to select exactly one line, and not the "\n" at the end, but maybe that's somewhere else in your program.
And that stuff at the end is just nonsense. This code:String OKUrl = new String(ss.toCharArray());is functionally equivalent to this:String OKUrl = ss;And I have never seen any point in "new String(someotherstring)", although people seem to use it for some reason.

Similar Messages

  • More ?undocumented? features in BDB 5.1.19

    I would love to read documentation about these following features, documented in http://download.oracle.com/docs/cd/E17076_02/html/installation/changelog_5_1.html
    Added the ability to specify that data should not be logged when removing pages from a database. This can be used if the ability to recover the data is not required after the database has been removed. [#18666]
    Added new DB_ENV->repmgr_get_local_site method.
    I need this info for updating the Python bindings.
    Thanks.

    Hello,
    The documentation for:
    Added the ability to specify that data should not be logged when removing pages from a database. This can be used if the ability to recover the data is not required after the database has been removed. [#18666]
    Can be found at:
    http://download.oracle.com/docs/cd/E17076_02/html/installation/build_unix_db_nosync.html
    "DB_NOSYNC Flag to Flush Files"
    In short, you can use the DB_NOSYNC flag so that removing or renaming a subdatabase will not cause the containing file to be flushed.
    From the documentation:
    Applications must now pass the DB_NOSYNC flag to the methods - DB->remove, DB->rename, DB_ENV->dbremove, and DB_ENV->dbrename, to avoid a multi-database file to be flushed from cache. This flag is applicable if you have created the database handle in a non-transactional environment.
    By default, all non-transactional database remove/rename operations cause data to be synced to disk. This can now be overridden using the DB_NOSYNC flag so that files can be accessed outside the environment after the database handles are closed.
    The documentation for DB_ENV->repmgr_get_local_site is missing. The internal SR for this is #19161.
    It will look like:
    #include <db.h>
    int
    DB_ENV->repmgr_get_local_site(DB_ENV *env,
    const char **host, u_int *port); 
    The host argument is the address of the caller's string pointer,
    into which we will return a pointer to the replication manager's
    internal storage where it is storing the host name. In other words,
    this method doesn't make a copy of the host name string; it just
    returns a pointer to our own internal copy of it. The port argument
    returns the port number that the replication manager is using locally.
    Thanks,
    Sandra

  • JSF component (file-chooser, string feature is only needed).

    For a rapid prototype...
    I'm looking for a file-chooser that uses a JSF component, so I can get the string to the backing bean.
    I do not need to upload a file.
    Whats the easiest way to do this?
    More specifically, I want to be able to push on a button and have the file chooser dialog open, and then have the selection go to the input text component. I also need to bind it to the backing bean. I'm using JSF 2.0 and also have primefaces setup. I tried to mix in tomahawk, but things went crazy.
    Thanks,
    Robert

    EJP wrote:
    And the documentation ;-(((((((Yay, A nice rant thread! Don't get me started on documentation, show me one API or framework that has documentation that covers not only the beginner things but also the production scale features (properly, not just mentioning that the features exist).
    Of course it all makes sense, complete and helpful documentation halts the sales of books. for example, did you know that a book about Richfaces 4 has just hit the market?

  • Undocumented String fearute

    Hey
    Take a look at this code and tell me where this is dosumentet i jdk.
    // display the result from the search, the most frequent first.
    // The string s is f.eks. /MyDocuments/test.html;Title_of_document
    // put the url and the title in a hashtable
    urls = new Hashtable();
    for (int k = int_tbl.length-1; k>=0;k--){
    String s = str_tbl[k];
    int slash = s.lastIndexOf(";");
    String kvasiUrl = s.substring(slash + 1,s.length());
    String ss = s.substring(0,slash);
    String OKUrl = new String(ss.toCharArray());
    urls.put(kvasiUrl, OKUrl);
    textArea.append(kvasiUrl+"\n");
    }//end for
    // set the current position to the first document in the list.
    textArea.setCaretPosition(1);
    }//end search
    // display the document in the browser, the target variable in the showDocument()
    // method is the target variable for html
    public void mouseClicked(MouseEvent evt){
    //System.out.println(textArea.getSelectedText());
    if (!(textArea.getSelectedText().equals(""))){
    try{
    String t = textArea.getSelectedText();
    String s = (String)urls.get(t);
    String mmm = getCodeBase().toString()+s;
    String s3 = new String(mmm.toCharArray());
    String s2 = new String(getCodeBase().toString()+s);
    URL url = new URL(s3);
    getAppletContext().showDocument(url,"_blank");
    // This will result in the following c:\User\Myloginname\NULL
    // the null part represents the variable s
    // the former part is the codebase
    // but a System.out.println(url.toString()) will print
    // c:\User\Myloginname\MyDocuments\test.html
    }catch(MalformedURLException ext){
    ext.printStackTrace();
    }//end try catch
    }//end if
    }//end mouseClicked
    I have heard erlier that the String concat often can cause problem and the solution is to make a new string with the toCharArray or getBytes in the constructor, but this does not help in this situation. Thats why I've tried with both the s2 and s3 string.
    Have anyone else encountered this problem??Or read something about it that can help me?
    TheLaw

    Well
    I thought that was the problem too, but by testing the code with variuos println to screen I found that it was not the problem.
    To make it easier to read
    String s = (String)urls.get(t);
    This code does not return null(i.e, s != null)
    String mmm = getCodeBase().toString()+s;
    URL url = new URL(mmm);
    getAppletContext().showDocument(url,"_blank");
    System.out.println(url.toString());
    -> c:\MyDocuments\Myloginname\Test\test.html
    but the new IExplorer that is open has a url
    -> c:\MyDocuments\Myloginname\NULL
    c:\MyDocuments\Myloginname\ is the codebase
    NULL should be the s string.
    and it is not an IExplorer error.
    I have tried this before but it did not fail but it does now and i think the reason is that the value of the hashtable is generated as a substring from an another string, that is the only diffrense between this nonfunctioning code and the other code. I this the problem occur when i try to concatinate the string s with the codeBase toString.
    Thanks trying to solve the problem
    TheLaw

  • "undocumented" (maybe) feature in PRE7

    What are the "sequence in/out" markers and what are they used for? I ran across them when editing the other day. I only know what they are called by moving them and going to the history window and seeing what they are called. I cannot find them documented in any place, online documentation, the book that came with the program, or Steve's Moviepix book. They are located at the very top of the timeline and look like vertical lines with little "bumps" in the middle. When these in and out markers are separated, it is indicated with a gray bar with a handle in the middle, similar to the work area bar. I have found that if these markers are both positioned beyond the end of your clips in the timeline, and you select and delete (at least) the last clip, that you get an internal error (something to do with the monitor panel) whenever you attempt to preview the timeline (press space bar, for instance). Undoing the clip deletion and moving both these "sequence" markers back (at least) to the beginning of the time line will fix this internal error from happening when you delete (at least) the last clip and preview the timeline. This error was very frustrating (and caused me bitter disappointment in PRE7) until I discovered this "fix". Anybody else seen this or similar problem?

    Charles,
    IIRC, these are actually a vestige from Premiere Pro, which allows multiple Sequences and several other true "features." In PE, they do nothing, except appear and confuse people. It seems that they are invoked by pressing the "I" and the "O" (that's an "oh" key).
    There is an article on www.muvipix.com on these. Again, from memory, Chuck Engles got the word down from Adobe product management. If I can find the exact article, I'll post the link.
    [Edit] Here is that link:
    http://muvipix.com/phpBB3/viewtopic.php?f=38&t=4349
    There is at least one post in this forum on these, especially the grey bar. I do not recall if anyone knew the answer then.
    Hunt

  • EXTENDING the string class

    ok, i know extending the string class is illegal because it's final, but i want to make an advanced string class that basically "extends" the string class and i've seen online this can be done through wrapper classes and/or composition, but i'm lost
    here is my sample code that is coming up with numerous compile time errors due to the fact that when i declare a new AdvString object, it doesn't inherit the basic string features (note: Add is a method that can add a character to a specified location in a string)
    class AdvString
         private String s;
         public AdvString(String s)
              this.s = s;
         public void Add(int pos, char ch)
              int this_len = (this.length()) + 1;
              int i;
              for(i=0;i<(this_len);i++)
                   if(pos == i)
                        this = this + ch;
                   else if(pos < i)
                        this = this + this.charAt(i-1);
                   else
                        this = this + this.charAt(i);
         public static void main(String[] args)
              AdvString s1;
              s1 = new AdvString("hello");
              char c = 'x';
              int i = 3;
              s1.Add(i,c);
              //s2 = Add(s1,i,c);
              //String s2_reversed = Reverse(s2);     
              System.out.println("s1 is: " + s1);
    any tips?

    see REString at,
    http://www.geocities.com/rmlchan/mt.html
    you will have to replicate all the String methods you are interested in, and just forward it to the String instance stored in REString or the like. it is like a conduit class and just passes most processing to the 'real' string. maybe a facade pattern.

  • New features of SQL & PLSQL

    Hi
    Could anyone please guide me to the oracle documentation where I can find the new features of SQL and PLSQL?
    Thanks

    What Oracle calls new features is not necessarily everything that is a new feature.
    Here are my personal lists:
    http://www.morganslibrary.org/reference/new_in_11gR1.html
    http://www.morganslibrary.org/reference/new_in_11gR2.html
    http://www.morganslibrary.org/reference/new_11_2_0_2.html
    http://www.morganslibrary.org/reference/new_11_2_0_3.html <-- still being built
    These lists include undocumented unsupported features as well as supported ones so review for a better understanding of the Oracle database but only implement those you find in the online Oracle docs and which are supported. You, the user, assume all risks for making bad choices.

  • How to get premultiplied alpha in a png embedded with compression=true

    Hi there,
    I found that the [embed] tag has many undocumented features (and WHY ... WHY are they not documented?! and IS there any place where it is all thoroughly documented? Well, the one in the Flex documentation isn't really that helpful)
    So you can embed PNGs in a compressed way like JPGs with compression=true and quality=70 i.e. to save a transparent PNG with JPEG compression.
    BUT when I do that, the alpha seems to not get premultiplied, it doesn't behave like when I don't compress it. The shadows aren't dark anymore but almost lighten the areas up. When not using compression & quality, the shadow areas look like they're supposed to.
    When using a PNG compressed by the Flash IDE, it works.
    So, is there ANOTHER undocumented embed-feature which lets you control if the alpha-channel gets premultiplied or not?
    That would really help in some cases.
    Right now I'm still using the Flash IDE for that, but it would be nice to know if there is a way to make it work merely by Flex EMBED tags.

    Hi corlettk,
    Thanks for your reply. I have defined my map as Map<String, Boolean> selectedIds = new HashMap<String, Boolean>();
                selectedIds.put("123-456", true);           
                int m=123; int n=456;
                                     selectedIds.put(String.valueOf(m) + "-" + String.valueOf(n),true);
                boolean viv = selectedIds.get("String.valueOf(m)-String.valueOf(n)");
                System.out.println(viv);
                My problem is the hashmap key must be set dynamically ("123-456" is just an example) and when i get the value i should be able to pass those varibales in an expression correctly. Please let me know how can i pass an expression like the one above as a hashmap key. Please advise.

  • TestStand Deployment Utility API

    Is there any API for the TestStand Deployment Utility I can use in labview to automatically launch a TSD file and build the deployment. I would like to create a little labview program which automates the whole process of creating deployments for me, especially when it is a minor change in subVI underneath, and none of the deployment configuration needs changing.
    Any info would be appreciated!

    Hi kewsvnet
    Sorry the the delay in getting back to you.
    There isn't currently a TestStand Deployment Utility API for LabVIEW, the closest I think you can get at the moment is to do a command-line deployment build by calling the System Exec VI.
    i.e.
    "C:\Program Files\National Instruments\Teststand 2010\Components\Tools\Deployment Utility\DeploymentUtility.exe" build "C:\mydeployment.tsd" 
    As the string input should build mydeployment.tsd
    Note:This is an undocumented internal feature we use for Testing the deployment utility.   The interface is very limited - you can do a build but there is no way
    to set parameters and no return value so you have to parse the log to determine if the build succeeded. There is further discussion of this here in a previous forum post.
    Kind Regards
    Chris | Applications Engineer NIUK

  • Navigate_absolute is not working in the quality system.

    Hi experts,
    i developed a webdynpro component and integrated into EP, Here when i test my application through ep (developmemt system) everthing is working fine. But when i test the application through ep (quality system) exit button is not working its not navigating to OVERVIEW SCREEN in EP, And the code which i have written in the exit button is.
    Exit button is working in development system but its not working in quality system.
    METHOD onactionexit .
    TYPES: BEGIN OF navigation,
        target       TYPE string,
        mode         TYPE string,
        features     TYPE string,
        window       TYPE string,
        history_mode TYPE string,
        target_title TYPE string,
        context_url  TYPE string,
       END OF navigation.
      DATA: wa_navigation TYPE navigation.
      DATA lo_api_component  TYPE REF TO if_wd_component.
      DATA lo_portal_manager TYPE REF TO if_wd_portal_integration.
      lo_api_component = wd_comp_controller->wd_get_api( ).
      lo_portal_manager = lo_api_component->get_portal_manager( ).
    wa_navigation-target =  'ROLES://pcd:portal_content/com.sap.pct/every_user/com.sap.pct.erp.ess.bp_folder/com.sap.pct.erp.ess.pages/com.sap.pct.erp.ess.overview'.
      wa_navigation-mode   = '0'.
      CALL METHOD lo_portal_manager->navigate_absolute
        EXPORTING
          navigation_target = wa_navigation-target
          navigation_mode   = wa_navigation-mode.
    please provide requried information.
    Thanks & Regards.
    Bhushan.

    Hi,
    The both mentioned virtual systems are in different LPAR's (Physical host).
    Already I have checked the /etc/services and looks every thing is fine in the file. I have also checked the file inetd.conf  and I didn't find any thing # on the Telnet.It seems every thing is fine in the both files.
    Can you please look in to it and provide some thing which I have to look in the OS level.
    Thanks & Regards,
    Sandeep

  • Print PDF from Forms

    Hi
    I wonder if anyone can help. We're running Forms 10.1.2.30 against an Oracle 10.1.0.5.0 database using IE8 on Windows XP and Windows 7 clients.
    We generate utility bills using Oracle Reports. These work fine at the moment as we print these reports directly to the printer from Reports. However, we now need to perform some post processing to the bills so I would like to produce the bill to a PDF, perform some post processing and then send the PDFs to the printer on batch.
    Does anyone have any tips on how to send the PDFs to a printer on batch? I can host it out to Acrobat using the undocumented/unsupported /t option, but I would rather not rely on third party software (especially undocumented/unsupported features).
    I've found a link to the Oracle Forms PJC/BEAN - PDF Project, but I cannot download the file. Something to do with the download site been seized by the FBI!
    https://sites.google.com/site/jvrpdfproject/version-1-5-2-english
    Thanks in advance.
    Neil

    Hi.
    What mechanism do you use now to send a PDF to printer? Do you have each printer defined on middleware (application server) or you download pdf from application server an print it localy?
    Best Regards
    Gregor

  • Multiple family mbrs, multiple ipods, multiple accnts, multiple computers

    I have a family of 6, we each have various ipods (iphone, ipod, nano, shuffle, etc), and we have multiple computers -- some Mac and some PC.
    We need to understand what factors impact the ability to put a particular track on one or more devices, manage a given device from one or more accounts on one or more computers, and share, as allowed, between devices, people, iTunes libraries, iTunes store accounts, for both purchaed tracks and MP3 files that we might already own, etc...
    I'm looking for a simple and concise description of all of the factors. Any pointers?
    If the iTunes world were simple we could simply each have our own music -- stored in one or more places in one or more accounts, on one or more computers. We would be able to share what we like, and put whatever subset we like on whichever device, manage any device from any account on any computer, etc... Of course this could be subject to licenses, but it should at least be possible to get a statement of what license restrictions exist.
    Can anyone suggest any references for this? I assumed it was simple, but anyone who has recently plugged a "guest" iPod into another computer will know this is not the case after having been rewarded with the choice of wiping all content off of the iPod, or somehow transferring the content to the friend / family member (with no clear indication of whether this also comprises transferring the content away from the original user, nor how, if possible, to undo such a move later, etc...)
    I have seen an article relating to using multiple ipods with one computer, but it does not address all of the issues -- for example using one ipod with multiple computers, etc...
    Thanks in advance.

    Let's see if we summarise the main points that will help you decide on a strategy:
    + An iPod can automatically sync (one-way transfer from iTunes to iPod) with just one iTunes library.
    + An iPod (but not an iPhone) in manual mode can accept tracks from multiple libraries.
    + iTunes can transfer (copy) purchases from an iPod into the library if authorised for the account used to purchase them.
    + Networks, memory sticks, portable hard drives, CD-R, DVD-D and iPod to PC transfer programs can be used to move other content between your libraries.
    + The new "home sharing" feature probably has some relevance too, but I've not explored just what the capabilities are.
    + For each account, DRM puchases can be authorised on up to 5 computers at any one time.
    + For each computer, up to 5 accounts may be authorised on it at any one time.
    + Each iPod may hold DRM content from up to 5 different accounts.
    + DRM content may be transfered to as many iPod's as you wish.
    + Most iTunes Store content is no longer subject to DRM, the main exceptions being Movies & Games/Applications.
    + iPods can be formated for use with either Mac or Windows. You can manage content on a Windows formatted iPod with either system, but the reverse is not the case. Firmware updates & restores must take place on the native system.
    + An undocumented/unsupported feature is that if you clone a library (make a complete copy of the iTunes library files and media content) and place this on another machine, an iPod "synced" to the original library will also see any clone as its "home" library. Once cloned you don't have to keep all the content available in each locataion. For regular iPods if syncable content cannot be found corresponding files on the device will be left alone (not updated or deleted).
    + The main database file of an iTunes library can only be opened by one process - multiple users on the same computer or over a network will lead to problems. Always close iTunes before switching profiles.
    + The media content folders can be simultaneously accessed by multiple accounts.
    + Automatic syncing has a number of advantages. You can update tag info. in iTunes knowing that when updated the iPod will recieve all the updates. Using playlists you can manage the content that will go on an iPod without having it connected. Ratings & playcounts can sync in both directions. All the content required to restore your iPod is in one location.
    + Manual management allows you to add content from whichever library you are connected to.
    + iTunes does not keep track of files moved or updated by other programs or instances of iTunes. If you share content folders then it is best to avoid the *Keep iTunes Media folder organised* option. When you update content on one machine, e.g. change a capitalisation or correct a spelling, other libraries will only notice the change if they access the file in some way, e.g. by playing it.
    I'm sure there's more that I can't think of just now but that's a start.
    *Personal Case history:*
    Our family has an iPhone, a Nano, 3 Classics (old & new) and a 5th gen. I started by making most of the purchases on my account, putting the children's gift cards onto my store account for example, but two now have their own accounts. I manage most of the music in one main library that sits on a network. One child has a separate library which started as clone of the original and then had content that he dislikes removed... This means I can update his iPod at either his machine or mine although if I add any of his music I have to remember to update both libraries. When he uses iTunes on his computer he only sees the rock/blues/metal that he likes whereas the main library has everybodys content lumped together.
    All the iPods are set to sync automatically using the method two (Sync with selected playlists) from the Apple support document How to use multiple iPods with one computer, although I have a slight twist. Rather than regular playlists I set the grouping field to indicate which users should receive which tracks and create smart playlists based on the content of this field.
    e.g.
    "Alice's Tracks" is "Playlist is Music" + "Grouping contains Alice" + "Kind contains audio"
    "Bob's Videos" is "Playlist is Music" + "Grouping contains Bob" + "Kind does not contain audio"
    Tracks that both Alice & Bob want on their iPods have the grouping set to "Alice/Bob"
    etc.
    This way each of us gets a different selection of content to suit our tastes and the capacity of our iPods. An advantage of using the grouping field is that it is stored in file tags (for non-wav audio files anyway) so that it is relatively easy to recreate the playlists should the iTunes library get trashed. Also useful if you move files about manually as playlist membership is preserved when you delete & re-import the tracks.
    However you choose to do things you should also create a backup. My main library gets synced to a portable hard drive using SyncToy 2.1 (Windows) which I sometimes take to work and sync there, giving me three complete copies of my library at any one time and I can update any iPod from any instance of the library. An occasional scan of the contnet folders with iTunes Folder Watch helps me catch up if, for example, a podcast has download at one location but the library is overwritten with a newer version from the other.
    Hope that's given you some useful food for thought...
    tt2

  • GPIB and RS232 communication problems

    I've been having several "interesting" problems with GPIB and RS232 communications in LabVIEW VIs.  Some I'll mention at the end for curiosity, but right now I'm facing a rather big problem.  I'm essentially self-taught at doing LabVIEW (using 8.5.1 right now), but by now I've had a lot of experience as their either has not been any drivers or pre-made VIs for the instruments I've needed or I've not been able to get the available drivers to work and had to write my own anyway (such as with the HP 3458A), but nothing seems to be working right now.  I'm not at work, but we typically find forum sites blocked anyway (I can't even download the NI drivers at work since they house them on a ftp server, go figures) so I can't give the VI itself (it wouldn't be easy to get approval even if I could) so the best I can do right now is in words describe everything I've tried.  I will be happy to post follow-ups of specific details if I can if they would be helpful.
    I've been working on a routine to read data from an MKS 670 Signal Conditioner/Display with a MKS 274 Multiplexer with 3 connected MKS 690A Baratrons.  Previously I've worked on programs using other older displays and the analog outputs which were being read by a DAQ card, but for a new project it was decided to try and just read the data directly.  I first worked with a unit with just an RS232 Serial Port which I managed to get to work, but had so much problems with garbage readings and having to add checks and re-reads that by the end no matter what delays I added between each reading and how simplified the command routine down to just 2 sequences and the read that it took at least 10 seconds to get 1 reading from each channel.
    Figuring maybe it was a limitation of the serial communications for these instruments I tried to re-work it for a unit with a GPIB port with which I'm actually much more familiar.  The problem is that I cannot get anything at all from the unit through GPIB.  Everything even the bare-bones built-in GPIB CLR function times out with no response from the instrument no matter how long I set the timeout limit and it also freezes the entire GPIB bus as well.  It isn't a waiting issue as it freezes on the very first command.  The GPIB initialization function seems to work (I typically find this to be unnecessary), but the instrument itself doesn't even respond with a status code.  I've also tried just the basic GPIB write functions with even just passing the <cr> and <lf> characters as well.  In Measurement and Automation Explorer most of the time the instrument won't even appear when doing search for instruments and when it does it shows as not responding to the *IDN? command (yes I've messed with the EOI, EOS, etc settings and I've even changed the GPIB address even though when it gets this far it confirms that I have the correct address) and even tried manually doing the *IDN?, *RST, and *CLR commands even with <cr> and <lf> characters which the manual for these units clearly states are compatible commands and NI SPY and everything show no response at all.  I've tried 2 different GPIB units, 3 different computers including several that are not online and haven't been updated for a while, and using older LabVIEW versions, extensive re-booting and resetting of computers and devices and still nothing.  I'm using an NI GPIB-USB-HS GPIB to USB adaptor which I've used extensively on other systems and even re-connected to those systems and everything worked fine.  When I hooked up equipment that I knew was working, it would either freeze the entire GPIB bus until well past whatever timeout setting I set at which point all the instruments would appear, but none responding to *IDN? queries or nothing would appear at all, or if I manually turned it off when frozen the other instruments would work and most even respond to the *IDN? queries.  The same goes for both of the GPIB instruments of this type that I tried and again for different versions of LabVIEW, difference computers (all Windows XP though), and every GPIB configuration setting I can find to mess with in every combination.
    Any thoughts or suggestions would be greatly appreciated.  I've had all sorts of weird problems with equipment and LabVIEW (you've got to love undocumented design features) that have frustrated me before, but I've never had an instrument never respond at all especially a GPIB one.  Getting garbage yes, no response at all, no.
    The side side issues I'm just mentioning as they may be related, but I'm really interested in the above as I have working solutions for these:
    One I've had is with a Hart Scientific (prior to being bought by Fluke) 1560 Black Stack that would continually stop responding to GPIB commands when on a continual read function taking readings just every 4 seconds with 250ms between each GPIB read or write command but for up to hours in total and the times it stops responding are random as far as I can tell.  I even started sending the *RST command before and after every read or write command and still it freezes.  The only thing is to manually turn it off and then back on or manually go through the menus and manually trigger the GPIB reset routine at which point it immediately starts responding.  However, when I got sick of having to babysit it and just decided to try the RS232 serial port (as that is all it has without the extended communications module) it works fine no problem and I can even get readings slightly faster from it.  Using a Hart Scientific 1529 Chub-e it could give me data on all 4 channels every second without problems.  I just find it a bit odd.
    When I couldn't get any of the HP 3458A driver packs to work to even give a single measurement reading and just made my own using basic GPIB read/write commands using the programming manual I still have a few interesting problems in randomly when reading off the full possible 256 bytes on the bus and clearing the bus I often find garbage partial readings on the bus every now and then.  I've added a few routines to do some basic checks, but it is annoying.  What is really weird is when just doing basic DC Voltage reads the "-" sign will randomly be dropped from some readings (started as about 1 out of every 5, down now to about 1 out of every 10).  Fortunately I'm taking several readings and averaging and taking the standard deviation with limits on the deviations and basically added a routine to say if there is even 1 negative number take the absolute value of all then make all negative, but again I find it weird.
    Thanks.
    -Leif
    Leif King
    Metrology Engineer
    Oak Ridge Metrology Center

    Greetings Leif,
    I understand you have completed extensive troubleshooting techniques to pin-point the problem with the GPIB communication. To begin, I want to ask you a few questions to help me understand your set-up and the issue at hand.
    1) Is the NI GPIB-USB-HS cable the one which cannot communicate with your instrument?
    2) When using the GPIB-USB-HS, does the GPIB interface show up in MAX?
    3) If yes, does the instrument appear in MAX after scanning for instruments (from what I understand in your issue, it does so in an intermittent manner..)?
    4) What driver version of VISA do you have installed in your computer?
    5) Are you able to communicate to the same instrument using another GPIB cable?
    Thank you for trying out some of these steps again, but we want to make sure we rule out other aspects in the systems which might be affecting the GPIB communication.
    As for your other issues, please post seperate threads for each so we can help you accordingly. Thanks!
    Sincerely,
    Aldo
    Aldo A
    Applications Engineer
    National Instruments

  • Need suggestion on security

    Hello,
    I need some suggestions on what might be the best way to handle security in my application.
    The application acts as a control panel with an initial login screen. When a user logs in it needs to be given access to certain menus and buttons based on the user group in which it belongs. The user groups need to be configurable (so policies will change over time).
    Is JAAS a viable solution? I am not concerned with the OS level of security. The application needs its own level of security. For example, user JohnDoe logs in to application. JohnDoe belongs to the GroupA user group. GroupA has AccessPrivsA, which currently allows him to view menus A B and C. Later on AccessPrivsA is changed by user Admin to only have access to menus A and B.
    Any ideas fellas?

    JAAS will allow you to authenticate the user and to obtain the users credentials via the OS or another source (depending on the LoginModule used) but it will not allow you to control access to various features in your application. For this you need to create an ACL (Access Control List) based framework within your application. An ACL is a list of groups/users that have a certain privileges. You would create an ACL for each of the features within your app that you want to control access to. The various classes within your app could check with the ACL management system to see if the current user has access to a specific feature. For example assume the following (not thread safe) code:
    public class AclMgr{
      private AclMgr _singleton;
      private HashMap _aclmap;
      private Subject _subject;
      private AclMgr(){
        _aclmap = new HashMap();
        // read in the ACLs and store in HashMap. This could be in a properties file.
        // e.g.
        // #My ACL property file
        // #format: feature=ACl
        // view.sensitve.data=ADMIN,SUPER
        // get a reference to the current Subject (which is essentially the user with credentials).
        // This assumes your using JAAS - you could also roll your own if you choose to.
        _subject = UserAuth.getInstance().getCurrentSubject();
      public static AclMgr getInstance(){
        if(_singleton == null){
          _singleton = new AclMgr();
        return _singleton;
      public boolean isAuthorized(String feature){
        boolean authorized = false;
        if(_aclmap.containsKey(feature)){
          // check the Subjects credentials (groups etc) against the ACL for this feature.
          // if the user is in a group that exists in this features ACL then set authorized=true .
        return authorized;
    public class MyJFrame extends JFrame{
      public MyJFrame (){
        super();
        // set up the UI
        // when we get ready to see if we add a feature then do something like this:
        if(AclMgr.getInstance().isAuthorized("view.sensitve.data")){
          // the user has access so add yer button!
    }Of course, this is overly simplified but gets the general idea across. We have implemented something similar in our Enterprise application and it works nicely. With a little more work you can probably provide an UI for authorized users (admins etc) to edit Access Control Lists for various features. Security will be increased if you store the ACL property file on a server somewhere so you can control access to its editing. Or even store it in a Database� lots of fun to be had here ;-)
    Hope this helps,
    Shane

  • Class, interface, or enum expected error

    import java.awt.Graphics;
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class InventoryFinal
    //main method begins execution of java application
    public static void main(final String args[])
    int i; // varialbe for looping
    double total = 0; // variable for total inventory
    final int dispProd = 0; // variable for actionEvents
    // Instantiate a product object
    final ProductAdd[] nwProduct = new ProductAdd[5];
    // Instantiate objects for the array
    for (i=0; i<5; i++)
    nwProduct[0] = new ProductAdd("CD", 10, 18, 12.00, "Jewel Case");
    nwProduct[1] = new ProductAdd("Blue Ray", 9, 20, 25.00, "HD");
    nwProduct[2] = new ProductAdd("Game", 8, 30, 40.00, "Game Case");
    nwProduct[3] = new ProductAdd("iPod", 7, 40, 50.00, "Box");
    nwProduct[4] = new ProductAdd("DVD", 6, 15, 15.00, "DVD Case");
    for (i=0; i<5; i++)
    total += nwProduct.length; // calculate total inventory cost
    final JButton firstBtn = new JButton("First"); // first button
    final JButton prevBtn = new JButton("Previous"); // previous button
    final JButton nextBtn = new JButton("Next"); // next button
    final JButton lastBtn = new JButton("Last"); // last button
    final JButton AddBtn = new JButton("Add"); // Add button
    final JButton DeleteBtn = new JButton("Delete"); // Delete button
    final JButton ModifyBtn = new JButton("Modify"); // Modify button
    final JButton SaveBtn = new JButton("Save"); // Save button
    final JButton SearchBtn = new JButton("Search"); // Search button
    final JLabel label; // logo
    final JTextArea textArea; // text area for product list
    final JPanel buttonJPanel; // panel to hold buttons
    //JLabel constructor for logo
    Icon logo = new ImageIcon("C:/logo.jpg"); // load logo
    label = new JLabel(logo); // create logo label
    label.setToolTipText("Company Logo"); // create tooltip
    buttonJPanel = new MyJPanel(); // set up panel
    buttonJPanel.setLayout( new GridLayout(1, 4)); //set layout
    // add buttons to buttonPanel
    buttonJPanel.add(firstBtn);
    buttonJPanel.add(prevBtn);
    buttonJPanel.add(nextBtn);
    buttonJPanel.add(lastBtn);
    buttonJPanel.add(AddBtn);
    buttonJPanel.add(DeleteBtn);
    buttonJPanel.add(ModifyBtn);
    buttonJPanel.add(SaveBtn);
    buttonJPanel.add(SearchBtn);
    textArea = new JTextArea(nwProduct[3]+"\n"); // create textArea for product display
    // add total inventory value to GUI
    textArea.append("/nTotal value of Inventory "+new java.text.DecimalFormat("$0.00").format(total)+"\n\n");
    textArea.setEditable(false); // make text uneditable in main display
    JFrame invFrame = new JFrame(); // create JFrame container
    invFrame.setLayout(new BorderLayout()); // set layout
    invFrame.getContentPane().add(new JScrollPane(textArea), BorderLayout.CENTER); // add textArea to JFrame
    invFrame.getContentPane().add(buttonJPanel, BorderLayout.SOUTH); // add buttons to JFrame
    invFrame.getContentPane().add(label, BorderLayout.NORTH); // add logo to JFrame
    invFrame.setTitle("CD & DVD Inventory"); // set JFrame title
    invFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // termination command
    //invFrame.pack();
    invFrame.setSize(600, 600); // set size of JPanel
    invFrame.setLocationRelativeTo(null); // set screen location
    invFrame.setVisible(true); // display window
    // assign actionListener and actionEvent for each button
    firstBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end firstBtn actionEvent
    }); // end firstBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    prevBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[4]+"\n");
    } // end prevBtn actionEvent
    }); // end prevBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    nextBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[2]+"\n");
    } // end nextBtn actionEvent
    }); // end nextBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    lastBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[3]+"\n");
    } // end lastBtn actionEvent
    }); // end lastBtn actionListener
    textArea.setText(nwProduct[4]+"n");// assign actionListener and actionEvent for each button
    AddBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end AddBtn actionEvent
    }); // end AddBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    // assign actionListener and actionEvent for each button
    DeleteBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end DeleteBtn actionEvent
    }); // end DeleteBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    // assign actionListener and actionEvent for each button
    ModifyBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end ModifyBtn actionEvent
    }); // end ModifyBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    // assign actionListener and actionEvent for each button
    SaveBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end SaveBtn actionEvent
    }); // end SaveBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    // assign actionListener and actionEvent for each button
    SearchBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end SearchBtn actionEvent
    }); // end SearchBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    // prevBtn.addActionListener(new ActionListener()
    // public void actionPerformed(ActionEvent ae)
    // dispProd = (nwProduct.length+dispProd-1) % nwProduct.length;
    // textArea.setText(nwProduct.display(dispProd)+"\n");
    // } // end prevBtn actionEvent
    // }); // end prevBtn actionListener
    } // end main
    } // end class Inventory4
    class Product
    protected String prodName; // name of product
    protected int itmNumber; // item number
    protected int units; // number of units
    protected double price; // price of each unit
    protected double value; // value of total units
    public Product(String name, int number, int unit, double each) // Constructor for class Product
    prodName = name;
    itmNumber = number;
    units = unit;
    price = each;
    } // end constructor
    public void setProdName(String name) // method to set product name
    prodName = name;
    public String getProdName() // method to get product name
    return prodName;
    public void setItmNumber(int number) // method to set item number
    itmNumber = number;
    public int getItmNumber() // method to get item number
    return itmNumber;
    public void setUnits(int unit) // method to set number of units
    units = unit;
    public int getUnits() // method to get number of units
    return units;
    public void setPrice(double each) // method to set price
    price = each;
    public double getPrice() // method to get price
    return price;
    public double calcValue() // method to set value
    return units * price;
    } // end class Product
    class ProductAdd extends Product
    private String feature; // variable for added feature
    public ProductAdd(String name, int number, int unit, double each, String addFeat)
    // call to superclass Product constructor
    super(name, number, unit, each);
    feature = addFeat;
    }// end constructor
    public void setFeature(String addFeat) // method to set added feature
    feature = addFeat;
    public String getFeature() // method to get added feature
    return feature;
    public double calcValueRstk() // method to set value and add restock fee
    return units * price * 0.10;
    public String toString()
    return String.format("Product: %s\nItem Number: %d\nIn Stock: %d\nPrice: $%.2f\nType: %s\nTotal Value of Stock: $%.2f\nRestock Cost: $%.2f\n\n",
    getProdName(), getItmNumber(), getUnits(), getPrice(), getFeature(), calcValue(), calcValueRstk());
    } // end class ProductAdd
    class MyJPanel extends JPanel
    //private static Random generator = new Random();
    private ImageIcon picture; //image to be displayed
    // load image
    public MyJPanel()
    picture = new ImageIcon("mypicture.png"); // set icon
    } // end MyJPanel constructor
    // display imageIcon on panel
    public void paintComponent( Graphics g )
    super.paintComponent( g );
    picture.paintIcon( this, g, 0, 0 ); // display icon
    } // end method paintComponent
    // return image dimensions
    //public Dimension getPreferredSize()
    // return new Dimension ( picture.getIconWidth(),
    //picture.getIconHeight() );
    } // end method getPreferredSize
    } // end class MyJPanel
    import java.io.File;
    import java.io.IOException;
    public class FileAccessDemo
    public static void main( String[] args ) throws IOException
    // declare variables
    String formatStr = "%s exists in %s? %b\n\n";
    // processing and output
    File file1 = new File( "studentScores.txt" ); // create a File object
    System.out.printf
    (formatStr, file1.getName(), file1.getAbsolutePath(), file1.exists());
    // processing and output
    File folder1 = new File( "c:/personnel/" ); // create a File object
    folder1.mkdir(); // make a directory
    File file2 = new File( "/personnel/faculty.txt" );
    file2.createNewFile(); // create a new file
    System.out.printf
    ( formatStr, file2.getName(), file2.getAbsolutePath(), file2.exists() );
    // processing and output
    file2.delete(); // delete a file, but not the directory
    System.out.printf
    ( formatStr, file2.getName(), file2.getAbsolutePath(), file2.exists() );
    } // end main
    } // end class
    I need help in resolving this error.
    Thanks

    That code isn't where your error is. Here's the errors I get compiling your code:
    H:\java>javac InventoryFinal.java
    InventoryFinal.java:78: ')' expected
    textArea.append("/nTotal value of Inventory "new java.text.DecimalFormat("$0.00").format(total)"\n\n
                                                 ^
    InventoryFinal.java:78: ';' expected
    textArea.append("/nTotal value of Inventory "new java.text.DecimalFormat("$0.00").format(total)"\n\n
                                                                                                   ^
    InventoryFinal.java:340: class, interface, or enum expected
    import java.io.File;
    ^
    InventoryFinal.java:341: class, interface, or enum expected
    import java.io.IOException;
    ^
    4 errorsThe last two errors are on your import statements, which can't be in the middle of a source file. The first two are on this line:
    textArea.append("/nTotal value of Inventory "new java.text.DecimalFormat("$0.00").format(total)"\n\n");Which certainly isn't a legal line of Java code. If you want to connect multiple Strings you need to use the "+" operator.

Maybe you are looking for