Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

construct a cache editor

Posted on 1998-07-06
9
Medium Priority
?
278 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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
 
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 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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 …
Suggested Courses

971 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