How to find out what a string contains?

I'm in the process of writing an XML parser for a project that I am working on. There will be one field in the XML that can be used to store an int, a date, or a string. I need to figure out a way to determine if that field contains an int, a date, or a string without modifying the XML at all. Meaning I can't just put an indicator in the XML itself. So given the string of data from the xml, how do I figure out what it is so that I can convert it to that type?
Any help would be appreciated as I don't have much time left to work on this.

How are you going to be able to tell?
There will be one field
in the XML that can be used to store an int, a date,
or a string. "20010101" fits all three. In the absence of any other information, there's no way to tell what the sender meant the type to be.
Now, if you assume some formatting information, then you have a chance. Let's say that "dates" MUST be in the format "YYYY-mm-dd hh:MM:ss". Use SimpleDateFormat and Calendar and try to parse the string. If it works - it's a Date.
If it doesn't work - try to parse it as an Integer. If it works - it's an int.
If THAT doesn't work - give up and just use the String.
Does that help?
Grant

Similar Messages

  • How to find out whether the String contains chinese characters

    I need to check if the string contains chinese characters in Java. Does anyone know how to do it? thx.

    Since Java strings contain UNICODE code points, check the content against the relevant page here - http://www.unicode.org/charts/ .

  • How to find out if a string is all alphabets

    Hi,
    How can I find out if a string contains all alphabets? Please help. Thanks.

    Hi,
    How can I find out if a string contains all
    all alphabets? Please help. Thanks. I am not sure if there's easier way. But this code should do what you want:
    boolean bAlpha = true;
    for (int i=0; i<str.length; i++)
    if (!Character.isLetter(str.charAt(i))){
    bAlpha = false;
    break;
    //bAlpha is true if str contains only alphabets.

  • How to find out what user locked account

    We had production type schema account locked this morning. I checked profile which this user belongs and it has 3 times for Failed Login Attempts. My question is how to find out what user had 3 unsuccessful login attempts and lock this account.
    Oracle version 8.1.7

    Assuming that [auditing was enabled|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/security.htm#sthref2916], the command
    AUDIT CONNECT WHENEVER NOT SUCCESSFULThat will write audit records when there is an unsuccessful login. Depending on how you've configured auditing, those records will either be written to the SYS.AUD$ table, in which case you can query them through a few different views, or to a file on the operating system that you can grep.
    Justin

  • "Web'n'Walk III" Huawei dongle, how to find out what Huawei model it is?

    I just bought this "web 'n' walk III" UMTS Modem (USB) made by Huawei. I want to instal it but do not know if the enclosed software is out of date (MobileConnectDriver(2.9.2)) and works under SL. Does anybody know how I find out what type of Huawei dangle it is so I can find the correct software?
    any tips as to how to use this smoothly as the stick is to SIM locked and I will use it with a SIM from an other provider (Stick is branded by T-Mobile).

    I worked out the model number, it is 'hidden' in small print on the back, in a larger number.

  • How to find out what is the lock key for the computer

    How to find out what is the lock key for the computer?

    You don't.
    If you forgot or lost the password, all you can practically do is reset it.
    The manner in which you do so depends on what version of OS X you are running. The older versions utilize the reset password utility on your recovery/re-installation disk/drive.
    On Lion, you use the following technique to reset the Administrators password:
    Boot to your Lion Recovery Partition, by holding down the Option key while starting, and then selecting the Recovery HD as the boot choice.
    Once booted, at the top of the screen is a menu ..., select Utilities / Terminal from the menu bar.
    In the Terminal window, type “resetpassword” (without the quotes) and press return. A “Reset Password” window will open. Select your boot volume (your SSD drive) if it is not already selected. Select your administrators username from the menu labeled “Select the user account” if it is not already selected. Follow the prompts to reset the password. Restart the computer from the apple menu.

  • How to find out what has been restored to a database instance?

    I'm using RMAN to back up and restore/recover. How to find out what has been restored/recovered to a database instance?
    Oracle version is 11gR2 but compatibility is set to 10.
    Edited by: 881656 on Aug 28, 2012 1:54 AM

    select output
    from V$rman_output
    order by stamp;
    select *
    from V$rman_status
    order by start_time desc;
    Regards
    Asif Kabir
    Handle:      881656
    Status Level:      Newbie
    Registered:      Aug 25, 2011
    Total Posts:      52
    Total Questions:      *30 (30 unresolved)*
    -- please close all the answered threads and mark your helpful post as correct/helpful

  • How to find out what generation my Classic is ?

    Can anyone advise me how I find out what generation my iPod Classic is ? Is there a website I can check with ?
    Many thanks,
    Shell

    Hi Niel, the article I get directed to, doesn't really explain the difference between 6th and 7th generation Classics. Is there anywhere (maybe on the Apple website) I can input the Serial Number and Part Number to be exact ?

  • How to find out what Oracle version?

    Hi,
    Could anyone tell me how to find out what Oracle version is on your AIX/Unix machine? It looks like Oracle Installer doesn't use the native OS installation(installp,pkgadd) process, so I can't use lslpp/pkginfo to find out what filesets are installed.
    Thanks
    HQ.

    Hi!
    As far ar Oracle version is concerned, you can find it at the database level after connecting to the database
    select * from v$version;
    i am not sure if there is someway to find at the o/s level.
    Good luck
    null

  • How to find out what are all the change pointers assoicated for an idoc ??

    Hi ,
    How to find out what are all the change pointers activated for an idoc ??
    Thanks,
    Varma

    Verma,
    You can check what are the active Change Pointers for the message type in tcode <b>BD50</b>
    Use tcode <b>BD61</b> to check whether change pointers are active or not??
    Hope this helps..

  • How to find out what the geniric short forms stand for?

    Hi if you see the ThreadLocal class in jdk1.6 it is written like this in doc. ThreadLocal<T> and if you see the method Class.forName() the return type is Class<?> i am just confused a littele bit. how to find out what this <T> and <?> stands for? I mean how do i know that what to pass in their place?

    [Start from Here|http://java.sun.com/docs/books/tutorial/extra/generics/index.html]

  • How to find out what option you got

    How to find out what option you got because i changed my option from option 1 to option 3 and they said that it will change 31st and i want to find out if it changed how do i do that?

    Log on to bt.yahoo.com, and look under the "My Account" section. It tells you what package you're on.

  • How to find out what network an iphone is locked to.

    How to find out what network an iphone is locked to.
    Assist.

    The previous owner/seller didn't provide this info?
    What does it say at Settings > General > About > Carrier?

  • How to find out what version of iTune and iPhoto I have?

    How to find out what version of iTune and iPhoto I have?

    For each application, launch it and choose About from that application's menu, or control-click its Dock icon, choose Show in Finder, control-click that, and choose Get Info.
    (76257)

  • How do find out what your network password is if you forgot it?

    How do find out what your network password is if you forgot it?

    It should be in your Keychain. Find it in Keychain Access.

Maybe you are looking for

  • Whose the smartest can figure this brain teaser of AS 3.0 problem?

    Spent all afternoon trying to figure out the following AS 3.0 problem in Flash CS4.  I can load an image using a custom class (called "BitmapExample") inside a unnamed package by placing the class name in Class field in the Properties panel inside of

  • PhoneGap Dreamweaver CS5.5 Android App Fail

    I am attempting the to create an Android app using Dreamweaver CS 5.5 and PhoneGap. The build always fails with the following message at the end of the error log: -dex:      [echo] Converting compiled files and external libraries into C:\Users\ROG\De

  • When I send e-mails sometimes they do not appear in my sent items?

    I send many e-mails but sometimes they do not appear in my sent items yet i know they have gone because I get a reply? It isn't all - just some?

  • Cost Center description in FB50 Transaction

    Dear All, We have requirement that in Transaction FB50 we need the Description of the cost center also similar to that of GL account. While any GL is entered the Short text of the GL is automatically displayed. Please help. Thanks. Sunil.

  • To_date function from dual

    Hi All, i have issued SELECT TO_DATE('07:19:47', 'HH:MI:SS') FROM DUAL in toad, and got the below output. 11/1/2007 7:19:47 AM Even sqlplus returns TO_DATE(' 01-NOV-07 Can anyone explain why this wont show sysdate? thanks