Jayakumar Thirumalai

Greenhorn
+ Follow
since Jul 08, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jayakumar Thirumalai

"In its essence, a messaging system allows separate, uncoupled applications to reliably communicate asynchronously. The messaging system architecture generally replaces the client/server model with a peer-to-peer relationship between individual components, where each peer can send and receive messages to and from other peers."
For further details, you may look into the following web page:
http://developer.java.sun.com/developer/technicalArticles//Networking/messaging/inde x.html
Oracle also provides message queueing services.
Jay

[This message has been edited by Jayakumar Thirumalai (edited October 22, 2000).]
Hello Moon,
Since you have Oracle 8i, you can deploy EJB using deployEJB command.
You can also write a small client application to access EJB.
You may refer Oracle manuals. Oracle8i Enterprise Javabeans and CORBA developer's guide has a chapter called 'A First EJB Application'.
Jay

[This message has been edited by Jayakumar Thirumalai (edited October 09, 2000).]
As suggested by Carl Trusiak, you may use either 'and' or '&' in the attributes.
Suggestion 1: (use 'and' instead of & )
<?xml version ="1.0"?>
<!DOCTYPE orders [
<!ELEMENT orders (order+)>
<!ELEMENT order EMPTY>
<!ATTLIST order
customerName CDATA #REQUIRED
customerAddr CDATA #IMPLIED >
]>
<orders>
<order customerName= " mark and john " customerAddr= "route15">
</order>
</orders>
Suggestion II: ( use '& amp;' instead of & )
<?xml version ="1.0"?>
<!DOCTYPE orders [
<!ELEMENT orders (order+)>
<!ELEMENT order EMPTY>
<!ATTLIST order
customerName CDATA #REQUIRED
customerAddr CDATA #IMPLIED >
]>
<orders>
<order customerName= " mark & amp; john " customerAddr= "route15">
</order>
</orders>
I tried to use CDATA section to give value to an element in the following way.
<?xml version ="1.0"?>
<!DOCTYPE orders [
<!ELEMENT orders (order+)>
<!ELEMENT order (#PCDATA)>
<!ATTLIST order
customerName CDATA #REQUIRED
customerAddr CDATA #IMPLIED >
]>
<orders>
<order
customerName="mark & amp; john"
customerAddr= "route15">
<![CDATA[
: & order string & : < >
]]>
</order>
</orders>
CDATA section can not be used to assign value to attributes. The following text is from XML Tutorial from Sun.
"One other area to watch for is attributes. The text of an attribute value could also contain angle brackets and semicolons that need to be replaced by entity references. (Attribute text can never be in a CDATA section, though, so there is never any question about doing that substitution.)"
You have used <![CDATA[ before order tag. is that right way to do it?
All the above xml documents are parsed without any error.
Jay

[This message has been edited by Jayakumar Thirumalai (edited October 03, 2000).]
Another product for XML Data binding - Breeze XML studio from www.breezefactor.com
I understand that it is a visual developer tool, generates Java classes from XML Schema.
Jay
Thank you very much for the information on XML data binding.
I was searching for information on XML data binding. I could get hardly one or two articles.
Article by Brett McLaughlin in IBM website is good.
Some articles are in http://java.sun.com/xml/white-papers.html
Jay

[This message has been edited by Jayakumar Thirumalai (edited October 01, 2000).]
As you may be aware, in Sun implementation of JAXP, SAX parser is being used to build DOM object. if you don't handle error conditions, it may not do anything.
I have added
docBuilder.setErrorHandler(new MyErrorHandler());
in your program.
Also I have added a class MyErrorHandler which extends HandlerBase to handler error.
Now, it works. You may checkup.
import java.io.File;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.*;
public class Xml1 {
public static void main (String argv []) {
Document doc= null;
if (argv.length != 1) {
System.err.println ("Usage: cmd filename");
System.exit (1);
}
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder docBuilder =
factory.newDocumentBuilder();
//************** Added to handle error
docBuilder.setErrorHandler(new MyErrorHandler());
doc = docBuilder.parse (new File (argv [0]));
doc.getDocumentElement ().normalize ();
System.out.println("");
} catch (SAXParseException err) {
System.out.println("SAXParseException");
System.out.println(" " + err.getMessage ());
} catch (SAXException e) {
System.out.println ("error");
} catch (Throwable t) {
t.printStackTrace ();
System.out.println ("error");
}
System.exit (0);
}
}
class MyErrorHandler extends HandlerBase {
public void error (SAXParseException e) throws SAXParseException {
throw e;
}
}

Jay
Thank you, Sarada Baskar.
IBM's site is very interesting, simple, easy to understand.
Pages are well written, not large.
Jayakumar
You may try
jframe.validate(); before repaint().
if you want the second image to overlap on first image, you may have to remove the icon from panel also.
You may also increase the sleep time from 3000 to 5000 or 6000. This will give some time for the image to load.
Jay
24 years ago
Hello Michal,
You have given a link to a very good article on "How and when to Deprecate API?".
Thanks
Jay
24 years ago
Hello Lionel,
You have said it in a very simple, easy to understand way.
I appreciate that.
Jay
Try with "'public int f()' instead of 'private int f()'".
1. public class Tester {
2. public static void main(String[] args) {
3. System.out.println(new Sub().g());
4. }
5. public int f() { return 2; }
6. int g() { return f(); }
7. }
8. class Sub extends Tester {
9. public int f() { return 1; }
10.}
The result is "1".
Reason - f() in Sub overrides f() in Tester().
When f() in Tester was private,
g() can execute f() in Tester because g() is a method in Tester. Any method in Tester can access private variables and methods.
Eventhough g() has access to both f() in Tester and f() in Sub, it prefers (???) to execute its own private f() method rather than public f() method in Sub.
is this more confusing !!!

As per Java2 Certification Study Guide Page 79:
The rules for overriding can be summarized as follows:
- A private method may be overridden by a private, friendly, protected or public method.
- A friendly method may be overridden by a friendly, protected,or public method.
- A protected method may be overridden by a protected or public method.
- A public method may only be overridden by a public method.
How about using RandomAccessFile (readLine) and StringTokenizer (hasMoreTokens and nextToken).
RandomAccessFile raf = new RandomAccessFile("filename", "r");
String line = raf.readLine();
StringTokenizer st = new StringTokenizer(line);
String s = st.nextToken();
You may use parse to get int from string.
Code the above in appropriate loop.
check for null for end of file.
use st.hasMoreTokens to check the end of st.
Jayakumar
24 years ago
MSB (Most significant bit) is sign bit - am I correct?
if so, in 0x80400000 MSB is 1 which makes it negative.
(negative numbers are stored in one's complement (or is two's).
So, while calculating value from the given hexadecimal number, you should take care of this)
For example, if you change the value to 0x40400000,
the value is 1077936128 which is not a negative number.
int is signed. So, it can hold negative values.
int Minimum value is -2,147,483,648
int Maximum value is 2,147,483,647
Another example, if you change the value to 0x80000000
the value is -2,147,483,648. This clearly shows that MSB is the sign bit.
Try with 0x7FFFFFFF.
the value is 2,147,483,647. This is the maximum value you can store in int.
I hope this makes it clear.
Jay

24 years ago