Loading ...
Sorry, an error occurred while loading the content.

File - faq.txt

Expand Messages
  • JSX-ideas@yahoogroups.com
    JSX FAQ - 14 November 2001 ======= JSX instantly XML-enables applications, by re-implementing the Serialization API for XML. FAQ Contents: (1). Background (2).
    Message 1 of 30 , Sep 1 2:41 AM
    • 0 Attachment
      JSX FAQ - 14 November 2001

      JSX instantly XML-enables applications, by re-implementing the Serialization
      API for XML.

      FAQ Contents:
      (1). Background
      (2). Using the Serialization API
      (3). Using JSX

      If your question is not answered here, please try the homepage:
      or mailing list:


      (1). Background

      (1.1) JSX stands for...?
      Java Serialization to XML

      (1.2) What does JOS stand for?
      Java Object Serialization (sometimes referred to as "Java's own Serialization")

      (1.3) What are the uses of JSX?
      - Long-term persistence - XML can be modified directly.
      - A transparent protocol for communicating between different components,
      that is easy to debug, and able to cope with different objects.
      - Configuration files.
      - A debugging tool - dumping object state.

      (1.4) What are the benefits of JSX?
      - A human-readable form of normally invisible objects
      - A human-edtiable form, for entering and editing objects
      - A human-comprehendible wire/file protocol for object and data exchange
      between other applications and languages

      (1.5) What are the goals of JSX?
      To be able to instantly XML-enable applications, without needing to change
      them at all.
      - to produce a "human comprehendible" XML representation of object graphs,
      that is readable and robust under human edits.
      - in the long-term, to help users handle the inevitable evolution of objects

      - a direct JOS replacement.
      - replaceable *by* JOS. Thus, JSX should not pollute the Serialization API -
      and so JSX can only add functionality through its constructors, using the
      Config object.

      (2). Using the Serialization API

      (2.1). Where's a good tutorial?
      "Advanced Object Serialization", by John Zukowski (August 2001)

      (2.2). How do I write my own readObject() and writeObject() methods?
      Here's the signatures:
      private void readObject(ObjectInputStream ois)
      throws ClassNotFoundException, IOException {
      //your code here
      private writeObject(ObjectOutputStream oos)
      throws IOException {
      //your code here

      (2.3). How do I use GetField?
      It can only be used within a readObject() method that you have coded for your
      class, and is called by the serialization system.

      See example in:
      It's almost halfway through, under the heading: "Using ObjectStreamField"

      (3). Using JSX

      (3.1). How do I use Config?

      Config is used to configure JSX for both input and output. You create the
      Config object, set it, and then pass it into the constructor of either an
      ObjIn or ObjOut. For example:

      Config cfg = new Config().setNoSuchFieldHandler(handler).setFormatting(false);
      ObjectInputStream in = new ObjIn(cfg); //pass it in

      Note that the option setting can be chained. Check the source code
      (Config.java) for more options.

      For the above example, "handler" is used like an event handler. A common
      approach is to subclass the default implementation with your own anonymous

      NoSuchFieldHandler handler = new NoSuchFieldHandler() {
      public String noSuchField(Class c, String fieldName) {
      if (c==TheClassName.class && fieldName.equals("theOldFieldName") )
      return "theNewFieldName";
      throw new NoSuchFieldException("No mapping for "+theOldFieldName+" in "+c);
      //NOTE: instead of "if" above, use a Hashtable or HashMap for more complex cases
      //Eg. could use two: first tier maps classes to HashMaps, which in turn maps
      //old fieldnames to new fieldnames.
    Your message has been successfully submitted and would be delivered to recipients shortly.