Aaron John

Ranch Hand
+ Follow
since May 30, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Aaron John

Paul Clapham wrote:

Aaron John wrote:Is there a special syntax for the double forward slash in xsl? For example, the use of "//"



I don't understand the question. That is syntax.



Oops, I didn't word the question properly. What I meant was - how is specifying a double slash different to specifying a single slash? I understand that specifying a single slash will point to the root element in the xml document, specifying an absolute path.

Paul Clapham wrote:One other thing you didn't know about XSLT is going to mess up that plan, no matter how you decide to store the data: once you assign a value to an xsl:variable, you subsequently can't change it. So you'll need to go back to the drawing board and design a completely different solution to your original problem.

Perhaps it would be better to just post your original problem? If you have a solution to a problem but don't know how to implement it at all, it's generally better to ask about the problem and not about the solution.

Edit: for example, if your problem is actually

I would like a collection that holds all the /order/method/description values

then just write an XPath expression which returns that directly. Like "//order/method/description".



Is there a special syntax for the double forward slash in xsl? For example, the use of "//"
Hi there,

I'm quite new to writing XSL. I was wondering whether it is possible to declare a variable that is a collection, e.g. something similar to a List or Map in the Java programming language.

A bit about what I want to do. I would like a collection that holds all the /order/method/description values. For each order, I check the collection. If the description does not exist in the collection, I add the description in the collection and perform some action. If the description does exist in the collection, I ignore it and move to the next order.



Is it possible to do this in XSL? All the variable declarations store a string value or a numeric value, can XSL support more complex variables? If no, is there an alternative?

Originally posted by Jethro Borsje:


You can also choose to read the data file into memory before hand, the Data class would then just hold a Map of the records in memory. Using this approach you do not have any IOExceptions during the usage of the Data class. You can catch these errors before hand we reading the file into memory. In my opinion this is also better, because you may not want th DB server to run at all if some serious IOExceptions occurred.



Ah okay, that is a good approach. Thanks for that. How often would one read the database in order to have the latest records in memory?

Originally posted by Jo´┐Żo Batista:
Think about the kinds of Exception that a method can throw and how they affect the method signature.
You'll find a way to disguise that IOException.



Hi Joao,

I could not follow your previous post. Could you give me an example please?

Thanks.

Originally posted by Jason Moors:
Hi Aaron,

A possible solution if you don't want to handle the RecordNotFoundException in your find method is to create a new private method for actually reading the record which doesn't throw an exception, this method would return null array if the record is not found or marked as deleted.



This new method would then be called by both the read and find, the read method would check if the returned value is null and throw a RecordNotFoundException, and the find method could ignore null array and not add to search results.

Hope it helps,
Jason

[ June 23, 2008: Message edited by: Jason Moors ]



Okay, for example in the read method, the read method will need to read the actual database file, but these kind of operations may throw an IOException. How would you handle the IOException so that it doesn't propogate to calling methods?
My interface for read is


If a client calls the read method with a given recNo, the read method has to check whether the record is flagged as deleted. When encountering a deleted record, is it necessary to throw a RecordNotFoundException? e.g.



I'm in two minds about this. If my client tries to read a deleted record, some sort of exception from the data layer should be sent to the client, indicating that the record is deleted, hence a RecordNotFoundException.

On the other hand, my find method also calls the read method, and throwing the RecordNotFoundException to my find method forces the find method to handle the exception - in this case, the find method would just ignore the exception (ignore any deleted records). To me, this isn't good use of RecordNotFoundException.

Does anyone have any thoughts on proper ways it should be implemented?

Originally posted by Roberto Perillo:
Well, to me, "Field n in the database file is described by criteria[n]" means that the search criteria should have the same number of fields of a record, and "A non-null value in criteria[n] matches any field value that begins with criteria[n]" means that any value in criteria[n] should match any field that is different from null and that starts with criteria[n].



Again, I have interpreted this differently. However your interpretation is also valid to me, so I believe justifying your interpretation as a design decision has to be done. My interpretation is:

* Field n in the database file is described by criteria[n].
I have interpreted this to mean: field[0] in the database file is described by criteria[0]. In the B&S assignment, field[0] is the name field. To search by name, the appropriate element in the criteria array must be used, i.e. criteria[0].

* A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)
I have interpreted this to mean: A null value in criteria[0] matches any value in field[0]. A non-null value in criteria[0] matches any value in field[0] that begins with criteria[0], ignoring case sensitivity. For example, criteria[0] is "dog". It will match any value in field[0] beginning with "dog", such as "Dogs with Tools", "Dog and Cat care", "Doggolono Sellers Ltd"
I believe I've answered my own question with this link

https://coderanch.com/t/188630/java-developer-SCJD/certification/Exceptions-created-as-member-classes

A member class is not a class that has visibility within a given package. This clears up my misunderstanding.

So obviously it makes sense to have these exceptions as public.

However for my other question, if I defined an exception in my business layer, would it be best to put that exception in the suncertify.db package or put that exception in my business layer package?
Hi, sorry if this has been brought up before, but I wasn't able to find anything regarding the following.

The assignment specification says.

Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package.

So my interface contains RecordNotFoundException and DuplicateKeyException. To my understanding member classes do not have any visibility outside of the package it belongs to. So RecordNotFoundException is only visible in the db package. Does that mean I must define my exceptions as the following?



If that's the case, how can I handle a RecordNotFoundException in my business layer?

Also in my business layer I defined new interfaces, is it necessary to put this interface in the suncertiy.db package as per the specification, or put the new interface in my business package?

thanks
[ June 06, 2008: Message edited by: Aaron John ]

Originally posted by Quintin Stephenson:
Hi All

I've gone for a dynamic approach with regards to the shema in a similar manner at Edwin. I read the meta data in the header and create a schema object. This object contains all the information that will dictate everything with regards to data (ie. data type, length postion in of column per records etc) and will ensure data ways ends up in the correct position in the datafile. It will also be used to affect my MVC model for the displayed GUI to my users.

My analysis of the data file gave me similar questions and conclusions(by the sounds of it) to Edwin. What redesign work would I have to go through if a new column was added (e.g. in my assignment I can see a need for a phone number column to be added). By the sounds of it some people are going for similar solutions to Andrew Monkhouse's book solution using a traditional hard coded Transfer Object design pattern.

I think you should be fine as long as you can justify it and remember to document it in your choices document as this is a major part of your assignment (your thought process and why you did certain things).

Cheers
Q



I am also doing the B&S assignment. For this schema object, how did you implement this schema object? I thought about:

- making the Schema object a singleton class so that metadata can be loaded only once (preventing unnecessary calls to loading metadata everytime a client accesses the database), and it can be made accessible throughout the entire application. But I came to the conclusion that we have a data layer interface for database operations, so having a singleton Schema object in the data layer kinda goes in the opposite direction.

- making a new interface called Metadata, which the Data class implements in addition to DBMain. The interface contains methods like getColumns() etc. The problem is that I don't know how to prevent unnecessary calls to loading metadata everytime a client connects to the database (ideally I only want metadata to be loaded once and once only), and I'll need to have two references to the interface to call the data layer (DBMain and Metadata), when ideally I would only really want one.

What have others implemented? Please share your ideas. Thanks

Originally posted by Musab Al-Rawi:
Hi,
you can either
1. define another interface and have your Data.java class implements both DBMain and the new interface.

2. or in UI call find for all contractors then extract the info that you need to build the combo boxes.




Thanks for that. Immediately after I posted my question, I thought about your 2nd idea.
Hi there,

After much internal debate, I decided to implement my UI to search for names and locations using combo boxes. My problem is how to expose these names and locations to the UI, so that these combo boxes are populated.

My Data class implements the DBMain interface. It contains a reference to SubcontractorFileAccess.java, which does the actual file reading using RandomAccessFile.



Now since SubcontractorFileAccess will be responsible for retrieving a collection of names and locations, how are these values made available to the client, without accessing SubcontractorFileAccess directly? The only way the Data class is accessed is through the DBMain interface, and according to the assignment specification I am not permitted to add new methods to the DBMain interface to get names and locations from the Data layer. I was going to add public methods to the Data class, but I would need a reference to the Data class implementation to access these methods. It is undesirable because my Data class is screaming for it to be accessed via the DBMain interface.

Does anyone have any ideas on how I can retrieve name and location from the Data layer?

Thanks in advance.
Is there any way to do this in reverse?

e.g. you have a date along the lines of 2008-02-19.

How would you end up with a String with something like 20080219 ??

Thanks
14 years ago

Originally posted by Mike Ottinger:
Hi Aaron,

I implemented the searching using combo boxes. I felt, even with a potential increase in names and locations, that this approaches was still tenable. I had two drop-downs, one for name and location each. Then a radio button indicating a search mode of 'any' or 'both', defaulting to 'any'. With drop-downs, the user input is controlled, thus removing the need for me to do any intensive validation of search terms. Hope this helps...




Thanks Mike. Your reason for using combo boxes was very sound to me. I will most likely follow that approach. Was concerned about the increase in names and locations, but after looking at the data I was supplied with, there were only 12 different locations, and 8 different names. So like you said, any increase in names/location won't affect usability. The search mode of 'any' or 'both' is also a good one. So if the name was Fred, the location was Atlantis and the search mode was 'any', then all records with name Fred will be returned (regardless of location), and all records with location Atlantis will be returned (regardless of name). And it's good that I don't need to do any string validation on entered text, such as invalid characters, case sensitivity. I imagine going down the combo box route could save a lot of headaches later on. BTW, I haven't actually started coding functionality, just mocking up some screens on paper and in code at the moment.