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

Similar Messages

  • 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.

  • Current Item for Authorization Scheme

    I would like to write a generic PL/SQL authorization scheme for each page item (including buttons). I can pass the user, the app and the page through substitution strings but I cannot seem to find how the pass the item for which the authorization scheme is being evaluated. Is there an undocumented string like APP_ITEM_ID or a way to access it through the globals in the WWV_FLOW package? If not, can this be an enhancement as I'm sure it could be useful for others as well?
    I realize I can accomplish this through the Conditional Display properties but my preference is to do it through the Authorization Scheme as this would allow for Conditional Display based on other criteria.

    Thanks for the quick reply. I can work around it.
    In spite of a few items such as this, I have become an evangelist for HTML DB. Great job!! Please pass on my appreciation to the others involved in its development and support.

  • Error While converting xml to sap abap string.

    Hi Experts,
    As i am doing an cross Application from SAP to .Net and vice versa.I am receiving an xml from .Net and it should be converted to ABAP string Using the following function module   SMUM_XML_PARSE 
    And the following string i am receiving from .net
    <Root><qApprovalInfo><RequesterId>xxxx</RequesterId><RequesterName>xxx</RequesterName><ApproverId>xxxx</ApproverId><ApproverLevel>1</ApproverLevel><PendingApprovalId>0200169911</PendingApprovalId><CreatedDate>20/07/2011</CreatedDate><CreatedBy>xx</CreatedBy><ModifiedDate>2011-07-20 16:45</ModifiedDate><ModifiedBy>xxxx</ModifiedBy><ApplicationCode>EPAY</ApplicationCode><WorkFlowCode>EPX</WorkFlowCode><ApprovalStatus>APPROVED</ApprovalStatus><ActionComments><![CDATA[APPROVED(through  Desktop)]]></ActionComments><Mode>CREATE</Mode><ActionSource>DESKTOP</ActionSource></qApprovalInfo><qApprovalHidden><Approverl>40002664</Approver><EmployeeId>40016515</EmployeeId></qApprovalHidden></Root>
    In this xml i am getting all the values except the <ActionComments><![CDATA[APPROVED(through Desktop)]]></ActionComments>
    is their any way to convert that CDATA value?..
    have anybody come across the following issue ?...
    can anybody provide the solution for this?.
    Edited by: basavaraj.p on Aug 29, 2011 10:54 AM

    Hi,
    SMUM_XML_PARSE is a simplified, unreleased and undocumented version of the powerful, released and documented iXML
    If you look at the GET_ELEMENT subroutine in that function module, you'll see that the nodes of type CO_NODE_CDATA_SECTION are simply ignored.
    The simpliest thing for you, maybe, is to duplicate the code of SMUM_XML_PARSE (as it is rather easy to handle), and add a section to GET_ELEMENT. You'll have also to use IF_IXML_CDATA_SECTION interface and ixml_iid_cdata_section constant.
    Documentation is here: [SAP Library: Interface if_ixml_cdata_section|http://help.sap.com/saphelp_nw70/helpdata/en/bb/576658dca511d4990b00508b6b8b11/frameset.htm ]
    Best regards,
    Sandra

  • Error converting XML to String

    I'm trying to use getXMLString() to put my XML document in a String variable. I get the following when I try to output the String:
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: This object has been closed. If the close() was implicit, and you would like the object not to be closed between calls, see the keepCursorAlive() method</ERROR>
    If I just output the XML doc without putting it into a String variable it works fine.
    System.out.println(q.getXMLString()); //OK
    // get the XML document in string format
    String xmlString = q.getXMLString(); //NOT OK
    System.out.println(xmlString);
    What am I doing wrong? Any help would be great!
    Thanks,
    Melani

    Hi,
    SMUM_XML_PARSE is a simplified, unreleased and undocumented version of the powerful, released and documented iXML
    If you look at the GET_ELEMENT subroutine in that function module, you'll see that the nodes of type CO_NODE_CDATA_SECTION are simply ignored.
    The simpliest thing for you, maybe, is to duplicate the code of SMUM_XML_PARSE (as it is rather easy to handle), and add a section to GET_ELEMENT. You'll have also to use IF_IXML_CDATA_SECTION interface and ixml_iid_cdata_section constant.
    Documentation is here: [SAP Library: Interface if_ixml_cdata_section|http://help.sap.com/saphelp_nw70/helpdata/en/bb/576658dca511d4990b00508b6b8b11/frameset.htm ]
    Best regards,
    Sandra

  • Inconsistent substitution string expansion in email templates - SCSM 2012 R2

    Coming to the conclusion that email templates should not be stored in a custom MP ?
    I'm seeing odd begaviour where only some fields are expanded when the email is created. See below example where ID in the subject line has not been expanded but it has been expanded in the body of the email. If I store the custom template in "Service
    Manager Incident Management Configuration Library" then it works as expected.
    In the following notification, Subject has not been expanded yet when ID is used in a subsequent field in the email body it is expanded (Fault No.)
    Also Affected User Firstname has not been expanded.
    Subject: Your call has been closed.  ID: $Context/Property[Type='WorkItem!System.WorkItem']/Id$
    Fault No: IR223
    Fault Description: Testing Open, resolve & close notifications
    Dear $Context/Path[Relationship='WorkItem!System.WorkItemAffectedUser' SeedRole='Source' TypeConstraint='System!System.Domain.User']/Property[Type='System!System.Domain.User']/FirstName$,
    Please be advised that this call has now been marked as closed.
    Ian Moran

    it should be noted that those substitution strings are contingent on the MP that stores the notification template. for example, 'System!System.Domain.User' is only valid if the
    MP Reference "System" points to an MP that contains the element System.WorkItemAffectedUser, and that element is a relationship class definition.
    to break it down:
    $Context/Path[Relationship='WorkItem!System.WorkItemAffectedUser' SeedRole='Source' TypeConstraint='System!System.Domain.User']/Property[Type='System!System.Domain.User']/FirstName$
    $ starts and ends a variable.
    Context is one of the keywords that control the behavior of the variable, but in this case, you can read it as the target of the notification template.
    Path[] means we are going down the projections path \
    Relationship modifies path by specifying which relationship to follow in the brackets with the Relationship element.
    SeedRole modifies path by setting which side of the relationship the starting objects is on, in this case, the "context" is the source of the relationship.
    TypeConstraint filters path based on what's on the other side of the relationship, in this case, it must be a user.
    Property[] means we're reading data from a property of this user, as opposed to pathing again
    Type modifies property by controling which class to get the property set from
    the last entry is the property name to get data from, i.e. the
    FirstName property.
    Consider http://technet.microsoft.com/en-us/library/ff719642.aspx and
    http://msdn.microsoft.com/en-us/library/ee533748.aspx, thou Context is new for service manager and is largely undocumented, I suspect it was added to address related classes, as (also speculation)
    Target may refer only to the target entity without its relationships.

  • How pass VISA resource string from C++ as uintptr_t* to a LabVIEW generated DLL ?

    My coworker build a DLL from LabVIEW that I am trying to call from C++.
    void__cdeclMeasureDCvolts(uintptr_t*VISAResourceName, int32_tChannelNumber,LVBoolean*MonitorResult,double*MeasuredVoltage, TD1*errorOut);
    Does "extcode.h" define macros or functions for string conversions?  Or should I request my coworker rebuild the VI's to make arguments more C/C++ friendly?
    Thanks in advance for any tips or direction.  Examples are * much * appreciated.
    -Ed
    TestObjectMeasurement* testObjectMeasurement = m_measurementMap[name];
    TestObjectInstrument* testObjectInstrument = m_instrumentMap[selectedInstrumentName];
    int slot = 1;
    int bank = 1;
    int channel = 1;
    int channelNumber = 1000 * slot + channel;
    char * visaResourceName = testObjectInstrument->visaResourceName().toLatin1().data();
    LVBoolean monitorResult = LVBooleanFalse;
    double measuredVoltage = -1.0;
    TD1 errorOut = {0};
    try
    // void __cdecl MeasureDCvolts(uintptr_t *VISAResourceName,
    // int32_t ChannelNumber, LVBoolean *MonitorResult, double *MeasuredVoltage,
    // TD1 *errorOut);
    MeasureDCvolts(reinterpret_cast<uintptr_t*>(visaResourceName), channelNumber, &monitorResult, &measuredVoltage, &errorOut);
    catch(...)
    qDebug() << "Exception thrown by: MeasureDCvolts";
    QString errorSource = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorOut.source)), LHStrLen(errorOut.source));
    qDebug() << errorSource;
    LStrHandle errorTextHandle = {0};
    bool foundErrorText = NIGetOneErrorCode(errorOut.code, &errorTextHandle);
    if(foundErrorText)
    QString errorText = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorTextHandle)), LHStrLen(errorTextHandle));
    MessageHelper::messageError(errorText, errorSource);

    Why is it not a solution? It was exactly about what you wanted to do and the solution in the last post is how it can be made to work. There is NO way to ddirectly create a LabVIEW native VISA resource in C code that is not called from within LabVIEW, unless you consider hacking the LabVIEW system and using undocumented functions a solution. But that has very good chances of breaking with future LabVIEW versions.
    Your only other option is to export another function from the DLL that accepts a String and uses VISA Open to explicitedly open the VISA session in your LabVIEW DLL and returning that VISA session to your C code. This is functionally equivalent to passing a String to your current function but avoids the lookup and potential recreation of the VISA refnum on each call. Something I would only feel bothered if you intend to call this function many thousend times each second, which for VISA communication seems very unlikely.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • HTTP Query String

    We use mod_plsql to create webpages. One annoying charactersitic of this framework is having to explicitly define all Query String parameters that a procedure could possibly accept.
    We have some jquery stuff we're developing that retrieves data from oracle using PL/SQL procedures over http (mostly XML formated, but we're also lookg at JSON). We have 1 tool we're exavluating that does this, but fails, and we don't know why...I think it's because it is sending some query string parameters that are undocumented and we're not getting any notice to what might be missing/sent.
    So, my question is, is there a way to tell what query string parameters are being passed to a procedure? Assuming it is failing by sending undefined parameters of course...

    oBean wrote:
    We use mod_plsql to create webpages. One annoying charactersitic of this framework is having to explicitly define all Query String parameters that a procedure could possibly accept.Why not use the 2 parameter call interface instead?
    You add an exclamation mark to the URL call to the procedure. E.g.
    instead of
    http://my-server.mydomain.com/orcl/scott.myproc?name=John&code=123
    the call is changed to the following:
    http://my-server.mydomain.com/orcl/!scott.myproc?name=John&code=123
    This instructs mod_plsql to pass the query string as name-value arrays. The signature of procedure SCOTT.MyProc will thus no longer look like this
    create or replace procedure MyProc( name vachar2, code number ) is ...
    But as follows:
    create or replace procedure MyProc( name_array owa_util.vc_arr, value_array owa_util.vc_arr ) is
    The procedure can now deal with variable query strings from the web browser.

  • Function to get reversal of any string ..!

    hi ,
    Is there any function in oracle to get reversal of any string.
    'london' --> 'nodnol'
    select func_name('london') from dual; --> is there any built-in function to do this operation?
    result- 'nodnol'
    rgds,
    pc

    SQL> with t as (
      select 'nodnol' str from dual
    select str,
           reverse (str) rev1,
           utl_raw.cast_to_varchar2 (utl_raw.reverse (utl_raw.cast_to_raw (str))) rev2,
           xmlquery('codepoints-to-string(reverse(string-to-codepoints(.)))' passing xmlelement(e,str) returning content).getstringval() rev3
      from t
    STR    REV1   REV2       REV3     
    nodnol london london     london   
    1 row selected.Note:
    REV1 is undocumented!
    REV2 works just for single-byte characters

  • Failure to read multiline string with Read Key.vi

    I converted 2D array into a spreadsheet string and attempetd to write it as a key value into a configuration file. This worked just fine. However, when I attempted to read this multiline string using Read Key.vi, I got just the first line in return (see two vi's attached).
    As sufficient documentation on configuration file vi's is all but missing, could you please advise on their (undocumented) features? What do I miss?
    Thank you.
    Michael
    Attachments:
    Save_2D_array_in_config_file.vi ‏29 KB
    Read_2D_array_from_config_file.vi ‏31 KB

    Hi Michael,
    MichaelS wrote in news:506500000008000000F7980000-
    [email protected]:
    > I converted 2D array into a spreadsheet string and attempetd to write
    > it as a key value into a configuration file. This worked just fine.
    > However, when I attempted to read this multiline string using Read
    > Key.vi, I got just the first line in return (see two vi's attached).
    I use Config files all the time. Much more user-friendly than the
    Registry. They are a Microsoft thing really, rather than LabView, and
    come from Windows 3.11. Each value is limited to one line, so when you
    write a spreadsheet string with end-of-line characters in it, you're
    effectively breaking the .inf file
    The solution? Try putting a "Search and Replace String
    " after your
    "Array To Spreadsheet String". Wire "Replace All" with a TRUE constant,
    and wire "Search String" with a string in "\" view and enter \r\n (or do
    0A0D in Hex view) and then then wire Replace String with a ";"
    Now your .inf file will look like:
    [Array]
    Data=1.0000,0.0000,0.0000;0.0000,2.0000,0.0000;0.0000,0.0000,3.0000;
    When reading it, just reverse the search and replace strings above.
    I hope this helps,
    Andrew

  • Conditional coding in Fscript - undocumented options

    Looking at some of the fusion installation scripts, I found some
    undocumented features in Fscript that I have long wanted.
    Some conditional processing at last, even if primitive.
    Here they are:
    1. Conditional processing
    if <argument1> <operation> <argument2>
    <fscript command>
    endif
    or
    if <argument1> <operation> <argument2>
    <fscript command>
    else
    <fscript command>
    endif
    The if-part that is not executed because the condition is not met is echoed
    to the output device with "SKIPPED: " comments.
    If ...else...endif constructions can be nested. The use of "exit" exists
    Fscript, not the innermost condition.
    The elements of these commands are:
    (1)
    <argument1> can be any string, including environment variables such as
    %{forte_root}.
    <operation> is either "=" (equal) or "!=" (not equal)
    In this case <argument2> must be a string (or environment variable)
    (2)
    <argument1> can be any string, including environment variables
    <operation> is "is"
    <argument2> is either:
    "set" - the <argument1> string is an environment variable with a
    value
    "unset" - the <argument1> string is not an environment variable
    "file" - the <argument1> string points to an existing file
    "directory" - the <argument1> string is a directory file
    Note that if <argument1> is specified as %{variable}, the <argument> has the
    value of the environment variable.
    Suppose environment variable myVar is set to "myValue". Then:
    if myVar is set <--- this environment variable exists
    echo "This is true"
    endif
    if %{myVar} is set <--- this becomes if myValue is set and
    there is no environment variable myValue
    else
    echo "This is false since myValue is not an environment variable but a
    the value of such variable"
    endif
    2. Set environment variables
    setenv <variablename> <stringvalue>
    Sets an environment variable to the specified value
    3. Output to logfiles
    echo <string>
    echo <string> >> <filespec>
    Outputs the <string> text string to the standard output or redirects it to
    the specified filespec. The ">>" is the redirection operator
    4. Silence output
    Commands that must be executed and must not be echoed are preceded by a "
    character. This includes the if / else / endif constructions:
    if FORTE_ROOT = "
    echo "No Forte root defined"
    setenv FAILED Yes
    endif
    5. Searching for a string in a file
    You can inspect a file for a particular string using the SearchFile command.
    This sets the environment variable STATUS to either 0 (success) or non-zero
    (not found)
    SearchFile <filespec> <searchstring>
    SearchFile %{FORTE_ROOT}
    if %{STATUS} = 0
    echo "Found it"
    else
    echo "No such string"
    endif
    Some examples:
    # Check if FORTE_ROOT is defined as environment variable
    If FORTE_ROOT is unset
    Echo "Error: FORTE_ROOT is not set"
    Exit
    EndIf
    # Check if FORTE_ROOT is pointing to a directory
    If %{FORTE_ROOT} is directory
    else
    echo "Not a valid directory"
    exit
    endif
    # check if a repository exists before overwriting it by accident
    if %{FORTE_ROOT}/repos/myrep.btx is file
    echo "Repository file myrep already exists"
    exit
    endif
    # See if the environment variable myrepos is set
    if myrepos is set
    echo "You defined environment variable myrepos = %{myrepos}"
    else
    echo "You did not define environment variable myrepos. Now being set to
    MYOWN"
    setenv myrepos MYOWN
    endif
    # Start logging in my own logfile
    Echo "--------------------------------" >>%{FORTE_ROOT}/log/mylogfile.log
    Echo %{$DATE$} >>%{FORTE_ROOT}/log/mylogfile.log
    Echo "Begin Load Distribution of my application "
    %{FORTE_ROOT}/log/mylogfile.log#Confirm that this is the correct version of Forte.
    SearchFile %{FORTE_ROOT}/install/scripts/FORTE.VER "DEV3.0.L"
    If %{STATUS} != 0
    Echo "Error: Forte version is incompatible for current application."
    Exit
    EndIf
    Theo de Klerk
    Architecture & Application Integration
    Professional Services
    Compaq Computer Corp. - the Netherlands

    I found the answer:
    The variable declarations were not on the same frame as the if/then statements. I solved the problem by adding (for each variable):
    var mywordGrumpy:vocabulary_Grumpy = new vocabulary_Grumpy();
    var mywordIncline:vocabulary_incline = new vocabulary_incline();
    var mywordOodles:vocabulary_oodles  = new vocabulary_oodles();
    This solved the problem! At the time the variables were being called they had not been declared, thus they had no value, thus the error message.

  • Cannot assign an empty string to a parameter with JDBC type VARCHAR

    Hi,
    I am seeing the aforementioned error in the logs. I am guessing its happening whenever I am starting an agent instance in PCo. Can somebody explain whats going on?
    Regards,
    Chanti.
    Heres the complete detail from logs -
    Log Record Details   
    Message: Unable to retreive path for , com.sap.sql.log.OpenSQLException: Failed to set the parameter 1 of the statement >>SELECT ID, PARENTID, FULLPATH, CREATED, CREATEDBY, MODIFIED, MODIFIEDBY, REMOTEPATH, CHECKEDOUTBY FROM XMII_PATHS WHERE FULLPATH =  ?  <<: Cannot assign an empty string to a parameter with JDBC type >>VARCHAR<<.
    Date: 2010-03-12
    Time: 11:32:37:435
    Category: com.sap.xmii.system.FileManager
    Location: com.sap.xmii.system.FileManager
    Application: sap.com/xappsxmiiear

    Sounds like a UI browsing bug (when no path is selected from a catalog tree folder browser) - I would suggest logging a support ticket so that it can be addressed.

  • Problems with string comparison and\or If statement

    Right now I'm trying to make a program that will look into all of my music folders, and rename the .mp3 files to a format i want, based on the id3 tags. The program so far looks in all of the folders I want it to, but I get stuck when I need to check if the files are .mp3 files or not. Here is my code so far:
    package fileRenamer;
    import java.io.File;
    public class FileRenamer {
    public static void main(String[] argv) {
         File artistsFolders = new File("F:/Music (MP3)");
         File[] artists = artistsFolders.listFiles();
         for(int i = 0; i < artists.length; i++){
              if(artists.isFile()) {
                   System.out.println(artists[i].getName());
         } else if (artists[i].isDirectory()) {
              System.out.println(artists[i].getName());
              File albumsFolders = new File("F:/Music (MP3)/"+artists[i].getName());
              File[] albums = albumsFolders.listFiles();
              for(int a = 0; a < albums.length; a++){
                   if(albums[a].isFile()) {
                        System.out.println("-" + albums[a].getName());
                   } else if (albums[a].isDirectory()) {
                        System.out.println("-" + albums[a].getName());
                   File songsFolders = new File("F:/Music (MP3)/"+artists[i].getName()+"/"+albums[a].getName());
                   File[] songs = songsFolders.listFiles();
                   for(int s = 0; s < songs.length; s++){
                        if(songs[s].isFile()) {
                             int dotPos = songs[s].getName().toString().lastIndexOf(".");
                             String extension = songs[s].getName().toString().substring(dotPos);
                             System.out.println(extension);
                             if(extension == ".mp3"){
                                  System.out.println("--" + songs[s].getName());
                   } else if (songs[s].isDirectory()) {
                             System.out.println("--" + songs[s].getName());
    When I test the code, the line System.out.println(extension); prints .mp3 into the console for all of the .mp3 files. Whatever I try, the if(extension == ".mp3") never seems to declare the two equal. If anyone knows what my problem is, I greatly appreciate the advice and help.
    Thanks in Advance,
    James

    Pojo226 wrote:
    I just tried that and it worked perfectly. Thanks.You're welcome.

  • Oracle, Null and empty Strings

    Currently I'm facing problems with a class, which contains a String, which
    is set to "" (empty String).
    When the class is persistent, oracle writes null to the table column
    (which seems to be common oracle behaviour) and when retrieving the class,
    the field is set to null as well, giving me a lot of null-pointer
    exceptions.
    Anyway ... I can cope with that (just a lot of extra work)
    far worse is the problem, wenn searching objects, that have this field set
    to "" oder null.
    Oracle can't find the records because JDO creates Querys "where
    string=null" or "where string=''" , where oracle expects "where string is
    null" to find the records.
    Is there a workaround or solution ?

    Yeah, that would work as well, thx, but since I have to cope with
    null-Strings now everywhere in my program, it doesn't hurt just to forbid
    empty strings on the program side.
    In future times I'll test on Oracle first, then porting to DB/2 - this way
    I suppose work is far less to garant compability.
    Nevertheless ... having to set the bankcode into quotes is a kodo bug in
    my opinion.
    Kodo knows the type of classfields (in this case string) and shouldn't
    send the parameter as a BigDecimal to the database.
    Given that, and having only bankcodes of null (only neccesary when using
    Oracle), the method would look like:
    public Collection getAccounts (String bankCode)
    throws Exception
    return getAccounts (Account.class, "bankcode=="+bankcode);
    which is how a transparent persistent layer, um, should be , um , I mean
    ... just transparent ;-D
    Marc Prud'hommeaux wrote:
    Stefan-
    Couldn't you just do something like:
    public Collection getAccounts (String bankCode)
    throws Exception
    String filter;
    if (bankCode == null || bankCode.length () == 0)
    filter = "(bankCode == null || bankCode == "")";
    else
    filter = "bankCode == "" + bankCode + """;
    return getAccounts (Account.class, filter);
    If I understand the problem correctly, this should work for all the
    databases.
    In article <[email protected]>, Stefan wrote:
    What operations are you performing to cause this SQL to be issued? You
    say you are having trouble removing objects, but this is clearly not a
    DELETE statement. Is this the SQL that is issued when looking up
    objects by identity?I'm not removing objects, I was removing just quotes from parameters ;-)
    A string column... is it also represented as a string field in your class?Yeah ... just to give you an impression of the code:
    First we have a class, representing a bank account:
    public class Account {
    private AccountMgr myAccountMgr;
    private String bankCode;
    private String id;
    Note, that in nearly all cases bankCode will be a number or null.
    I have a second class "AccountMgr", which does all of the persistant stuff
    (seaching, making persistent etc.)
    This class has two methods, one versatile (protected) to retrieve accounts
    by a given filterString and one who just returns accounts by bankCode,
    building the expected filterstring. Here is my current working version:
    public class AccountMgr {
    public Collection getAccounts(String bankCode) throws Exception {
    if (bankCode!=null) {
    if (bankCode.equals("")) {
    throw new Exception("check code, bankCode='' not allowed to get
    same behavior from DB2 and Oracle");
    // if set, quote the bankCode
    bankCode="""+bankCode+""";
    return getAccounts(Account.class,"bankCode=="+bankCode);
    protected Collection getAccounts(Class accountClass, String filterAdd)
    throws Exception {
    PersistenceManager pm = MyHelper.getPersistenceManager();
    String filter="";
    if (filterAdd!=null && !filterAdd.trim().equals("")) {
    filter+=filterAdd + " && ";
    filter += "myAccountMgr==_accMgr";
    Query query = pm.newQuery(accountClass, filter);
    query.declareParameters("AccountMgr _accMgr");
    return (Collection) query.execute(this);
    As you can see, in the first method I have to set the bankCode into
    quotes, when it's not null.
    This is because otherwise a filter like "bankCode=1234" will be translated
    in a way, where 1234 is send as a BigDecimal to the database:
    [...] executing statement <4239745>: (SELECT [...] FROM JDO_ACCOUNT t0
    WHERE t0.BANKCODE = ? : [reused=1;params={(BigDecimal) 1234}]
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • NULL and Empty String

    Hi There,
    As far as I know, Null is not the same as an empty string; however, when I try this out, I get some unexpected results (well, at least unexpected for my liking):
    SQL> CREATE TABLE TS (MID NUMBER,
      2  MDESC VARCHAR2(20) DEFAULT '' NOT NULL);
    Table created.
    SQL> INSERT INTO TS VALUES(1,'');
    INSERT INTO TS VALUES(1,'')
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("TT"."TS"."MDESC")So, according to the above scenario, I can't insert an empty string!! However, an empty string is a valid string that doesn't have tuples/data!!
    How come Oracle translates the null string '' as NULL?
    Thanks

    William Robertson wrote:
    There is a special case to do with CHAR values, whereby '' counts as a string and so gets blank-padded, whereas NULL does not.Are you referring to:
    SQL> DECLARE
      2      flag CHAR(2);
      3      PROCEDURE check_null (p_flag IN CHAR)
      4      IS
      5      BEGIN
      6        IF p_flag = '  '
      7        THEN
      8          dbms_output.put_line ('flag is equal to ''  ''');
      9        ELSIF p_flag IS NULL
    10        THEN
    11          dbms_output.put_line ('flag is null');
    12        ELSE
    13          dbms_output.put_line ('other');
    14        END IF;
    15      END;
    16    BEGIN
    17      flag := '';
    18      check_null (flag);
    19      flag := NULL;
    20      check_null (flag);
    21    end;
    22  /
    flag is equal to '  '
    flag is null
    PL/SQL procedure successfully completed.
    SQL> alter session set events '10932 trace name context forever, level 16384';
    Session altered.
    SQL> DECLARE
      2      flag CHAR(2);
      3      PROCEDURE check_null (p_flag IN CHAR)
      4      IS
      5      BEGIN
      6        IF p_flag = '  '
      7        THEN
      8          dbms_output.put_line ('flag is equal to ''  ''');
      9        ELSIF p_flag IS NULL
    10        THEN
    11          dbms_output.put_line ('flag is null');
    12        ELSE
    13          dbms_output.put_line ('other');
    14        END IF;
    15      END;
    16    BEGIN
    17      flag := '';
    18      check_null (flag);
    19      flag := NULL;
    20      check_null (flag);
    21    end;
    22  /
    flag is null
    flag is null
    PL/SQL procedure successfully completed.
    SQL> SY.
    P.S. Don't ask me why normal (or at least consistent) behavior is not the default.

Maybe you are looking for