Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Private Member Functions
TestINIParser Class Reference

List of all members.

Static Public Member Functions

static void main (String[] args) throws FileNotFoundException, IOException

Static Private Member Functions

static void createSampleINIFile (File aFile) throws IOException
static void printValidSections (INIParser aParser)

Detailed Description

Definition at line 44 of file TestINIParser.java.


Member Function Documentation

static void TestINIParser.createSampleINIFile ( File  aFile) throws IOException [inline, static, private]

Definition at line 81 of file TestINIParser.java.

                                                                         {
    BufferedWriter out = new BufferedWriter(new FileWriter(aFile));
    out.write("; first comment\n");
    out.write("; second comment\n");
    out.newLine();
    out.write("[good section 1]\n");
    out.write("param1=value1\n");
    out.write("param2=value2\n");
    out.newLine();
    out.write("[invalid section] 1\n");
    out.write("blah=blippity-blah\n");
    out.newLine();
    out.write("[good section 2]       \n");
    out.write("param3=value3\n");
    out.write("param4=value4\n");
    out.newLine();
    out.write("param5=value5\n");
    out.newLine();
    out.write("invalid pair\n");
    out.write("this shouldn't appear\n");
    out.write("   ; another comment\n");

    out.close();
  }

Here is the caller graph for this function:

static void TestINIParser.main ( String[]  args) throws FileNotFoundException, IOException [inline, static]
Parameters:
argspath of INI file to parse, or null to parse a sample file
Exceptions:
IOException
FileNotFoundException

Definition at line 52 of file TestINIParser.java.

                      {
    if (args.length > 1) {
      System.err.println("TestINIParser [file]");
      return;
    }

    INIParser parser = null;
    File iniFile = null;
    File tempFile = null;

    try {
      if (args.length == 1) {
        iniFile = new File(args[0]);
        parser = new INIParser(iniFile);
      } else {
        tempFile = File.createTempFile("testiniparser", null);
        createSampleINIFile(tempFile);
        parser = new INIParser(tempFile);
      }

      printValidSections(parser);
    } finally {
      if (tempFile != null) {
        tempFile.delete();
      }
    }
  }

Here is the call graph for this function:

static void TestINIParser.printValidSections ( INIParser  aParser) [inline, static, private]

Definition at line 106 of file TestINIParser.java.

                                                            {
    Iterator sectionsIter = aParser.getSections();
    while (sectionsIter.hasNext()) {
      String sectionName = (String) sectionsIter.next();
      System.out.println("[" + sectionName + "]");

      Iterator keysIter = aParser.getKeys(sectionName);
      while (keysIter.hasNext()) {
        String key = (String) keysIter.next();
        String value = aParser.getString(sectionName, key);
        System.out.println(key + " = " + value);
      }

      System.out.println();
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:


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