THE FU LIBRARIES

Fu is a bunch of Java code with the pretention to be useful (to someone sometime).

Fu is a Java library with common implementation of facilities not found in J2SDK.


FU MAPS

Fu makes intensive use of maps and provide some nice ones. Among them, emphasis is due to typed maps. Rather than use a code like this:

    java.util.Map map = new java.util.HashMap();
    map.put("name", "java-fu");
    map.put("desc", "The Fu Libraries");
    map.put("rev", new Integer(400));
    
    String n = (String) map.get("name");
    int r = ((Integer)map.get("rev")).intValue();

you can write:

    fu.util.TypedMap map = new fu.util.TypedHashMap();
    map.put("name", "java-fu");
    map.put("desc", "The Fu Libraries");
    map.put("rev", 400);
    
    String n = map.getString("name");
    int r = map.getInt("rev");

They can do some handy conversions also:

    map.put("rev", "400");
    int r = map.getInt("rev"); // allright for lax typed maps
    map.put("class", "java.lang.String");
    Class cl = map.getClass("class");

You have facilities also for maps with case-insensitive behavior for String keys, map comparators, etc., etc.


SIMPLE XML

Well, for simple, we mean that you read a XML file like this and have a Java structure to play with. It is composed of maps (I have said that they were going to happen a lot here), lists and strings.

    Simple s = new fu.xml.Simple();
    Map map = s.in("my.xml");


SMART SQL STATEMENTS

If you like programming JDBC with code snippets like this:

    String SQL = "SELECT a, b FROM T WHERE k1 = ? AND k2 = ?";
    PreparedStatement stmt = conn.prepareStatement(SQL);
    stmt.setInt(1, k1);
    stmt.setString(2, k2);
    ResultSet rs = stmt.executeQuery();
    while (rs.next()) {
      System.out.println("a: " + rs.getInt("a") + ", b: " + rs.getString("b"));
    }

that's allright.

We prefer to do it this way:

    String SQL = "SELECT a, b FROM T WHERE k1 = ? AND k2 = ?";
    SQLStatement stmt = conn.prepare(SQL);
    SQLResultSet rs = stmt.executeQuery(params);
    while (rs.next()) {
      System.out.println(rs.get());
    }


LINKS


COPYRIGHT

Copyright (C) 2005 Adriano R. Ferreira. All rights reserved. This is free software; you can redistribute it and/or modify it under the terms of GPL or LGPL.


NOTES

This project is hosted at Sourceforge.

    $Date: 2005/05/24 14:12:11 $
SourceForge.net Logo