16th, May ---------First day of class. Sounds promising. Looking forward to learning some GUI stuff.
18th May ---------Got hold of a book. Barbara Johnston's Java Programming today. It's got some nice pointers on OOP design patterns. Reviewed the chapters on
23rd May ---------Spent few hours trying to get the applet to work from utd server. It was working fine from my machine, as soon as I would upload it to the server, the applet would not initilalize. I was getting an "applet not inited" error. Searched on the google and seems everybody on this planet who has ever written an applet encountered the problem.
MainPictures.java ---> Class object
AnyJavaClass.java --> Class object. etc
Class object can't negotiate anything beyond type or hierarchy information relating to the type it is connected with. So, calling a method of the type (e.g., MainPictures.drawAPic()) through MainPicture's Class object won't work. For this to work, one has to create an instance of the type.Class mpic = Class.forName("MainPictures"); //watch out, don't write "MainPictures.class" in the arg param
Object o = mpic.newInstance(); // o needs to be explicitly downcast to MainPictures before calling methods specific to MainPictures. Alternatively MainPictures mp = mpic.newInstance().
Working from the opposite direction, one can get a Class object if one has the object of the specific type. For example,MainPictures mp = new MainPictures();
Class cl = mp.getClass(); // now operate on the meta info of MainPictures
25th May ---------It's getting more and more confusing. The applet works just fine from a different machine, but not from mine. I uninstalled my JRE and installed again from java.com. JDK has an internal JRE (under the jdk folder) and then there's a seperate JRE that is run by the browsers as a plug-in. I compile my programs to JDK's JRE. I brought up the java console and looked at the error trace (it's available from the JRE/bin folder. Run the jcpl.exe and from the advanced tab, check in show console, which brings up a java coffee cup logo everytime there's an applet related acitiviy going on). The error is a classNotFoundException. I don't know if my machine is corrupting the JRE/JVM for the browsers. The applet can be executed here
28th May ---------Since the next week the topic for the class would be on XML, thought I would go over it ahead of time. I already knew XML syntax, so I wound up spending the whole evening on XML schema. XML schema provides an alternative means to more commonly used counterpart - DTD. W3C's schema language, unlike DTD, is just another XML document and therefore relives the XML application developer of not having to know two different platforms. Schema language is more powerful than DTD insofar as its rich repatoire of built-in data types and custom types bestows more control on developers. But after looking at few examples, I think DTD is more intuitive than XML Schema and doesn't produce a shipwreck as the final result. Besides the argument about DTD being an alien platform and thus it makes potential developers wince at it is overstated. It took me more time to figure out elements in XML Schema specification and how they can applied than the whole DTD shebang. The real argument should lie in its power, not ease of use. I think standardizations are merging towards XML Schema and modern applications and parsers are supposed to recognize and exercise this than DTD, meaning DTD mechanism is left to saunter to a graceful death.
1. Schema Namespace ===> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 2. Element tag to identify document elements ===> <xs:element ...> 3. Element tag to identify document attributes ===> <xs:attribute ...>
29th May ---------XML Schema continues...
7th June ---------Was working on an RDF project that requires walking through the RDF tree and flattening it to grab the statements info. Unfortunately, the Jena API -- the backburner that enables working with RDF in a programming level -- strips property resources belonging to a subject resource from their structured, coalesced form and make a new statement out each of them. What this means is if a subject contains two properties in an RDF file you wrote in your RDF Editor, they are part of two different statements in the Jena model holding the tree. While this exposes the internal membrane of the RDF philsophy -- that is, a statement consists of single subject, single property, single value -- this is cumbersome when you need to print them out in say System.out by walking through the statements. Since, subjects having multiple properties are duplicated, they appear same number of times as they have properties, which resembles N-triple format. Obviously, model.write(tree,"RDF/XML-ABBREV") provides the desired output, but this call goes directly to output stream without me being able to manipulate the statements. So I need to store the statements in a Java collection that forbids duplicates. The whole reason for the long-winded paragraph is to set the basis for why collection is such an important framework. There're two collections that majority of people are familiar with. One is the C++ STD library and the other is Java's Collection Framework (JCF). Since Jena is Java based (and so is this class :-)), I will have to study the collection classes.
10th June ---------JCF is backed by several interfaces and the concrete classes that implement those interaces. Interfaces are straightforward and hierarchical: At the top is the Collection interface and Map (Map doesn't inherit from Collection)
Collection Map
|
------------------------
| | |
Set List Queue
The implementation classes that provide the concrete implementations for these are quite interesting:
Interface --------------- Concrete Classes
1) Set HashSet, TreeSet, LinkedHashSet
2) List ArrayList, Vector
3) Map HashMap, TreeMap, LinkedHashMap
These interface are defined in a generic fashion and requies explicit type information when creating their instances (Hello C++!). So a set could be created as Set<String> s = new HashSet<String>. Obviously, s could have been HashSet too, but that runs against the polymorphism ideals and therefore not good programming practice. Difference between Hash*, Tree*, LinkedHash* is the first one doesn't provide ordering, second one provides ordering based on element values (can be quirky), and the last one provides ordering based on insertion(meaning programmer defines the ordering). HashSet is the fastest implementation, but I need LinkedHashSet for my work.
Some Important methods that provide the basic operations are as follows:
1)Set --