Computer Chemistry Consultancy - XML4Pharma, Katzelbachweg 18, A-8052 Thal, Austria, info@CompChemCons.com |
|||||
|
|
|
|
|
|
This page contains a number of goodies, code that you may download, copy,
change, ...
However, this is code "as is", so we cannot guarantee that it works 100%
perfectly.
If you find any bugs in the code, please let us know.
There are a lot of "Table of Elements" - applets on the internet. However, this one is written as a Java Bean, and it comes with source code ! The Java Bean itself is implemented as a JPanel, so that you can easily integrate it in other panels and containers, as part of a larger application. The bean has a large number of "getters and setters" so that you can easily adapt it to what you want with very little programming effort. A demo is given where the bean is incorporated in a Dialog (i.e. it works as a chemical element chooser).
This Java Radioactive Decay Applet was designed, constructed,
tested and deployed in just somewhat more than 2 days. It shows that when a
developer has the right expertise, and making use of reusable compounds, a
robust application can be made in very little time.
The applet is made modular, so that we can easily integrate it in any
web-application, such as a Radioactive Materials Supply Management System.
The applet enables to calculate radioactivity levels at any date when the
activity at a certain date is known. Also one can calculate the date at which
a certain radioactivity was or will be reached for the given nuclide. This
applet is free for use on intranet or internet.
This applet is very popular: it has been downloaded over 1500 times from our website (status March 2004).
A typical way the class is used consists of:
The XML is returned as a String that already contains carriage returns, so
that it can easily be written to a file using some outputstream.
Danny Ayers
original class returned the XML with the information in the attributes.
This class returns it as XML without attributes by default, but you can
choose to do it Danny's way using the method:
Here is the code:
JDBCToXML.java
XMLUtil.java, a helper class
Important Remark: You can get in serious difficulties if the
data that come from the database themselve contain characters like >, <,
" or &. In order to avoid problems we strongly
advise you to use the filter method of the class
"ServletUtilities" that can be found below, or at http://www.coreservlets.com.
This class and method
filters out these characters and replaces them by the strings > ,
< , " and &.
Do you understand why ?
You can find the answer in the following section
When reading text (from a form, database, etc..) and putting the text in an XML element or attribute, some characters can lead to invalid XML data. For example, if you add the text "doses <5 mg or >10 mg", this can be recognized as an XML element (<5 or>), but as it does not occur in the DTD, the XML file is considered invalid by applications (the element name is invalid anyway, as it contains a blank).
To avoid such problems, software that reads text and converts it XML should always filter specific characters, and replace them by their entities. The Java source code to do this is given here. It comes from the book "Servlets and Java Server Pages" by Marti Hall.
JNumberField is a Swing JTextField that only accepts numbers. Characters that cannot belong to a number are rejected during typing. This means that it is impossible to get an error when reading out the JNumberField and converting it to a number. JNumberField accepts numbers in different formats, also in scientific notation. E.g.:
The archive file comes in two versions: one for JDK1.3.x (JNumberField.jar) and one for JDK1.1.x (x>=7) (JNumberField1.jar). We couldn't get JNumberField to work correctly under JDK1.2 (bug in JDK?). However, as Swing is an integral part of Java2, we encourage you to use JNumberField under JDK1.3.x. For applets, this means the use of the Java2-plugin in the browser.
All (including the javadoc documentation) is included in the following
ZIP-file:
JNumberField.zip
Please let me know about your experience with JNumberField.
JIntegerField works very analogously to JNumberField. The main difference is that it only accepts integers. This means that any other typed characters (excluding + and -) are simply rejected during typing.
The archive file we provide was created with JDK1.3, so it will not work with earlier versions of the JDK. For applets, this means the use of the Java2-plugin in the browser.
All (including the javadoc documentation) is included in the following
ZIP-file:
JIntegerField.zip
Please let me know about your experience with JIntegerField