Parsing a string to object attribute's

My string will be delimited by tab spaces. I need to parse the contents of the string then assign these to the attributes on an object. The solution I believe would similar to this String to Vector method:
public Vector stringParser(String inString) {
     //Local variables.
     int lastIndex = 0;
     Vector retVector = new Vector();     
     int theCount = 0;
     int indexOf = inString.indexOf( dConstants.DVX_CHAR_SEP );
     //Keep on looping until there are no more DVX_CHAR_SEP
     while( indexOf != -1 && lastIndex != indexOf ){
          retVector.addElement( new String( inString.substring( lastIndex, indexOf - 1 )));
          lastIndex = indexOf;
          indexOf = inString.indexOf( dConstants.DVX_CHAR_SEP, lastIndex + 1 );
     }//while there are DVX_CHAR_SEP's
     //The last bit of string will not be DVX_CHAR_SEP terminated. Grab it now.
     if( indexOf == -1 ){
     //Just in case there weren't any DVX_CHAR_SEP.
     indexOf = 0;
     retVector.addElement( new String( inString.substring( indexOf, inString.length()) ));
     return retVector;
NB. public final char DVX_CHAR_SEP = '\t';

And your question is...?
(By the way, I generally use a StringTokenizer to do exactly that.)

Similar Messages

  • How to parse XML to Java object... please help really stuck

    Thank you for reading this email...
    If I have a **DTD** like:
    <!ELEMENT person (name, age)>
    <!ATTLIST person
         id ID #REQUIRED
    >
    <!ELEMENT name ((family, given) | (given, family))>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT family (#PCDATA)>
    <!ELEMENT given (#PCDATA)>
    the **XML** like:
    <person id="a1">
    <name>
         <family> Yoshi </family>
         <given> Samurai </given>
    </name>
    <age> 21 </age>
    </person>
    **** Could you help me to write a simple parser to parse my DTD and XML to Java object, and how can I use those objects... sorry if the problem is too basic, I am a beginner and very stuck... I am very confuse with SAXParserFactory, SAXParser, ParserAdapter and DOM has its own Factory and Parser, so confuse...
    Thank you for your help, Yo

    Hi, Yo,
    Thank you very much for your help. And I Wish you are there...I'm. And I plan to stay - It's sunny and warm here in Honolulu and the waves are up :)
    A bit more question for dear people:
    In the notes, it's mainly focus on JAXB,
    1. Is that mean JAXB is most popular parser for
    parsing XML into Java object? With me, definitely. There are essentially 3 technologies that allow you to parse XML documents:
    1) "Callbacks" (e.g. SAX in JAXP): You write a class that overrides 3 methods that will be called i) whenever the parser encounters a start tag, ii) an end tag, or iii) PCDATA. Drawback: You have to figure out where the heck in the document hierarchy you are when such a callback happens, because the same method is called on EACH start tag and similarly for the end tag and the PCDATA. You have to create the objects and put them into your own data structure - it's very tedious, but you have complete control. (Well, more or less.)
    2) "Tree" (e.g. DOM in JAXP, or it's better cousin JDOM): You call a parser that in one swoop creates an entire hierarchy that corresponds to the XML document. You don't get called on each tag as with SAX, you just get the root of the resulting tree. Drawback: All the nodes in the tree have the same type! You probably want to know which tags are in the document, don't you? Well, you'll have to traverse the tree and ask each node: What tag do you represent? And what are your attributes? (You get only strings in response even though your attributes often represent numbers.) Unless you want to display the tree - that's a nice application, you can do it as a tree model for JTree -, or otherwise don't care about the individual tags, DOM is not of much help, because you have to keep track where in the tree you are while you traverse it.
    3) Enter JAXB (or Castor, or ...): You give it a grammar of the XML documents you want to parse, or "unmarshall" as the fashion dictates to call it. (Actually the name isn't that bad, because "parsing" focuses on the input text while "unmarshalling" focuses on the objects you get, even though I'd reason that it should be marshalling that converts into objects and unmarshalling that converts objects to something else, and not vice versa but that's just my opinion.) The JAXB compiler creates a bunch of source files each with one (or now more) class(es) (and now interfaces) that correspond to the elements/tags of your grammar. (Now "compiler" is a true jevel of a misnomer, try to explain to students that after they run the "compiler", they still need to compile the sources the "compiler" generated with the real Java compiler!). Ok, you've got these sources compiled. Now you call one single method, unmarshall() and as a result you get the root node of the hierarchy that corresponds to the XML document. Sounds like DOM, but it's much better - the objects in the resulting tree don't have all the same type, but their type depends on the tag they represent. E.g if there is the tag <ball-game> then there will be an object of type myPackage.BallGame in your data structure. It gets better, if there is <score> inside <ball-game> and you have an object ballGame (of type BallGame) that you can simply call ballGame.getScore() and you get an object of type myPackage.Score. In other words, the child tags become properties of the parent object. Even better, the attributes become properties, too, so as far as your program is concerned there is no difference whether the property value was originally a tag or an attribute. On top of that, you can tell in your schema that the property has an int value - or another primitive type (that's like that in 1.0, in the early release you'll have to do it in the additional xjs file). So this is a very natural way to explore the data structure of the XML document. Of course there are drawbacks, but they are minor: daunting complexity and, as a consequence, very steep learning curve, documentation that leaves much to reader's phantasy - read trial and error - (the user's guide is too simplicistic and the examples too primitive, e.g. they don't even tell you how to make a schema where a tag has only attributes) and reference manual that has ~200 pages full of technicalities and you have to look with magnifying glas for the really usefull stuff, huge number of generated classes, some of which you may not need at all (and in 1.0 the number has doubled because each class has an accompanying interface), etc., etc. But overall, all that pales compared to the drastically improved efficiency of the programmer's efforts, i.e. your time. The time you'll spend learning the intricacies is well spent, you'll learn it once and then it will shorten your programming time all the time you use it. It's like C and Java, Java is order of magnitude more complex, but you'd probably never be sorry you gave up C.
    Of course the above essay leaves out lots and lots of detail, but I think that it touches the most important points.
    A word about JAXB 1.0 vs. Early Release (EA) version. If you have time, definitively learn 1.0, they are quite different and the main advantage is that the schema combines all the info that you had to formulate in the DTD and in the xjs file when using the EA version. I suggested EA was because you had a DTD already, but in retrospect, you better start from scratch with 1.0. The concepts in 1.0 are here to stay and once your surmounted the learning curve, you'll be glad that you don't have to switch concepts.
    When parser job is done,
    what kind of Java Object we will get? (String,
    InputStream or ...)See above, typically it's an object whose type is defined as a class (and interface in 1.0) within the sources that JABX generates. Or it can be a String or one of the primitive types - you tell the "compiler" in the schema (xjs file in EA) what you want!
    2. If we want to use JAXB, we have to contain a
    XJS-file? Something like:In EA, yes. In 1.0 no - it's all in the schema.
    I am very new to XML, is there any simpler way to get
    around them? It has already take me 4 days to find a
    simple parser which give it XML and DTD, then return
    to me Java objects ... I mean if that kind of parser
    exists....It'll take you probably magnitude longer that that to get really familiar with JAXB, but believe me it's worth it. You'll save countless days if not weeks once you'll start developing serious software with it. How long did it take you to learn Java and it's main APIs? You'll either invest the time learning how to use the software others have written, or you invest it writing it yourself. I'll take the former any time. But it's only my opinion...
    Jan

  • How to Parse a string into an XML DOM ?

    Hi,
    I want to parse a String into an XML DOM. Not able to locate any parser which supports that. Any pointers to this?

    Download Xerces from xml.apache.org. Place the relevant JAR's on your classpath. Here is sample code to get a DOM document reference.
    - Saish
    public final class DomParser extends Object {
         // Class Variables //
         private static final DocumentBuilder builder;
         private static final String JAXP_SCHEMA_LANGUAGE =
             "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
         /** W3C schema definitions */
         private static final String W3C_XML_SCHEMA =
             "http://www.w3.org/2001/XMLSchema";
         // Constructors //
         static {
              try {
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   factory.setNamespaceAware(true);
                   factory.setValidating(true);
                   factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   builder = factory.newDocumentBuilder();
                   builder.setErrorHandler(new ErrorHandler() {
                       public void warning(SAXParseException e) throws SAXException {
                           System.err.println("[warning] "+e.getMessage());
                       public void error(SAXParseException e) throws SAXException {
                           System.err.println("[error] "+e.getMessage());
                       public void fatalError(SAXParseException e) throws SAXException {
                           System.err.println("[fatal error] "+e.getMessage());
                           throw new XmlParsingError("Fatal validation error", e);
              catch (ParserConfigurationException fatal) {
                   throw new ConfigurationError("Unable to create XML DOM document parser", fatal);
              catch (FactoryConfigurationError fatal) {
                   throw new ConfigurationError("Unable to create XML DOM document factory", fatal);
         private DomParser() {
              super();
         // Public Methods //
         public static final Document newDocument() {
              return builder.newDocument();
         public static final Document parseDocument(final InputStream in) {
              try {
                   return builder.parse(in);
              catch (SAXException e) {
                   throw new XmlParsingError("SAX exception during parsing.  Document is not well-formed or contains " +
                        "illegal characters", e);
              catch (IOException e) {
                   throw new XmlParsingError("Encountered I/O exception during parsing", e);
    }- Saish

  • How to parse a string in CVP 7.0(1). Is there a built-in java class, other?

    Hi,
    I need to parse,in CVP 7.0(1), the BAAccountNumber variable passed by the ICM dialer.  Is there a built-in java class or other function that would help me do this?
    Our BAAccountNumber variable looks something like this: 321|XXX12345678|1901|M. In IP IVR I use the "Get ICM Data" object to read the BAAccountNumber variable from ICM and then I use the "token index" feature to parse the variable (picture below).
    Alternately, IP IVR also has a Java class that allows me to do this; the class is "java.lang.String" and the method is "public int indexOf(String,int)"
    Is there something equivalent in CVP 7.0(1)?
    thanks

    Thanks again for your help.  This is what I ended up doing:
    This configurable action element takes a string seperated by two "|" (123|123456789|12)
    and returns 3 string variables.
    you can add more output variables by adding to the Setting array below.
    // These classes are used by custom configurable elements.
    import com.audium.server.session.ActionElementData;
    import com.audium.server.voiceElement.ActionElementBase;
    import com.audium.server.voiceElement.ElementData;
    import com.audium.server.voiceElement.ElementException;
    import com.audium.server.voiceElement.ElementInterface;
    import com.audium.server.voiceElement.Setting;
    import com.audium.server.xml.ActionElementConfig;
    public class SOMENAMEHERE extends ActionElementBase implements ElementInterface
         * This method is run when the action is visited. From the ActionElementData
         * object, the configuration can be obtained.
        public void doAction(String name, ActionElementData actionData) throws ElementException
            try {
                // Get the configuration
                ActionElementConfig config = actionData.getActionElementConfig();
                //now retrieve each setting value using its 'real' name as defined in the getSettings method above
                //each setting is returned as a String type, but can be converted.
                String input = config.getSettingValue("input",actionData);
                String resultType = config.getSettingValue("resultType",actionData);
                String resultEntityID = config.getSettingValue("resultEntityID",actionData);
                String resultMemberID = config.getSettingValue("resultMemberID",actionData);
                String resultTFNType = config.getSettingValue("resultTFNType",actionData);
                //get the substring
                //String sub = input.substring(startPos,startPos+numChars);
                String[] BAAcctresults = input.split("\\|");
                //Now store the substring into either Element or Session data as requested
                //and store it into the variable name requested by the Studio developer
                if(resultType.equals("Element")){
                    actionData.setElementData(resultEntityID,BAAcctresults[0]);
                    actionData.setElementData(resultMemberID,BAAcctresults[1]);
                    actionData.setElementData(resultTFNType,BAAcctresults[2]);
                } else {
                    actionData.setSessionData(resultEntityID,BAAcctresults[0]);
                    actionData.setSessionData(resultMemberID,BAAcctresults[1]);
                    actionData.setSessionData(resultTFNType,BAAcctresults[2]);
                actionData.setElementData("status","success");
            } catch (Exception e) {
                //If anything goes wrong, create Element data 'status' with the value 'failure'
                //and return an empty string into the variable requested by the caller
                e.printStackTrace();
                actionData.setElementData("status","failure");
        public String getElementName()
            return "MEDDOC PARSER";
        public String getDisplayFolderName()
            return "SSC Custom";
        public String getDescription()
            return "This class breaks down the BAAccountNumber";
        public Setting[] getSettings() throws ElementException
             //You must define the number of settings here
             Setting[] settingArray = new Setting[5];
              //each setting must specify: real name, display name, description,
              //is it required?, can it only appear once?, does it allow substitution?,
              //and the type of entry allowed
            settingArray[0] = new Setting("input", "Original String",
                       "This is the string from which to grab a substring.",
                       true,   // It is required
                       true,   // It appears only once
                       true,   // It allows substitution
                       Setting.STRING);
            settingArray[1] = new Setting("resultType", "Result Type",
                    "Choose where to store result \n" +
                    "into Element or Session data",
                    true,   // It is required
                    true,   // It appears only once
                    false,  // It does NOT allow substitution
                    new String[]{"Element","Session"});//pull-down menu
            settingArray[1].setDefaultValue("Session");
            settingArray[2] = new Setting("resultEntityID", "EntityID",
              "Name of variable to hold the result.",
              true,   // It is required
              true,   // It appears only once
              true,   // It allows substitution
              Setting.STRING);  
            settingArray[2].setDefaultValue("EntityID");
            settingArray[3] = new Setting("resultMemberID", "MemberID",
                    "Name of variable to hold the result.",
                    true,   // It is required
                    true,   // It appears only once
                    true,   // It allows substitution
                    Setting.STRING);  
            settingArray[3].setDefaultValue("MemberID");
            settingArray[4] = new Setting("resultTFNType", "TFNType",
                      "Name of variable to hold the result.",
                      true,   // It is required
                      true,   // It appears only once
                      true,   // It allows substitution
                      Setting.STRING);  
            settingArray[4].setDefaultValue("TFNType");    
    return settingArray;
        public ElementData[] getElementData() throws ElementException
            return null;

  • Parsing a string in a sproc

    I have a Java class that calls a stored proc and passes a stringbuffer object to it. The sproc should parse the string to retrieve the different ids that are concatenated in the stringbuffer and for each id retrieve a row from a table and in the end return a cursor containing the returned rows.Can anyone help me out with the parsing logic for a pipe delimited string.
    Tathagata

    This might help you. If you want to handle the cursor in java, then convert the below into a function which returns the cursor.
    SQL> CREATE TABLE EMP(ENAME VARCHAR2(100),ENO NUMBER(5),DEPT NUMBER(5))
      2  /
    Table created.
    SQL> INSERT INTO EMP VALUES('SCOTT',1,2);
    1 row created.
    SQL> INSERT INTO EMP VALUES('TIGER',2,5);
    1 row created.
    SQL> INSERT INTO EMP VALUES('THOMAS',3,10);
    1 row created.
    SQL> INSERT INTO EMP VALUES('PETER',4,10);
    1 row created.
    SQL> INSERT INTO EMP VALUES('HARRY',7,10);
    1 row created.
    SQL> CREATE OR REPLACE PROCEDURE PARSE_STRING(STR VARCHAR2)
      2  AS
      3  TYPE EmpCurTyp IS REF CURSOR;
      4  emp_cv EmpCurTyp;
      5  STRING VARCHAR2(1000);
      6  type emp_t is table of emp%rowtype;
      7  emp_tab emp_t;
      8  BEGIN
      9  STRING := REPLACE(STR,'|',',');
    10  OPEN emp_cv FOR 'SELECT ENAME,ENO,DEPT FROM EMP WHERE ENO IN('||string||')';
    11  FETCH emp_cv BULK COLLECT INTO EMP_TAB;
    12  CLOSE emp_cv;
    13  FOR I IN 1..EMP_TAB.LAST
    14  LOOP
    15  DBMS_OUTPUT.PUT_LINE(EMP_TAB(I).ENAME);
    16  END LOOP;
    17  EXCEPTION
    18  WHEN OTHERS THEN
    19  DBMS_OUTPUT.PUT_LINE('ERROR OCCURED ' || SQLCODE ||' ' || SQLERRM);
    20  END;
    21  /
    Procedure created.
    SQL> set serveroutput on;
    SQL> BEGIN
      2  PARSE_STRING('1|2|3|4');
      3  END;
      4  /
    SCOTT
    TIGER
    THOMAS
    PETER
    PL/SQL procedure successfully completed.
    SQL>Regards,
    Mohana

  • Purpose of request.setAttribute(String parm1, Object parm2)

    HttpServletRequest request.setAttribute(String parm1, Object parm2) vs. HttpSession session.setAttribute(String parm1, Object parm2)
    hi
    can anybody please explain to me what does HttpServletRequest request.setAttribute() do? and for what purpose is it used for?
    i already know that HttpSession session.setAttribute(String parm1, Object parm2) is used to bind a session to a variable, so that it can be accessed throughout the servlet application.
    thanx
    shankha
    ps: please correct me if i'm wrong

    shankha,
    What does the API doco say?
    I think it just sets a request scoped attribute... ie a request parameter.
    This looks pertinant: http://www.rgagnon.com/javadetails/java-0401.html

  • Access object attributes using other object JNI native method

    Hi. I'm trying to change an attribute of object O1 from another object O2 without invoking a O1 method and without making the attribute as public or protected.
    The only possibility that comes to my mind for doing so is writting a JNI native method
    public class O1 {
    static public native changeAttribute (Object O2, Object newAttributeValue) ;
    that change the attribute memory reference, but all I've found about accesing attributes in JNI is about accessing the invoker attributes (in this case, O1).
    �Does any one know if it's possible to do so? Thanks.

    I know that is not a good practice but I cannot figure out another way.
    I'll try to explain the whole problem so you see the reason. I'm working with transactions, using objects as the data. An object can be opened for write by several transactions because the granularity for conflicts is not the object, is each of its attributes. As long as two transaction don't write the same attribute, they both can write. For writing, each transactions uses a private copy of the object. At committing, the actual copy of the object must be replaced by the committer one, but as far as the granularity is the object attributes, only each written attribute must be replaced (if not, only the last commit would be visible).
    This attribute replace must be done by the transaction manager as far as the transactional object is provided by the client. So what i was thinking was to use JNI or some trick like that to replace the object attributes transparently to the object.
    I hope the explain is clear, my english is a little asleep :-(.
    How to do it with reflection? I thought that was only for method calling. Anyway, there wouldn't be problems if the attributes are private?
    Thanks for answering.
    EDIT: I've been able to change a public field using reflection, but not the private one
    import java.lang.reflect.*;
    class Caca {
    public static void main(String[] args) {
    Integer r = new Integer(0);
    System.out.println("original: " + r.toString());
    modifyWidth(r, 300);
    System.out.println("modified: " + r.toString());
    static void modifyWidth(Integer r, int newValue ) {
    Field valueField; Class c = r.getClass();
    try {
    valueField = c.getField("value");
    valueField.set(r, newValue);
    } catch (Exception e) { System.out.println(e); }
    Message was edited by:
    dfasdfsdafsadfasdf

  • Help regarding parsing the string

    I wanted to display diffrent colored strings in the Textarea which is not possible. But from somewhere I came to know that it is possible by parsing the strings comming frm various sources and then display them with diffrent colors. can anyone help me out regarding this. The format is something like:
    &x100100100This is a colored string!&n
    the &x100100100 means that the text after it should use RGB value of 100,100,100. &n meant that the colors should stop and return to default.
    Well... this makes the client need to parse strings and set colors etc
    Can anyone explain me with some small code without using the swing class. thanks in advance.

    Here is my code I am trying to do...Pls see to it and tell me the mistake....
    import java.net.*;
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    import java.util.*;
    import java.lang.*;
    public class client extends Applet
         //implements KeyListener
              TextArea display;
              //TextField send;
              TextArea send;
              Label status;
              Color color;
              mypanel p1;
              boolean connected=false;
              private Socket sock;
               protected BufferedReader instream;
              private DataOutputStream out;
              private String IP;
              private int port;
              Thread reader;
              private String fontName;
              private int fontSize;
              private String company;
              private String userName;
              private String userID;
              private String compName;
         public void start()
                   String param;
                   String mStr ;
                   IP=getParameter("IP");
                   userID=getParameter("userID");
                   userName=getParameter("userName");
                   fontName=getParameter("fontName");
                   company=getParameter("company");
                   mStr=userID+"#"+userName+"#US#"+company+"#1#A";
                   param=getParameter("fontSize");
                   try{
                        if (param!=null)
                             fontSize=Integer.parseInt(param);
                        else
                             fontSize=0;
                        } catch (NumberFormatException e){
                             fontSize=-1;                    
                   param=getParameter("port");
                   try{
                        if (param!=null)
                             port=Integer.parseInt(param);
                        else
                             port=2;
                        } catch (NumberFormatException e){
                             port=-1;     
                        //display.append(sock.getURL());
                        connect(IP,port,mStr);
         public void init()
                   setBackground(Color.white);
                   //color = new Color(221,240,255);
                   setForeground(Color.black);
                   p1=new mypanel();
                   add(p1);
                   reader = new readMessage(this);
                reader.setPriority(1);
                   //send.addKeyListener(this);
         public void paint(Graphics g){
              String s;
              double p;
              int i;
              //status.setBackground(Color.blue);
              g.setColor(color);
              display.setEditable(false);
              status.setForeground(Color.black);
              display.setBackground(Color.white);
              p1.cmdSend.setBackground(Color.white);
              p1.cmdSend.setForeground(Color.black);
              display.setFont(new Font("Arial", Font.PLAIN, 11));
              //status.setBackground(Color.blue);
              display.setForeground(Color.blue);
         public void connect(String host,int p,String mStr)
               try{
                   sock=new Socket(host,p);
                   instream = new BufferedReader( new InputStreamReader(sock.getInputStream()));
                   out = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
                   out.writeBytes(mStr);
                   connected=true;
                   out.flush();
                   reader.start();
                   setStatus("You are Connected Successfully. ");
                   display.append("Welcome to "+company+" chat . A Customer Support Executive will assist you shortly.\n");
                   catch (UnknownHostException a) {
                             connected=false;
                             p1.cmdSend.setEnabled(false);
                             send.setEditable(false);
                             display.append(company+" live support service fails due to some technical reason.");
                            //status.setText("Intelecorp Live Suport service fails due to some technical reasions.");
                   catch (IOException b) {
                             connected=false;
                             p1.cmdSend.setEnabled(false);
                             send.setEditable(false);
                             display.append(company+" live support service fails due to some technical reason.");
                            //status.setText("Intelecorp Live Suport service fails due to some technical reasions.");
                   catch (SecurityException c ) {
                        connected = false;
                        display.append("Error");
              public void setStatus(String mstr)
                   status.setText(mstr);
              public boolean action (Event e, Object arg)
                   if(e.target instanceof Button)
                        if (e.target==p1.cmdSend)
                             sendMessage(send.getText());
                             send.setText("");
                             return true;
                   return false;
    public boolean keyUp(Event e, int key)
            if(key==Event.ENTER)
                   sendMessage(send.getText());
                  send.setText("");
                   return true;
            return false;
         public void keyPressed(KeyEvent e)
              switch (e.getKeyCode()) {
                   case KeyEvent.VK_ENTER:
                        sendMessage(send.getText());
                        send.setText("");
                        break;
                   default:
                        break;
              return ;
         public void keyReleased(KeyEvent e) {} ;
         public void keyTyped(KeyEvent e) {} ;
         public void sendMessage(String mStr)
                   int mflag;
                   try{
                        mflag=mStr.lastIndexOf('\n');
                        mStr.trim();
                        if ((connected==true) && (mStr.length()>0))
                             if (mflag<0)
                                  mStr=mStr+"\n";
                             display.append(userName+" : "+"&x100100100"+mStr+"!&n");
                             out.writeBytes(mStr);
                             out.flush();
                             send.setText("");
                   }catch (IOException e){
                             connected=false;
                             p1.cmdSend.setEnabled(false);
                             send.setEditable(false);
                             display.append("Unable to send the message, you may be disconnected from the server.");
                             //status.setText("Unable to send the message, you may disconnected from the server.");
    public void destroy(){
              try{
                   sock.close();
                   }catch (IOException e){
                             status.setText(e.toString());
    class readMessage extends Thread{
              client mClient;
              private String mStr;
             public readMessage(client c){
                        super("Client Reader");
                        this.mClient = c;
    public void run()
              mStr=null;
         try{
                        if (connected==true)
                             while(true)
                               mStr = instream.readLine();
                               display.append("&x200200200"+mStr+"!&n"+"\n");
                               //display.setText(display.getText()+"\n"+mStr);
                                    if (mStr==null)
                                  break;
              }catch (IOException e){
                             connected=false;
                             p1.cmdSend.setEnabled(false);
                             send.setEditable(false);
                             display.append("Unable to read the messages, you may be disconnected from the server.");
                             //status.setText("Unable to read the messages, you may disconnected from the server.");
    class mypanel extends Panel 
                   Label l1,l2,l3;
                   Button cmdSend;
                   mypanel()
                        setLayout(new BorderLayout());
                        add("North",display=new TextArea("",12,50,TextArea.SCROLLBARS_VERTICAL_ONLY));
                        add("West",send=new TextArea("",2,50,TextArea.SCROLLBARS_VERTICAL_ONLY));
                        //add("West",send=new TextField());
                        add("East",cmdSend=new Button("  Send  "));
                        add("South",status=new Label(""));
    }

  • Parsing XML Node with href attribute

    Hi,
    I have the following XML that has to be parsed using JSP DOM. All fine except for one. The only problem that i have is when to parsing the Node with href attribute.
    I am using the following method, and it returned with weird result
    currNode.getAttributes() ====> the result is com.sun.org.apache.xerces.internal.dom.AttributeMap@111ae04
    currNode.getNodeValue() ====> the result is null
    currNode.TextNode ===> it returned *2*
    Can anyone please let me know what did I miss here? What should I do to parse the href attribute into the jsp page?
    The below is the xml.
    <MovieList>
    <Movie href="DarkKnight.xml">
       <head>
             <Title>Batman Dark Knight</Title>
             <Genres>
                   <Genre>Action</Genre>
                   <Genre>Sci-Fi</Genre>
             </Genres>
             <Description>Movie Details here</Description>
       </head>
    </Movie>
    </MovieList>Thanks

    I am not sure what "JSP DOM" is exactly. In the W3C DOM supported since SUN Java 1.4 if you have an element node and want to access an attribute value you can simply use String href = movieElement.getAttribute("href"); You might need to cast your Node to Element first e.g.Element movieElement = (Element)currNode;

  • Parsing a string using StringTokenizer

    Hi,
    I want to parse a string such as
    String input = ab{cd}:"abc""de"{
    and the extracted tokens should be as follows
    ab
    cd
    "abc""de"
    As a result, I used the StringTokenizer class with deilmeter {,},:
    StringTokenizer tokenizer = new StringTokenizer(input,"{}:", true);
    In this was, I can separate the tokens and also can get the delimeters. The problem is I don't know how to parse the string that has double quote on it. If a single quote " is taken as a delimeter then
    ", abc, ",", de," all of them will be taken as a separate token. My intention is to get the whole string inside the double quote as a token including the quotes on it. Moreover, if there is any escape character "", it should be also included in the token. Help please.
    Thanks

    A bit of a "sticky tape"-solution...
    import java.util.StringTokenizer;
    public class Test {
        public static void main(String[] args) {
            String input = "ab{cd}:\"abc\"\"de\"";
            StringTokenizer st = new StringTokenizer(input, "{}:", true);
            while(st.hasMoreTokens()) {
            String token = st.nextToken();
            if(token.startsWith("\"") && token.endsWith("\"")) {
            token = token.substring(1,token.length()-1);
                System.out.println(token);
    }

  • How to reference the Parent view Object attribute in Child View object

    Hi , I have the requirememt to generate Tree like struture to display Salary from joining date to retirement date in yearly form.I have writtent two Pl/SQL function to return parent node and child nodes(based on selected year).
    1.First function --> Input paramter (employee id, retirement date , joining date) --> return parent node row with start_date and end_date
    2. 2nd function --> input paarmter(employee id, startDate, end_date) --> return child node based on selected parent node i.e. start date and end date
    I have created two ADF view object based on two function return
    Parent Node --> select * from Table( EUPS.FN_GET_CONTR_SAL_BY_YR(employeeId,retirement Date, dateOf joining)) ;
    Child Node --> select * FROM TABLE( EUPS.FN_GET_CONTR_SAL_FOR_YEAR( employeId,startDate, endDate) ) based on selected parent node.
    I am giving binding variable as input for 2nd function (child node) . I don't know how to reference the binding variable value in child view from parent view.
    Like I have to refernce employeId,startDate, endDate values in 2nd function from parent view object. some thing like parentNode.selectedStart_date parentNode.employeeId.
    I know we can achive this writing the code in backing bean.But i want to know how can we refernce parent view object attribute values in child view object using Groovy or otherway?
    I will appreciate your help.
    Thanks

    I have two view com.ContractualSalaryByYearlyView for Parent Node and com.ContractualSalaryByYearlyView for child Node.
    I have created view link(ContractualSalYearlyByYearViewLink) betweem two view by giving common field empId, stDate , endDate.(below is the view link xml file).
    I tried give the binding attribute values using parent object reference like below in com.ContractualSalaryByYearlyView xml file but getting error
    Variable ContractualSalaryByYearlyView not recognized.I think i am using groovy expression.
    Thanks for quick response.
    com.ContractualSalaryByYearlyView xml
    <ViewObject
    <DesignTime>
    <Attr Name="_isExpertMode" Value="true"/>
    </DesignTime>
    <Variable
    Name="empId"
    Kind="where"
    Type="java.lang.Integer">
    <TransientExpression><![CDATA[adf.object.ContractualSalaryByYearlyView.EmpId]]></TransientExpression>
    </Variable>
    ContractualSalYearlyByYearViewLink.xml file
    <ViewLinkDefEnd
    Name="ContractualSalaryByYearlyView"
    Cardinality="1"
    Owner="com.ContractualSalaryByYearlyView"
    Source="true">
    <DesignTime>
    <Attr Name="_finderName" Value="ContractualSalaryByYearlyView"/>
    <Attr Name="_isUpdateable" Value="true"/>
    </DesignTime>
    <AttrArray Name="Attributes">
    <Item
    Value="com.ContractualSalaryByYearlyView.EmpId"/>
    <Item
    Value="com.ContractualSalaryByYearlyView.StDate"/>
    <Item
    Value="com.ContractualSalaryByYearlyView.EndDate"/>
    </AttrArray>
    </ViewLinkDefEnd>
    <ViewLinkDefEnd
    Name="ContractualSalaryForYearView"
    Cardinality="-1"
    Owner="com.ContractualSalaryForYearView">
    <DesignTime>
    <Attr Name="_finderName" Value="ContractualSalaryForYearView"/>
    <Attr Name="_isUpdateable" Value="true"/>
    </DesignTime>
    <AttrArray Name="Attributes">
    <Item
    Value="com.ContractualSalaryForYearView.EmpId"/>
    <Item
    Value="com.ContractualSalaryForYearView.StDate"/>
    <Item
    Value="com.ContractualSalaryForYearView.EndDate"/>
    </AttrArray>
    </ViewLinkDefEnd>

  • Caused by: oracle.xml.parser.v2.XMLParseException: '=' missing in attribute

    This is a Bursting problem under EBS 5.6.3. In production we have 5.6.2 and since our development system to 5.6.3 has been upgraded, the following error occurs on every single Burst being done using the Concurrent Manager only:
    Caused by: oracle.xml.parser.v2.XMLParseException: '=' missing in attribute.
         at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:205)
         at oracle.xml.parser.v2.NonValidatingParser.parseAttrValue(NonValidatingParser.java:1502)
         at oracle.xml.parser.v2.NonValidatingParser.parseAttr(NonValidatingParser.java:1408)
         at oracle.xml.parser.v2.NonValidatingParser.parseAttributes(NonValidatingParser.java:1350)
         at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1180)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:301)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:201)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.burstingConfigParser(BurstingProcessorEngine.java:1340)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.process(BurstingProcessorEngine.java:1297)
         at oracle.apps.xdo.batch.DocumentProcessor.process(DocumentProcessor.java:213)
         at xxwel.ebs.xmlp.XXWELBurster.processDocuments(XXWELBurster.java:143)
    I can run the same file through 5.6.3 ($JAVA_TOP) libraries mounted on my JDev with no problems. Also the same XML file runs fine on Production under 5.6.2 - no problems. I have also checked the XML file using a syntax checker. I know this is not a syntax issue even though it looks like it.
    Could someone point me in the right direction - explain what this means. Getting desperate as 5.6.3 will be going into production soon and all Bursting will fail with this error. I can't get the simplest XML File to Burst - NOTE this is only occurring on the EBS system (even running without the CM ie. a standalone java main it fails). I think this has something to do with the XML parser version and the EBS environment.
    Please help...

    Hi Tim, good thinking - wouldn't have thought to check this file. Anyway can confirm that the problem is happening with multiple burst control files so I haven't checked the files themselves as the problem seems systemic. anyway here is an example.
    <?xml version="1.0" encoding="UTF-8"?>
    <xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi">
    <xapi:request select="/XXWEL_BIP_UNI_INVOICES/LIST_G_CUSTOMER_NUMBER/G_CUSTOMER_NUMBER">
    <xapi:delivery>
    <xapi:email server="mailwa01" port="25"
    from="${ADMIN_EMAIL}" reply-to ="${ADMIN_EMAIL}">
    <xapi:message id="111" to="${ADMIN_EMAIL}" attachment="true" subject="Unigas Inv
    oice No: ${TRX_NUMBER}">
    </xapi:message>
    </xapi:email>
    </xapi:delivery>
    <xapi:document output-type="pdf" delivery="111">
    <xapi:template type="rtf" location="/u02/prod/prodappl/wel/11.5.0/interface/bip/templates/uni_invoice_template.rtf">
    </xapi:template>
    </xapi:document>
    </xapi:request>
    </xapi:requestset>
    I will start stripping the control files to make sure they are not the problem in the meantime.

  • Problem to access the object attribute in a code

    Hi guys,
    I need to pass the attribute of a business object to class.Below is the code but its throwing an error 'There is no component ZYBTT in l_bus2000116'.Since the business object conatins the attribute but its throwing an error.Could any one throw some light on the below code -
    data: l_BUS2000116 type swc_object,
          Z_BRF_Function_name TYPE FDT_UUID.
    swc_get_element ac_container 'Z_Quotation' l_BUS2000116.
    swc_get_element ac_container 'Z_BRF_Function_name' Z_BRF_Function_name.
    CALL METHOD ZYCLOTO_AGENTDTMT_BRF=>ZYOTOM_GET_AGENT_IDS_SING_LEV
      EXPORTING
        IM_FUNCTION_ID  = Z_BRF_Function_name
        IM_BTT          = l_BUS2000116-ZYBTT
       IM_COMPL_CAT    =
       IM_COUNTRY_CODE = ZYCOUNTRY
        IM_LEAD_BRAND   = l_BUS2000116-leadbrand
        IM_RISK_LEVEL   = l_BUS2000116-ZYRISKLEVEL
        IM_SALES_ORG    = l_BUS2000116-ZYsalesorg
        IM_TCV          = l_BUS2000116-ZYTCV.
    IMPORTING
       EX_FULL_NAME    =
       EX_RETURN       =

    Hi,
    Is ZYBTT a new attribute? Have you changed the status of the attribute to implemented or released (in SWO1: Edit -> Change release status)?
    And actually I think that your syntax is wrong too (BOR world is different compared to classes). If you want to use an attribute, I think that the syntax should be something like this:
    SWC_GET_PROPERTY <Object> <Attribute> <AttributeValue>.
    Read more here:
    http://help.sap.com/saphelp_nw04/helpdata/en/c5/e4acef453d11d189430000e829fbbd/content.htm
    Regards,
    Karri

  • Parsing formatted String to Int

    How can I parse formatted string to Integer ?
    I have a formated string like this $900,000 and I need to convert it to 900000 so I could do calculations with it.
    I tried something like this
    NumberFormat nf = NumberFormat.getIntegerInstance(request.getLocale());
    ttlMargin=nf.parse(screenVal);I got this exception
    "java.lang.NumberFormatException: For input string: "$1,050,000""

    I am working on the JSP file that provides
    margins,sales etc. I am reading this data off the
    screen where it is beeing displayed according to the
    accounting practices.
    That's why I get it as a formatted string and why I
    am trying covert that string to the numberScreen-scraping is a problematic, bad design. It sounds like what you really want is to call a web service which returns its results as data that a program can understand (XML, for example), not HTML (which is meant more for humans to read). I know, you probably can't change the design at this point... just food for thought. In the meantime, you'll probably have to manually parse those strings yourself by stripping out the '$' and ',' characters and then use parseInt on the result.

  • How to parse a string containing xml data

    Hi,
    Is it possible to parse a string containing xml data into a array list?
    my string contains xml data as <blood_group>
         <choice id ='1' value='A +ve'/>
         <choice id ='2' value='B +ve'/>
             <choice id ='3' value='O +ve'/>
    </blood_group>how can i get "value" into array list?

    There are lot of Java XML parsing API's available, e.g. JAXP, DOM4J, JXPath, etc.
    Of course you can also write it yourself. Look which methods the String API offers you, e.g. substring and *indexOf.                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • How to Get Rid of Update Option on an App, iPhone, iPad etc...

    Dear Apple, I understand this is not possible, yet! Please fix this one annoying oversight/bug you have had for ever. The option to "Update All" is great but it's useless if you have one or more apps that you don't want to update. Not everyone wants

  • Preview no longer imports pdfs into each other.

    Last year I could add pdf documents together in Preview to make a compilation that was much easier to print in booklet form as it avoided blank pages. Some time this year the behaviour changed, and now when I drag one open pdf onto the window of anot

  • How to create a list with customised listItem

    I want to create a list with 2 icons and text. I want to display one icon at the left, one icon to the right and text at center. Everytime my icon images might change. I want to know how create this type of list.

  • Errors in Data Collection

    Hi All, I have 2 Exceptions in the Early Watch Report under Service Preparation Section which are : Errors in Data Collection Function Name - Exception DB6_TABLE_MAX_GROWTH_NEW - NO_HISTORY_FOUND DB6_TABLE_MAX_SIZE_NEW---- NO_HISTORY_FOUND I don't kn

  • IPhoto missing events

    I am using OS X Lion and the latest version of iPhoto.  Last night I imported about 100 images and created an event.  I then synched my iPhone and all the images were on the phone. All was well. Today I again importeed a couple of images and I notice