Serializing Java Boolean to AS

Hi. I have a weirdest problem - my Boolean field are not deserialized property to AS Boolean variables. Namely it is always null fo rme. Simple Java boolean works fine, but not Boolean. I am not sure what to do. I was able to go around it until I had to return Map<String, Boolean> from my method. Any ideas, hints? It is more or less simple as that:
JAVA:
class A {
    private Boolean _Foo = Boolean.TRUE;
    private Map<String, Boolean> _Flags;
    public Boolean getFoo() { return _Foo; }
    public Map<String, Boolean> getFlags() { return _Flags; }
AS:
class A {
    private var foo:Boolean;
    private var flags:Object;

There is no single way to serialize Objects to a stream so I'm not really sure what kind of answer you are expecting. I'm not sure that all serilizable Java Objects are serializable to XML in a generic way.
Value types i.e. beans are pretty easily serialized and deserialized to XML, but the class definition of what you serialize may not be whatr you get when you deserialize the XML.

Similar Messages

  • The Proper way to go - Passing Serialized Java Objects vs. Web Services?

    The team which I am apart of in our little "community" is trying to convince some "others" (management) that we should not use web services to communicate (move large data) within the same application (allbeit a huge application spanning across many servers).
    Furthermore these "others" are trying to tell us that in this same application when two small apps. inside of this large app. are both java we should not communicate via serialized java objects but instead we should use Web Services and XML. We are trying to convince them that the simplest way is best.
    They have asked us to provide them with proof that passing serialized java objects back and forth between two smaller java applications inside of a larger one is an Industry Standard. Can anyone help either straighten my fellow workers and I out or help us convince the "others" of the proper way to go?

    When I was a consultant we always gave the client what they wanted. Even if it was the wrong choice. Suck it up.
    I'm glad I wasn't one of those customers. Although I agree that a customer is the one who decides what to do, when I pay someone for consultancy, I expect them to consult me. If they know I'm trying to do something that I shouldn't be doing, I expect a good consultant to be able to show me that there's a better way (not just tell me I'm not doing it right, mind you).
    We pass a lot of data using XML and we don't have any transmission or processing speed issues.
    Then you either have a much better network than our customer did, or we're not talking about the same amounts of data here.
    I used the JAX-RPC RI ...
    That's cool... our customer was, unfortunately, infected with Borland products, so we had to use BES. The web services on BES were run by Axis.
    How large were these messages?
    Huge... each element had about 15 attributes, so 1,200 elements would require 19,200 XML nodes (envelope not included). By comparison, the serialized messages weren't even a quarter that size. It's not just about what you send across the network; it's also the effort of parsing XML compared to desrializing Java objects. Our web service wasn't exactly the only process running at the server.
    Anyone who understand the fundamental difference between ASCII (XML) and binary (serialized) formats realizes that no web service can possibly achieve the performance of binary Java services. Why do you think that work is being put into binary web services? I'm not saying XML is never a good thing; just that it's not The Holy Grail that a lot of people are making it look like.
    http://issues.apache.org/jira/browse/AXIS-688
    Ouch.

  • Un-serializing java objects.

    Hi,
    I have a serialized java object.How can I convert it to a normal object or string object?
    Thanks
    Vivek

    Hi,
    I am not writing object into a file.I am
    just creating a objectoutputstream object.I have to
    convert it to string which i guess can be done using
    objectInputstream object .So is there any way out?
    Thanks
    vivekI'm confused by what you are trying to accomplish. An ObjectOutputStream is intended to write objects to a file. You can't convert an ObjectOutputStream to a String, they aren't related. Are you trying to write the objects to a String? I don't see the point of that.

  • How to use Java NIO to implement disk cache for serialized java objects

    Hi,
    I have a cache (implemented as hahstable etc.) that contains java objects (mostly strings) and swaps objects from runtime memory to the disk and back based on some algorithms. Currently, the reading and writing from the disk is implemented using java.io.* package i.e. fileInputstream and FileOutputStream. Essentially, I serialize the java object and write to the disk and the deserialize and give it back to the Hashtable cache.
    The performance of swapping from disk to memory is kinda slow. I have read that memory mapping would improve the performance.
    My idea is to do the following:
    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBuffer for that but then I have the following questions. I will not store objects in the hashtable anymore.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?
    As you can see, I am beginner in memory mapped io and need help.

    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBufferThis is a good idea, one that I have worked on. It involves quite a bit of manipulation with temporary buffers and a deep working knowledge of object serialization.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?The best way to handle this is do a two-step process, cutting the file into two pieces and gluing it back together where the original one is...
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.It is hard. Wrapping the streams and making the IO work properly is not the challenge however. The hard part comes in hacking the object streams. The object input/output streams use a ClassDescriptor object which only gets written once/ read once. This shouldn't be a problem if you will read/write the entire file at once, but will bring you grief if you want random access to your objects. You will also need an indexing mechanism to support random access.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?I guess it depends on your needs. Do you require random access to objects? NIO provides some performance gains, but mostly for very large amounts of data (>10M in my experience).
    You can always write all your objects into the same file using normal io techniques and you can still generate an index and acheive random access. It might be easier...
    Good luck

  • Creating a serialized java bean

    I want to store a hashcode in a serialized bean... This hashcode shld be accessible by other jsps, servlets. How is the .ser file created ?

    http://java.sun.com/docs/books/tutorial/essential/io/serializing.html

  • Convert Serialized Java Objects to XML

    I have seen numerous ways that you can modify a java application to serlialize it's data as XML rather than a binary stream. Does anyone know if there are any utilities, libraries, DLLS, tools, whatever to convert an already serialized binary stream to an XML file.
    At the moment I am working on a script to do this, and it works for simple objects, but I am hitting snags as I test with more complicated class heirachies. I would love to find something that already does this for me.

    I want to read data serialized by a java program in a C++ application. I don't want to have to modify the java application, but I do want to make it's data available in other applications.
    I could modify the java app and serialize it's data in XML, but that isn't the prefered solution. :)

  • Serializing Java Bean to XML

    I would like to know if it is possible with XMLBeans to convert existing java beans to XML.
    I learnt by going trhu' few materials of XMLBeans that we need to create bean classes from XSD and can use these classes for marshalling/unmarshalling.
    But I have java beans already defined which I want to serialize/deserialize to/from XML.
    Thanks in advance.
    --Ramu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    If you are not interested in writing a bunch of code (which is probably the case), I know of a couple options for WLS 8.1:
    1. Use the "undocumented" and "unsupported" java2xsd class, in the %WL_HOME%\server\lib\webservices.jar.
    2. Use the Java2Schema tool in the Systinet Server for Java product.
    Here's the contents of a sample build.xml that uses the java2xsd class:
    <project
    name="java2xsd"
    default="assemble"
    basedir="."
    >
         <path id="compile.classpath">
              <fileset dir="d:/bea81sp4/">
                   <include name="lib/tools.jar" />
              </fileset>
              <fileset dir="d:/bea81sp4/weblogic81">
                   <include name="server/lib/weblogic.jar"/>
                   <include name="server/lib/webservices.jar"/>
              </fileset>
         </path>
         <target name="clean">
              <delete dir="xsd" />
         </target>
         <target name="run-java2xsd">
    <delete dir="xsd" />
    <mkdir dir="xsd"/>
    <java
         classname="weblogic.xml.schema.binding.util.java2xsd"
    fork="true"
    >
    <jvmarg line="-Djava.io.tmpdir=xsd"/>
    <arg line="
    com.acme.world.schema.x2005.x11.elending.Loan
    com.acme.world.schema.x2005.x11.elending.Applicant
    com.acme.world.schema.x2005.x11.ebillpay.Account
    "/>
    <classpath>
    <path refid="compile.classpath"/>
    <pathelement location="classes"/>
    </classpath>
    </java>
         </target>
         <target name="assemble" depends="run-java2xsd">
         </target>
    </project>
    Here, you would replace the paths in the <path> element of course, but you would also need to come up with a way to provide a list of the JavaBean classes to process. The good thing is that java2xsd is smart enough to put all the classes in a given Java package, in the same <xs:schema> element :-) For instance, in:
    <arg line="
    com.acme.world.schema.x2005.x11.elending.Loan
    com.acme.world.schema.x2005.x11.elending.Applicant
    com.acme.world.schema.x2005.x11.ebillpay.Account
    "/>
    the complexType element for "Loan" and "Applicant", will be defined in the same <xs:schema>. There will only be one schemas.xsd file. I don't know of an easy way to change the file name, but it will contain a <xs:schema> for each unique Java package name. Once you have this schemas.xsd file, you can decide how you want to create the XMLBeans from it. You can either break each <xs:schema> element out into it's own .xsd file, or create a WSDL that uses the contents of the schemas.xsd file. You'll notice that there is a <type> element wrapping all the <xs:schema> elements in the schemas.xsd file, which is exactly the name of the element that WSDL uses :-)
    Again, java2xsd is not a "supported" class, so don't confuse it (or the information provided above) with being "the tool that BEA provides" for doing what you want to do :-)
    Regards,
    Mike Wooten

  • Serializing Java Objects to XML files

    Hi,
    We looking for SAP library which can serialize Java Objects into XML files.
    Can you point us were to find it ?
    We have found such open source library called "XStream" at the following link
    http://www.xml.com/pub/a/2004/08/18/xstream.html
    Is it allowed to use that library inside SAP released software ?
    Thanks
    Orit

    How about https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/83f6d2fb-0c01-0010-a2ba-a2ec94ba08f4 [original link is broken] [original link is broken]? Depends on your use cases...
    Both are supported in SAP NW CE 7.1.
    HTH!
    -- Vladimir

  • Can any boby send me a snippet of code telling mw how to "store serialized java object in iplanet directory services

     

    You will find everything you need to know including code samples in the JNDI Tutorial :
    http://java.sun.com/products/jndi/tutorial/objects/index.html
    Regards,
    Ludovic.

  • How to NOT ignore java beans read only properties when serializing Java to AS?

    As stated in the Adobe LCDS documentation, the read-only properties of a java bean are ignored in the AMF serialization process.
    Would you know what to do so that Java beans read only properties do not get discarded when sending it via BlazeDS AMF?
    Many thanks in advance.

    Hi,
    I've managed to get what I needed by using a shift register + event structure as suggested by Adnan. However, I face another problem after implementing SR+event. I've attached two files, first the original program and second the updated program using SR + event. (it's only the jpg file as I've forgotten to save the labview program, will upload the program by tomorrow.
    In the original program, I have an elapsed time that is able to run continuously when I run the program. In the updated program, my elapsed time don't seem to run continuously when I run the program (as shown by elapsed time indicator). I need the elapsed time to run continuously as a input to calculate my motor profile.
    I suppose this is caused by the introduction of the event structure, will adding a case structure to wrap the event structure solve the problem or is there another way to get pass this. Appreciate if someone could drop me a pointer or two.
    Thanks
    Attachments:
    Mar 16 - continuous elapsed time.png ‏12 KB
    Mar 16 - elapsed time not continuous after introducing shift register + event structure.png ‏17 KB

  • OID and binding java serialized object

    Hi there,
    How are you doing? I am trying to bind a serialized java object to a name in Oracle Internet Diectory (oid) using JNDI.
    it gives me an errror.
    "OperationNotSupported LDAPA error 53: Unwilling to perform:
    I have directory manager 2.1.1 and JNDI 1.2.1
    I arrpeciate any clue and/or help
    Thanks
    null

    Hello:
    Although OID supports calls from JNDI, the JNDI schema for storing JAVA serialized objects is not yet a standard part of the OID schema. This is easy to remedy. Go to javasoft.sun.com and download the JNDI schema for java serialized objects and load the attributes and objectclasses into OID from the ldif files provided at this web site. . Make sure the attributes are loaded before the objectclasses.
    Once this schema is loaded this problem should go away
    Use the ldapmodify command line tool to add the schema items from the ldif file.
    Let me know if you need further assistance setting this up. A future version of OID will contain these schema items standard.
    Thanks,
    Jay
    null

  • Flash - Java - SerialData Translation issues

    This is for an art installation we're building in a gallery here in NYC. It opens Saturday, and we are in a jam with a problem.
    I'm using Dan O'Sullivan's Serial Server http://itp.nyu.edu/~dbo3/SerialServer/SerialServer.html , which is a little java server that connects to Flash via XML socket and to the serial port. It passes data back and forth since Flash doesn't talk to the serial port.
    The problem is this: Flash won't put the incoming data into the object and trigger the onData handler until it sees a null byte delimiter. On the other side, my serial device -- an encoder & adapter -- has no interest in producing a delimiter and cannot be programmed to do so. The data from the encoder is generally in the form of 4 bytes. You send it 1 byte to poll it.
    Thus the server app has to step in and patch things up, either (a) by indiscriminately appending 0's to everything it sees from the encoder (and figuring it all out in Flash) or better, (b) by having the server do the polling and keeping the current 4 bytes in a string, ready for when Flash requests it.
    This doesn't seem too bad - the server code is relatively simple - but I'm not a Java programmer (sorry, wish I were). I'm inserting the code here - any chance someone can help us out ... immediately?? Thanks very much.
    /Eric Liftin
    MESH Architectures http://mesh-arc.com
    * SerialServer.java
    * Title:               SerialServer
    * Description:          This relays bytes between a serial port and a socket connection.
    * @author               Administrator
    * @version               
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Frame;
    import java.awt.Toolkit;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.StringTokenizer;
    public class SerialServer extends java.applet.Applet  implements SerialListener {
         // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated
         // every time the form is saved. All manual changes will be overwritten.
         // BEGIN GENERATED CODE
         // member declarations
         java.awt.Choice baud = new java.awt.Choice();
         java.awt.Checkbox interpretation = new java.awt.Checkbox();
         java.awt.Choice ports = new java.awt.Choice();
         java.awt.TextField socketPort = new java.awt.TextField();
         java.awt.Label softwarePort = new java.awt.Label();
         java.awt.Button sendToSocket = new java.awt.Button();
         java.awt.Button sendToSerial = new java.awt.Button();
         java.awt.TextField sendText = new java.awt.TextField();
         java.awt.TextArea traffic = new java.awt.TextArea();
         java.awt.Checkbox debugButton = new java.awt.Checkbox();
         java.awt.Label socketStatus = new java.awt.Label();
         java.awt.Label serialStatus = new java.awt.Label();
         java.awt.Label numbersFootnote = new java.awt.Label();
         java.awt.Button clearButton = new java.awt.Button();
         java.awt.Button cover = new java.awt.Button();
         // END GENERATED CODE
         String serialType = null;
         static Socketer mySocket;
         static Serial mySerial;
         boolean isStandalone = false;
         static boolean debug = false;
         public SerialServer() {}
         static HashMap argsHash;
         int substituteChar = 0;
         public void start() {
              //figure out what driver to use
              if (isStandalone == false) {
                        serialType =  getParameter("SerialDriver");
                   } else {
                        serialType = (String) argsHash.get("SerialDriver");
              if( serialType != null){  //if they did not specify
                   serialType= serialType.toLowerCase();
              newSerial();
              if (isStandalone == false) {
                   System.out.println("This is an Applet");
                   useParameters(getParameter("Baud"), getParameter("SerialPort"), getParameter("SocketPort"), getParameter("Sub0ForChar"), getParameter("SerialDriver"));
              } else {
                   useParameters((String) argsHash.get("Baud"), (String) argsHash.get("SerialPort"), (String) argsHash.get("SocketPort"), (String) argsHash.get("Sub0ForChar"),(String) argsHash.get("SerialDriver"));
              newSocket();
              connectSerial();
              //          event handling
              baud.addItemListener(new java.awt.event.ItemListener() {
                   public void itemStateChanged(java.awt.event.ItemEvent e) {
                        baudItemStateChanged(e);
              interpretation.addItemListener(new java.awt.event.ItemListener() {
                   public void itemStateChanged(java.awt.event.ItemEvent e) {
                        interpretationItemStateChanged(e);
              ports.addItemListener(new java.awt.event.ItemListener() {
                   public void itemStateChanged(java.awt.event.ItemEvent e) {
                        portsItemStateChanged(e);
              socketPort.addTextListener(new java.awt.event.TextListener() {
                   public void textValueChanged(java.awt.event.TextEvent e) {
                        socketPortTextValueChanged(e);
              sendToSocket.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent e) {
                        sendToSocketPerformed(e);
              sendToSerial.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent e) {
                        sendToSerialActionPerformed(e);
              sendText.addTextListener(new java.awt.event.TextListener() {
                   public void textValueChanged(java.awt.event.TextEvent e) {
                        sendTextTextValueChanged(e);
              ////     traffic.addTextListener(new java.awt.event.TextListener() {
              //     public void textValueChanged(java.awt.event.TextEvent e) {
              //          trafficTextValueChanged(e);
              debugButton.addItemListener(new java.awt.event.ItemListener() {
                   public void itemStateChanged(java.awt.event.ItemEvent e) {
                        debugItemStateChanged(e);
              clearButton.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent e) {
                        clearActionPerformed(e);
              //populatePorts();
         // Initialize the applet
         public void init() {
              try {
                   initComponents();
              } catch (Exception e) {
                   e.printStackTrace();
         public void useParameters(String _baud, String _serialPort, String _socketPort, String _subChar, String _serialType) {
              System.out.println("Input Parameters Baud:" + _baud + " SerialPort:" + _serialPort + " SocketPort:" + _socketPort + " SubChar:" + _subChar+ " SerialType:" + _serialType);
              if (_baud != null) {
                   baud.select(_baud);
              if (_subChar != null) {
                   substituteChar = Integer.parseInt(_subChar);
              } else {
                   substituteChar = 0;
              //else{
              //          baud.select("9600");
              if (_serialPort != null) {
                   ports.select(_serialPort);
              } //else{
              //     ports.select("COM1") ;
              //if ((_baud != null) || (_serialPort != null)){
              //     newSerial();
              if (_socketPort != null) {
                   socketPort.setText(_socketPort);
                   //     newSocket();
         public void initComponents() throws Exception {
              // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated
              // every time the form is saved. All manual changes will be overwritten.
              // BEGIN GENERATED CODE
              // the following code sets the frame's initial state
              baud.setVisible(true);
              baud.setLocation(new java.awt.Point(222, 31));
              baud.setSize(new java.awt.Dimension(70, 21));
              interpretation.setVisible(true);
              interpretation.setLabel("Use decimals instead of letters.");
              interpretation.setLocation(new java.awt.Point(43, 175));
              interpretation.setSize(new java.awt.Dimension(200, 20));
              ports.setVisible(true);
              ports.setLocation(new java.awt.Point(222, 10));
              ports.setSize(new java.awt.Dimension(108, 21));
              socketPort.setLocation(new java.awt.Point(18, 10));
              socketPort.setVisible(true);
              socketPort.setText("9001");
              socketPort.setSize(new java.awt.Dimension(40, 20));
              softwarePort.setVisible(true);
              softwarePort.setLocation(new java.awt.Point(60, 10));
              softwarePort.setText("<Socket > ------------- <Serial>");
              softwarePort.setSize(new java.awt.Dimension(160, 20));
              sendToSocket.setVisible(true);
              sendToSocket.setLabel("<TestSend");
              sendToSocket.setLocation(new java.awt.Point(1, 60));
              sendToSocket.setSize(new java.awt.Dimension(80, 20));
              sendToSerial.setVisible(true);
              sendToSerial.setLabel("Test Send>");
              sendToSerial.setLocation(new java.awt.Point(279, 60));
              sendToSerial.setSize(new java.awt.Dimension(80, 20));
              sendText.setLocation(new java.awt.Point(82, 60));
              sendText.setVisible(true);
              sendText.setSize(new java.awt.Dimension(197, 20));
              traffic.setLocation(new java.awt.Point(5, 95));
              traffic.setVisible(true);
              traffic.setSize(new java.awt.Dimension(352, 80));
              debugButton.setFont(new java.awt.Font("Serif", 0, 12));
              debugButton.setVisible(true);
              debugButton.setLabel("debug");
              debugButton.setLocation(new java.awt.Point(130, 39));
              debugButton.setSize(new java.awt.Dimension(50, 20));
              socketStatus.setVisible(true);
              socketStatus.setAlignment(java.awt.Label.CENTER);
              socketStatus.setLocation(new java.awt.Point(65, 26));
              socketStatus.setSize(new java.awt.Dimension(45, 20));
              serialStatus.setVisible(true);
              serialStatus.setAlignment(java.awt.Label.CENTER);
              serialStatus.setLocation(new java.awt.Point(177, 26));
              serialStatus.setSize(new java.awt.Dimension(40, 20));
              numbersFootnote.setVisible(false);
              numbersFootnote.setLocation(new java.awt.Point(49, 79));
              numbersFootnote.setText("*Put spaces between numbers for test send.");
              numbersFootnote.setSize(new java.awt.Dimension(280, 20));
              clearButton.setVisible(true);
              clearButton.setLabel("Clear");
              clearButton.setLocation(new java.awt.Point(260, 178));
              clearButton.setSize(new java.awt.Dimension(58, 19));
              setLocation(new java.awt.Point(0, 0));
              setLayout(null);
              add(cover);
              add(baud);
              add(interpretation);
              add(ports);
              add(socketPort);
              add(softwarePort);
              add(sendToSocket);
              add(sendToSerial);
              add(sendText);
              add(traffic);
              add(debugButton);
              add(socketStatus);
              add(serialStatus);
              add(numbersFootnote);
              add(clearButton);
              setSize(new java.awt.Dimension(356, 274));
              // END GENERATED CODE
              baud.add("110");
              baud.add("300");
              baud.add("1200");
              baud.add("2400");
              baud.add("4800");
              baud.add("9600");
              baud.add("19200");
              baud.add("31250"); //   //31250
              baud.add("38400");
              baud.add("57600");
              baud.add("230400");
              baud.add("460800");
              baud.add("921600");
              baud.select("9600");
              cover.setVisible(true);
              //cover.setLayout(null);
              cover.setLocation(new java.awt.Point(-10, 57));
              cover.setSize(new java.awt.Dimension(964, 287));
         public void relayToSerial(int what) {
              boolean ok = mySerial.send(what).equals("OKAY");
              if (debug) {
                   socketStatus.setText("<IN>");
                   if (ok) {
                        serialStatus.setText("<OUT>");
                   showText(what);
         public void gotFromSerial(byte[] _byteArray){
         //public void relayToSocket(int what) {
             for(int i = 0; i < _byteArray.length; i++){
                 int what = (int) (_byteArray[i] & 0xff);
              if ((substituteChar != 0) && (what == substituteChar))
                   what = 0;
              boolean ok = mySocket.send(what).equals("OKAY");
              if (debug) {
                   serialStatus.setText("<IN>");
                   if (ok) {
                        socketStatus.setText("<OUT>");
                   showText(what);
         public void appendDebug(String what) {
              if (traffic.getText().toCharArray().length > 200)
                   traffic.setText(traffic.getText().substring(50));
              traffic.setText(traffic.getText() + "\n" + what + "\n");
              String strMessage = traffic.getText();
              traffic.setCaretPosition(strMessage.length());
         public void showText(int what) {
              if (interpretation.getState()) {
                   traffic.setText(traffic.getText() + " " + what);
              } else {
                   traffic.setText(traffic.getText() + ((char) what));
              String strMessage = traffic.getText();
              traffic.setCaretPosition(strMessage.length());
         // Standard method to start the applet
         //public void start() {
         //     newSocket();
         //     newSerial();
         public void populatePorts() {
              ports.removeAll();
              ArrayList portList = mySerial.getPortsList();
              for (int i = 0; i < portList.size(); i++) {
                   String[] portAndOwner = (String[]) portList.get(i);
                   System.out.println("owner" + portAndOwner[1]);
                   String port = portAndOwner[0];
                   String owner = portAndOwner[1];
                   //System.out.println(owner + " " + port + " number of Ports " + portList.size());
                   if (owner == null || owner.equals("Port currently not owned")) {
                        boolean alreadyThere = false;
                        for (int j = 0; j < ports.getItemCount(); j++) {
                             String alrdy = ports.getItem(j);
                             //System.out.println(port+ " Ports Already " + alrdy );
                             if (alrdy.equals(port)) {
                                  alreadyThere = true;
                                  break;
                        if (alreadyThere == false) {
                             ports.add(port);
                   } else {
                        System.out.println("Can't use it!" + port + owner);
                   //ports.add(((String) portList.get(i)));
         public void newSerial() {
              serialStatus.setText("!");
              mySerial = new Serial(this, serialType);
              if (ports.getItemCount() == 0) {
                   populatePorts();
         public void connectSerial() {
              if (ports.getItemCount() == 0) {
                   appendDebug("No serial ports found.");
              } else {
                   String status = mySerial.connect(ports.getSelectedItem(), Integer.parseInt(baud.getSelectedItem()));
                   if (status.startsWith("Got")) {
                        serialStatus.setText("<OK>");
                        //mySerial.start();
                   } else {
                        serialStatus.setText("Bad");
                        //populatePorts();
                   appendDebug(status);
         public void newSocket() {
              mySocket = new Socketer(Integer.parseInt(socketPort.getText()), this);
         public void socketStatus(String status) {
              if (status.startsWith("Got")) {
                   socketStatus.setText("<OK>");
              } else if (status.startsWith("Waiting")) {
                   socketStatus.setText("Waiting");
              } else {
                   socketStatus.setText("Bad");
              appendDebug(status);
         // Standard method to stop the applet
         public void stop() {
              mySerial.kill();
              mySocket.kill();
         // Standard method to destroy the applet
         public void destroy() {}
         // Main entry point when running standalone
         public static void main(String[] args) {
              SerialServer applet = new SerialServer();
              applet.isStandalone = true;
              Frame frame = new Frame();
              frame.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowClosing(java.awt.event.WindowEvent e) {
                        Frame f = (Frame) e.getSource();
                        f.setVisible(false);
                        f.dispose();
                        System.exit(0);
              frame.setTitle("Serial Server");
              frame.add(applet, BorderLayout.CENTER);
              frame.setSize(400, 320);
              Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
              frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
              frame.setVisible(true);
              applet.init();
              argsHash = new HashMap();
              for (int i = 0; i < args.length; i++) {
                   String pair = args;
                   String parts[] = pair.split(":");
                   if (parts.length == 2) {
                        argsHash.put(parts[0], parts[1]);
                   }else{
                        System.out.println("Problem with format of parameter "+ pair);
              applet.start();
              frame.pack();
         public void sendTextTextValueChanged(java.awt.event.TextEvent e) {}
         public void interpretationItemStateChanged(java.awt.event.ItemEvent e) {
              numbersFootnote.setVisible(interpretation.getState());
              System.out.println("Interpretation" + interpretation.isVisible());
         public void socketPortTextValueChanged(java.awt.event.TextEvent e) {
              mySocket.kill();
              mySocket = null;
              newSocket();
              System.out.println("Changed Socket");
         public void sendToSocketPerformed(java.awt.event.ActionEvent e) {
              if (interpretation.getState()) {
                   StringTokenizer st = new StringTokenizer(sendText.getText(), " ");
                   while (st.hasMoreTokens()) {
                        try {
                             int what = Integer.parseInt(st.nextToken());
                             if ((substituteChar != 0) && (what == substituteChar))
                                  what = 0;
                             //System.out.println(substituteChar + "debugSend" + what);
                             mySocket.send(what);
                        } catch (NumberFormatException nfe) {
                             System.out.println("You are are entering letters but you checked the decimal interpretation.");
              } else {
                   byte[] asbytes = sendText.getText().getBytes();
                   for (int i = 0; i < asbytes.length; i++) {
                        int what = asbytes[i];
                        if ((substituteChar != 0) && (what == substituteChar))
                             what = 0;
                        System.out.println(substituteChar + "debugSend" + what);
                        mySocket.send(what);
         public void sendToSerialActionPerformed(java.awt.event.ActionEvent e) {
              if (interpretation.getState()) {
                   StringTokenizer st = new StringTokenizer(sendText.getText(), " ");
                   while (st.hasMoreTokens()) {
                        try {
    mySerial.send(Integer.parseInt(st.nextToken()));
    } catch (NumberFormatException e1) {
         appendDebug("Enter a number.");
              } else {
                   byte[] asbytes = sendText.getText().getBytes();
                   for (int i = 0; i < asbytes.length; i++) {
                        mySerial.send(asbytes[i]);
         public void portsItemStateChanged(java.awt.event.ItemEvent e) {
              mySerial.kill();
              mySerial = null;
              newSerial();
              connectSerial();
              System.out.println("Serial Port Changed");
         public void baudItemStateChanged(java.awt.event.ItemEvent e) {
              mySerial.kill();
              mySerial = null;
              newSerial();
              connectSerial();
              System.out.println("Serial Baud Changed");
         public void debugItemStateChanged(java.awt.event.ItemEvent e) {
              debug = debugButton.getState();
              if (debug) {
                   cover.setLocation(-1000, -1000);
              } else {
                   cover.setLocation(-10, 57);
                   //cover.setVisible(true);
              //System.out.println("debugl Changed" + debug);
         public void clearActionPerformed(java.awt.event.ActionEvent e) {
              traffic.setText("");

    Whoops, I'll fix it up so it's more presentable
    for (int row = 0; row <= 8 ; row++){
        for (int column = 1; column <= row; column++ )
         System.out.print(" ");
        for (int i = 0; i < row; i++){
         System.out.print(" " + (int) Math.pow(2,i));
        for (int j = row-1; j >= 0; j--)
         System.out.print(" " + (int)Math.pow(2, j));
        System.out.println();
    }About the space, I was checking to see what adding and removing them would do, although even after fixing it I seem to get a bunched up mass.
    -edit-
    Another thing I've noted is that pasting the text here seems to throw off the indentations which look normal in eclipse.
    Edited by: Yummyfishman on Oct 5, 2007 8:33 PM
    Edited by: Yummyfishman on Oct 5, 2007 8:35 PM
    Edited by: Yummyfishman on Oct 5, 2007 8:36 PM
    Edited by: Yummyfishman on Oct 5, 2007 8:40 PM

  • Type Mismatch error while calling a Java Function from Visual Basic 6.0...

    Hi,
    I'm having a problem in calling the Java Applet's Function from Visual Basic. First, I'm getting the handle of the Java Applet and components of it using "Document.Applets(n)" which is a HTML function. I'm calling this function from Visual Basic. My code is something like this...
    ' // Web1 is IE Browser in my Form.
    Dim Ap,Comp
    Dim Bol as Boolean
    Bol = true
    Ap = Web1.Document.Applets(0).getWindow() ' \\ Gets the Parent Window.
    Ap.setTitle("My Java Applet") ' \\ Sets the Title of the window.
    msgbox Ap.getVisibility() ' \\ This will return a Java boolean ( true or false )
    Ap.setVisibility(Bol) ' \\ Function Syntax is : void setVisibility(boolean b)
    Here in my code , i'm able to call any function that which accepts Integer or String but not boolean. So, i m facing problem with Ap.setVisibility() function. It gives me a "Type mismatch error" while executing it. Can you please tell me a way to do this from Visual Basic !
    I'm using Visual Basic 6.0, Windows 2000 , J2SDK 1.4.2_05.
    Please help me Friends.
    Thanks and Regards,
    Srinivas Annam.

    Hi
    I am not sure about this solution. try this
    Declare a variable as variant and store the boolean value in that variable and then use in ur method.
    Post ur reply in this forum.
    bye for now
    sat

  • Writing and  Reading serialized Objects

    [code=java]
    /*hey guys i'm new to java and i have been given an exercise to make a cd collection, write it into a file and read the data back to the program.
    the program is suppose to show you a menu to select from where you can add, delete, view sort, CD's when you add a CD it must be written to a file as an Object and when you want to view CDs or search for a CD the program must read the CD objects from the file they have been written to and must return a cd nam, artist and release date. the code looks like it is writing the Cd to a file but when i try to read (view or search for a cd from the file it gives an error null). so i think i'm note reading the right way.
    thank you for helping .
    import java.io.Serializable;
    public class cd implements Serializable {
         //creating attributes
              private String cdname = null;
              private double price = 0.0;
              private String artist =null;
              private int ratings =0;
              private String genre=null;
              private String releaseDate =null;
         // creating an Empty constructor
              public cd(){
              public cd (String cdname,double price, int ratings, String genre, String artist, String releaseDate){
              this.cdname=cdname;
              this.price=price;
              this.artist=artist;
              this.ratings=ratings;
              this.genre=genre;
              this.releaseDate=releaseDate;
              public String getGenre(){
                   return genre;
              public void setGenre(String genre){
                   this.genre =genre;
              public String getArtist(){
                   return artist;
              public void setArtist(String artist){
                   this.artist=artist;
              public String getName(){
              return cdname;
              public void setName(String cdname){
              this.cdname = cdname;
              public Double getPrice(){
              return price;
              public void setPrice(double price){
              this.price = price;
              public String getReleaseDate(){
              return releaseDate;
              public void setReleaseDate(String releaseDate){
              this.releaseDate = releaseDate;
              public int getRatings(){
              return ratings;
              public void setRatings( int ratings){
              this.ratings = ratings;
    import java.util.*;
    public class hipHopCollection {
    ArrayList<cd> list = new ArrayList <cd> ();
    EasyIn ei = new EasyIn();
         private cd invoke;
         private int b;
         public void load()
              System.out.println(" You Entered " + b + " To Add A CD ");
              invoke = new cd();
              System.out.println("Please Enter A CD Name ");     
              invoke.setName(ei.readString());
              System.out.println("Please Enter A CD Price");
              invoke.setPrice(ei.readDouble());
              System.out.println("Please Give Ratings For The CD");
              invoke.setRatings(ei.readInt());
              System.out.println("Please Enter A CD release date ");
              invoke.setReleaseDate(ei.readString());
              System.out.println("Please Enter artist Name ");
              invoke.setArtist(ei.readString());
              System.out.println("Please Enter A CD Genre ");
              invoke.setGenre(ei.readString());
              list.add(invoke); // trying to add cd information to invoke.
         }// end of load
    // The following method should return the Object variable invoke that holds the cd INFO
         public Object getInvoke()
         return invoke;
         public int getB()
         return b;
         public void setB()
         b=ei.readInt();
         public void menu(){
              System.out.println("......................................................... ");
              System.out.println("Hi There Please Enter A Number For Your Choice");
              System.out.println(" Pess >>");
              System.out.println("1 >> Add A CD");
              System.out.println("2 >> View List Of CD's");
              System.out.println("3 >> Sort CD's By Price");
              System.out.println("4 >> Search CD By Name");
              System.out.println("5 >> Remove CD(s) By Name");
              System.out.println("0 >> Exit");
              System.out.println(".........................................................");
              System.out.print("Please Enter Chioce >> ");     
         }// end of menu
         public void GoodBye()
              System.out.println(" You Entered " + b + " To exit Good_bye" );
              System.exit(0);
         }//end of GoodBye
         public void PriceSort()
              System.out.println(" You Entered " + b + " To Sort CD(s) By price ");
              Collections.sort(list, new SortByPrice());
              for(cd s : list)
              System.out.println(s.getName() + ": " + s.getPrice());
         }// end of PriceSort
         public void NameSearch()
                   System.out.println(" You Entered " + b + " To Search CD(s) By Name ");
                   System.out.println("Please Enter The Name Of The CD You Are Searching For " );
                   String search = ei.readString();
                   for(int i=0; i<list.size();i++){
                   if(search.equalsIgnoreCase(list.get(i).getName() )){
                   System.out.println(list.get(i).getName() + " " + list.get(i).getPrice() + " " + list.get(i).getRatings() + " " + list.get(i).getGenre() );
    }//end of NameSearch
         public void ViewList()
                   System.out.println(" You Entered " + b + " To view CD(s) By Name ");
                   for(int i=0; i<list.size();i++)
                   System.out.println(list.get(i).getName() + " " + list.get(i).getPrice() + " " + list.get(i).getRatings() + " " + list.get(i).getGenre() );
         }// end of ViewList
         public void DeleteCd()
                   System.out.println(" You Entered " + b + " To Delete CD(s) By Name ");
                   System.out.println("Please Enter The Name Of The CD You Want to Delete ");
                   String search = ei.readString();
                   for(int i=0; i<list.size();i++)
                   if(search.equalsIgnoreCase(list.get(i).getName() ))
                   System.out.println(list.get(i).getName());
                   list.remove(i);
         }// end of DeleteCD
         public static void main(String[] args) {
         //creating an Instance of EasyIn by object ei. Easy in is a Scanner class for reading
              EasyIn ei = new EasyIn();
              ArrayList<cd> list = new ArrayList <cd> (); // creating an array cd list
              hipHopCollection call = new hipHopCollection();
              ReadWrite rw = new ReadWrite();
                   while (true){
                   call.menu();
                   call.setB();
                   //b = ei.readInt();
                   if(call.getB()==0)
                        call.GoodBye();
                   if(call.getB()==1)
                        call.load();
                        rw.doWriting();// trying to write the cd object to a file
                   if(call.getB()==2)
                   rw.doReading();// trying to read the cd object from a file
                   //call.ViewList();
                   if(call.getB()==3)
                   call.PriceSort();
                   if(call.getB()==4)
                        call.NameSearch();
                   if(call.getB()==5)
                        call.DeleteCd();
         }// end of while
    }// end of main
    }// end of class
    // importing all the packages that we will use
    import java.io.ObjectInputStream;
    import java.io.FileInputStream;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.ObjectOutputStream;
    import java.io.OutputStream;
    import java.io.Serializable;
    public class ReadWrite {
    // these are all the attributes
         private String FileName ="CdCollections.dat";     
         private OutputStream output;
         private ObjectOutputStream oos;
         private FileOutputStream fos;
         private File file;
         private FileInputStream fis;
         private ObjectInputStream ois;
         //creating an empty constructor
         public ReadWrite()
         // we could initialise all the attributes inside this empty constructor
         //creating a constructor with arguments of a file name.
         public ReadWrite(File file)
              this.file=file;
              try
                   //Use a FileOutputStream to send data to a file called CdCollections.dat
                   fos = new FileOutputStream(file,true);
                   Use an ObjectOutputStream to send object data to the
                   FileOutputStream for writing to disk.
                   oos = new ObjectOutputStream (fos);
                   fis=new FileInputStream(file);
                   ois = new ObjectInputStream(fis);
              catch(FileNotFoundException e)
                   System.out.println("File Not Found");
              catch(IOException a)
                   System.out.println(a.getMessage());
                   System.out.println("Please check file permissions of if file is not corrupt");
         }// end of the second constructor
         //the following lines of code will be the accessors and mutators
         * @return the output
         public OutputStream getOutput() {
              return output;
         * @param output the output to set
         public void setOutput(OutputStream output) {
              this.output = output;
         * @return the objStream
         public ObjectOutputStream getOos() {
              return oos;
         * @param objStream the objStream to set
         public void setObjStream(ObjectOutputStream objStream) {
              this.oos = oos;
         public File getFile() {
              return file;
         public void setFile(File file) {
              this.file = file;
         public FileInputStream getFis() {
              return fis;
         public void setFis(FileInputStream fis) {
              this.fis = fis;
         public ObjectInputStream getOis() {
              return ois;
         public void setOis(ObjectInputStream ois) {
              this.ois = ois;
         // the following lines of code will be the methods for reading and writing
    the following method doWriting will write data from the hipHopCollections source code.
    that will be all the cd information.
    Pass our object to the ObjectOutputStream's
    writeObject() method to cause it to be written out
    to disk.
    obj_out.writeObject (myObject);
         public void doWriting()
              hipHopCollection call = new hipHopCollection();
    //creating an Object variable hold that will hold cd data from hipHopCollections invoke
              Object hold = call.getInvoke();// THI COULD BE THE PART WHERE I MADE A MISTAKE
              ReadWrite stream = new ReadWrite (new File(FileName));
              try
              Pass our object to the ObjectOutputStream's
              writeObject() method to cause it to be written out to disk.
              stream.getOos().writeObject(hold);
                   stream.getOos().writeObject(hold);
                   stream.getOos().close();
                   System.out.println("Done writing Object");
              catch (IOException e)
                   System.out.println(e.getMessage());
                   System.out.println("Program Failed To Write To The File");     
              finally
                   System.out.println("The program Has come To An End GoodBye");
         }// end of method DoWriting
    The following method is for reading data from the file written by the above method named
    DoWriting
    // PLEASE NOT THIS IS THE METHOD THAT GIVES ME NULL EXCEPTION
         public void doReading()
         ReadWrite read = new ReadWrite(new File(FileName));
              try{
                   //System.out.println("I AM NOW INSIDE THE TRY TO READ");
                   Object obj = read.getOis().readObject();
                   System.out.println("tried reading the object");
                   cd c = (cd)obj; // trying to cast the object back to cd type
                   System.out.println("I have typed cast the Object");               
                   System.out.println(c.getName());
                   System.out.println(c.getGenre());
                   System.out.println(c.getArtist());
                   System.out.println(c.getPrice());
                   System.out.println(c.getRatings());
                   System.out.println(c.getReleaseDate());
                   read.getOis().close();
              catch(ClassNotFoundException e)
              System.out.println(e.getMessage());
              System.out.println("THE CLASS COULD NOT BE FOUND");
              catch(IOException e)
              System.out.println(e.getMessage());// null
              System.out.println("WE COULD NOT READ THE DATA INSIDE THE FILE");
         }//end of method doReading
    }// end of class ReadWrite

    Cross posted
    http://www.java-forums.org/new-java/59965-writing-reading-serialized-java-object.html
    Moderator advice: Please read the announcement(s) at the top of the forum listings and the FAQ linked from every page. They are there for a purpose.
    Then edit your post and format the code correctly.
    db

  • How much space does a boolean takes up

    Hi.
    I know an integer primitives takes 32 bits
    how many bits does the java boolean takes up. 2 bits ?
    also, would it be the same as the Boolean object ?
    Anyone can help answer this question ? thank you :)

    Hi.
    I know an integer primitives takes 32 bits
    how many bits does the java boolean takes up. 2 bits
    also, would it be the same as the Boolean object ?
    Anyone can help answer this question ? thank you :)Why 2 bits? One bit is enough, but I doubt this would be an
    efficient way to store it from an access time point of view.
    I think it should take some minimum number of full bytes that
    are eficiently accessible on a given architecture(4 or perhaps 2 or 1). The language specification does not prescribe any particular size.
    Allocate yourself a huge boolean[] and check the increase of size of the
    VM, this should give you an idea. Boolean, on the other hand, is an object, pretty sure it's a small one (as small as a boolean), but the overhead of a Boolean[] should be bigger (the objects and the references to them).

Maybe you are looking for

  • BI Publisher Report not Generating any Output in the Excel SHeet

    We have a CUstom BI PUblisher Report .When we run it ,it completes normally but there is no data in the Excel Sheet generated .It shows NO DATA FOUND .But when i run the Query seperately i do get some data . Don't know why it is not viewable in the E

  • Firefox crashes at every start

    First I could open Firefox and it crashed after a few minutes. When I tried it again, the same happened. I could start Firefox in the safe mode. Now, not even this works. When I start Firefox the screen becomes black and the computer freezes for a se

  • Flash file with trancparency as dashboard widget

    trancparency only works for pictures on lower layers but not for the desktop background the picture "Default.png" behind the flash file is partial visible but the widget has a 200 x 200 pixel black background, areas without pictures on lower layers a

  • Stacked format in chart using graphics:chart

    I Implemented a graphics:chart element and is working fine, I know how to set Pie format, bars, line in 2D or 3D, but I cant find info about how to set the stacked format. I read the PDF that comes with the SAP chart Designer. In the section “Blocks”

  • Issue resolving a classloader error

    Good Day. I've created and deployed ear that references another application (ear). For example, I have an application named: sampleapp.ear. That file deployed sucessfully. When I try to use that application http://localhost:50000/sampleapp/start.jsp?