Writing parsers in java

when do we use
: after { braces while writing code in java i.e
a format like {:                                                                                                                                                                           

I also created a simulator for a machine. It is quite simpler than yours, but I built it in an object-oriented way, using polimorphism (that is, without using switch logic or similar stuff derived from C language). Although there are many classes, the source code is very small. Most of the classes have aprox. 10 lines of code, representing the execution of instructions.
Unfortunately, my Java source code is written in Portuguese. If you are interested, post a new reply. I also want suggestions to make it even better.
Good luck!
Antonielly

Similar Messages

  • Please ..give me some example APDU for writing data to java card

    morning everybody .. :)
    I need some example APDUs for writing data to java card. (CLA || INS || P1 || P2 etc)..
    please..thank for your attention .. god blessing u.

    Hi,
    did you check some articles about JavaCards:
    [Understanding Java Card 2.0|http://www.javaworld.com/cgi-bin/mailto/x_java.cgi?pagetosend=/export/home/httpd/javaworld/javaworld/jw-03-1998/jw-03-javadev.html&pagename=/javaworld/jw-03-1998/jw-03-javadev.html&pageurl=http://www.javaworld.com/javaworld/jw-03-1998/jw-03-javadev.html&site=jw_core]
    [How to write a Java Card applet: A developer's guide|http://www.javaworld.com/cgi-bin/mailto/x_java.cgi?pagetosend=/export/home/httpd/javaworld/javaworld/jw-07-1999/jw-07-javacard.html&pagename=/javaworld/jw-07-1999/jw-07-javacard.html&pageurl=http://www.javaworld.com/javaworld/jw-07-1999/jw-07-javacard.html&site=jw_core]
    Hope it helps,
    Tex

  • Writing data from Java to Excel

    Hi,
    I am trying to writhe data from Java to an Excel Sheet by using JACOB.
    This is my code :
    import java.util.*;
    import java.io.*;
    //import cost.util.*;
    import com.jacob.com.*;
    import com.jacob.activeX.*;
    class XLStock
         public static void main(String argv[])
              XLStock xls = new XLStock();
              xls.main2(argv);
         public void main2(String argv[])
              System.setSecurityManager(null);
              System.runFinalizersOnExit(true);
              Vector v = new Vector();
              XLSPutItem pi;
              String sheetfile = null;
              ActiveXComponent xl;
              Object xlo=null;
              Object workbooks;
              Object workbook;
              Object sheets;
              Variant vOptn = new Variant();
              vOptn.noParam();
              try
                   xl = new ActiveXComponent("Excel.Application");
                   xlo = xl.getObject();
                   Dispatch.put(xlo, "Visible", new Variant(true));
                   xl.setProperty("Visible", new Variant(true));
                   workbooks = xl.getProperty("Workbooks").toDispatch();
                   Variant vTemp = new Variant(argv[0]);
                   workbook = Dispatch.invoke(workbooks, "Open", Dispatch.Method,
                        new Variant[] {vTemp, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn},
                        new int[1]).toDispatch();
                   sheets = Dispatch.get(workbook,"Sheets").toDispatch();
                   pi = new XLSPutItem();
                   if (pi.Parse("1:A1;ciao;6"))
                        v.addElement(pi);
                   for (int i=0; i<v.size(); i++)
                        pi = (XLSPutItem)v.elementAt(i);
                        pi.sheet = Dispatch.invoke(sheets, "Item", Dispatch.Get, new Object[] {new Variant(pi.sheetNumber)}, new int[1]).toDispatch();
                        pi.cell = Dispatch.invoke(pi.sheet, "Range", Dispatch.Get, new Object[] {pi.cellName}, new int[1]).toDispatch();
              catch (Exception e)
                   e.printStackTrace();
              pi = (XLSPutItem)v.firstElement();
              Dispatch.put(pi.cell, "Value", "ciao");
    What happen is that my code always fail at this line :
    xl = new ActiveXComponent("Excel.Application");
    whit this error :
    C:\VJWorks\JNI\jxls>java jxls.XLStock
    com.jacob.com.ComFailException: Can't co-create object
    at com.jacob.com.Dispatch.createInstance(Native Method)
    at com.jacob.com.Dispatch.<init>(Dispatch.java)
    at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java)
    at jxls.XLStock.main2(XLStock.java:53)
    at jxls.XLStock.main(XLStock.java:28)
    Exception in thread "main" java.util.NoSuchElementException
    at java.util.Vector.firstElement(Vector.java:450)
    at jxls.XLStock.main2(XLStock.java:79)
    at jxls.XLStock.main(XLStock.java:28)
    I task that something is wrong in my system configuration.
    I work on a Win2000 platform and Office 97.
    Someone knows the reason of this error and can suggest what to make.
    Thanks in advance.
    Antonio M.

    Antonio, maybe you can post this back to the Jacob list. As an alternative to Jacob, what about Apache POI or writing the data as comma-delimited and opening the file using Runtime?
    Hope that may help.
    Good luck.

  • Writing functions in Java

    Hi there,
    I'm pretty much a newbie to Java, but have had some experience with C++. I've been trying to write functions to use within the main class but they don't seem to work properly, although I have kinda found a solution, I just don't know if it's the right solution.
    example
    public class test
    static int ival;
    public static void init(void)
    ival = 55;
    public static void show(void)
    System.out.println(ival);
    public static void main(String []args)
    test.ival();
    test.show();
    }not sure if that should work as I am writing it off the top of my head. The thing is I need to create a modular program that doesn't use other objects in it (otherwise I would just define them and use the member functions of the class definition to do the work that I need done). In terms of C++, the code I'm used to writing is more like this:
    #include <iostream>
    // prototypes
    void init(void);
    void display(void);
    // main program
    void main(void)
    int var1;
    init();
    display();
    // function definitions
    void init(void)
    var1 = 55;
    void display(void)
    cout<<var1<<endl;
    }Then again, now that I look at the code, I don't know if the C++ code will work properly (*sigh*)... And people wonder why I prefer using PHP - no complications...
    So if anyone can help clarify this for me, I would greatly appreciate it.
    Many thanks,
    Garatheus

    There really isn't a "main class" in Java (and I don't recall C++ enough to compare); there's just classes potentially with main methods, which can be the starting point for execution as invoked by the JVM.
    Also IIRC Java's OOP model is cleaner than C++'s -- to the point which you don't have standalone functions, just methods within a class.
    Although maybe I shouldn't be posting here, as I've spent the last few years trying to forget C++.

  • XML parsers in JAVA

    Hi all,
    I need to parse XML files in JAVA. Is there any specific package in java for XML parsing?

    Example for using DOM :
    import java.io.File;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    // using DOM
    public class ParseXML_Dom {
        public static void main(String[] args) {
            File file = new File("test.xml");
            try {
                DocumentBuilder builder =
                        DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document doc = builder.parse(file);
                NodeList nodes = doc.getElementsByTagName("topic");
                for (int i = 0; i < nodes.getLength(); i++) {
                    Element element = (Element) nodes.item(i);
                    NodeList title = element.getElementsByTagName("title");
                    Element line = (Element) title.item(0);
                    System.out.println("Title: " + getCharacterDataFromElement(line));
                    NodeList url = element.getElementsByTagName("url");
                    line = (Element) url.item(0);
                    System.out.println("Url: " + getCharacterDataFromElement(line));
            } catch (Exception e) {
                e.printStackTrace();
         The file "text.xml" might contain this :
    <?xml version="1.0"?>
    <howto>
      <topic>
          <title>Searching</title>
          <url>http://www.google.com</url>
      </topic>
        <topic>
          <title>Masturbation</title>
          <url>http://www.jackinworld.com</url>
      </topic>
          <topic>
            <title>Shopping</title>
            <url>http://www.amazon.com</url>
      </topic>
          <topic>
            <title>Sound</title>
            <url>http://www.dailywav.com</url>
      </topic>
    </howto>
        public static String getCharacterDataFromElement(Element e) {
            Node child = e.getFirstChild();
            if (child instanceof CharacterData) {
                CharacterData cd = (CharacterData) child;
                return cd.getData();
            return "?";
    }

  • Some advice for this newbie please ... writing Network in Java

    K, i'm new to Java, and i've hardly done much Object-oriented coding but I have the basic concepts. University modules too focused on C, Visual Basic programming. =o( Currently, on Internship, I've been tasked to write Mobitex Network in Java, poll-driven. Have spent 3 weeks breathing Java =P, camping in Java Developer Connection too. =o) (enjoyed the exchange of ideas especially the post on "Java sucks")
    My questions are:
    1) Does Java have an indexed library like MSDN for VB? or is there any other way i can search for
    method names, their uses and the syntax? (the case-sensitivity of Java had me crazily
    debugging a simple test application) The lists of libraries available eg java.lang.string.*.
    2) Is there a help somewhere where i can check what my errors are referring to? I'm using
    JDK1.3.1_02 and Forte for Java, Community Edition version 3 for my IDE.
    3) I have plans to design simple user-interface, one that would probably look dos-like but with
    some buttons and forms coz the network has lots of functionalities that involve loop-back tests,
    choice of sending data, control or information frames. Duration to complete this project is 2
    months. Please suggest the best approach I should tackle this assignment and perhaps the
    links and softwares you'd recommend.
    ps: i chose this project over the rest to specifically learn Java. I knew the learning curve is steep but I seriously do want to get to know Java better, like a friend. And I'm looking forward to the sense of satisfaction awarded when I complete the application program. Thanks for your patience and words of advice. =)

    oh, ok then... I assume, then, that you have access to the C and/or C++ code.
    Is the C++ code written in "good" OOD style? Or is it C wrapped in some C++ syntax? If it's OO, without multiple inheritance, then you just have some porting to do. Painful, but not as bad as writing a Mobitex implementation on your own.
    Of course, timing is everything in this environment; depending on your platform (J2ME, I'd guess), you're gonna have to worry about meeting real-time-ish committments...
    I'd concentrate on getting the Mobitex functionality solid first. I'd assume that there are (some?) reference applications that have been created against the C & C++ implementations. Port those, or use those as inspiration for your own (little!) app...
    Larry

  • Is there any way to format a text file while writing it in java ?

    Heyya Fellas,
    I am working on a project and at the end of the process, the project should generate a report file in .txt format in the location prescribed by user. I am able to generate it and do all the processing but can i the report in a more presentable way. Like is there any method in java code so that we can make the text in the report file appear bold or italic while writing a file in java in runtime?
    Please help me.. any gist or click will be a favor.
    Thanks and Cheers
    Phoenix

    masijade. wrote:
    Text is text, nothing more, nothing less. Any "effects" to the text (i.e. bold, italic, underlined, striked, whatever) can only be acheived through some type of markup (i.e. html markup or rtf/pdf formats and the like). The text itself can never be bold or italic.
    If you are producing csv, then html style markup is a definate candidate, if you are producing reports than look into iText for creating pdf documents.I beleive dats it..
    Actually i am hitting a JSP's URL and it inturn calls a servlet and then the process takes place..
    and i generate the specified output file..
    The files are generated and every thig is working fine but i wanted to add that extra bit of a gloss to report.
    Well thanks for the response.

  • Need help in writing a small java code

    Hi,
    I have a small requirement where I need write a small java code. I am thinking of using array. Please suggest if you know the solution:
    1. Need to compare user logon id is preset in the lookup table or not.
    2. If user id present in the lookup then send type "A" mail
    3. If user id in not present in the lookup then send type "B" email.
    Please suggest.
    Thanks,
    Kalpana.

    use this code . you have to pass userlogin and lookup name
    Public String GetEmail(String UserLogin,String lookupcode)
    String email;
    try{
    tcLookupOperationIntf lookupIntf = Platform.getService(tcLookupOperationIntf.class);
    HashMap<String, String> lookupValues = getLookupHashMap(lookupIntf, lookupCode);
    String found = lookupValues.get(UserLogin);
    if (found!=null) email= "EMAIL A";
    else
    email= "EMAIL B";
    }catch(Exception e){}
    return email;
    private HashMap<String, String> getLookupHashMap(tcLookupOperationsIntf lookupOperationsIntf, String lookupCode)throws tcAPIException,tcInvalidLookupException,tcColumnNotFoundException {
    HashMap<String, String> lookupMap = new HashMap<String, String>();
              tcResultSet resultLookupHashMap = lookupOperationsIntf
                        .getLookupValues(lookupCode);
              int countResultLookupHashMap = resultLookupHashMap.getRowCount();
    if (countResultLookupHashMap > 0) {
                   for (int i = 0; i < countResultLookupHashMap; i++) {
                        resultLookupHashMap.goToRow(i);
                        lookupMap.put(resultLookupHashMap..getStringValue("Lookup Definition.Lookup Code Information.Code Key"),
    resultLookupHashMap.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
    return lookupMap;
    }

  • Writing Urdu in java swing component

    Hi firiends,
    I am searching out how to write urdu as input in java swing JTextField. I have searched a lot but still i am unable to get right information. So plz guys help me how i do use urdu on java swing JTextField. i will be higly thankful to you..
    i am waiting your good reponses .
    THANKS
    Sahibzada

    This forum is exclusively for Sun Java Studio Creator. Please post your queries on appropriate forums to have better discussions :
    e.g.
    Swing Forum :
    http://forum.java.sun.com/forum.jspa?forumID=57
    Here are some helpful URLs :
    How to Use Text Areas
    http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html
    http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html#contents

  • Writing Programs with java in 10.3.9

    So, I'm trying to teach myself the basics of Java. Here's what I did:
    I went to the apple website and poked around until I found what I THOUGHT was the right download. (JavaForMacOSX10.3Update5.pkg). This SEEMS to have created a Java folder (Applications/Utilities/Java) However I can't confirm that it wasn't there before I downloaded and ran the JavaForMacOSX10.3Update5.pkg. Inside this folder are four applications (Applet Launcher, Input Method HotKey and two other PlugIns).
    After reading a bunch of stuff about Java it seemed like I needed to be working with the Terminal Application in order to do command line stuff. I wrote a little program in TextEditor, saved it as "HelloApp.java" (like the book told me to) and then went to Terminal to try to compile it.
    When I open Terminal, here's what I see:
    Last login: Tue Jun 10 19:29:19 on ttyp1
    Welcome to Darwin!
    [Peter-Booths-Computer:~] peterboo%
    I typed in <javac HelloApp.java> and here's what I got back:
    error: cannot read: HelloApp.java
    1 error
    [Peter-Booths-Computer:~] peterboo%
    Sooo... my questions:
    How do I tell the computer through command line entries exactly WHERE my HelloApp.java file is? On a PC, they do something like cd C:/ to change directories to the location where the file is saved. Is there an equivalent command on a Mac?
    I'm not even sure that I've got the Java JDK or JSE or whatever the heck it's called on my computer. Can someone tell me how to figure that out?
    Is there a slicker way to compile, run etc. code with Java beside command line stuff in Terminal?
    Thanks a TON to anyone who can help me.
    Peter Booth
    Message was edited by: Peter Booth1

    Specify the path in the Terminal; a path will look like ~/Desktop/HelloApp.java if the item is on your desktop; when starting a path, ~ refers to your home folder, while / refers to the top level of the drive. Using 'cd' followed by a path will take you to that location from your current folder unless the path starts with a ~ or /, which work as above.
    A path which starts with ../ refers to the folder enclosing the one you're currently looking at.
    (32782)

  • Ok writing DLLs in Java

    Can I compile a DLL using java! Or how about an ActiveX! And if I can how?

    You used to be able to this with Microsoft J++ (Visual Studio 6). I don't think this is supported any more though. There is a thing called J# which is part of .NET which will allow you to write code for the CLR (Common Language Runtime), but I doubt you will find it to be "pure" Java. It's more likely a "java-like" language as J++ was, and I don't know if you can write DLLs, I think it may only be ".NET Components" that you can write. (Don't really know much about this)
    If you are wanting to write an ActiveX DLL and want to do it in Java, I think you are probably barking up the wrong tree. If you don't want to go down the complete C++ path, you could try Visual Basic. VB is a simple language and it shouldn't take long to learn.
    If you are trying to access Windows features or applications not available from the standard Java APIs, then you will need to use JNI. Of course you will probably still have to code a C++ dll to act as a "wrapper" for your JNI class (JNI calls the wrapper which calls the native code).

  • Learn about writing applet for java smart card

    hi to all i am newbie in here and need to start write applet for my project
    but i am little confuse about writing applet please guide me for doing that
    thank you

    maybe this link how to develop new smart card application(write and read data on smart card will be useful

  • New to Programming, need your help with writing code for java in Xcode.

    Hey everyone! Sorry if I sound like a total idiot here with a bunch of developers but I could really use your help. I am in college and having a bit of problems with my intro to programming class. The class is entirely Java based and so, after having to use dos windows on my grandpas crappy laptop I found out about xcode. I downloaded and installed it but I am having problems seeing where exactly it is that I am to write my code for a normal java application. Any help would be greatly appreciated! I wrote it on the bottom of a bunch of code that looked strange to me. For relatively simple java programs I chose the java application template. Is there something here that I missed?

    The Java Application project template looks like it sets up an application and some kind of starting UI using Swing/AWT. I didn't look at it too indepth, but if you are in an introductory course this might be more than you need to complete your assignments. There doesn't seem to be blank Java template, so I don't know what you should use. Perhaps just a blank project you add your .java files to.
    To answer where to write code, you would write it in your .java files under the /src folder. Execution begins in
    public static void main(String args[]) {}
    in YourAppName.java, then creates an object based on your application class, and runs the code from there to display the UI.

  • Writing XML from java and import this into OpenOffice

    Hello , i'd like to write a XML file which covers Text and Images and can be imported into OpenOffice. The Export to XML already works. But i don't know what XSL or other files a necessary ? Does anyone have a converter ? Or can gibe a clue ?

    dunno if it is feasable with only an XML file.
    i am doing this by generating an SXW file (OpenOffice) using JAXP for the XML content and java.util.zip to pack the XML and the images in the SXW.

  • Ramifications of writing everything in Java

    Along with JSF/EJB3/JPA I am using JBoss Seam and RichFace/Ajax4Jsf. I had to do some reports for a web app so for my web page all I wrote was basically this:
       <h:panelGrid id="fullRptPanel"
                 binding="#{statusReport3.fullRptPanel}"/>Then I wrote the whole thing in Java using stuff like this
        HtmlDataTable neighborTable = new HtmlDataTable();
        neighborTable.setId("table"+neighborhoodCounter);
        neighborTable.setValueExpression("value", createValueExpression
         ("#{statusReport3.rptGen("+neighborhoodCounter+")}", List.class));
        neighborTable.setVar("loc");I wrote all the report logic in Java with for loops and if statements, etc. I had been wanting to try something like this for a while and it worked really well.
    HTML might be great for publishers but it doesn't seem well fitted for software engineering of business apps that run over the Internet as oppoesed to websites.
    I am not sure what all the ramifications of this would be. It would seem that it would put some additional load on the server but this might not necessarily be a bad thing considering some of the wimpy client machines I have seen verses the beefed up servers. Then I also started trying to picture how AJAX fits into this kind of approach.
    Would anybody care to comment on this?
    How much Java do other people write when they are creating JSF applications?
    Thanks, Mike Price.

    I don't see a problem with this kind of approach, if the needs of your application are too difficult to meet using straight JSF views expressed in whichever view technology you are using. I don't see much of a difference on the server side, since the interpreter would have to do much the same thing to create the component tree (actually I suppose it is possible that this eliminated some overhead in the view technology and is faster).
    In terms of how much Java people write, I expect that much more code is written to handle business logic than this type of presentation code.

Maybe you are looking for

  • Itunes 11.1.5.5 crashes when playing a Music Video

    Itunes 11.1.5.5 crashes when trying to play back one specific video that was purchased through ITunes. It played once just fine. Now it crashes Itunes with every attempt at playback. Other previously purchased music videos play just fine. Any suggest

  • Copying basic dates to forecast dates

    Hi Experts, I am using WBSE and activities in my project. I want to copy basic dates to forecast dates. But, when i am doing this in Edit>Reconcile date->Transfer basic dates to forecast dates. Then my Planning type in network header also gets change

  • Error when trying to access sqlplus!!!

    Hi, Our server (RedHat 5.2 - 2.0.36 - PII-350 - 128Mb RAM) was in standby for all the night and at this morning o first thing I did in an open telnet session since yesterday was: sqlplus The server was not responding, then (the following). But after

  • Rman Script with ORacle10g in RHEL5

    Dear Friends , I have to install ORacle10g in RHEL5 . Now I need to take rman backup and for this reason I make the following script : ============================ rman target / << ! run allocate channel t1 type disk; backup format 'df_%t_%s_%p' (dat

  • Login Loop on admin account

    I started having problems a couple of weeks ago with logging into my main account, I have 10.6.8, when I login to my main account it will either just be blue or maybe show the background image then will return to the login screen, I could access my g