Vous êtes sur la page 1sur 43

CHAPTER 1

INTRODUCTION
1.1 overview
Download manager is a soft ware used for managing internet downloads. Managing means to provide functionality like you can pause a download in the middle resume from the previous position manage multiple downloads etc. Download Managers usefulness is its ability to take advantage of downloading only specific portions of a file. In a classic download scenario, a whole file is downloaded from beginning to end. If the transmission of file is interrupted for any reason, the progress made towards completing the download of a file is lost. The Download Manager, however, can pick up from where an interruption occurs and then download only the files remaining fragment. This program requires interfacing with the internet which shows that the javas network capabilities are unsurpassed. Internet downloads can be mainly done by using two protocols i.e. FTP and HTTP. Nowadays normally we use HTTP. HTTP downloads come in two forms: 1. Resumable(HTTP 1.0) 2. NonResumable(HTTP 1.1) In HTTP 1.1 we can ask for a specific portion of a file from the sender but in the case of HTTP 1.0 we can only ask for the full file and not for the specific portion of a file. The download manager uses a simple yet effective GUI interface built with javas swing libraries. The download managers window is shown below. Each download in the list

reports its URL, size of the file in bytes, progress as a percentage towards completion and current status.

Figure Main page The download manager is broken into four modules or classes: 1. Download 2. DownloadsTableModel 3. ProgressRenderer 4. DownloadManager

The DownloadManager class is responsible for the GUI interface and makes use of DownloadsTableModel and ProgressRenderer classes for displaying the current list of 2

downloads. The Download class represents a managed download and is responsible for performing the actual downloading of a file.

1.2 Objective
Airport Management System Objective of airport planning to airport operations management, the components of an effective airport management system can be far-reaching. Intergraph offers a full and comprehensive set of software solutions that, when integrated with your airport management system can provide operational efficiencies and protect your passengers.

Airport Management System We invite you to learn more about the ways in which software solutions from Intergraph can help your organization develop a comprehensive airport management system.

Contact Intergraph Planning an effective airport management system can prompt many questions. If your organization is currently planning to develop or improve your airport planning and management systems, we encourage you to contact us today. Our decades of experience can help. For sales inquiries, please use our information request form.

Airport Management System: To Serve and Protect Intergraph provides operations management solutions that help you reduce delays and get your customers where they need to be on time. Our airport planning and management

solutions encompass numerous safety-related software offerings to handle emergencies from positions of both prevention and response. Critical Infrastructure Protection. Chicago's O'Hare International Airport is one of the world's busiest airports, serving more than 72 million customers every year. When they were looking for an airport management system that focused intently on protection and safety, they chose Intergraph. That was in 1991. Today, more than 16 years later, they are still choosing Intergraph. To help promote comprehensive airport planning and management, Intergraph provides powerful critical infrastructure protection software to help ensure safety. Through automation and design intelligence, Intergraph gives you the ability to create an airport management system that addresses the unique airport planning and management needs of your organization. All the while, your organization gains the tools it needs to ensure the utmost level of safety at the same time. Airport Management System Solutions from Intergraph To build a system that meets all of your organization's objectives, contact Intergraph today. With decades of experience helping some of the world's largest airports, we can work with you in devising a host of airport planning and management options.

1.3 Company details

HCLCDC As the training arm of HCL Infosystems, HCL Career Development Centre (CDC) carries forth a legacy of excellence spanning across more than three decades.

HeadHCLCDC

"At HCL the concept of people-empowerment has been our guiding force through an eventful journey of over three decades having made HCL a $5.1 billion global conglomerate."

GuidingPrinciples

"Together we create the enterprises of tomorrow"

HCLCDCAdvantage Learn industry nitty-gritty from top HCL professionals.

Quality

"We shall develop and Impart Industry relevent ICT Education to meet the requirement of customers,Industry and scocity by conitnually updating technology content and improving our processes"

IndividualLearningSolutions

At CDC, we believe that each individual's learning requirements are unique. With this mindset, we have a diverse portfolio of training programs for the benefit of individual learners, and we continuously upgrade our product offering as per their requirements.

Enterprise Learning Solutions

Drawing strength and inspiration from the HCL group?s expertise across diverse business domains within and beyond the IT space, HCL CDC has established itself as a leading provider of Enterprise Learning Solutions.

Learning Solutions for Government

Employees

Guided by our mission towards creating an IT-empowered nation, HCL CDC is proud to have been associated with Governmental bodies in a number of social sector projects.

Learning Solutions for Colleges/Academic Institutions

In order to bridge the gap of Industry and Academia and to prepare the candiates with right skill-sets as per the industry requirements, HCL Infosystems Ltd. presents an exclusive model called Institutional Alliance.

Allances

1. Promtric 2. Liqvid 3. Service Desk Institution (S.D.I) 4. Microsoft 5. Global Alliances 6. Career Launcher 7. Red Hat 8. I.B.M 9. C.A.

CHAPTER 2 METHODOLOGY 2.1 Introduction

to Java

Introduction to Object Oriented Programming Commonly used programming methodologies include: 1. Procedural programming 2. Object-oriented programming Procedural Programming The procedural programming methodology involves dividing a large program into a set of sub-procedures or subprograms that performs specific task. Object-Oriented Programming A large application consists of component objects, which interact with each other. This is referred to as the object-oriented approach to develop an application. Object and Classes An object is a software package consisting of variables and methods. An object is defined as an instance of a class. Classes are designed such that they can be reused. Encapsulation Encapsulation is the process of hiding all the details of an object that do not contribute to its essential characteristics. Encapsulation is also known called information hiding. Abstraction An abstraction denotes the essential characteristics of an object that distinguishes it from all other kind of objects and thus provides crispy defined conceptual boundaries, relative to the perspective of the viewer. 8

Inheritance Inheritance enables you to extend the functionality of an existing class. You create a class that inherits the attributes and behavior of another class. In addition, the new class can consist of a few new attributes and behaviors that are specific to the class. Types of inheritance supported in java: Single inheritance Multiple inheritance Java Programming Language Java is an object-oriented programming language that was designed to meet the need for a platform independent language. Java is used to create applications that can run on a single computer as well as a distributed network. Java is both a language and a technology used to develop stand-alone and internet-based applications. Characteristics of Java Simple: A java programmer does not need to know the internal details of java as to how memory is allocated to data because in java. The programmer does not need to handle memory manipulation. Object-Oriented: Java supports the object-oriented approach to develop programs. It supports various features of an object-oriented language, such as abstraction, encapsulation, inheritance and polymorphism. Compiled and Interpreted: The java programs are first compiled and then interpreted. While compiling, the compiler software checks for the errors in the program and lists all the errors on the screen.

Portable: Portability refers to the ability of a program to run on any platform without changing the source code of the program. Distributed: Java is used to develop applications that can be distributed among various computers on the network. Secure: Java has built-in security features that verify that the programs do not perform any destructive task, such as accessing the files on a remote system. Java does not allow the use of explicit pointers. Java Programming Language and class File Java programs are saved with an extension .java. A .java file is compiled to generate the .class file, which contains the byte codes. The JVM converts the byte code contained in the .class file to the machine object code. The JVM needs to be implemented for each platform running on a different operating system. The java programming language is unusual than other programming languages it first compiles and then interprets the program. Compile first translate the program into intermediate language called intermediate language called java byte code. Java byte code is platform independent code, which is further interpreted by the interpreter on the java platform. Interpreter parses and run each java byte code instruction on the computer. Compilation occurs only once, interpretation occurs each time when the program is executed.

Figure - java structure 10

The Java Platform A platform is the hardware or software environment in which a program runs. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other, hardware-based platforms. Most other platforms are described as a combination of hardware and operating system. The Java platform has two components:

The Java Virtual Machine (Java VM) The Java Application Programming Interface (Java API)

We've already been introduced to the Java VM. It's the base for the Java platform and is ported onto various hardware-based platforms. The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets. The Java API is grouped into libraries (packages) of related components. The following figure depicts a Java program, such as an application or applet, that's running on the Java platform. As the figure shows, the Java API and Virtual Machine insulates the Java program from hardware dependencies.

Figure Java Plateform

11

As a platform-independent environment, Java can be a bit slower than native code. However, smart compilers, well-tuned interpreters, and just-in-time byte code compilers can bring Java's performance close to that of native code without threatening portability. Exceptions in Java As the name implies, an exception is an exceptional condition. An exception is something that is out of the ordinary. Most often, exceptions are used as a way to report error conditions. Exceptions can be u report error conditions. Exceptions can be used as a means of indicating other situations as well Throw, try, and catch Blocks To respond to an exception, the call to the method that produces it must be placed within a try block. A try block is a block of code beginning with the try keyword followed by a left and a right curly brace. Every try block is associated with one or more catch blocks.

12

2.2 E-R Diagram


An ER-diagram for the airport management system is shown in the figure below.

13

14

Figure- E-R diagram of Airport management system

2.3 Requirement analysis

2.3.1 Hardware Requirements 1. Normal PC Configuration.: Any Processor, 128 MB RAM or higher, Hard disk 40 GB or above

15

2. Networking Components. 1. NIC Card. 2. Cables. 3. Switch. 2.3.2 Software Requirements 1. Front end: Java, Java runtime version1.3 or higher, Jdk toolkit version1.3 or higher. 2. Operating system: Windows xp , windows 7 2.3.3 Functional Requirements The functional requirements specify the services that are provided to the user. This will also specify how the system should react to particular inputs and how system should behave in particular situation. It may also explicitly state what the system should not do. Accordingly the functional requirements of our system can be specified as follows:

Software to be used as a standalone program or as a component of another program as several components are embedded into it. The user interface consists of a single window, from where all functionalities are available. Mouse control to be used Help document to be provided to assist user when deemed necessary.

2.3.4 Non-Functional requirements These requirements specify the services that are not directly linked to the working of application but specify the environment and the way the software is expected to function. Accordingly the non-functional requirements of system are as follows

16

Performance should be reliable, If any error occurs or data is missing the user should be informed. Easy to use User Interface. Reusability of independent module

17

CHAPTER 3 PROJECT DESIGN &TESTING 3.1 Flow diagram

3.1.1 Control Flow Diagram

Download manager

Add download

Pause

Resume

18

Cancel

Clear

Figure Control Flow Diagram

3.2 Screenshots

19

Figure Download Manager main page

20

Figure Downloading a file

21

Figure Downloading three files simultaniously

22

Figure Two files are paused

23

Figure Error in URL

24

Figure One file is paused and other is cancelled

3.3 SOURCE CODE


DOWNLOAD CLASS import java.io.*; import java.net.*; import java.util.*; 25

class Download extends Observable implements Runnable { private static final int MAX_BUFFER_SIZE = 1024; public static final String STATUSES[] = {"Downloading", "Paused", "Complete", "Cancelled", "Error"}; public static final int DOWNLOADING = 0; public static final int PAUSED = 1; public static final int COMPLETE = 2; public static final int CANCELLED = 3; public static final int ERROR = 4; private URL url; private int size; private int downloaded; private int status; public Download(URL url) { this.url = url; size = -1; downloaded = 0; status = DOWNLOADING; download(); } public String getUrl() { return url.toString(); } public int getSize() { return size; } 26 // download URL // size of download in bytes // number of bytes downloaded // current status of download

public float getProgress() { return ((float) downloaded / size) * 100; } public int getStatus() { return status; } public void pause() { status = PAUSED; stateChanged(); } public void resume() { status = DOWNLOADING; stateChanged(); download(); } public void cancel() { status = CANCELLED; stateChanged(); } private void error() { status = ERROR; stateChanged(); } private void download() { Thread thread = new Thread(this); thread.start(); } private String getFileName(URL url) { String fileName = url.getFile(); return fileName.substring(fileName.lastIndexOf('/') + 1); } 27

public void run() { RandomAccessFile file = null; InputStream stream = null; try { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Range", "bytes=" + downloaded + "-"); connection.connect(); if (connection.getResponseCode() / 100 != 2) { error(); } int contentLength = connection.getContentLength(); if (contentLength < 1) { error(); } if (size == -1) { size = contentLength; stateChanged(); } file = new RandomAccessFile(getFileName(url), "rw"); file.seek(downloaded); stream = connection.getInputStream(); while (status == DOWNLOADING) { byte buffer[]; if (size - downloaded > MAX_BUFFER_SIZE) { buffer = new byte[MAX_BUFFER_SIZE]; 28

} else { buffer = new byte[size - downloaded]; } int read = stream.read(buffer); if (read == -1) break; file.write(buffer, 0, read); downloaded += read; stateChanged(); } if (status == DOWNLOADING) { status = COMPLETE; stateChanged(); } } catch (Exception e) { error(); } finally { if (file != null) { try { file.close(); } catch (Exception e) {} } if (stream != null) { try { stream.close(); } catch (Exception e) {} private void stateChanged() { 29 }}}

setChanged(); notifyObservers(); }} DOWNLOADS TABLE MODEL CLASS import java.util.*; import javax.swing.*; import javax.swing.table.*; class DownloadsTableModel extends AbstractTableModel implements Observer { private static final String[] columnNames = {"URL", "Size", "Progress", "Status"}; private static final Class[] columnClasses = {String.class, String.class, JProgressBar.class, String.class}; private ArrayList<Download> downloadList = new ArrayList<Download>(); public void addDownload(Download download) { download.addObserver(this); downloadList.add(download); fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1); } public Download getDownload(int row) { return (Download) downloadList.get(row); } public void clearDownload(int row) { downloadList.remove(row); fireTableRowsDeleted(row, row); } 30

public int getColumnCount() { return columnNames.length; } public String getColumnName(int col) { return columnNames[col]; } public Class getColumnClass(int col) { return columnClasses[col]; } public int getRowCount() { return downloadList.size(); } public Object getValueAt(int row, int col) { Download download = downloadList.get(row); switch (col) { case 0: return download.getUrl(); case 1: int size = download.getSize(); return (size == -1) ? "" : Integer.toString(size); case 2: // Progress // Size // URL

return new Float(download.getProgress()); case 3: // Status

return Download.STATUSES[download.getStatus()]; } return ""; } public void update(Observable o, Object arg) { int index = downloadList.indexOf(o); 31

// Fire table row update notification to table. fireTableRowsUpdated(index, index); }}

PROGRESS RENDERER CLASS import java.awt.*; import javax.swing.*; import javax.swing.table.*; class ProgressRenderer extends JProgressBar implements TableCellRenderer { public ProgressRenderer(int min, int max) { super(min, max); } public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column { setValue((int) ((Float) value).floatValue()); return this; }} DOWNLOAD MANAGER CLASS import java.awt.*; import java.awt.event.*; import java.net.*; import java.util.*; import javax.swing.*; import javax.swing.event.*;

32

public class DownloadManager extends JFrame implements Observer { private JTextField addTextField; private DownloadsTableModel tableModel; private JTable table; private JButton pauseButton, resumeButton; private JButton cancelButton, clearButton; private Download selectedDownload; private boolean clearing; public DownloadManager() { setTitle("Download Manager"); setSize(640, 480); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { actionExit(); }}); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); JMenuItem fileExitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X); fileExitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {

33

actionExit(); }}); fileMenu.add(fileExitMenuItem); menuBar.add(fileMenu); setJMenuBar(menuBar); JPanel addPanel = new JPanel(); addTextField = new JTextField(30); addPanel.add(addTextField); JButton addButton = new JButton("Add Download"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionAdd(); }}); addPanel.add(addButton); tableModel = new DownloadsTableModel(); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { tableSelectionChanged(); }}); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ProgressRenderer renderer = new ProgressRenderer(0, 100); renderer.setStringPainted(true); // show progress text table.setDefaultRenderer(JProgressBar.class, renderer); table.setRowHeight(

34

(int) renderer.getPreferredSize().getHeight()); JPanel downloadsPanel = new JPanel(); downloadsPanel.setBorder( BorderFactory.createTitledBorder("Downloads")); downloadsPanel.setLayout(new BorderLayout()); downloadsPanel.add(new JScrollPane(table), BorderLayout.CENTER); JPanel buttonsPanel = new JPanel(); pauseButton = new JButton("Pause"); pauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionPause(); }}); pauseButton.setEnabled(false); buttonsPanel.add(pauseButton); resumeButton = new JButton("Resume"); resumeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionResume(); } }); resumeButton.setEnabled(false); buttonsPanel.add(resumeButton); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {

35

actionCancel(); }}); cancelButton.setEnabled(false); buttonsPanel.add(cancelButton); clearButton = new JButton("Clear"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionClear(); }}); clearButton.setEnabled(false); buttonsPanel.add(clearButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(addPanel, BorderLayout.NORTH); getContentPane().add(downloadsPanel, BorderLayout.CENTER); getContentPane().add(buttonsPanel, BorderLayout.SOUTH); } private void actionExit() { System.exit(0); } private void actionAdd() { URL verifiedUrl = verifyUrl(addTextField.getText()); if (verifiedUrl != null) { tableModel.addDownload(new Download(verifiedUrl)); addTextField.setText(""); // reset add text field } else { JOptionPane.showMessageDialog(this, "Invalid Download URL", "Error",

36

JOptionPane.ERROR_MESSAGE); } } private URL verifyUrl(String url) { if (!url.toLowerCase().startsWith("http://")) return null; URL verifiedUrl = null; try { verifiedUrl = new URL(url); } catch (Exception e) { return null; } if (verifiedUrl.getFile().length() < 2) return null; return verifiedUrl; } private void tableSelectionChanged() { if (selectedDownload != null) selectedDownload.deleteObserver(DownloadManager.this); if (!clearing && table.getSelectedRow() > -1) { selectedDownload = tableModel.getDownload(table.getSelectedRow()); selectedDownload.addObserver(DownloadManager.this); updateButtons(); }} private void actionPause() { selectedDownload.pause(); updateButtons(); }

37

private void actionResume() { selectedDownload.resume(); updateButtons(); } private void actionCancel() { selectedDownload.cancel(); updateButtons(); } private void actionClear() { clearing = true; tableModel.clearDownload(table.getSelectedRow()); clearing = false; selectedDownload = null; updateButtons(); } private void updateButtons() { if (selectedDownload != null) { int status = selectedDownload.getStatus(); switch (status) { case Download.DOWNLOADING: pauseButton.setEnabled(true); resumeButton.setEnabled(false); cancelButton.setEnabled(true); clearButton.setEnabled(false); break; case Download.PAUSED:

38

pauseButton.setEnabled(false); resumeButton.setEnabled(true); cancelButton.setEnabled(true); clearButton.setEnabled(false); break; case Download.ERROR: pauseButton.setEnabled(false); resumeButton.setEnabled(true); cancelButton.setEnabled(false); clearButton.setEnabled(true); break; default: // COMPLETE or CANCELLED pauseButton.setEnabled(false); resumeButton.setEnabled(false); cancelButton.setEnabled(false); clearButton.setEnabled(true); }} else { pauseButton.setEnabled(false); resumeButton.setEnabled(false); cancelButton.setEnabled(false); clearButton.setEnabled(false); } }

39

public void update(Observable o, Object arg) { if (selectedDownload != null && selectedDownload.equals(o)) updateButtons(); } public static void main(String[] args) { DownloadManager manager = new DownloadManager(); manager.setVisible(true); }

Chapter 4
SCOPE AND CONCLUSION 4.1 Conclusion
Download manager systems have the ability to download file easily and save our time upto a great extent . With Download Manager we can download more than one file simultaneously. With the help of Download Manager we can download everything and we can resume our download later also which we lost due to power failure. We can download files even on poor connection. It works on both online and offline mode automatically.

4.2 Future enhancements


Download managers commonly include one or more of the following features: 40

Pausing the downloading of large files. Resuming broken or paused downloads (especially for very large files). Downloading files on poor connections. Downloading several files from a site automatically according to simple rules (file types, updated files, etc. - see also Offline Browser).

Variable bandwidth usage. Automatic subfolder generation.

Download managers are useful for very active Internet users. For dial-up users, they can automatically dial the Internet Service Provider at night, when rates or tariffs are usually much lower, download the specified files, and hang-up. They can record which links the user clicks on during the day, and queue these files for later download. For broadband users, download managers can help download very large files by resuming broken downloads, by limiting the bandwidth used, so that other internet activities are not affected (slowed) and the server is not overloaded, or by automatically navigating a site and downloading pre-specified content (photo galleries, MP3 collections, etc.) this can also include automatically downloading whole sites and regularly updating them (see Mirroring). Many download managers support Metalink, an XML file listing mirrors, checksums, and other information useful for downloading.

41

BIBLIOGRAPHY
Books And Sites
1. Java completes reference by Herbert.Schildt (2nd Edition) 2. Java hand book by Patrick Naughton (2nd Edition) 3. Java server programming by Subramanyam Allamaraju, CedricBuest. (7th Edition) 4. http://download.oracle.com/javase/tutorial/ 42

5. http://www.javaworld.com/jw-12-1996/jw-12-sockets.html 6. http://www.javaworld.com/javaworld/jw-01-1997/jw-01-chat.html?page=1

43

Vous aimerez peut-être aussi