Public Member Functions | Static Public Member Functions

de.mfuchs.Example3 Class Reference

Example to use XMLStorage for writing and reading XML files. More...

List of all members.

Public Member Functions

void testWrite () throws Exception
 Write an example XML file to disk.
void testRead () throws Exception
 Read the example file back again.

Static Public Member Functions

static void main (String[] args)
 Main function of Example3.

Detailed Description

Example to use XMLStorage for writing and reading XML files.

Author:
martin

Definition at line 58 of file Example3.java.


Member Function Documentation

static void de.mfuchs.Example3.main ( String[]  args ) [static]

Main function of Example3.

Parameters:
argsunused command line arguments

Definition at line 117 of file Example3.java.

References de.mfuchs.Example3.testRead(), and de.mfuchs.Example3.testWrite().

    {
        Example3 me = new Example3();

        try {
            me.testWrite();
            me.testRead();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

Here is the call graph for this function:

void de.mfuchs.Example3.testRead (  ) throws Exception

Read the example file back again.

Exceptions:
Exception

Definition at line 84 of file Example3.java.

References de.mfuchs.xmlstorage.XMLPos.back(), de.mfuchs.xmlstorage.XMLPos.get(), de.mfuchs.xmlstorage.XMLPos.go(), de.mfuchs.xmlstorage.XMLInt.intValue(), and de.mfuchs.xmlstorage.XMLDoc.readFile().

Referenced by de.mfuchs.Example3.main().

    {
        XMLDoc doc = new XMLDoc();

         // Einlesen des XML-Files
        doc.readFile("example3.xml");

        XMLPos pos = new XMLPos(doc);

        int stopbits = 0;
        String parity = "";

         // Abfrage der Attributwerte des Elements "Y_ACHSE"
        if (pos.go("Y_ACHSE")) {
            stopbits = new XMLInt(pos, "Stopbits").intValue();
            parity = pos.get("Parity");

            pos.back();
        }

         // Ausgabe der ermittelten Werte
        System.out.println("Stopbits: " +  stopbits);
        System.out.println("Parity: " +  parity);

        assertTrue("Stopbits", 1==stopbits); 
        assertEquals("Parity", "N", parity); 
    }

Here is the call graph for this function:

void de.mfuchs.Example3.testWrite (  ) throws Exception

Write an example XML file to disk.

Exceptions:
Exception

Definition at line 64 of file Example3.java.

References de.mfuchs.xmlstorage.XMLIntRef.assign(), de.mfuchs.xmlstorage.XMLPos.back(), de.mfuchs.xmlstorage.XMLPos.create(), de.mfuchs.xmlstorage.XMLPos.put(), and de.mfuchs.xmlstorage.XMLDoc.writeFile().

Referenced by de.mfuchs.Example3.main().

    {
        XMLDoc doc = new XMLDoc();
        XMLPos pos = new XMLPos(doc);

         // Zusammenstellen der XML-Struktur im Dokument 'doc'
        pos.create("Y_ACHSE");
          new XMLIntRef(pos, "Stopbits").assign(1);
          pos.put("Parity", "N");
        pos.back();

         // Schreiben der XML-Datei
        doc.writeFile("example3.xml");
    }

Here is the call graph for this function:


The documentation for this class was generated from the following file: