Solved

construct a cache editor

Posted on 1998-07-06
9
219 Views
Last Modified: 2010-03-30
This is what I am trying to do. Perhaps you can point me in
the general direction because I am confused. I have been
researching sorting methods and I am confused. I want to
take the cache entries which are html gif jpg and class
files mostly and put them into order according to when
they were last modified. I want to display this in a window
like a database but it is an editor. So I will have an html
file followed by the images and java in it in the order.
I want to be able to erase one html file and all the images
and java that go with it so I can edit my cache. I figured
I have to get the file names first and order them; but also
it would be nice if I could look in the html file and extract all the src's and get just the image file names
without the paths and also get all the java class files.
This would be better than just erasing the following
files after the html file. Can you give me some hints and
pointers. Dont ware your brains out with details, just get
me started would be okay. I figure the sort method is in
the java.util but maybe also in the java.io but I do not
see how I demand it to sort in any specific way. I mean
it seems like you just sort and this means alphabetically;
but I want to sort numerically and specifically in the
time and date area. Since the time is measured in seconds
then I must sort the seconds column. Can you help?
0
Comment
Question by:johnh619
  • 5
  • 4
9 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 1224747
There seem to be a bunch of questions here: getting at the cache, identifying pages in pages and sorting. Perhaps you could identify more clearly which you are interested in, or, if it is some or all of them, at least separate them.

0
 

Author Comment

by:johnh619
ID: 1224748
step 1:get all files names from cache(this could be four caches
in IE-c:/windows/tempor~1/cache1 thru 4)
step 2:sort according to last second of modification(it must
be to the second and not just to the minute)
step 3: take one htm file and either erase all the gif, jpg,
midi, class files from it to the next htm file or, what would
be better would be to extract all the src's file names and
class file names from one htm file and then erase all the files
using this extraction.
0
 

Author Comment

by:johnh619
ID: 1224749
also is this true: that in order to describe the sort method
as either alphbetic sorting or numerical or some type of sorting,
do I have to describe it with logic or is the sort method further
subdivided into types which I can not find. Incidentally I found
this thing call the java explorer which is an applet which
downloads and makes a double window, you can look at the part of
each class file or push the button and access a sun java site
for additional info. I thought maybe it is this additional info
which I desire and which I can not find in books.
0
 

Author Comment

by:johnh619
ID: 1224750
I hope you got my last reply, it has been a week since I sent it.
But if possibly did not get it then I write again. If you are too
busy I will understand. In the mean time I have been compressing
my site images with Gif Wizard, it really needed it. Now my pages
load almost twice as fast. I paid them $19 for one month unlimited use. Sincerely JohnH
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:imladris
ID: 1224751
John,

I have no experience with the first two components of the question. I have been working in an application environment for the last year, not applet/browser.

If you want, I can help you with the last question; the sort.

0
 

Author Comment

by:johnh619
ID: 1224752
Please help me with the sort then and I will resubmit some or
all of the question and let them find someone else to help
perhaps. Thankyou
Incidentally I was wondering: Do you work for this company and
trade your points in for cash and they use this as an incentive
system. I could not imagine what you would do with so many points
and I figured you did not have to ask to many questions yourselfs. Sincerely JohnH
0
 
LVL 16

Expert Comment

by:imladris
ID: 1224753
Sorry, I missed you're reply here somehow. Are you still looking for help with the sort?

No, none of the experts work for experts-exchange, nor do we receive any cash. The experts are all volunteers. This site operates more like a bulletin board or newsgroup than anything else. The format just makes it a lot more focussed.

0
 

Author Comment

by:johnh619
ID: 1224754
yes please help with numberic sort for date and time down to
the second
0
 
LVL 16

Accepted Solution

by:
imladris earned 50 total points
ID: 1224755
OK, I don't know how your data is going to be represented when you read it in. But for starters I will assume that you will have the information on File names and times in a Vector. A Vector is convenient for such things since it automatically resizes, and it provides some standard housekeeping methods to boot. Furthermore, then, the files will each be represented by some object, which will then go into the Vector. Each object should implement a Sortable interface (we'll get into that at the end) and the Vector can be sorted by the following routine:

public static void ssort(Vector sv)
{      int gap,i,j,tmp;
      Sortable a,b;

      int l=sv.size();
      for(gap=l/2; gap>0; gap/=2)
      {      for(i=gap; i<l; ++i)
            {      for(j=i-gap; j>=0; j-=gap)
                  { a=(Sortable)sv.elementAt(j);
                    b=(Sortable)sv.elementAt(j+gap);
                     if(a.comp(b)>0)
                    {      sv.setElementAt(b,j);
                          sv.setElementAt(a,j+gap);
                    }
                    else break;
                            }
                     }
                 }
                return;
}

This is a relatively straightforward implementation of a standard shellsort. A Vector of objects is passed in, and they are rearranged into sorted order. In order to do that, the objects must be sortable, i.e. provide a comp method which will reveal the correct order of any two objects. The Sortable interface would be:

public interface Sortable
{   public int comp(Sortable o);
}

The shellsort routine assumes that comp returns -1 if a is less than b, 0 if they are equal and 1 if a is greater than b (similar to strcmp in C).

So finally, in this scenario, you would need a file object that provides a comp. It would be something like the following:

public class FileEntry implements Sortable
{    String name;
      long  timestamp;

     ...
     ...  (whatever methods you need)

     public int comp(Sortable o)
     {   FileEntry f=(FileEntry)o;
         if(timestamp==f.timestamp)return(0);
         return(timestamp<f.timestamp?-1:1);
     }
}


This structure is assuming that the timestamp instance variable  got the timestamp of the file from the lastModified() method in the File class in the io package.. That allows a standard comparison to reveal their ordering.

Let me know if there is anything you need clarified.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now