diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3877ae0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..6aed1b7 --- /dev/null +++ b/NOTICE @@ -0,0 +1,17 @@ + Copyright (C) 2018-2019 Jose Francisco Mena Ceca + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + JGutenbergDownload is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JGutenbergDownload. If not, see . + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). diff --git a/README.md b/README.md index 2122a84..553dd89 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,101 @@ -# JGutenbergDownload -Descarga de ficheros desde los repositorios del proyecto Gutenberg. - -## Contenido -+ jar-flat: fichero jar con las clases de la aplicación junto a las dependencias necesarias, que se ubican en la carpeta lib -+ jar-shaded: fichero jar con las clases de la aplicación y con las dependencias necesarias incluidas en él -+ javadoc: documentación del código -+ src: Código fuente - -## Uso -Desde línea de comandos: - -java -jar JGutenbergDownload-1.0-shaded.jar [*opciones*] - -opciones: - --t tipo fichero (por defecto txt) --i idioma (por defecto en) --d tiempo de espera en milisegundos (por defecto 2000) --s ruta donde guardar las descargas --m total_ficheros_a_descargar (por defecto 10, el valor 0 descarga todo) --z descomprimir (true/false, por defecto true) --o sobreescribir existentes (true/false, por defecto false) --x modo de descarga (SOFT/GREEDY, por defecto SOFT) - --h muestra lista de opciones - -## Notas -Si se usa el jar flat hay que asegurarse que exista la carpeta lib dentro de la carpeta desde la que ejecutemos la aplicación. - -El fichero de log generado se guarda en la carpeta log. +# JGutenbergDownload +This software allows you to download books from the Gutenberg project repositories. + +The Gutenberg project website is intended for human users only. If you want to download many books using an automated tool like this, keep in mind that your ip address can be blocked temporarily or permanently. +The Gutenberg project is a solidarity project based on the hard work of thousands of volunteers. So please, don't abuse. + +[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) + +## Getting Started + +The project is a Maven project, so you can import it in your favorite IDE as any other Maven project. + +~~~ +mvn install +~~~ + +will install the artifact in your local repository, being ready to be used as a dependency in any project: + +~~~ + + org.josfranmc.gutenberg + JGutenbergDownload + 2.0 + +~~~ + +When you build the project with Maven you get two jars in the target directory: _JGutenbergDownload-2.0.jar_ and _JGutenbergDownload-2.0-shaded.jar_. The first one is the standard jar of the project. The second one is an _uber_ jar with all necessary dependencies, which is suitable to use from command line. + +Download the latest _uber_ jar from [Releases](https://github.com/josfranmc/JGutenbergDownload/releases). + +## Usage + +The main class to use is `JGutenbergDownload`, which offers some methods to set up the download process. + +The following code will download 20 english books in a folder called _mybooks_: + +~~~ +try { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setLanguage("en"); + jg.setSavePath("mybooks"); + jg.setMaxFilesToDownload(20); + jg.downloadBooks(); +} catch(GutenbergException e) { + System.err.println(e.getMessage()); +} +~~~ + +You can also use the `DownloadParams` class to set up: + +~~~ +try { + DownloadParams params = new DownloadParams(); + params.setLanguage("en"); + params.setSavePath("mybooks"); + params.setMaxFilesToDownload(20); + + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setParameters(params); + jg.downloadBooks(); +} catch(GutenbergException e) { + System.err.println(e.getMessage()); +} +~~~ + +Finally, you can execute the `JGutenbergDownload`'s main method by passing the setting options as argument. The following code perfoms the same function as the previous ones: + +~~~ +try { + String[] args = {"-l", "en", "-s", "mybooks", "-m", "20" }; + JGutenbergDownload.main(args); +} catch(GutenbergException e) { + System.err.println(e.getMessage()); +} +~~~ + +These are the options you can use as arguments: + +~~~ +-f xxx (xxx type of files to download, default: txt) +-l xx (xx language of books to download, default: es) +-s xxx (xxx download path on local machine, default: program folder) +-d xxx (xxx delay between downloads in milliseconds, default 2000) +-m xx (xx max number of downloads (default 10, 0 for dowload all) +-o ( overwrite existing files, default: false) +-z ( don't unzip downloads, default: true) +(only -h to show options list)"); +~~~ + +--- + +It is possible to run the program from the command line. To this purpose, you may use the _JGutenbergDownload-2.0-shaded.jar_ package with any of the options above: + +~~~ +java -jar JGutenbergDownload-2.0-shaded.jar -l en -s mybooks -m 20 +~~~ + +## License + +[GPLv3](https://www.gnu.org/licenses/gpl-3.0) or later, see +[LICENSE](LICENSE) for more details. \ No newline at end of file diff --git a/jar-flat/JGutenbergDownload-1.0.jar b/jar-flat/JGutenbergDownload-1.0.jar deleted file mode 100644 index 65b393c..0000000 Binary files a/jar-flat/JGutenbergDownload-1.0.jar and /dev/null differ diff --git a/jar-flat/lib/hamcrest-core-1.3.jar b/jar-flat/lib/hamcrest-core-1.3.jar deleted file mode 100644 index 9d5fe16..0000000 Binary files a/jar-flat/lib/hamcrest-core-1.3.jar and /dev/null differ diff --git a/jar-flat/lib/junit-4.12.jar b/jar-flat/lib/junit-4.12.jar deleted file mode 100644 index 3a7fc26..0000000 Binary files a/jar-flat/lib/junit-4.12.jar and /dev/null differ diff --git a/jar-flat/lib/log4j-1.2.17.jar b/jar-flat/lib/log4j-1.2.17.jar deleted file mode 100644 index 1d425cf..0000000 Binary files a/jar-flat/lib/log4j-1.2.17.jar and /dev/null differ diff --git a/jar-shaded/JGutenbergDownload-1.0-shaded.jar b/jar-shaded/JGutenbergDownload-1.0-shaded.jar deleted file mode 100644 index b05b1ce..0000000 Binary files a/jar-shaded/JGutenbergDownload-1.0-shaded.jar and /dev/null differ diff --git a/javadoc/allclasses-frame.html b/javadoc/allclasses-frame.html index 3d54f94..7806993 100644 --- a/javadoc/allclasses-frame.html +++ b/javadoc/allclasses-frame.html @@ -2,10 +2,9 @@ - - + All Classes - + @@ -13,27 +12,18 @@

All Classes

diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html index 27e3cfa..8552275 100644 --- a/javadoc/allclasses-noframe.html +++ b/javadoc/allclasses-noframe.html @@ -1,40 +1,30 @@ - - - - - - -All Classes - - - - - -

All Classes

- - - + + + + + +All Classes + + + + + +

All Classes

+ + + diff --git a/javadoc/constant-values.html b/javadoc/constant-values.html index 466c133..bcd9bf0 100644 --- a/javadoc/constant-values.html +++ b/javadoc/constant-values.html @@ -1,125 +1,153 @@ - - - - - - -Constant Field Values - - - - - - - - -
- - - - - - - -
- - -
-

Constant Field Values

-

Contents

-
- -
- - - - - - - -
- - - - + + + + + +Constant Field Values + + + + + + + + +
+ + + + + + + +
+ + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

org.josfranmc.*

+
    +
  • + + + + + + + + + + + + + + +
    org.josfranmc.gutenberg.download.DownloadParams 
    Modifier and TypeConstant FieldValue
    + +public static final java.lang.StringURL_BOOKS"http://www.gutenberg.org/robot/"
    +
  • +
+
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/deprecated-list.html b/javadoc/deprecated-list.html index 74d7f54..a2175ba 100644 --- a/javadoc/deprecated-list.html +++ b/javadoc/deprecated-list.html @@ -1,125 +1,124 @@ - - - - - - -Deprecated List - - - - - - - - -
- - - - - - - -
- - -
-

Deprecated API

-

Contents

-
- -
- - - - - - - -
- - - - + + + + + +Deprecated List + + + + + + + + +
+ + + + + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/help-doc.html b/javadoc/help-doc.html index 97672f3..675e791 100644 --- a/javadoc/help-doc.html +++ b/javadoc/help-doc.html @@ -1,230 +1,229 @@ - - - - - - -API Help - - - - - - - - -
- - - - - - - -
- - -
-

How This API Document Is Organized

-
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
-
-
-
    -
  • -

    Overview

    -

    The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

    -
  • -
  • -

    Package

    -

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    -
      -
    • Interfaces (italic)
    • -
    • Classes
    • -
    • Enums
    • -
    • Exceptions
    • -
    • Errors
    • -
    • Annotation Types
    • -
    -
  • -
  • -

    Class/Interface

    -

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    -
      -
    • Class inheritance diagram
    • -
    • Direct Subclasses
    • -
    • All Known Subinterfaces
    • -
    • All Known Implementing Classes
    • -
    • Class/interface declaration
    • -
    • Class/interface description
    • -
    -
      -
    • Nested Class Summary
    • -
    • Field Summary
    • -
    • Constructor Summary
    • -
    • Method Summary
    • -
    -
      -
    • Field Detail
    • -
    • Constructor Detail
    • -
    • Method Detail
    • -
    -

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    -
  • -
  • -

    Annotation Type

    -

    Each annotation type has its own separate page with the following sections:

    -
      -
    • Annotation Type declaration
    • -
    • Annotation Type description
    • -
    • Required Element Summary
    • -
    • Optional Element Summary
    • -
    • Element Detail
    • -
    -
  • -
  • -

    Enum

    -

    Each enum has its own separate page with the following sections:

    -
      -
    • Enum declaration
    • -
    • Enum description
    • -
    • Enum Constant Summary
    • -
    • Enum Constant Detail
    • -
    -
  • -
  • -

    Use

    -

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

    -
  • -
  • -

    Tree (Class Hierarchy)

    -

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    -
      -
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • -
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • -
    -
  • -
  • -

    Deprecated API

    -

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    -
  • -
  • -

    Index

    -

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    -
  • -
  • -

    Prev/Next

    -

    These links take you to the next or previous class, interface, package, or related page.

    -
  • -
  • -

    Frames/No Frames

    -

    These links show and hide the HTML frames. All pages are available with or without frames.

    -
  • -
  • -

    All Classes

    -

    The All Classes link shows all classes and interfaces except non-static nested types.

    -
  • -
  • -

    Serialized Form

    -

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    -
  • -
  • -

    Constant Field Values

    -

    The Constant Field Values page lists the static final fields and their values.

    -
  • -
-This help file applies to API documentation generated using the standard doclet.
- -
- - - - - - - -
- - - - + + + + + +API Help + + + + + + + + +
+ + + + + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Overview

    +

    The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

    +
  • +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Use

    +

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-1.html b/javadoc/index-files/index-1.html index ce3a277..3e379e0 100644 --- a/javadoc/index-files/index-1.html +++ b/javadoc/index-files/index-1.html @@ -1,132 +1,151 @@ - - - - - - -A-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

A

-
-
AbstractDownload - Class in org.josfranmc.gutenberg.download
-
-
Encapsula el proceso que ha de seguirse para la descarga de un recurso.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +C-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

C

+
+
create() - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
+
+
Creates an engine for downloading.
+
+
create(DownloadEngineType) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
+
+
Creates a download engine of the indicated type.
+
+
create(URL, DownloadEngineType) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
+
+
Creates a download engine of the indicated type for downloading an url.
+
+
create(URL) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
+
+
Creates an engine for downloading an url.
+
+
create(URL, String, DownloadEngineType) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
+
+
Creates an engine for downloading.
+
+
create(URL, String) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
+
+
Creates an engine for downloading.
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-10.html b/javadoc/index-files/index-10.html index d2d6025..79ac760 100644 --- a/javadoc/index-files/index-10.html +++ b/javadoc/index-files/index-10.html @@ -1,132 +1,133 @@ - - - - - - -N-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

N

-
-
newInstance(URL, String) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
-
-
Crea una instancia DownloadHttpUrlConnection de tipo IDownloadEngine.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +O-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

O

+
+
org.josfranmc.gutenberg.download - package org.josfranmc.gutenberg.download
+
 
+
org.josfranmc.gutenberg.download.engine - package org.josfranmc.gutenberg.download.engine
+
 
+
org.josfranmc.gutenberg.util - package org.josfranmc.gutenberg.util
+
 
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-11.html b/javadoc/index-files/index-11.html index 3cab517..6f20d11 100644 --- a/javadoc/index-files/index-11.html +++ b/javadoc/index-files/index-11.html @@ -1,138 +1,129 @@ - - - - - - -O-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

O

-
-
org.josfranmc.gutenberg.download - package org.josfranmc.gutenberg.download
-
 
-
org.josfranmc.gutenberg.download.client - package org.josfranmc.gutenberg.download.client
-
 
-
org.josfranmc.gutenberg.download.engine - package org.josfranmc.gutenberg.download.engine
-
 
-
org.josfranmc.gutenberg.engine - package org.josfranmc.gutenberg.engine
-
 
-
org.josfranmc.gutenberg.util - package org.josfranmc.gutenberg.util
-
 
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +R-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

R

+
+
run() - Method in class org.josfranmc.gutenberg.download.DownloadThread
+
 
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-12.html b/javadoc/index-files/index-12.html index d236429..a563b31 100644 --- a/javadoc/index-files/index-12.html +++ b/javadoc/index-files/index-12.html @@ -1,132 +1,219 @@ - - - - - - -R-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

R

-
-
run() - Method in class org.josfranmc.gutenberg.download.DownloadGreedy
-
-
Inicia un proceso de descarga.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +S-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

S

+
+
setDelay(int) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets delay between downloads
+
+
setDelay(int) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets delay between downloads
+
+
setEngineType(DownloadEngineType) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets the type of downloading engine to use
+
+
setEngineType(DownloadEngineType) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets the type of downloading engine to use
+
+
setFileType(String) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets the type of file to download.
+
+
setFileType(String) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets the type of file to download.
+
+
setHeaders(URLConnection) - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
+
+
Sets the header obtained in response to a connection
+
+
setLanguage(String) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets the language of the files to download acording to Gutenberg nomeclature.
+
+
setLanguage(String) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets the language of the files to download acording to Gutenberg nomeclature.
+
+
setMaxFilesToDownload(int) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets the maximum number of files to download.
+
+
setMaxFilesToDownload(int) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets the maximum number of files to download.
+
+
setOverwrite(boolean) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets if the existing files must be overwritten by the downloaded ones
+
+
setOverwrite(boolean) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets if the existing files must be overwritten by the downloaded ones
+
+
setParameters(DownloadParams) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets the application parameters through a DownloadParams object
+
+
setResource(URL) - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
+
+
Sets the resource of the url to download, in the form of a URL object
+
+
setResource(URL) - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
+
+
Sets the resource of the url to download, in the form of a URL object
+
+
setSavedFilePath(String) - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
+
+
Sets the path of the downloaded file on the local machine.
+
+
setSavePath(String) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets folder path where to get downloaded resources
+
+
setSavePath(String) - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
+
+
Sets the local path where to save the resource to be download
+
+
setSavePath(String) - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
+
+
Sets the local path where to save the resource to be download
+
+
setSavePath(String) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets folder path where to get downloaded resources
+
+
setUnzip(boolean) - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Sets if downloaded files must be unzipping,
+
+
setUnzip(boolean) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Sets if downloaded files must be unzipping,
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-13.html b/javadoc/index-files/index-13.html index 9a09d34..35a23f3 100644 --- a/javadoc/index-files/index-13.html +++ b/javadoc/index-files/index-13.html @@ -1,252 +1,135 @@ - - - - - - -S-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

S

-
-
setDelay(int) - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
-
Establece el intervalo de espera entre descargas.
-
-
setDelay(int) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece el tiempo de espera entre descargas, en milisegundos
-
-
setDelay(int) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Establece el tiempo de espera entre descargas, en milisegundos.
-
-
setDownloadMode(DownloadMode) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece el mode de realizar las descargas
-
-
setDownloadMode(DownloadMode) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Establece el mode de realizar las descargas
-
-
setEngineType(DownloadEngineType) - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
-
Establece el tipo de motor de descarga a utilizar
-
-
setEngineType(DownloadEngineType) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece el tipo de motor a utilizar para realizar las descargas
-
-
setEngineType(DownloadEngineType) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Establece el tipo de motor a utilizar para realizar las descargas.
-
-
setError(String) - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
-
Establece un mensaje de error.
-
-
setFileOutputPath(String) - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
-
Establece la ruta del fichero descargado.
-
-
setFileType(String) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece el tipo de ficheros a descargar.
-
-
setFileType(String) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
setHeaders(URLConnection) - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
-
Establece la colección de campos de cabecera devuelta por una conexión realizada
-
-
setLanguage(String) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece el idioma de los ficheros a descargar, según la nomenclatura usada por el proyecto Gutenberg.
-
-
setLanguage(String) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
setMaxFilesToDownload(int) - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
-
Establece el número máximo de ficheros a descargar.
-
-
setMaxFilesToDownload(int) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece el número máximo de ficheros a descargar
-
-
setMaxFilesToDownload(int) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Establece el número máximo de ficheros a descargar
-
-
setOverwrite(boolean) - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
-
Establece si deben sobreescribirse los recursos existentes por las nuevas descargas en caso de ser los mismos
-
-
setOverwrite(boolean) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece si se deben sobreescribir los ficheros ya existentes en la carpeta especificada por las nuevas descargas en caso de ser los mismos
-
-
setOverwrite(boolean) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
setResource(URL) - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
-
-
Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL
-
-
setResource(URL) - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
-
-
Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL
-
-
setSavePath(String) - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
-
Establece la ruta de la carpeta en la que obtener los recursos descargados.
-
-
setSavePath(String) - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
-
-
Establece la ruta donde guardar el recurso a descargar
-
-
setSavePath(String) - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
-
-
Establece la ruta donde guardar el recurso a descargar
-
-
setSavePath(String) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece la ruta de la carpeta en la que guardar los archivos descargados
-
-
setSavePath(String) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Establece la ruta de la carpeta en la que guardar los archivos descargados.
-
-
setUnzip(boolean) - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
-
Establece si se deben descomprimir los archivos descargados
-
-
setUnzip(boolean) - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Establece si se deben descomprimir los ficheros una vez descargados
-
-
setUnzip(boolean) - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
setUp() - Static method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Método ejecutado una vez antes de la ejecución de todos los tests
-
-
setUrlBase(URL) - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
-
Establece la dirección url inicial del recurso a obtener
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +U-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

U

+
+
unzipFiles(String, String) - Static method in class org.josfranmc.gutenberg.util.FileManager
+
+
Unzips files in format zip from a certain folder.
+
+
URL_BOOKS - Static variable in class org.josfranmc.gutenberg.download.DownloadParams
+
+
Base URL of the Gutenberg project to download
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-14.html b/javadoc/index-files/index-14.html index e80e606..1117d08 100644 --- a/javadoc/index-files/index-14.html +++ b/javadoc/index-files/index-14.html @@ -1,148 +1,136 @@ - - - - - - -T-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

T

-
-
tearDown() - Method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Método ejecutado después de la ejecución de cada test
-
-
testDownload() - Method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Comprobar que se ha descargado un fichero concreto en la carpeta de ejecución del programa.
-
-
testGetLocalFileName() - Method in class org.josfranmc.gutenberg.util.FileManagerTest
-
-
Comprobar si es correcto el nombre del archivo contenido en una ruta.
-
-
testGetLocalFilePathFromURL() - Method in class org.josfranmc.gutenberg.util.FileManagerTest
-
-
Comprobar si es correcta la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo.
-
-
testParametersDefaultValue() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
-
Comprueba si los valores por defecto de los parámetros de descarga a la hora de crear un IGutenbergDownload son los correctos
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +V-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

V

+
+
valueOf(String) - Static method in enum org.josfranmc.gutenberg.download.engine.DownloadEngineType
+
+
Returns the enum constant of this type with the specified name.
+
+
values() - Static method in enum org.josfranmc.gutenberg.download.engine.DownloadEngineType
+
+
Returns an array containing the constants of this enum type, in +the order they are declared.
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-15.html b/javadoc/index-files/index-15.html deleted file mode 100644 index 07a8032..0000000 --- a/javadoc/index-files/index-15.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - -U-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

U

-
-
unzipFiles(String, String) - Static method in class org.josfranmc.gutenberg.util.FileManager
-
-
Descomprime los ficheros comprimidos en formato zip de una determinada carpeta.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - diff --git a/javadoc/index-files/index-16.html b/javadoc/index-files/index-16.html deleted file mode 100644 index 6a5e2fa..0000000 --- a/javadoc/index-files/index-16.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - -V-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

V

-
-
valueOf(String) - Static method in enum org.josfranmc.gutenberg.download.DownloadMode
-
-
Returns the enum constant of this type with the specified name.
-
-
valueOf(String) - Static method in enum org.josfranmc.gutenberg.download.engine.DownloadEngineType
-
-
Returns the enum constant of this type with the specified name.
-
-
values() - Static method in enum org.josfranmc.gutenberg.download.DownloadMode
-
-
Returns an array containing the constants of this enum type, in -the order they are declared.
-
-
values() - Static method in enum org.josfranmc.gutenberg.download.engine.DownloadEngineType
-
-
Returns an array containing the constants of this enum type, in -the order they are declared.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - diff --git a/javadoc/index-files/index-2.html b/javadoc/index-files/index-2.html index 61cb4e7..80fc767 100644 --- a/javadoc/index-files/index-2.html +++ b/javadoc/index-files/index-2.html @@ -1,160 +1,177 @@ - - - - - - -C-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

C

-
-
create(DownloadMode) - Static method in class org.josfranmc.gutenberg.download.DownloadFactory
-
-
Crea un objeto concreto para realizar descargas
-
-
create() - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
-
-
Crea un motor para realizar la descarga de recursos en red.
-
-
create(DownloadEngineType) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
-
-
Crea un motor determinado para realizar la descarga de recursos en red
-
-
create(URL, DownloadEngineType) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
-
-
Crea un motor determinado para realizar la descarga desde una determinada URL
-
-
create(URL) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
-
-
Crea un motor para realizar la descarga desde una determinada URL.
-
-
create(URL, String, DownloadEngineType) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
-
-
Crea un motor determinado para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local
-
-
create(URL, String) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
-
-
Crea un motor para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local.
-
-
create() - Static method in class org.josfranmc.gutenberg.download.JGutenbergDownloadFactory
-
-
Crea un objeto JGutenbergDownload que implementa toda la funcionalidad necesaria para la descarga de libros
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +D-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

D

+
+
download() - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
+
+
Runs a download.
+
+
download() - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
+
+
Runs a download.
+
+
DownloadBooks - Class in org.josfranmc.gutenberg.download
+
+
Allows to perform the file download process.
+
+
DownloadBooks(DownloadParams) - Constructor for class org.josfranmc.gutenberg.download.DownloadBooks
+
 
+
downloadBooks() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Begins the process of downloading books.
+
+
DownloadEngineFactory - Class in org.josfranmc.gutenberg.download.engine
+
+
Factory for creating IDownloadEngine objects.
+
+
DownloadEngineType - Enum in org.josfranmc.gutenberg.download.engine
+
+
Types of download engines
+
+
DownloadHttpUrlConnection - Class in org.josfranmc.gutenberg.download.engine
+
+
Allows to download a resource identified by an url and save it in a local folder.
+
+
DownloadParams - Class in org.josfranmc.gutenberg.download
+
+
Parameters used in the application.
+
+
DownloadParams() - Constructor for class org.josfranmc.gutenberg.download.DownloadParams
+
+
Main constructor.
+
+
DownloadResult - Class in org.josfranmc.gutenberg.download.engine
+
+
It encapsulates the result of downloading a resource.
+
+
DownloadResult() - Constructor for class org.josfranmc.gutenberg.download.engine.DownloadResult
+
 
+
DownloadThread - Class in org.josfranmc.gutenberg.download
+
+
Downloads a resource.
+
+
DownloadThread(URL, DownloadParams) - Constructor for class org.josfranmc.gutenberg.download.DownloadThread
+
 
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-3.html b/javadoc/index-files/index-3.html index deb2ea1..5ba8ee9 100644 --- a/javadoc/index-files/index-3.html +++ b/javadoc/index-files/index-3.html @@ -1,218 +1,131 @@ - - - - - - -D-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

D

-
-
done() - Static method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Método ejecutado una vez después de la ejecución de todos los tests
-
-
download() - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
-
-
Ejecuta el proceso de descarga.
-
-
download() - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
-
-
Ejecuta el proceso de descarga.
-
-
downloadBooks() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
-
Desacarga libros
-
-
downloadBooks() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Inicia el proceso de descarga de los libros.
-
-
DownloadEngineFactory - Class in org.josfranmc.gutenberg.download.engine
-
-
Factoría para la creación de objetos de tipo IDownloadEngine mediante el método create - Este método está sobregargado, de forma que se puede invocar combinando tres parámetros: - - target: recurso a descargar - savePath: ruta local donde obtener el recurso - type: tipo de motor a utilizar para la descarga (si no se indica ninguno por defecto se usa DownloadEngineType.HTTTP_CONNECTION) -
-
-
DownloadEngineFactory() - Constructor for class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
-
 
-
DownloadEngineFactoryTest - Class in org.josfranmc.gutenberg.engine
-
 
-
DownloadEngineFactoryTest() - Constructor for class org.josfranmc.gutenberg.engine.DownloadEngineFactoryTest
-
 
-
DownloadEngineType - Enum in org.josfranmc.gutenberg.download.engine
-
-
Tipos de motores de descarga
-
-
DownloadFactory - Class in org.josfranmc.gutenberg.download
-
-
Factoría que permite crear un objeto para realizar un tipo determinado de descarga
-
-
DownloadFactory() - Constructor for class org.josfranmc.gutenberg.download.DownloadFactory
-
 
-
DownloadGreedy - Class in org.josfranmc.gutenberg.download
-
-
Realiza el proceso de descarga de los libros de forma "avariciosa".
-
-
DownloadGreedy() - Constructor for class org.josfranmc.gutenberg.download.DownloadGreedy
-
-
Constructor por defecto.
-
-
DownloadHttpUrlConnection - Class in org.josfranmc.gutenberg.download.engine
-
-
Permite realizar la descarga de un recurso identificado por una URL.
-
-
DownloadHttpUrlConnectionTest - Class in org.josfranmc.gutenberg.engine
-
 
-
DownloadHttpUrlConnectionTest() - Constructor for class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
 
-
DownloadMode - Enum in org.josfranmc.gutenberg.download
-
-
Tipos de descarga.
-
-
DownloadParams - Class in org.josfranmc.gutenberg.download
-
-
Encapsula los parámetros que permiten configurar la aplicación.
-
-
DownloadParams() - Constructor for class org.josfranmc.gutenberg.download.DownloadParams
-
-
Constructor por defecto.
-
-
DownloadResult - Class in org.josfranmc.gutenberg.download.engine
-
-
Encapsula el resultado de la descarga de un recurso.
-
-
DownloadResult() - Constructor for class org.josfranmc.gutenberg.download.engine.DownloadResult
-
-
Constructor principal.
-
-
DownloadSoft - Class in org.josfranmc.gutenberg.download
-
-
Realiza el proceso de descarga de los libros de forma no "avariciosa".
-
-
DownloadSoft() - Constructor for class org.josfranmc.gutenberg.download.DownloadSoft
-
-
Constructor por defecto.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +E-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

E

+
+
executeDownload() - Method in class org.josfranmc.gutenberg.download.DownloadBooks
+
+
Perfoms the book download process.
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-4.html b/javadoc/index-files/index-4.html index 3bb2da7..551f0d3 100644 --- a/javadoc/index-files/index-4.html +++ b/javadoc/index-files/index-4.html @@ -1,132 +1,139 @@ - - - - - - -E-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

E

-
-
executeDownload(DownloadParams) - Method in class org.josfranmc.gutenberg.download.AbstractDownload
-
-
Ejecuta el proceso de desarga.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +F-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

F

+
+
fileExists(String, String) - Static method in class org.josfranmc.gutenberg.util.FileManager
+
+
Checks if the file indicated by an url already exists in a local path.
+
+
FileManager - Class in org.josfranmc.gutenberg.util
+
+
Tools for managing files.
+
+
FileScraping - Class in org.josfranmc.gutenberg.util
+
+
Tools for searching web links in files.
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-5.html b/javadoc/index-files/index-5.html index b9ac61c..aafa3b6 100644 --- a/javadoc/index-files/index-5.html +++ b/javadoc/index-files/index-5.html @@ -2,10 +2,9 @@ - - -F-Index - + +G-Index + @@ -13,7 +12,7 @@ - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

G

-
-
getContentLength() - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
 
-
getContentType() - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
 
-
getDelay() - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
 
-
getDelay() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getDelay() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Obtiene el tiempo de espera entre descargas establecido, en milisegundos.
-
-
getDownloadMode() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getDownloadMode() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
getEngineType() - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
 
-
getEngineType() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getEngineType() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
getError() - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
 
-
getFileOutputPath() - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
 
-
getFileType() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getFileType() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
getHeaders() - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
 
-
getLanguage() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getLanguage() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
getLastModified() - Method in class org.josfranmc.gutenberg.download.engine.DownloadResult
-
 
-
getLinks(String) - Static method in class org.josfranmc.gutenberg.util.FileScraping
-
-
Obtiene una lista con todos los enlaces contenidos dentro de un fichero HTML.
-
-
getLocalFileName(String) - Static method in class org.josfranmc.gutenberg.util.FileManager
-
-
Devuelve el nombre del archivo contenido en una ruta.
-
-
getLocalFilePathFromURL(String, String) - Static method in class org.josfranmc.gutenberg.util.FileManager
-
-
Devuelve la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo.
-
-
getMaxFilesToDownload() - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
 
-
getMaxFilesToDownload() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getMaxFilesToDownload() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
getResource() - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
-
-
Obtiene la dirección del recurso a descargar como un objeto de tipo URL
-
-
getResource() - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
-
-
Obtiene la dirección del recurso a descargar como un objeto de tipo URL
-
-
getSavePath() - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
 
-
getSavePath() - Method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
-
-
Obtiene la ruta donde guardar el recursos a descargar
-
-
getSavePath() - Method in interface org.josfranmc.gutenberg.download.engine.IDownloadEngine
-
-
Obtiene la ruta donde guardar el recursos a descargar
-
-
getSavePath() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getSavePath() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
getUrlBase() - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
 
-
getUrlBase() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
getUrlBase() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
givenDownloadModeWhenNullThenIllegalArgumentException() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
-
Si el parámetro DownloadMode es null, entonces lanzar excepción IllegalArgumentException
-
-
givenDownloadParametersWhenNullThenDownloadResultShoulbBeNotNull() - Method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Si los parámetros de descarga (ruta del recurso a descargar y ruta donde guardar la descarga) son nulos, entonces se devuelve un objeto - resultado (DownloadResult) con valores a null.
-
-
givenInputPathAndOutputPathWhenNullThenAvoidNullPointerException() - Method in class org.josfranmc.gutenberg.util.FileManagerTest
-
-
Si la ruta del directorio donde se encuentran los ficheros zip o la ruta del directorio en el que descomprimir los ficheros son null, - entonces el método FileManager.unzipFiles no debe lanzar NullPointerException
-
-
givenMaxFilesToDownloadWhenMinusZeroThenIllegalArgumentException() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
-
Si el parámetro MaxFilesToDownload es menor de cero, entonces lanzar excepción IllegalArgumentException
-
-
givenSavePathWhenNoExistsThenIllegalArgumentException() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
-
Si la ruta indicada para guardar las descargas no existe, entonces lanzar excepción IllegalArgumentException
-
-
givenSavePathWhenNullThenIllegalArgumentException() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
-
Si la ruta indicada para guardar las descargas es null, entonces lanzar excepción IllegalArgumentException
-
-
givenSavePathWhenNullThenReturnUserDir() - Method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Si la ruta donde guardar las descargas no se ha especificado, entonces la carpeta de descarga debe ser la carpeta de ejecución del programa.
-
-
givenUrlParametersWhenEmptyThenIllegalArgumentException() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
-
Si no se ha indicado tipo de fichero e idioma para realizar las descargas, entonces lanzar excepción IllegalArgumentException y mostrar mensaje
-
-
givenUrlParametersWhenNullThenIllegalArgumentException() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
-
Si no se ha indicado tipo de fichero e idioma para realizar las descargas, entonces lanzar excepción IllegalArgumentException y mostrar mensaje
-
-
givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull() - Method in class org.josfranmc.gutenberg.engine.DownloadEngineFactoryTest
-
-
Si se indica DownloadEngineType con valor null, entonces se debe crear un IDownloadEngineType de tipo DownloadEngineType.HTTP_CONNECTION
-
-
givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull() - Method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Si se indica una dirección de descarga errónea, entonces la ruta donde se ha guardado la descarga debe ser null (en el objeto DownloadResult).
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +I-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

I

+
+
IDownloadEngine - Interface in org.josfranmc.gutenberg.download.engine
+
+
Defines the behavior that a class have to implement in order to have the ability to download resources on net.
+
+
isOverwrite() - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
 
+
isOverwrite() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
 
+
isUnzip() - Method in class org.josfranmc.gutenberg.download.DownloadParams
+
 
+
isUnzip() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
 
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-7.html b/javadoc/index-files/index-7.html index af9f7e9..91df234 100644 --- a/javadoc/index-files/index-7.html +++ b/javadoc/index-files/index-7.html @@ -1,154 +1,135 @@ - - - - - - -I-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

I

-
-
IDownloadEngine - Interface in org.josfranmc.gutenberg.download.engine
-
-
Define el comportamiento que tiene que ofrecer toda clase que quiera implementar la capacidad de descargar - un recurso identificado por una URL
-
-
IGutenbergDownload - Interface in org.josfranmc.gutenberg.download
-
-
Establece el interfaz de uso que debe implementarse para llevar a cabo la gestión y desarrollo del proceso de descarga de los libros alojados - por el proyecto Gutenberg (http://www.gutenberg.org/)
-
-
init() - Method in class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
-
-
Método ejecutado antes de la ejecución de cada test
-
-
isOverwrite() - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
 
-
isOverwrite() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
isOverwrite() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
isUnzip() - Method in class org.josfranmc.gutenberg.download.DownloadParams
-
 
-
isUnzip() - Method in interface org.josfranmc.gutenberg.download.IGutenbergDownload
-
 
-
isUnzip() - Method in class org.josfranmc.gutenberg.download.JGutenbergDownload
-
 
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +J-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

J

+
+
JGutenbergDownload - Class in org.josfranmc.gutenberg.download
+
+
It allows to download books from the Gutenberg project repositories.
+
+
JGutenbergDownload() - Constructor for class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Main constructor.
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-8.html b/javadoc/index-files/index-8.html index 25fbafb..429502d 100644 --- a/javadoc/index-files/index-8.html +++ b/javadoc/index-files/index-8.html @@ -1,155 +1,131 @@ - - - - - - -J-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

J

-
-
JGutenbergDownload - Class in org.josfranmc.gutenberg.download
-
-
Implementa el proceso y gestión de descarga de libros alojados por el proyecto Gutenberg (http://www.gutenberg.org)
-
-
JGutenbergDownload() - Constructor for class org.josfranmc.gutenberg.download.JGutenbergDownload
-
-
Constructor principal.
-
-
JGutenbergDownloadClient - Class in org.josfranmc.gutenberg.download.client
-
-
Clase que permite ejecutar un progrma cliente para realiza descargas de libros desde los repositorios del proyecto Gutenberg.
-
-
JGutenbergDownloadClient() - Constructor for class org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient
-
 
-
JGutenbergDownloadFactory - Class in org.josfranmc.gutenberg.download
-
-
Factoría que crea objetos de tipo IGutenbergDownload, los cuales implementan los servicios necesarios para la gestión y desarrollo - del proceso de descarga de libros alojados por el proyecto Gutenberg.
-
-
JGutenbergDownloadFactory() - Constructor for class org.josfranmc.gutenberg.download.JGutenbergDownloadFactory
-
 
-
JGutenbergDownloadTest - Class in org.josfranmc.gutenberg.download
-
-
Clase que implementa los test para probar los métodos de la clase JGutenbergDownloadTest
-
-
JGutenbergDownloadTest() - Constructor for class org.josfranmc.gutenberg.download.JGutenbergDownloadTest
-
 
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +M-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

M

+
+
main(String[]) - Static method in class org.josfranmc.gutenberg.download.JGutenbergDownload
+
+
Main method for running the application.
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index-files/index-9.html b/javadoc/index-files/index-9.html index c6b9bf1..fbe5425 100644 --- a/javadoc/index-files/index-9.html +++ b/javadoc/index-files/index-9.html @@ -1,132 +1,131 @@ - - - - - - -M-Index - - - - - - - - -
- - - - - - - -
- - -
A C D E F G I J M N O R S T U V  - - -

M

-
-
main(String[]) - Static method in class org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient
-
-
Método principal de ejecución.
-
-
-A C D E F G I J M N O R S T U V 
- -
- - - - - - - -
- - - - + + + + + +N-Index + + + + + + + + +
+ + + + + + + +
+ + +
C D E F G I J M N O R S U V  + + +

N

+
+
newInstance(URL, String) - Static method in class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
+
+
Creates a DownloadHttpUrlConnection object which is an IDownloadEngine type instance.
+
+
+C D E F G I J M N O R S U V 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index.html b/javadoc/index.html index dfd0048..336c2c0 100644 --- a/javadoc/index.html +++ b/javadoc/index.html @@ -1,75 +1,74 @@ - - - - - - -Generated Documentation (Untitled) - - - - - - - - - -<noscript> -<div>JavaScript is disabled on your browser.</div> -</noscript> -<h2>Frame Alert</h2> -<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> - - - + + + + + +Generated Documentation (Untitled) + + + + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/AbstractDownload.html b/javadoc/org/josfranmc/gutenberg/download/AbstractDownload.html deleted file mode 100644 index 983fec4..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/AbstractDownload.html +++ /dev/null @@ -1,268 +0,0 @@ - - - - - - -AbstractDownload - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Class AbstractDownload

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.AbstractDownload
    • -
    -
  • -
-
-
    -
  • -
    -
    Direct Known Subclasses:
    -
    DownloadGreedy, DownloadSoft
    -
    -
    -
    -
    public abstract class AbstractDownload
    -extends java.lang.Object
    -
    Encapsula el proceso que ha de seguirse para la descarga de un recurso.
    - Esta clase actúa como plantilla (template), de forma que las clases que hereden de ella deben implementar los métodos indicados para realizar las descargas. - En concreo, se debe definir como se configuran los parámetros pasados y como se realiza el procesamiento de las páginas que exponen los enlaces a los - libros del proyecto Gutenberg (http://www.gutenberg.org/)
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    See Also:
    -
    DownloadParams, -IDownloadEngine
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidexecuteDownload(DownloadParams downloadParams) -
      Ejecuta el proceso de desarga.
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        executeDownload

        -
        public void executeDownload(DownloadParams downloadParams)
        -
        Ejecuta el proceso de desarga.
        Una vez realizada la configuración de los elementos necesarios, se realiza la descarga del recurso indicado - en los parámetros pasados. Si el recurso obtenido es una página con enlaces de descarga se extraen estos enlaces - para realizar la descarga de los recursos que se referencian.
        -
        -
        Parameters:
        -
        downloadParams - parámetros de configuración de la descarga
        -
        Throws:
        -
        java.lang.IllegalStateException - si se ha devuelto algún error al hacer las descargas
        -
        See Also:
        -
        DownloadParams
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/engine/DownloadEngineFactoryTest.html b/javadoc/org/josfranmc/gutenberg/download/DownloadBooks.html similarity index 67% rename from javadoc/org/josfranmc/gutenberg/engine/DownloadEngineFactoryTest.html rename to javadoc/org/josfranmc/gutenberg/download/DownloadBooks.html index 902f7ff..f46c9dd 100644 --- a/javadoc/org/josfranmc/gutenberg/engine/DownloadEngineFactoryTest.html +++ b/javadoc/org/josfranmc/gutenberg/download/DownloadBooks.html @@ -1,275 +1,288 @@ - - - - - - -DownloadEngineFactoryTest - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.engine
-

Class DownloadEngineFactoryTest

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.engine.DownloadEngineFactoryTest
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class DownloadEngineFactoryTest
    -extends java.lang.Object
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        DownloadEngineFactoryTest

        -
        public DownloadEngineFactoryTest()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull

        -
        public void givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull()
        -
        Si se indica DownloadEngineType con valor null, entonces se debe crear un IDownloadEngineType de tipo DownloadEngineType.HTTP_CONNECTION
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +DownloadBooks + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download
+

Class DownloadBooks

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.josfranmc.gutenberg.download.DownloadBooks
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class DownloadBooks
    +extends java.lang.Object
    +
    Allows to perform the file download process.
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    See Also:
    +
    JGutenbergDownload, +DownloadParams
    +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidexecuteDownload() +
      Perfoms the book download process.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DownloadBooks

        +
        public DownloadBooks(DownloadParams parameters)
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        executeDownload

        +
        public void executeDownload()
        +
        Perfoms the book download process.

        + The first download should be a file with links to the books to download. All existing links are downloaded. + If there is a link to another page with more links, this page is downloaded and processed in the same way. + This process continues until there are no more pages.

        + All downloads run on separate threads.

        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/DownloadFactory.html b/javadoc/org/josfranmc/gutenberg/download/DownloadFactory.html deleted file mode 100644 index 7269443..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/DownloadFactory.html +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - -DownloadFactory - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Class DownloadFactory

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.DownloadFactory
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class DownloadFactory
    -extends java.lang.Object
    -
    Factoría que permite crear un objeto para realizar un tipo determinado de descarga
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    See Also:
    -
    AbstractDownload, -DownloadMode
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      DownloadFactory() 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static AbstractDownloadcreate(DownloadMode type) -
      Crea un objeto concreto para realizar descargas
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        DownloadFactory

        -
        public DownloadFactory()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        create

        -
        public static AbstractDownload create(DownloadMode type)
        -
        Crea un objeto concreto para realizar descargas
        -
        -
        Parameters:
        -
        type - tipo de descarga según DownloadType
        -
        Returns:
        -
        objeto para realizar descargas
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/DownloadMode.html b/javadoc/org/josfranmc/gutenberg/download/DownloadMode.html deleted file mode 100644 index fdb51cf..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/DownloadMode.html +++ /dev/null @@ -1,355 +0,0 @@ - - - - - - -DownloadMode - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Enum DownloadMode

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • java.lang.Enum<DownloadMode>
    • -
    • -
        -
      • org.josfranmc.gutenberg.download.DownloadMode
      • -
      -
    • -
    -
  • -
-
-
    -
  • -
    -
    All Implemented Interfaces:
    -
    java.io.Serializable, java.lang.Comparable<DownloadMode>
    -
    -
    -
    -
    public enum DownloadMode
    -extends java.lang.Enum<DownloadMode>
    -
    Tipos de descarga.
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Enum Constant Summary

      - - - - - - - - - - - -
      Enum Constants 
      Enum Constant and Description
      GREEDY -
      Descarga concurrente de recursos (más rápida)
      -
      SOFT -
      Descarga normal (lenta)
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static DownloadModevalueOf(java.lang.String name) -
      Returns the enum constant of this type with the specified name.
      -
      static DownloadMode[]values() -
      Returns an array containing the constants of this enum type, in -the order they are declared.
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Enum

        -compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -getClass, notify, notifyAll, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Enum Constant Detail

      - - - -
        -
      • -

        SOFT

        -
        public static final DownloadMode SOFT
        -
        Descarga normal (lenta)
        -
      • -
      - - - -
        -
      • -

        GREEDY

        -
        public static final DownloadMode GREEDY
        -
        Descarga concurrente de recursos (más rápida)
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        values

        -
        public static DownloadMode[] values()
        -
        Returns an array containing the constants of this enum type, in -the order they are declared. This method may be used to iterate -over the constants as follows: -
        -for (DownloadMode c : DownloadMode.values())
        -    System.out.println(c);
        -
        -
        -
        Returns:
        -
        an array containing the constants of this enum type, in the order they are declared
        -
        -
      • -
      - - - -
        -
      • -

        valueOf

        -
        public static DownloadMode valueOf(java.lang.String name)
        -
        Returns the enum constant of this type with the specified name. -The string must match exactly an identifier used to declare an -enum constant in this type. (Extraneous whitespace characters are -not permitted.)
        -
        -
        Parameters:
        -
        name - the name of the enum constant to be returned.
        -
        Returns:
        -
        the enum constant with the specified name
        -
        Throws:
        -
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        -
        java.lang.NullPointerException - if the argument is null
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/DownloadParams.html b/javadoc/org/josfranmc/gutenberg/download/DownloadParams.html index b4b1246..378e342 100644 --- a/javadoc/org/josfranmc/gutenberg/download/DownloadParams.html +++ b/javadoc/org/josfranmc/gutenberg/download/DownloadParams.html @@ -1,538 +1,678 @@ - - - - - - -DownloadParams - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Class DownloadParams

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.DownloadParams
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class DownloadParams
    -extends java.lang.Object
    -
    Encapsula los parámetros que permiten configurar la aplicación. Son los siguientes: -
      -
    • urlBase: url del recurso a descargar
    • -
    • savePath: ruta local donde descargar los recursos
    • -
    • overwrite: indica si se deben sobreescribir recursos que ya están descargados
    • -
    • delay: tiempo de espera entre descargas
    • -
    • unzip: indica si los recursos descargados en formato zip deben o no descomprimirse
    • -
    • engineType: tipo de motor a utilizar para la descarga
    • -
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    See Also:
    -
    DownloadEngineType
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      DownloadParams() -
      Constructor por defecto.
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      intgetDelay() 
      DownloadEngineTypegetEngineType() 
      intgetMaxFilesToDownload() 
      java.lang.StringgetSavePath() 
      java.net.URLgetUrlBase() 
      booleanisOverwrite() 
      booleanisUnzip() 
      voidsetDelay(int delay) -
      Establece el intervalo de espera entre descargas.
      -
      voidsetEngineType(DownloadEngineType engineType) -
      Establece el tipo de motor de descarga a utilizar
      -
      voidsetMaxFilesToDownload(int maxFilesToDownload) -
      Establece el número máximo de ficheros a descargar.
      -
      voidsetOverwrite(boolean overwrite) -
      Establece si deben sobreescribirse los recursos existentes por las nuevas descargas en caso de ser los mismos
      -
      voidsetSavePath(java.lang.String savePath) -
      Establece la ruta de la carpeta en la que obtener los recursos descargados.
      -
      voidsetUnzip(boolean unzip) -
      Establece si se deben descomprimir los archivos descargados
      -
      voidsetUrlBase(java.net.URL urlBase) -
      Establece la dirección url inicial del recurso a obtener
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        DownloadParams

        -
        public DownloadParams()
        -
        Constructor por defecto.
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getUrlBase

        -
        public java.net.URL getUrlBase()
        -
        -
        Returns:
        -
        la dirección url inicial del recurso a obtener
        -
        -
      • -
      - - - -
        -
      • -

        setUrlBase

        -
        public void setUrlBase(java.net.URL urlBase)
        -
        Establece la dirección url inicial del recurso a obtener
        -
        -
        Parameters:
        -
        urlBase - dirección url
        -
        -
      • -
      - - - -
        -
      • -

        getSavePath

        -
        public java.lang.String getSavePath()
        -
        -
        Returns:
        -
        la ruta de la carpeta en la que obtener los recursos descargados
        -
        -
      • -
      - - - -
        -
      • -

        setSavePath

        -
        public void setSavePath(java.lang.String savePath)
        -
        Establece la ruta de la carpeta en la que obtener los recursos descargados.
        -
        -
        Parameters:
        -
        savePath - ruta de la carpeta en la que obtener los recursos descargados
        -
        -
      • -
      - - - -
        -
      • -

        isOverwrite

        -
        public boolean isOverwrite()
        -
        -
        Returns:
        -
        true si se deben sobreescribir los archivos existentes por los descargados en caso de ser los mismos, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        setOverwrite

        -
        public void setOverwrite(boolean overwrite)
        -
        Establece si deben sobreescribirse los recursos existentes por las nuevas descargas en caso de ser los mismos
        -
        -
        Parameters:
        -
        overwrite - true si se deben sobreescribir los archivos, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        getDelay

        -
        public int getDelay()
        -
        -
        Returns:
        -
        el intervalo de espera entre descargas, en milisegundos
        -
        -
      • -
      - - - -
        -
      • -

        setDelay

        -
        public void setDelay(int delay)
        -
        Establece el intervalo de espera entre descargas.
        -
        -
        Parameters:
        -
        delay - tiempo de espera, en milisegundos
        -
        -
      • -
      - - - -
        -
      • -

        isUnzip

        -
        public boolean isUnzip()
        -
        -
        Returns:
        -
        true si se deben descomprimir los archivos descargados, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        setUnzip

        -
        public void setUnzip(boolean unzip)
        -
        Establece si se deben descomprimir los archivos descargados
        -
        -
        Parameters:
        -
        unzip - true si se deben descomprimir los archivos descargados, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        getMaxFilesToDownload

        -
        public int getMaxFilesToDownload()
        -
        -
        Returns:
        -
        el número máximo de ficheros a descargar
        -
        -
      • -
      - - - -
        -
      • -

        setMaxFilesToDownload

        -
        public void setMaxFilesToDownload(int maxFilesToDownload)
        -
        Establece el número máximo de ficheros a descargar. El valor cero indica descargar todos los ficheros disponibles.
        -
        -
        Parameters:
        -
        maxFilesToDownload - número máximo de ficheros
        -
        -
      • -
      - - - -
        -
      • -

        getEngineType

        -
        public DownloadEngineType getEngineType()
        -
        -
        Returns:
        -
        el tipo de motor de descarga a utilizar
        -
        -
      • -
      - - - -
        -
      • -

        setEngineType

        -
        public void setEngineType(DownloadEngineType engineType)
        -
        Establece el tipo de motor de descarga a utilizar
        -
        -
        Parameters:
        -
        engineType - tipo de motor de descarga a utilizar
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +DownloadParams + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download
+

Class DownloadParams

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.josfranmc.gutenberg.download.DownloadParams
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class DownloadParams
    +extends java.lang.Object
    +
    Parameters used in the application. They are: +
      +
    • fileType: the type of files to download (default txt)
    • +
    • language: the language of files to download (default es)
    • +
    • urlBase: initial download url
    • +
    • savePath: path where to get downloaded resources (default System.getProperty("user.dir"))
    • +
    • overwrite: if the existing files must be overwritten by the downloaded ones (default false)
    • +
    • delay: delay between downloads, in milliseconds (default 2000)
    • +
    • unzip: if downloaded files must be unzipping (default true)
    • +
    • maxFilesToDownload: the maximum number of files to download (default 10, 0 for download all existing)
    • +
    • engineType: the type of downloading engine to use (default DownloadEngineType.HTTP_CONNECTION)
    • +
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    See Also:
    +
    DownloadEngineType, +JGutenbergDownload
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      static java.lang.StringURL_BOOKS +
      Base URL of the Gutenberg project to download
      +
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      DownloadParams() +
      Main constructor.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        URL_BOOKS

        +
        public static final java.lang.String URL_BOOKS
        +
        Base URL of the Gutenberg project to download
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DownloadParams

        +
        public DownloadParams()
        +
        Main constructor. It initializes the object with default values: +
          +
        • fileType: txt
        • +
        • language: es
        • +
        • savePath: System.getProperty("user.dir")
        • +
        • overwrite: false
        • +
        • delay: 2000 milliseconds
        • +
        • unzip: true
        • +
        • maxFilesToDownload: 10 (0 for download all existing)
        • +
        • engineType: DownloadEngineType.HTTP_CONNECTION
        • +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getFileType

        +
        public java.lang.String getFileType()
        +
        +
        Returns:
        +
        the type of files to download
        +
        +
      • +
      + + + +
        +
      • +

        setFileType

        +
        public void setFileType(java.lang.String fileType)
        +
        Sets the type of file to download. Valid types: txt, epub, html
        +
        +
        Parameters:
        +
        fileType - type of file to download
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if an invalid file type is indicated
        +
        +
      • +
      + + + +
        +
      • +

        getLanguage

        +
        public java.lang.String getLanguage()
        +
        +
        Returns:
        +
        the language of files to download
        +
        +
      • +
      + + + +
        +
      • +

        setLanguage

        +
        public void setLanguage(java.lang.String language)
        +
        Sets the language of the files to download acording to Gutenberg nomeclature.
        + Ej.: es - spanish, en - english, fr - french
        +
        +
        Parameters:
        +
        language - type of language
        +
        +
      • +
      + + + +
        +
      • +

        getUrlBase

        +
        public java.net.URL getUrlBase()
        +
        +
        Returns:
        +
        initial download url
        +
        +
      • +
      + + + +
        +
      • +

        getSavePath

        +
        public java.lang.String getSavePath()
        +
        +
        Returns:
        +
        folder path where to get downloaded resources
        +
        +
      • +
      + + + +
        +
      • +

        setSavePath

        +
        public void setSavePath(java.lang.String savePath)
        +
        Sets folder path where to get downloaded resources
        +
        +
        Parameters:
        +
        savePath - folder path where to get downloaded resources
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if the parameter is null
        +
        +
      • +
      + + + +
        +
      • +

        getZipsPath

        +
        public java.lang.String getZipsPath()
        +
        +
        Returns:
        +
        folder path where to get downloaded zips
        +
        +
      • +
      + + + +
        +
      • +

        isOverwrite

        +
        public boolean isOverwrite()
        +
        +
        Returns:
        +
        true if the existing files must be overwritten by the downloaded ones, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        setOverwrite

        +
        public void setOverwrite(boolean overwrite)
        +
        Sets if the existing files must be overwritten by the downloaded ones
        +
        +
        Parameters:
        +
        overwrite - true if the existing files must be overwritten, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        getDelay

        +
        public int getDelay()
        +
        +
        Returns:
        +
        delay between downloads, in milliseconds
        +
        +
      • +
      + + + +
        +
      • +

        setDelay

        +
        public void setDelay(int delay)
        +
        Sets delay between downloads
        +
        +
        Parameters:
        +
        delay - waiting time, in milliseconds
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if a number less than zero is indicated
        +
        +
      • +
      + + + +
        +
      • +

        isUnzip

        +
        public boolean isUnzip()
        +
        +
        Returns:
        +
        true if downloaded files must be unzipping, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        setUnzip

        +
        public void setUnzip(boolean unzip)
        +
        Sets if downloaded files must be unzipping,
        +
        +
        Parameters:
        +
        unzip - true if downloaded files must be unzipping, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        getMaxFilesToDownload

        +
        public int getMaxFilesToDownload()
        +
        +
        Returns:
        +
        the maximum number of files to download
        +
        +
      • +
      + + + +
        +
      • +

        setMaxFilesToDownload

        +
        public void setMaxFilesToDownload(int maxFilesToDownload)
        +
        Sets the maximum number of files to download. The zero indicates downloading all available files.
        +
        +
        Parameters:
        +
        maxFilesToDownload - files number
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if a number less than zero is indicated
        +
        +
      • +
      + + + + + + + +
        +
      • +

        setEngineType

        +
        public void setEngineType(DownloadEngineType engineType)
        +
        Sets the type of downloading engine to use
        +
        +
        Parameters:
        +
        engineType - engine type
        +
        See Also:
        +
        DownloadEngineType
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/DownloadGreedy.html b/javadoc/org/josfranmc/gutenberg/download/DownloadThread.html similarity index 65% rename from javadoc/org/josfranmc/gutenberg/download/DownloadGreedy.html rename to javadoc/org/josfranmc/gutenberg/download/DownloadThread.html index 5a1528f..65bd7e6 100644 --- a/javadoc/org/josfranmc/gutenberg/download/DownloadGreedy.html +++ b/javadoc/org/josfranmc/gutenberg/download/DownloadThread.html @@ -1,314 +1,295 @@ - - - - - - -DownloadGreedy - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Class DownloadGreedy

-
-
- -
-
    -
  • -
    -
    All Implemented Interfaces:
    -
    java.lang.Runnable
    -
    -
    -
    -
    public class DownloadGreedy
    -extends AbstractDownload
    -implements java.lang.Runnable
    -
    Realiza el proceso de descarga de los libros de forma "avariciosa". La estrategia utilizada es la de ejecutar diversos hilos para realizar - la descarga de los libros de forma concurrrente y sin realizar ninguna pausa entre las descargas.
    - Este método de descarga es más eficiente, desde el punto de vista de la velocidad de las descargas, que el usado por el tipo DownloadSoft - pero no respeta las condiciones de uso del servicio ofrecido por el proyecto Gutenberg ya que se hace un uso abusivo de las mismas. Utilizar este - modo de descarga puede suponer que nuestra dirección ip sea bloqueada, impidiéndonos el acceso a los servidores.

    - Más info: http://www.gutenberg.org/wiki/Gutenberg:Information_About_Robot_Access_to_our_Pages

    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    See Also:
    -
    AbstractDownload, -DownloadParams
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      DownloadGreedy() -
      Constructor por defecto.
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidrun() -
      Inicia un proceso de descarga.
      -
      - -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        DownloadGreedy

        -
        public DownloadGreedy()
        -
        Constructor por defecto.
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        run

        -
        public void run()
        -
        Inicia un proceso de descarga.
        -
        -
        Specified by:
        -
        run in interface java.lang.Runnable
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +DownloadThread + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download
+

Class DownloadThread

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.josfranmc.gutenberg.download.DownloadThread
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    java.lang.Runnable
    +
    +
    +
    +
    public class DownloadThread
    +extends java.lang.Object
    +implements java.lang.Runnable
    +
    Downloads a resource.
    + Objects of this class can be runned in separate threads.
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidrun() 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DownloadThread

        +
        public DownloadThread(java.net.URL target,
        +                      DownloadParams parameters)
        +
        +
        Parameters:
        +
        target - download url
        +
        parameters - settings
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        run

        +
        public void run()
        +
        +
        Specified by:
        +
        run in interface java.lang.Runnable
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/IGutenbergDownload.html b/javadoc/org/josfranmc/gutenberg/download/IGutenbergDownload.html deleted file mode 100644 index ac53d8c..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/IGutenbergDownload.html +++ /dev/null @@ -1,605 +0,0 @@ - - - - - - -IGutenbergDownload - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Interface IGutenbergDownload

-
-
-
-
    -
  • -
    -
    All Known Implementing Classes:
    -
    JGutenbergDownload
    -
    -
    -
    -
    public interface IGutenbergDownload
    -
    Establece el interfaz de uso que debe implementarse para llevar a cabo la gestión y desarrollo del proceso de descarga de los libros alojados - por el proyecto Gutenberg (http://www.gutenberg.org/)
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    See Also:
    -
    DownloadMode, -DownloadEngineType
    -
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        downloadBooks

        -
        void downloadBooks()
        -
        Desacarga libros
        -
      • -
      - - - -
        -
      • -

        getDownloadMode

        -
        DownloadMode getDownloadMode()
        -
        -
        Returns:
        -
        el modo de descarga utilizado
        -
        -
      • -
      - - - -
        -
      • -

        setDownloadMode

        -
        void setDownloadMode(DownloadMode mode)
        -
        Establece el mode de realizar las descargas
        -
        -
        Parameters:
        -
        mode - tipo de descarga DownloadMode
        -
        See Also:
        -
        DownloadMode
        -
        -
      • -
      - - - -
        -
      • -

        setDelay

        -
        void setDelay(int delay)
        -
        Establece el tiempo de espera entre descargas, en milisegundos
        -
        -
        Parameters:
        -
        delay - tiempo de espera entre descargas
        -
        -
      • -
      - - - -
        -
      • -

        getDelay

        -
        int getDelay()
        -
        -
        Returns:
        -
        el tiempo de espera entre descargas
        -
        -
      • -
      - - - -
        -
      • -

        setOverwrite

        -
        void setOverwrite(boolean value)
        -
        Establece si se deben sobreescribir los ficheros ya existentes en la carpeta especificada por las nuevas descargas en caso de ser los mismos
        -
        -
        Parameters:
        -
        value - true si se deben sobreescribir los archivos, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        isOverwrite

        -
        boolean isOverwrite()
        -
        -
        Returns:
        -
        si está activado/desactivado el indicador de sobreescribir ficheros ya descargados
        -
        -
      • -
      - - - -
        -
      • -

        getUrlBase

        -
        java.lang.String getUrlBase()
        -
        -
        Returns:
        -
        la dirección URL desde donde realizar la descarga de los archivos
        -
        -
      • -
      - - - -
        -
      • -

        setSavePath

        -
        void setSavePath(java.lang.String savePath)
        -
        Establece la ruta de la carpeta en la que guardar los archivos descargados
        -
        -
        Parameters:
        -
        savePath - ruta de la carpeta en la que guardar los archivos descargados
        -
        -
      • -
      - - - -
        -
      • -

        getSavePath

        -
        java.lang.String getSavePath()
        -
        -
        Returns:
        -
        la ruta en la que guardar los archivos descargados
        -
        -
      • -
      - - - -
        -
      • -

        setUnzip

        -
        void setUnzip(boolean value)
        -
        Establece si se deben descomprimir los ficheros una vez descargados
        -
        -
        Parameters:
        -
        value - true si se deben descomprimir los archivos descargados, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        isUnzip

        -
        boolean isUnzip()
        -
        -
        Returns:
        -
        true si se deben descomprimir los archivos descargados, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        setFileType

        -
        IGutenbergDownload setFileType(java.lang.String fileType)
        -
        Establece el tipo de ficheros a descargar. Tipos válidos: txt, epub, html
        -
        -
        Parameters:
        -
        fileType - tipo de fichero a desrgargar
        -
        Returns:
        -
        una referencia al propio objeto que hace la llamada
        -
        See Also:
        -
        IGutenbergDownload
        -
        -
      • -
      - - - -
        -
      • -

        getFileType

        -
        java.lang.String getFileType()
        -
        -
        Returns:
        -
        el tipo de fichero configurado para descargar.
        -
        -
      • -
      - - - -
        -
      • -

        setLanguage

        -
        IGutenbergDownload setLanguage(java.lang.String language)
        -
        Establece el idioma de los ficheros a descargar, según la nomenclatura usada por el proyecto Gutenberg. Ej.: es - español, en - inglés, fr - francés

        - Más info: http://www.gutenberg.org/catalog/

        -
        -
        Parameters:
        -
        language - tipod e idioma
        -
        Returns:
        -
        una referencia al propio objeto que hace la llamada
        -
        See Also:
        -
        IGutenbergDownload
        -
        -
      • -
      - - - -
        -
      • -

        getLanguage

        -
        java.lang.String getLanguage()
        -
        -
        Returns:
        -
        el idioma configurado de los ficheros para descargar.
        -
        -
      • -
      - - - -
        -
      • -

        getMaxFilesToDownload

        -
        int getMaxFilesToDownload()
        -
        -
        Returns:
        -
        el número máximo de ficheros a descargar
        -
        -
      • -
      - - - -
        -
      • -

        setMaxFilesToDownload

        -
        void setMaxFilesToDownload(int maxFilesToDownload)
        -
        Establece el número máximo de ficheros a descargar
        -
        -
        Parameters:
        -
        maxFilesToDownload - número máximo de ficheros
        -
        -
      • -
      - - - -
        -
      • -

        setEngineType

        -
        void setEngineType(DownloadEngineType engineType)
        -
        Establece el tipo de motor a utilizar para realizar las descargas
        -
        -
        Parameters:
        -
        engineType - tipode motor DownloadEngineType
        -
        See Also:
        -
        DownloadEngineType
        -
        -
      • -
      - - - - -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownload.html b/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownload.html index 55de25e..ab148e9 100644 --- a/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownload.html +++ b/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownload.html @@ -1,738 +1,678 @@ - - - - - - -JGutenbergDownload - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Class JGutenbergDownload

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.JGutenbergDownload
    • -
    -
  • -
-
- -
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      JGutenbergDownload() -
      Constructor principal.
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voiddownloadBooks() -
      Inicia el proceso de descarga de los libros.
      -
      intgetDelay() -
      Obtiene el tiempo de espera entre descargas establecido, en milisegundos.
      -
      DownloadModegetDownloadMode() 
      DownloadEngineTypegetEngineType() 
      java.lang.StringgetFileType() 
      java.lang.StringgetLanguage() 
      intgetMaxFilesToDownload() 
      java.lang.StringgetSavePath() 
      java.lang.StringgetUrlBase() 
      booleanisOverwrite() 
      booleanisUnzip() 
      voidsetDelay(int delay) -
      Establece el tiempo de espera entre descargas, en milisegundos.
      -
      voidsetDownloadMode(DownloadMode mode) -
      Establece el mode de realizar las descargas
      -
      voidsetEngineType(DownloadEngineType engineType) -
      Establece el tipo de motor a utilizar para realizar las descargas.
      -
      JGutenbergDownloadsetFileType(java.lang.String fileType) -
      Establece el tipo de ficheros a descargar.
      -
      JGutenbergDownloadsetLanguage(java.lang.String language) -
      Establece el idioma de los ficheros a descargar, según la nomenclatura usada por el proyecto Gutenberg.
      -
      voidsetMaxFilesToDownload(int maxFilesToDownload) -
      Establece el número máximo de ficheros a descargar
      -
      voidsetOverwrite(boolean value) -
      Establece si se deben sobreescribir los ficheros ya existentes en la carpeta especificada por las nuevas descargas en caso de ser los mismos
      -
      voidsetSavePath(java.lang.String savePath) -
      Establece la ruta de la carpeta en la que guardar los archivos descargados.
      -
      voidsetUnzip(boolean value) -
      Establece si se deben descomprimir los ficheros una vez descargados
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        JGutenbergDownload

        -
        public JGutenbergDownload()
        -
        Constructor principal. Establece los parámetros de configuración que usa la apliación con valores por defecto. Concretamente: -
          -
        • Se establece como carpeta base de descarga la carpeta desde la que se ejecuta el programa
        • -
        • Se fija un tiempo de demora entre descargas de 2 segundos
        • -
        • Se establece que no se sobreescriban ficheros previamente descargados
        • -
        • Se establece que se descompriman los ficheros zips descargados
        • -
        • Se indica que se utilice un motor de descarga del tipo DownloadEngineType.HTTP_CONNECTION
        • -
        • Se indica que las descargas se realicen usando un modo DownloadMode.SOFT
        • -
        • Se indica que se descarguen todos los ficheros disponibles
        • -
        -
        -
        See Also:
        -
        DownloadParams, -DownloadEngineType, -DownloadMode
        -
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        downloadBooks

        -
        public void downloadBooks()
        -
        Inicia el proceso de descarga de los libros.
        - Crea una carpeta para guardar los zip descargados dentro de la carpeta indicada para almacenar descargar las descargas. - - Se comprueba si se ha indicado el tipo de ficheros a descargar y el idioma de los mismos. - Si no se se han indicado no se puede realizar la descarga.
        -
        -
        Specified by:
        -
        downloadBooks in interface IGutenbergDownload
        -
        Throws:
        -
        java.lang.IllegalArgumentException - si no se ha indicado tipo de fichero e idioma
        -
        -
      • -
      - - - - - - - - - - - -
        -
      • -

        setDelay

        -
        public void setDelay(int delay)
        -
        Establece el tiempo de espera entre descargas, en milisegundos.
        -
        -
        Specified by:
        -
        setDelay in interface IGutenbergDownload
        -
        Parameters:
        -
        delay - tiempo de espera entre descargas
        -
        See Also:
        -
        DownloadParams
        -
        -
      • -
      - - - -
        -
      • -

        getDelay

        -
        public int getDelay()
        -
        Obtiene el tiempo de espera entre descargas establecido, en milisegundos.
        -
        -
        Specified by:
        -
        getDelay in interface IGutenbergDownload
        -
        Returns:
        -
        el tiempo de espera entre descargas
        -
        -
      • -
      - - - -
        -
      • -

        setOverwrite

        -
        public void setOverwrite(boolean value)
        -
        Description copied from interface: IGutenbergDownload
        -
        Establece si se deben sobreescribir los ficheros ya existentes en la carpeta especificada por las nuevas descargas en caso de ser los mismos
        -
        -
        Specified by:
        -
        setOverwrite in interface IGutenbergDownload
        -
        Parameters:
        -
        value - true si se deben sobreescribir los archivos, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        isOverwrite

        -
        public boolean isOverwrite()
        -
        -
        Specified by:
        -
        isOverwrite in interface IGutenbergDownload
        -
        Returns:
        -
        si está activado/desactivado el indicador de sobreescribir ficheros ya descargados
        -
        -
      • -
      - - - -
        -
      • -

        getUrlBase

        -
        public java.lang.String getUrlBase()
        -
        -
        Specified by:
        -
        getUrlBase in interface IGutenbergDownload
        -
        Returns:
        -
        la dirección URL desde donde realizar la descarga de los archivos
        -
        -
      • -
      - - - -
        -
      • -

        setSavePath

        -
        public void setSavePath(java.lang.String savePath)
        -
        Establece la ruta de la carpeta en la que guardar los archivos descargados. Se añade el caracter separador de directorios a la final de la - ruta en caso de que no lo lleve.
        Esta ruta se añade a los parámetros de la aplicación y se establece como ruta raiz del proceso.
        -
        -
        Specified by:
        -
        setSavePath in interface IGutenbergDownload
        -
        Parameters:
        -
        savePath - ruta de la carpeta
        -
        Throws:
        -
        java.lang.IllegalArgumentException - ruta errónea
        -
        -
      • -
      - - - -
        -
      • -

        getSavePath

        -
        public java.lang.String getSavePath()
        -
        -
        Specified by:
        -
        getSavePath in interface IGutenbergDownload
        -
        Returns:
        -
        la ruta en la que guardar los archivos descargados
        -
        -
      • -
      - - - -
        -
      • -

        isUnzip

        -
        public boolean isUnzip()
        -
        -
        Specified by:
        -
        isUnzip in interface IGutenbergDownload
        -
        Returns:
        -
        true si se deben descomprimir los archivos descargados, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        setUnzip

        -
        public void setUnzip(boolean value)
        -
        Description copied from interface: IGutenbergDownload
        -
        Establece si se deben descomprimir los ficheros una vez descargados
        -
        -
        Specified by:
        -
        setUnzip in interface IGutenbergDownload
        -
        Parameters:
        -
        value - true si se deben descomprimir los archivos descargados, false en caso contrario
        -
        -
      • -
      - - - -
        -
      • -

        getFileType

        -
        public java.lang.String getFileType()
        -
        -
        Specified by:
        -
        getFileType in interface IGutenbergDownload
        -
        Returns:
        -
        el tipo de fichero configurado para descargar.
        -
        -
      • -
      - - - -
        -
      • -

        setFileType

        -
        public JGutenbergDownload setFileType(java.lang.String fileType)
        -
        Description copied from interface: IGutenbergDownload
        -
        Establece el tipo de ficheros a descargar. Tipos válidos: txt, epub, html
        -
        -
        Specified by:
        -
        setFileType in interface IGutenbergDownload
        -
        Parameters:
        -
        fileType - tipo de fichero a desrgargar
        -
        Returns:
        -
        una referencia al propio objeto que hace la llamada
        -
        See Also:
        -
        IGutenbergDownload
        -
        -
      • -
      - - - -
        -
      • -

        getLanguage

        -
        public java.lang.String getLanguage()
        -
        -
        Specified by:
        -
        getLanguage in interface IGutenbergDownload
        -
        Returns:
        -
        el idioma configurado de los ficheros para descargar.
        -
        -
      • -
      - - - -
        -
      • -

        setLanguage

        -
        public JGutenbergDownload setLanguage(java.lang.String language)
        -
        Description copied from interface: IGutenbergDownload
        -
        Establece el idioma de los ficheros a descargar, según la nomenclatura usada por el proyecto Gutenberg. Ej.: es - español, en - inglés, fr - francés

        - Más info: http://www.gutenberg.org/catalog/

        -
        -
        Specified by:
        -
        setLanguage in interface IGutenbergDownload
        -
        Parameters:
        -
        language - tipod e idioma
        -
        Returns:
        -
        una referencia al propio objeto que hace la llamada
        -
        See Also:
        -
        IGutenbergDownload
        -
        -
      • -
      - - - -
        -
      • -

        getMaxFilesToDownload

        -
        public int getMaxFilesToDownload()
        -
        -
        Specified by:
        -
        getMaxFilesToDownload in interface IGutenbergDownload
        -
        Returns:
        -
        el número máximo de ficheros a descargar
        -
        -
      • -
      - - - -
        -
      • -

        setMaxFilesToDownload

        -
        public void setMaxFilesToDownload(int maxFilesToDownload)
        -
        Establece el número máximo de ficheros a descargar
        -
        -
        Specified by:
        -
        setMaxFilesToDownload in interface IGutenbergDownload
        -
        Parameters:
        -
        maxFilesToDownload - número máximo de ficheros
        -
        Throws:
        -
        java.lang.IllegalArgumentException - si se indica un número inferior a cero
        -
        -
      • -
      - - - - - - - -
        -
      • -

        setEngineType

        -
        public void setEngineType(DownloadEngineType engineType)
        -
        Establece el tipo de motor a utilizar para realizar las descargas.
        - Lo asigna al atributo que encapsula los parámetros de la aplicación
        -
        -
        Specified by:
        -
        setEngineType in interface IGutenbergDownload
        -
        Parameters:
        -
        engineType - tipode motor DownloadEngineType
        -
        See Also:
        -
        DownloadEngineType
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +JGutenbergDownload + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download
+

Class JGutenbergDownload

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.josfranmc.gutenberg.download.JGutenbergDownload
    • +
    +
  • +
+
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JGutenbergDownload

        +
        public JGutenbergDownload()
        +
        Main constructor. It initializes the application with default values.
        +
        +
        See Also:
        +
        DownloadParams
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getParameters

        +
        public DownloadParams getParameters()
        +
        +
        Returns:
        +
        an object with the current parameters
        +
        See Also:
        +
        DownloadParams
        +
        +
      • +
      + + + +
        +
      • +

        setParameters

        +
        public void setParameters(DownloadParams parameters)
        +
        Sets the application parameters through a DownloadParams object
        +
        +
        Parameters:
        +
        parameters - application parameters
        +
        See Also:
        +
        DownloadParams
        +
        +
      • +
      + + + +
        +
      • +

        downloadBooks

        +
        public void downloadBooks()
        +
        Begins the process of downloading books.

        + If there is any problem It can be thrown GutenbergException

        +
      • +
      + + + +
        +
      • +

        getFileType

        +
        public java.lang.String getFileType()
        +
        +
        Returns:
        +
        the type of files to download
        +
        +
      • +
      + + + +
        +
      • +

        setFileType

        +
        public void setFileType(java.lang.String fileType)
        +
        Sets the type of file to download. Valid types: txt, epub, html
        +
        +
        Parameters:
        +
        fileType - type of file to download
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if an invalid file type is indicated
        +
        +
      • +
      + + + +
        +
      • +

        getLanguage

        +
        public java.lang.String getLanguage()
        +
        +
        Returns:
        +
        the language of files to download
        +
        +
      • +
      + + + +
        +
      • +

        setLanguage

        +
        public void setLanguage(java.lang.String language)
        +
        Sets the language of the files to download acording to Gutenberg nomeclature.
        + Ej.: es - spanish, en - english, fr - french
        +
        +
        Parameters:
        +
        language - type of language
        +
        +
      • +
      + + + +
        +
      • +

        getUrlBase

        +
        public java.lang.String getUrlBase()
        +
        +
        Returns:
        +
        initial download url
        +
        +
      • +
      + + + +
        +
      • +

        getSavePath

        +
        public java.lang.String getSavePath()
        +
        +
        Returns:
        +
        folder path where to get downloaded resources
        +
        +
      • +
      + + + +
        +
      • +

        setSavePath

        +
        public void setSavePath(java.lang.String savePath)
        +
        Sets folder path where to get downloaded resources
        +
        +
        Parameters:
        +
        savePath - folder path where to get downloaded resources
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if the parameter is null
        +
        +
      • +
      + + + +
        +
      • +

        isOverwrite

        +
        public boolean isOverwrite()
        +
        +
        Returns:
        +
        true if the existing files must be overwritten by the downloaded ones, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        setOverwrite

        +
        public void setOverwrite(boolean value)
        +
        Sets if the existing files must be overwritten by the downloaded ones
        +
        +
        Parameters:
        +
        value - true if the existing files must be overwritten, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        getDelay

        +
        public int getDelay()
        +
        +
        Returns:
        +
        delay between downloads, in milliseconds
        +
        +
      • +
      + + + +
        +
      • +

        setDelay

        +
        public void setDelay(int delay)
        +
        Sets delay between downloads
        +
        +
        Parameters:
        +
        delay - waiting time, in milliseconds
        +
        +
      • +
      + + + +
        +
      • +

        isUnzip

        +
        public boolean isUnzip()
        +
        +
        Returns:
        +
        true if downloaded files must be unzipping, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        setUnzip

        +
        public void setUnzip(boolean value)
        +
        Sets if downloaded files must be unzipping,
        +
        +
        Parameters:
        +
        value - true if downloaded files must be unzipping, false otherwise
        +
        +
      • +
      + + + +
        +
      • +

        getMaxFilesToDownload

        +
        public int getMaxFilesToDownload()
        +
        +
        Returns:
        +
        the maximum number of files to download
        +
        +
      • +
      + + + +
        +
      • +

        setMaxFilesToDownload

        +
        public void setMaxFilesToDownload(int maxFilesToDownload)
        +
        Sets the maximum number of files to download. The zero indicates downloading all available files.
        +
        +
        Parameters:
        +
        maxFilesToDownload - files number
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if a number less than zero is indicated
        +
        +
      • +
      + + + + + + + +
        +
      • +

        setEngineType

        +
        public void setEngineType(DownloadEngineType engineType)
        +
        Sets the type of downloading engine to use
        +
        +
        Parameters:
        +
        engineType - engine type
        +
        See Also:
        +
        DownloadEngineType
        +
        +
      • +
      + + + +
        +
      • +

        main

        +
        public static void main(java.lang.String[] args)
        +
        Main method for running the application.
        +
        +
        Parameters:
        +
        args - list of arguments with application parameters
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownloadFactory.html b/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownloadFactory.html deleted file mode 100644 index a16c6e1..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownloadFactory.html +++ /dev/null @@ -1,292 +0,0 @@ - - - - - - -JGutenbergDownloadFactory - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Class JGutenbergDownloadFactory

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.JGutenbergDownloadFactory
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class JGutenbergDownloadFactory
    -extends java.lang.Object
    -
    Factoría que crea objetos de tipo IGutenbergDownload, los cuales implementan los servicios necesarios para la gestión y desarrollo - del proceso de descarga de libros alojados por el proyecto Gutenberg.
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    See Also:
    -
    IGutenbergDownload, -JGutenbergDownload
    -
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static IGutenbergDownloadcreate() -
      Crea un objeto JGutenbergDownload que implementa toda la funcionalidad necesaria para la descarga de libros
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        JGutenbergDownloadFactory

        -
        public JGutenbergDownloadFactory()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        create

        -
        public static IGutenbergDownload create()
        -
        Crea un objeto JGutenbergDownload que implementa toda la funcionalidad necesaria para la descarga de libros
        -
        -
        Returns:
        -
        objeto del tipo IGutenbergDownload
        -
        See Also:
        -
        IGutenbergDownload
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownloadTest.html b/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownloadTest.html deleted file mode 100644 index bc3ba96..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/JGutenbergDownloadTest.html +++ /dev/null @@ -1,378 +0,0 @@ - - - - - - -JGutenbergDownloadTest - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download
-

Class JGutenbergDownloadTest

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.JGutenbergDownloadTest
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class JGutenbergDownloadTest
    -extends java.lang.Object
    -
    Clase que implementa los test para probar los métodos de la clase JGutenbergDownloadTest
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        JGutenbergDownloadTest

        -
        public JGutenbergDownloadTest()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        testParametersDefaultValue

        -
        public void testParametersDefaultValue()
        -
        Comprueba si los valores por defecto de los parámetros de descarga a la hora de crear un IGutenbergDownload son los correctos
        -
      • -
      - - - -
        -
      • -

        givenUrlParametersWhenNullThenIllegalArgumentException

        -
        public void givenUrlParametersWhenNullThenIllegalArgumentException()
        -
        Si no se ha indicado tipo de fichero e idioma para realizar las descargas, entonces lanzar excepción IllegalArgumentException y mostrar mensaje
        -
      • -
      - - - -
        -
      • -

        givenUrlParametersWhenEmptyThenIllegalArgumentException

        -
        public void givenUrlParametersWhenEmptyThenIllegalArgumentException()
        -
        Si no se ha indicado tipo de fichero e idioma para realizar las descargas, entonces lanzar excepción IllegalArgumentException y mostrar mensaje
        -
      • -
      - - - -
        -
      • -

        givenSavePathWhenNullThenIllegalArgumentException

        -
        public void givenSavePathWhenNullThenIllegalArgumentException()
        -
        Si la ruta indicada para guardar las descargas es null, entonces lanzar excepción IllegalArgumentException
        -
      • -
      - - - -
        -
      • -

        givenSavePathWhenNoExistsThenIllegalArgumentException

        -
        public void givenSavePathWhenNoExistsThenIllegalArgumentException()
        -
        Si la ruta indicada para guardar las descargas no existe, entonces lanzar excepción IllegalArgumentException
        -
      • -
      - - - -
        -
      • -

        givenMaxFilesToDownloadWhenMinusZeroThenIllegalArgumentException

        -
        public void givenMaxFilesToDownloadWhenMinusZeroThenIllegalArgumentException()
        -
        Si el parámetro MaxFilesToDownload es menor de cero, entonces lanzar excepción IllegalArgumentException
        -
      • -
      - - - -
        -
      • -

        givenDownloadModeWhenNullThenIllegalArgumentException

        -
        public void givenDownloadModeWhenNullThenIllegalArgumentException()
        -
        Si el parámetro DownloadMode es null, entonces lanzar excepción IllegalArgumentException
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/AbstractDownload.html b/javadoc/org/josfranmc/gutenberg/download/class-use/AbstractDownload.html deleted file mode 100644 index 7b29db1..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/AbstractDownload.html +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.AbstractDownload - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.AbstractDownload

-
-
- -
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadSoft.html b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadBooks.html similarity index 77% rename from javadoc/org/josfranmc/gutenberg/download/class-use/DownloadSoft.html rename to javadoc/org/josfranmc/gutenberg/download/class-use/DownloadBooks.html index db64509..22d501a 100644 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadSoft.html +++ b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadBooks.html @@ -1,125 +1,124 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.DownloadSoft - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.DownloadSoft

-
-
No usage of org.josfranmc.gutenberg.download.DownloadSoft
- - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.download.DownloadBooks + + + + + + + + + + + +
+

Uses of Class
org.josfranmc.gutenberg.download.DownloadBooks

+
+
No usage of org.josfranmc.gutenberg.download.DownloadBooks
+ + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadFactory.html b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadFactory.html deleted file mode 100644 index 127a5e8..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadFactory.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.DownloadFactory - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.DownloadFactory

-
-
No usage of org.josfranmc.gutenberg.download.DownloadFactory
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadMode.html b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadMode.html deleted file mode 100644 index 0b64e46..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadMode.html +++ /dev/null @@ -1,209 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.DownloadMode - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.DownloadMode

-
-
- -
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadParams.html b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadParams.html index 75dd000..c58a1ef 100644 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadParams.html +++ b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadParams.html @@ -1,167 +1,194 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.DownloadParams - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.DownloadParams

-
-
- -
- - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.download.DownloadParams + + + + + + + + + + + +
+

Uses of Class
org.josfranmc.gutenberg.download.DownloadParams

+
+
+ +
+ + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadGreedy.html b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadThread.html similarity index 80% rename from javadoc/org/josfranmc/gutenberg/download/class-use/DownloadGreedy.html rename to javadoc/org/josfranmc/gutenberg/download/class-use/DownloadThread.html index 55990a6..0f83c00 100644 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadGreedy.html +++ b/javadoc/org/josfranmc/gutenberg/download/class-use/DownloadThread.html @@ -2,10 +2,9 @@ - - -Uses of Class org.josfranmc.gutenberg.download.DownloadGreedy - + +Uses of Class org.josfranmc.gutenberg.download.DownloadThread + @@ -13,7 +12,7 @@ - - - - - - - - -
-

Uses of Interface
org.josfranmc.gutenberg.download.IGutenbergDownload

-
-
- -
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownload.html b/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownload.html index 3ef4f86..60d4c31 100644 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownload.html +++ b/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownload.html @@ -1,169 +1,124 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.JGutenbergDownload - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.JGutenbergDownload

-
-
- -
- - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.download.JGutenbergDownload + + + + + + + + + + + +
+

Uses of Class
org.josfranmc.gutenberg.download.JGutenbergDownload

+
+
No usage of org.josfranmc.gutenberg.download.JGutenbergDownload
+ + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownloadFactory.html b/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownloadFactory.html deleted file mode 100644 index c6e2f21..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownloadFactory.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.JGutenbergDownloadFactory - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.JGutenbergDownloadFactory

-
-
No usage of org.josfranmc.gutenberg.download.JGutenbergDownloadFactory
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownloadTest.html b/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownloadTest.html deleted file mode 100644 index 865ad8e..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/class-use/JGutenbergDownloadTest.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.JGutenbergDownloadTest - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.JGutenbergDownloadTest

-
-
No usage of org.josfranmc.gutenberg.download.JGutenbergDownloadTest
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/client/JGutenbergDownloadClient.html b/javadoc/org/josfranmc/gutenberg/download/client/JGutenbergDownloadClient.html deleted file mode 100644 index 6404a41..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/client/JGutenbergDownloadClient.html +++ /dev/null @@ -1,286 +0,0 @@ - - - - - - -JGutenbergDownloadClient - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download.client
-

Class JGutenbergDownloadClient

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class JGutenbergDownloadClient
    -extends java.lang.Object
    -
    Clase que permite ejecutar un progrma cliente para realiza descargas de libros desde los repositorios del proyecto Gutenberg.
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static voidmain(java.lang.String[] args) -
      Método principal de ejecución.
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        JGutenbergDownloadClient

        -
        public JGutenbergDownloadClient()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        main

        -
        public static void main(java.lang.String[] args)
        -
        Método principal de ejecución.
        -
        -
        Parameters:
        -
        args - lista de argumentos pasados en la invocación del programa
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/client/class-use/JGutenbergDownloadClient.html b/javadoc/org/josfranmc/gutenberg/download/client/class-use/JGutenbergDownloadClient.html deleted file mode 100644 index 8c820f8..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/client/class-use/JGutenbergDownloadClient.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient

-
-
No usage of org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/client/package-frame.html b/javadoc/org/josfranmc/gutenberg/download/client/package-frame.html deleted file mode 100644 index 0725672..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/client/package-frame.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - -org.josfranmc.gutenberg.download.client - - - - - -

org.josfranmc.gutenberg.download.client

-
-

Classes

- -
- - diff --git a/javadoc/org/josfranmc/gutenberg/download/client/package-summary.html b/javadoc/org/josfranmc/gutenberg/download/client/package-summary.html deleted file mode 100644 index 695ea17..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/client/package-summary.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - -org.josfranmc.gutenberg.download.client - - - - - - - - - - - -
-

Package org.josfranmc.gutenberg.download.client

-
-
-
    -
  • - - - - - - - - - - - - -
    Class Summary 
    ClassDescription
    JGutenbergDownloadClient -
    Clase que permite ejecutar un progrma cliente para realiza descargas de libros desde los repositorios del proyecto Gutenberg.
    -
    -
  • -
-
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/client/package-tree.html b/javadoc/org/josfranmc/gutenberg/download/client/package-tree.html deleted file mode 100644 index f8b146c..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/client/package-tree.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - -org.josfranmc.gutenberg.download.client Class Hierarchy - - - - - - - - - - - -
-

Hierarchy For Package org.josfranmc.gutenberg.download.client

-Package Hierarchies: - -
-
-

Class Hierarchy

- -
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/client/package-use.html b/javadoc/org/josfranmc/gutenberg/download/client/package-use.html deleted file mode 100644 index d75f667..0000000 --- a/javadoc/org/josfranmc/gutenberg/download/client/package-use.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Uses of Package org.josfranmc.gutenberg.download.client - - - - - - - - - - - -
-

Uses of Package
org.josfranmc.gutenberg.download.client

-
-
No usage of org.josfranmc.gutenberg.download.client
- - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.html b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.html index ecfcbf3..69faad4 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.html @@ -1,415 +1,381 @@ - - - - - - -DownloadEngineFactory - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download.engine
-

Class DownloadEngineFactory

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class DownloadEngineFactory
    -extends java.lang.Object
    -
    Factoría para la creación de objetos de tipo IDownloadEngine mediante el método create - Este método está sobregargado, de forma que se puede invocar combinando tres parámetros: -
      -
    • target: recurso a descargar
    • -
    • savePath: ruta local donde obtener el recurso
    • -
    • type: tipo de motor a utilizar para la descarga (si no se indica ninguno por defecto se usa DownloadEngineType.HTTTP_CONNECTION)
    • -
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static IDownloadEnginecreate() -
      Crea un motor para realizar la descarga de recursos en red.
      -
      static IDownloadEnginecreate(DownloadEngineType type) -
      Crea un motor determinado para realizar la descarga de recursos en red
      -
      static IDownloadEnginecreate(java.net.URL target) -
      Crea un motor para realizar la descarga desde una determinada URL.
      -
      static IDownloadEnginecreate(java.net.URL target, - DownloadEngineType type) -
      Crea un motor determinado para realizar la descarga desde una determinada URL
      -
      static IDownloadEnginecreate(java.net.URL target, - java.lang.String savePath) -
      Crea un motor para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local.
      -
      static IDownloadEnginecreate(java.net.URL target, - java.lang.String savePath, - DownloadEngineType type) -
      Crea un motor determinado para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        DownloadEngineFactory

        -
        public DownloadEngineFactory()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        create

        -
        public static IDownloadEngine create()
        -
        Crea un motor para realizar la descarga de recursos en red. El motor creado es de tipo DownloadEngineType.HTTP_CONNECTION
        -
        -
        Returns:
        -
        un motor de descarga
        -
        -
      • -
      - - - -
        -
      • -

        create

        -
        public static IDownloadEngine create(DownloadEngineType type)
        -
        Crea un motor determinado para realizar la descarga de recursos en red
        -
        -
        Parameters:
        -
        type - tipo de motor a crear
        -
        Returns:
        -
        un motor de descarga
        -
        -
      • -
      - - - -
        -
      • -

        create

        -
        public static IDownloadEngine create(java.net.URL target,
        -                                     DownloadEngineType type)
        -
        Crea un motor determinado para realizar la descarga desde una determinada URL
        -
        -
        Parameters:
        -
        target - dirección URL
        -
        type - tipo de motor a crear
        -
        Returns:
        -
        un motor de descarga
        -
        -
      • -
      - - - -
        -
      • -

        create

        -
        public static IDownloadEngine create(java.net.URL target)
        -
        Crea un motor para realizar la descarga desde una determinada URL. El motor creado es de tipo DownloadEngineType.HTTP_CONNECTION
        -
        -
        Parameters:
        -
        target - dirección URL
        -
        Returns:
        -
        un motor de descarga
        -
        -
      • -
      - - - -
        -
      • -

        create

        -
        public static IDownloadEngine create(java.net.URL target,
        -                                     java.lang.String savePath,
        -                                     DownloadEngineType type)
        -
        Crea un motor determinado para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local
        -
        -
        Parameters:
        -
        target - dirección URL
        -
        savePath - ruta donde obtener las descargas
        -
        type - tipo de motor a crear
        -
        Returns:
        -
        un motor de descarga
        -
        -
      • -
      - - - -
        -
      • -

        create

        -
        public static IDownloadEngine create(java.net.URL target,
        -                                     java.lang.String savePath)
        -
        Crea un motor para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local. - El motor creado es de tipo DownloadEngineType.HTTP_CONNECTION.
        -
        -
        Parameters:
        -
        target - dirección URL
        -
        savePath - ruta donde obtener las descargas
        -
        Returns:
        -
        un motor de descarga
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +DownloadEngineFactory + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download.engine
+

Class DownloadEngineFactory

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class DownloadEngineFactory
    +extends java.lang.Object
    +
    Factory for creating IDownloadEngine objects.
    + It make use of the create method. This method is overloaded, so it can be invoked combining three parameters: +
      +
    • target: the url address to download
    • +
    • savePath: local path where to save download
    • +
    • type: engine type for downloading (for default DownloadEngineType.HTTTP_CONNECTION is used)
    • +
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        create

        +
        public static IDownloadEngine create()
        +
        Creates an engine for downloading. Engine type is DownloadEngineType.HTTP_CONNECTION.
        +
        +
        Returns:
        +
        a download engine
        +
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static IDownloadEngine create(DownloadEngineType type)
        +
        Creates a download engine of the indicated type.
        + The url to download and the path where to save are not initialized.
        +
        +
        Parameters:
        +
        type - engine type for downloading
        +
        Returns:
        +
        a download engine in the form of a IDownloadEngine object
        +
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static IDownloadEngine create(java.net.URL target,
        +                                     DownloadEngineType type)
        +
        Creates a download engine of the indicated type for downloading an url.
        + The path where to save the download is not initialized.
        +
        +
        Parameters:
        +
        target - the url address to download
        +
        type - engine type for downloading
        +
        Returns:
        +
        a download engine in the form of a IDownloadEngine object
        +
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static IDownloadEngine create(java.net.URL target)
        +
        Creates an engine for downloading an url. Engine type is DownloadEngineType.HTTP_CONNECTION.
        +
        +
        Parameters:
        +
        target - the url address to download
        +
        Returns:
        +
        a download engine in the form of a IDownloadEngine object
        +
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static IDownloadEngine create(java.net.URL target,
        +                                     java.lang.String savePath,
        +                                     DownloadEngineType type)
        +
        Creates an engine for downloading.
        +
        +
        Parameters:
        +
        target - the url address to download
        +
        savePath - local path where to save download
        +
        type - engine type for downloading
        +
        Returns:
        +
        a download engine in the form of a IDownloadEngine object
        +
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static IDownloadEngine create(java.net.URL target,
        +                                     java.lang.String savePath)
        +
        Creates an engine for downloading. Engine type is DownloadEngineType.HTTP_CONNECTION.
        +
        +
        Parameters:
        +
        target - the url address to download
        +
        savePath - local path where to save download
        +
        Returns:
        +
        a download engine in the form of a IDownloadEngine object
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineType.html b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineType.html index b36f6b5..b37afc6 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineType.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadEngineType.html @@ -1,340 +1,339 @@ - - - - - - -DownloadEngineType - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download.engine
-

Enum DownloadEngineType

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • java.lang.Enum<DownloadEngineType>
    • -
    • -
        -
      • org.josfranmc.gutenberg.download.engine.DownloadEngineType
      • -
      -
    • -
    -
  • -
-
-
    -
  • -
    -
    All Implemented Interfaces:
    -
    java.io.Serializable, java.lang.Comparable<DownloadEngineType>
    -
    -
    -
    -
    public enum DownloadEngineType
    -extends java.lang.Enum<DownloadEngineType>
    -
    Tipos de motores de descarga
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Enum Constant Summary

      - - - - - - - - -
      Enum Constants 
      Enum Constant and Description
      HTTP_CONNECTION -
      Descargas basadas en el objeto java.net.HttpURLConnection
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static DownloadEngineTypevalueOf(java.lang.String name) -
      Returns the enum constant of this type with the specified name.
      -
      static DownloadEngineType[]values() -
      Returns an array containing the constants of this enum type, in -the order they are declared.
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Enum

        -compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -getClass, notify, notifyAll, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Enum Constant Detail

      - - - -
        -
      • -

        HTTP_CONNECTION

        -
        public static final DownloadEngineType HTTP_CONNECTION
        -
        Descargas basadas en el objeto java.net.HttpURLConnection
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        values

        -
        public static DownloadEngineType[] values()
        -
        Returns an array containing the constants of this enum type, in -the order they are declared. This method may be used to iterate -over the constants as follows: -
        -for (DownloadEngineType c : DownloadEngineType.values())
        -    System.out.println(c);
        -
        -
        -
        Returns:
        -
        an array containing the constants of this enum type, in the order they are declared
        -
        -
      • -
      - - - -
        -
      • -

        valueOf

        -
        public static DownloadEngineType valueOf(java.lang.String name)
        -
        Returns the enum constant of this type with the specified name. -The string must match exactly an identifier used to declare an -enum constant in this type. (Extraneous whitespace characters are -not permitted.)
        -
        -
        Parameters:
        -
        name - the name of the enum constant to be returned.
        -
        Returns:
        -
        the enum constant with the specified name
        -
        Throws:
        -
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        -
        java.lang.NullPointerException - if the argument is null
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +DownloadEngineType + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download.engine
+

Enum DownloadEngineType

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • java.lang.Enum<DownloadEngineType>
    • +
    • +
        +
      • org.josfranmc.gutenberg.download.engine.DownloadEngineType
      • +
      +
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    java.io.Serializable, java.lang.Comparable<DownloadEngineType>
    +
    +
    +
    +
    public enum DownloadEngineType
    +extends java.lang.Enum<DownloadEngineType>
    +
    Types of download engines
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Enum Constant Summary

      + + + + + + + + +
      Enum Constants 
      Enum Constant and Description
      HTTP_CONNECTION +
      Downloads based on the java.net.HttpURLConnection object
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static DownloadEngineTypevalueOf(java.lang.String name) +
      Returns the enum constant of this type with the specified name.
      +
      static DownloadEngineType[]values() +
      Returns an array containing the constants of this enum type, in +the order they are declared.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Enum

        +compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +getClass, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Enum Constant Detail

      + + + +
        +
      • +

        HTTP_CONNECTION

        +
        public static final DownloadEngineType HTTP_CONNECTION
        +
        Downloads based on the java.net.HttpURLConnection object
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        values

        +
        public static DownloadEngineType[] values()
        +
        Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
        +for (DownloadEngineType c : DownloadEngineType.values())
        +    System.out.println(c);
        +
        +
        +
        Returns:
        +
        an array containing the constants of this enum type, in the order they are declared
        +
        +
      • +
      + + + +
        +
      • +

        valueOf

        +
        public static DownloadEngineType valueOf(java.lang.String name)
        +
        Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.)
        +
        +
        Parameters:
        +
        name - the name of the enum constant to be returned.
        +
        Returns:
        +
        the enum constant with the specified name
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        +
        java.lang.NullPointerException - if the argument is null
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.html b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.html index cda83db..9ff7fce 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.html @@ -1,381 +1,378 @@ - - - - - - -DownloadHttpUrlConnection - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download.engine
-

Class DownloadHttpUrlConnection

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
    • -
    -
  • -
-
-
    -
  • -
    -
    All Implemented Interfaces:
    -
    IDownloadEngine
    -
    -
    -
    -
    public class DownloadHttpUrlConnection
    -extends java.lang.Object
    -implements IDownloadEngine
    -
    Permite realizar la descarga de un recurso identificado por una URL. Para ello se hace uso de la clase java.net.HttpURLConnection.
    - El recurso descargado se guarda en la ruta que ha debido establecerse previamente a la descarga.
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    See Also:
    -
    IDownloadEngine
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      DownloadResultdownload() -
      Ejecuta el proceso de descarga.
      -
      java.net.URLgetResource() -
      Obtiene la dirección del recurso a descargar como un objeto de tipo URL
      -
      java.lang.StringgetSavePath() -
      Obtiene la ruta donde guardar el recursos a descargar
      -
      static IDownloadEnginenewInstance(java.net.URL target, - java.lang.String savePath) -
      Crea una instancia DownloadHttpUrlConnection de tipo IDownloadEngine.
      -
      voidsetResource(java.net.URL resource) -
      Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL
      -
      voidsetSavePath(java.lang.String savePath) -
      Establece la ruta donde guardar el recurso a descargar
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        newInstance

        -
        public static IDownloadEngine newInstance(java.net.URL target,
        -                                          java.lang.String savePath)
        -
        Crea una instancia DownloadHttpUrlConnection de tipo IDownloadEngine.
        -
        -
        Parameters:
        -
        target - direccion URL del recurso a descargar
        -
        savePath - ruta de la carpeta en la qu obtener la descarga
        -
        Returns:
        -
        una instancia de tipo IDownloadEngine
        -
        See Also:
        -
        IDownloadEngine
        -
        -
      • -
      - - - -
        -
      • -

        download

        -
        public DownloadResult download()
        -
        Ejecuta el proceso de descarga. Previamente se ha debido indicar la dirección del recurso a descargar y la ruta de la carpeta en la que obtenerlo.
        - Si la descarga es correcta, se obtiene en la carpeta indicada un nuevo fichero cuyo nombre es el nombre delfichero contenido en el enlace de descarga - (se toma desde el último caracter separador de directorios)
        -
        -
        Specified by:
        -
        download in interface IDownloadEngine
        -
        Returns:
        -
        el resultado de la descarga encapsulado en un objeto de tipo DownloadResult
        -
        See Also:
        -
        DownloadResult
        -
        -
      • -
      - - - -
        -
      • -

        setResource

        -
        public void setResource(java.net.URL resource)
        -
        Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL
        -
        -
        Specified by:
        -
        setResource in interface IDownloadEngine
        -
        Parameters:
        -
        resource - dirección url
        -
        -
      • -
      - - - -
        -
      • -

        getResource

        -
        public java.net.URL getResource()
        -
        Obtiene la dirección del recurso a descargar como un objeto de tipo URL
        -
        -
        Specified by:
        -
        getResource in interface IDownloadEngine
        -
        Returns:
        -
        dirección del recurso a descargar
        -
        -
      • -
      - - - -
        -
      • -

        setSavePath

        -
        public void setSavePath(java.lang.String savePath)
        -
        Establece la ruta donde guardar el recurso a descargar
        -
        -
        Specified by:
        -
        setSavePath in interface IDownloadEngine
        -
        Parameters:
        -
        savePath - ruta de la carpeta donde guardar
        -
        -
      • -
      - - - -
        -
      • -

        getSavePath

        -
        public java.lang.String getSavePath()
        -
        Obtiene la ruta donde guardar el recursos a descargar
        -
        -
        Specified by:
        -
        getSavePath in interface IDownloadEngine
        -
        Returns:
        -
        la ruta de la carpeta donde guardar el recursos a descargar
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +DownloadHttpUrlConnection + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download.engine
+

Class DownloadHttpUrlConnection

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    IDownloadEngine
    +
    +
    +
    +
    public class DownloadHttpUrlConnection
    +extends java.lang.Object
    +implements IDownloadEngine
    +
    Allows to download a resource identified by an url and save it in a local folder.
    + It makes use of the java.net.HttpURLConnection class for downloading.
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    See Also:
    +
    IDownloadEngine, +GutenbergException
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      DownloadResultdownload() +
      Runs a download.
      +
      java.net.URLgetResource() 
      java.lang.StringgetSavePath() 
      static IDownloadEnginenewInstance(java.net.URL target, + java.lang.String savePath) +
      Creates a DownloadHttpUrlConnection object which is an IDownloadEngine type instance.
      +
      voidsetResource(java.net.URL resource) +
      Sets the resource of the url to download, in the form of a URL object
      +
      voidsetSavePath(java.lang.String savePath) +
      Sets the local path where to save the resource to be download
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        newInstance

        +
        public static IDownloadEngine newInstance(java.net.URL target,
        +                                          java.lang.String savePath)
        +
        Creates a DownloadHttpUrlConnection object which is an IDownloadEngine type instance.
        +
        +
        Parameters:
        +
        target - resource url to download
        +
        savePath - path where to save the download
        +
        Returns:
        +
        an IDownloadEngine instance in the form of a DownloadHttpUrlConnection
        +
        See Also:
        +
        IDownloadEngine
        +
        +
      • +
      + + + +
        +
      • +

        download

        +
        public DownloadResult download()
        +
        Runs a download.

        + Previously, it has been necessary to indicate the url address of the resource to download and the path of the folder in which to save it.
        + If the download is correct a new file in the indicated folder is obtained. The file name is extracted from download link, + beginning from the last directory separator character.

        +
        +
        Specified by:
        +
        download in interface IDownloadEngine
        +
        Returns:
        +
        the result of the download in the form of a DownloadResult object
        +
        Throws:
        +
        GutenbergException - if there is any error downloading
        +
        See Also:
        +
        DownloadResult
        +
        +
      • +
      + + + +
        +
      • +

        setResource

        +
        public void setResource(java.net.URL resource)
        +
        Sets the resource of the url to download, in the form of a URL object
        +
        +
        Specified by:
        +
        setResource in interface IDownloadEngine
        +
        Parameters:
        +
        resource - url address
        +
        +
      • +
      + + + +
        +
      • +

        getResource

        +
        public java.net.URL getResource()
        +
        +
        Specified by:
        +
        getResource in interface IDownloadEngine
        +
        Returns:
        +
        the resource of the url to download, in the form of a URL object
        +
        +
      • +
      + + + +
        +
      • +

        setSavePath

        +
        public void setSavePath(java.lang.String savePath)
        +
        Sets the local path where to save the resource to be download
        +
        +
        Specified by:
        +
        setSavePath in interface IDownloadEngine
        +
        Parameters:
        +
        savePath - local path
        +
        +
      • +
      + + + +
        +
      • +

        getSavePath

        +
        public java.lang.String getSavePath()
        +
        +
        Specified by:
        +
        getSavePath in interface IDownloadEngine
        +
        Returns:
        +
        the local path where to save the resource to be download
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadResult.html b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadResult.html index 5609b1c..3f0c5e0 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/DownloadResult.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/DownloadResult.html @@ -1,433 +1,391 @@ - - - - - - -DownloadResult - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download.engine
-

Class DownloadResult

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • org.josfranmc.gutenberg.download.engine.DownloadResult
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class DownloadResult
    -extends java.lang.Object
    -
    Encapsula el resultado de la descarga de un recurso. Esta clase sirve para guardar juntos diferentes datos realacionados con la descarga - de un recurso: la cabecera devuelta en la conexión y el nombre del fichero creado, junto con su ruta. Además, si se ha producido algún error - puede indicarse un mensaje descriptivo del mismo.
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      DownloadResult() -
      Constructor principal.
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.lang.StringgetContentLength() 
      java.lang.StringgetContentType() 
      java.lang.StringgetError() 
      java.lang.StringgetFileOutputPath() 
      java.util.Map<java.lang.String,java.util.List<java.lang.String>>getHeaders() 
      java.lang.StringgetLastModified() 
      voidsetError(java.lang.String error) -
      Establece un mensaje de error.
      -
      voidsetFileOutputPath(java.lang.String fileOutputPath) -
      Establece la ruta del fichero descargado.
      -
      voidsetHeaders(java.net.URLConnection urlConnection) -
      Establece la colección de campos de cabecera devuelta por una conexión realizada
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        DownloadResult

        -
        public DownloadResult()
        -
        Constructor principal.
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        setHeaders

        -
        public void setHeaders(java.net.URLConnection urlConnection)
        -
        Establece la colección de campos de cabecera devuelta por una conexión realizada
        -
        -
        Parameters:
        -
        urlConnection - conexión
        -
        -
      • -
      - - - -
        -
      • -

        getHeaders

        -
        public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHeaders()
        -
        -
        Returns:
        -
        la colección de las cabeceras obtenidas
        -
        -
      • -
      - - - -
        -
      • -

        getLastModified

        -
        public java.lang.String getLastModified()
        -
        -
        Returns:
        -
        el valor del campo de la cebecera "Last-Modified"
        -
        -
      • -
      - - - -
        -
      • -

        getContentType

        -
        public java.lang.String getContentType()
        -
        -
        Returns:
        -
        el valor del campo de la cebecera "Content-Type"
        -
        -
      • -
      - - - -
        -
      • -

        getContentLength

        -
        public java.lang.String getContentLength()
        -
        -
        Returns:
        -
        el valor del campo de la cebecera "Content-Length"
        -
        -
      • -
      - - - -
        -
      • -

        setFileOutputPath

        -
        public void setFileOutputPath(java.lang.String fileOutputPath)
        -
        Establece la ruta del fichero descargado.
        -
        -
        Parameters:
        -
        fileOutputPath - ruta del fichero descargado
        -
        -
      • -
      - - - -
        -
      • -

        getFileOutputPath

        -
        public java.lang.String getFileOutputPath()
        -
        -
        Returns:
        -
        la ruta del fichero descargado
        -
        -
      • -
      - - - -
        -
      • -

        getError

        -
        public java.lang.String getError()
        -
        -
        Returns:
        -
        el emnsaje de error establecido
        -
        -
      • -
      - - - -
        -
      • -

        setError

        -
        public void setError(java.lang.String error)
        -
        Establece un mensaje de error.
        -
        -
        Parameters:
        -
        error - mensaje
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +DownloadResult + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download.engine
+

Class DownloadResult

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.josfranmc.gutenberg.download.engine.DownloadResult
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class DownloadResult
    +extends java.lang.Object
    +
    It encapsulates the result of downloading a resource. This class serves to save together different data related to the download: + the header returned in the connection and the name of the file created, along with its path.
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      DownloadResult() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.lang.StringgetContentLength() 
      java.lang.StringgetContentType() 
      java.util.Map<java.lang.String,java.util.List<java.lang.String>>getHeaders() 
      java.lang.StringgetLastModified() 
      java.lang.StringgetSavedFilePath() 
      voidsetHeaders(java.net.URLConnection urlConnection) +
      Sets the header obtained in response to a connection
      +
      voidsetSavedFilePath(java.lang.String fileOutputPath) +
      Sets the path of the downloaded file on the local machine.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DownloadResult

        +
        public DownloadResult()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setHeaders

        +
        public void setHeaders(java.net.URLConnection urlConnection)
        +
        Sets the header obtained in response to a connection
        +
        +
        Parameters:
        +
        urlConnection - connection made
        +
        +
      • +
      + + + +
        +
      • +

        getHeaders

        +
        public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHeaders()
        +
        +
        Returns:
        +
        the header obtained in response to a connection
        +
        +
      • +
      + + + +
        +
      • +

        getLastModified

        +
        public java.lang.String getLastModified()
        +
        +
        Returns:
        +
        the value of the header field "Last-Modified"
        +
        +
      • +
      + + + +
        +
      • +

        getContentType

        +
        public java.lang.String getContentType()
        +
        +
        Returns:
        +
        the value of the header field "Content-Type"
        +
        +
      • +
      + + + +
        +
      • +

        getContentLength

        +
        public java.lang.String getContentLength()
        +
        +
        Returns:
        +
        the value of the header field "Content-Length"
        +
        +
      • +
      + + + +
        +
      • +

        setSavedFilePath

        +
        public void setSavedFilePath(java.lang.String fileOutputPath)
        +
        Sets the path of the downloaded file on the local machine.
        +
        +
        Parameters:
        +
        fileOutputPath - path of the downloaded file
        +
        +
      • +
      + + + +
        +
      • +

        getSavedFilePath

        +
        public java.lang.String getSavedFilePath()
        +
        +
        Returns:
        +
        the path of the downloaded file on the local machine.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/IDownloadEngine.html b/javadoc/org/josfranmc/gutenberg/download/engine/IDownloadEngine.html index a0f6d39..510f126 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/IDownloadEngine.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/IDownloadEngine.html @@ -1,323 +1,320 @@ - - - - - - -IDownloadEngine - - - - - - - - - - - - -
-
org.josfranmc.gutenberg.download.engine
-

Interface IDownloadEngine

-
-
-
-
    -
  • -
    -
    All Known Implementing Classes:
    -
    DownloadHttpUrlConnection
    -
    -
    -
    -
    public interface IDownloadEngine
    -
    Define el comportamiento que tiene que ofrecer toda clase que quiera implementar la capacidad de descargar - un recurso identificado por una URL
    -
    -
    Version:
    -
    1.0
    -
    Author:
    -
    Jose Francisco Mena Ceca
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Abstract Methods 
      Modifier and TypeMethod and Description
      DownloadResultdownload() -
      Ejecuta el proceso de descarga.
      -
      java.net.URLgetResource() -
      Obtiene la dirección del recurso a descargar como un objeto de tipo URL
      -
      java.lang.StringgetSavePath() -
      Obtiene la ruta donde guardar el recursos a descargar
      -
      voidsetResource(java.net.URL resource) -
      Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL
      -
      voidsetSavePath(java.lang.String savePath) -
      Establece la ruta donde guardar el recurso a descargar
      -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        download

        -
        DownloadResult download()
        -
        Ejecuta el proceso de descarga.
        -
        -
        Returns:
        -
        el resultado de la descarga encapsulado en un objeto de tipo DownloadResult
        -
        See Also:
        -
        DownloadResult
        -
        -
      • -
      - - - -
        -
      • -

        setResource

        -
        void setResource(java.net.URL resource)
        -
        Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL
        -
        -
        Parameters:
        -
        resource - dirección del recurso que se quiere obtener
        -
        -
      • -
      - - - -
        -
      • -

        getResource

        -
        java.net.URL getResource()
        -
        Obtiene la dirección del recurso a descargar como un objeto de tipo URL
        -
        -
        Returns:
        -
        dirección del recurso a descargar
        -
        -
      • -
      - - - -
        -
      • -

        setSavePath

        -
        void setSavePath(java.lang.String savePath)
        -
        Establece la ruta donde guardar el recurso a descargar
        -
        -
        Parameters:
        -
        savePath - ruta donde guardar
        -
        -
      • -
      - - - -
        -
      • -

        getSavePath

        -
        java.lang.String getSavePath()
        -
        Obtiene la ruta donde guardar el recursos a descargar
        -
        -
        Returns:
        -
        ruta donde guardar
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - + + + + + +IDownloadEngine + + + + + + + + + + + + +
+
org.josfranmc.gutenberg.download.engine
+

Interface IDownloadEngine

+
+
+
+
    +
  • +
    +
    All Known Implementing Classes:
    +
    DownloadHttpUrlConnection
    +
    +
    +
    +
    public interface IDownloadEngine
    +
    Defines the behavior that a class have to implement in order to have the ability to download resources on net.
    +
    +
    Version:
    +
    2.0
    +
    Author:
    +
    Jose Francisco Mena Ceca
    +
    See Also:
    +
    IDownloadEngine, +GutenbergException
    +
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        download

        +
        DownloadResult download()
        +
        Runs a download.
        +
        +
        Returns:
        +
        the result of the download in the form of a DownloadResult object
        +
        Throws:
        +
        GutenbergException - if there is any error downloading
        +
        See Also:
        +
        DownloadResult
        +
        +
      • +
      + + + +
        +
      • +

        setResource

        +
        void setResource(java.net.URL resource)
        +
        Sets the resource of the url to download, in the form of a URL object
        +
        +
        Parameters:
        +
        resource - url address
        +
        +
      • +
      + + + +
        +
      • +

        getResource

        +
        java.net.URL getResource()
        +
        +
        Returns:
        +
        the resource of the url to download, in the form of a URL object
        +
        +
      • +
      + + + +
        +
      • +

        setSavePath

        +
        void setSavePath(java.lang.String savePath)
        +
        Sets the local path where to save the resource to be download
        +
        +
        Parameters:
        +
        savePath - local path
        +
        +
      • +
      + + + +
        +
      • +

        getSavePath

        +
        java.lang.String getSavePath()
        +
        +
        Returns:
        +
        the local path where to save the resource to be download
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineFactory.html b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineFactory.html index f6a35b3..372504e 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineFactory.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineFactory.html @@ -1,125 +1,124 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory - - - - - - - - - - - -
-

Uses of Class
org.josfranmc.gutenberg.download.engine.DownloadEngineFactory

-
-
No usage of org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
- - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.download.engine.DownloadEngineFactory + + + + + + + + + + + +
+

Uses of Class
org.josfranmc.gutenberg.download.engine.DownloadEngineFactory

+
+
No usage of org.josfranmc.gutenberg.download.engine.DownloadEngineFactory
+ + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineType.html b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineType.html index 3c5a1b8..3f5a659 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineType.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadEngineType.html @@ -2,10 +2,9 @@ - - + Uses of Class org.josfranmc.gutenberg.download.engine.DownloadEngineType - + @@ -36,7 +35,7 @@
  • Package
  • Class
  • -
  • Tree
  • +
  • Tree
  • Deprecated
  • Index
  • Help
  • @@ -113,10 +112,6 @@

    Uses of DownloadEngineType -IGutenbergDownload.getEngineType()  - - -DownloadEngineType DownloadParams.getEngineType()  @@ -131,19 +126,13 @@

    Uses of void JGutenbergDownload.setEngineType(DownloadEngineType engineType) -
    Establece el tipo de motor a utilizar para realizar las descargas.
    +
    Sets the type of downloading engine to use
    void -IGutenbergDownload.setEngineType(DownloadEngineType engineType) -
    Establece el tipo de motor a utilizar para realizar las descargas
    - - - -void DownloadParams.setEngineType(DownloadEngineType engineType) -
    Establece el tipo de motor de descarga a utilizar
    +
    Sets the type of downloading engine to use
    @@ -185,14 +174,14 @@

    Uses of static IDownloadEngine DownloadEngineFactory.create(DownloadEngineType type) -
    Crea un motor determinado para realizar la descarga de recursos en red
    +
    Creates a download engine of the indicated type.
    static IDownloadEngine DownloadEngineFactory.create(java.net.URL target, DownloadEngineType type) -
    Crea un motor determinado para realizar la descarga desde una determinada URL
    +
    Creates a download engine of the indicated type for downloading an url.
    @@ -200,7 +189,7 @@

    Uses of DownloadEngineFactory.create(java.net.URL target, java.lang.String savePath, DownloadEngineType type) -
    Crea un motor determinado para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local
    +
    Creates an engine for downloading.
    @@ -223,7 +212,7 @@

    Uses of Package
  • Class
  • -
  • Tree
  • +
  • Tree
  • Deprecated
  • Index
  • Help
  • diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadHttpUrlConnection.html b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadHttpUrlConnection.html index c468f76..1fd7a08 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadHttpUrlConnection.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadHttpUrlConnection.html @@ -1,125 +1,124 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection - - - - - - - - - - - -
    -

    Uses of Class
    org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection

    -
    -
    No usage of org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
    - - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection + + + + + + + + + + + +
    +

    Uses of Class
    org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection

    +
    +
    No usage of org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadResult.html b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadResult.html index 5a9a9ef..5bcc314 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadResult.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/DownloadResult.html @@ -2,10 +2,9 @@ - - + Uses of Class org.josfranmc.gutenberg.download.engine.DownloadResult - + @@ -36,7 +35,7 @@
  • Package
  • Class
  • -
  • Tree
  • +
  • Tree
  • Deprecated
  • Index
  • Help
  • @@ -105,14 +104,14 @@

    Uses of DownloadResult -IDownloadEngine.download() -
    Ejecuta el proceso de descarga.
    +DownloadHttpUrlConnection.download() +
    Runs a download.
    DownloadResult -DownloadHttpUrlConnection.download() -
    Ejecuta el proceso de descarga.
    +IDownloadEngine.download() +
    Runs a download.
    @@ -135,7 +134,7 @@

    Uses of Package
  • Class
  • -
  • Tree
  • +
  • Tree
  • Deprecated
  • Index
  • Help
  • diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/IDownloadEngine.html b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/IDownloadEngine.html index 26e242b..72852b3 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/class-use/IDownloadEngine.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/class-use/IDownloadEngine.html @@ -1,223 +1,222 @@ - - - - - - -Uses of Interface org.josfranmc.gutenberg.download.engine.IDownloadEngine - - - - - - - - - - - -
    -

    Uses of Interface
    org.josfranmc.gutenberg.download.engine.IDownloadEngine

    -
    -
    - -
    - - - - - - + + + + + +Uses of Interface org.josfranmc.gutenberg.download.engine.IDownloadEngine + + + + + + + + + + + +
    +

    Uses of Interface
    org.josfranmc.gutenberg.download.engine.IDownloadEngine

    +
    +
    + +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/package-frame.html b/javadoc/org/josfranmc/gutenberg/download/engine/package-frame.html index da6a051..9021f83 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/package-frame.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/package-frame.html @@ -1,31 +1,30 @@ - - - - - - -org.josfranmc.gutenberg.download.engine - - - - - -

    org.josfranmc.gutenberg.download.engine

    - - - + + + + + +org.josfranmc.gutenberg.download.engine + + + + + +

    org.josfranmc.gutenberg.download.engine

    + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/package-summary.html b/javadoc/org/josfranmc/gutenberg/download/engine/package-summary.html index ebb6343..193fce3 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/package-summary.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/package-summary.html @@ -1,198 +1,190 @@ - - - - - - -org.josfranmc.gutenberg.download.engine - - - - - - - - - - - -
    -

    Package org.josfranmc.gutenberg.download.engine

    -
    -
    -
      -
    • - - - - - - - - - - - - -
      Interface Summary 
      InterfaceDescription
      IDownloadEngine -
      Define el comportamiento que tiene que ofrecer toda clase que quiera implementar la capacidad de descargar - un recurso identificado por una URL
      -
      -
    • -
    • - - - - - - - - - - - - - - - - - - - - -
      Class Summary 
      ClassDescription
      DownloadEngineFactory -
      Factoría para la creación de objetos de tipo IDownloadEngine mediante el método create - Este método está sobregargado, de forma que se puede invocar combinando tres parámetros: - - target: recurso a descargar - savePath: ruta local donde obtener el recurso - type: tipo de motor a utilizar para la descarga (si no se indica ninguno por defecto se usa DownloadEngineType.HTTTP_CONNECTION) -
      -
      DownloadHttpUrlConnection -
      Permite realizar la descarga de un recurso identificado por una URL.
      -
      DownloadResult -
      Encapsula el resultado de la descarga de un recurso.
      -
      -
    • -
    • - - - - - - - - - - - - -
      Enum Summary 
      EnumDescription
      DownloadEngineType -
      Tipos de motores de descarga
      -
      -
    • -
    -
    - - - - - - + + + + + +org.josfranmc.gutenberg.download.engine + + + + + + + + + + + +
    +

    Package org.josfranmc.gutenberg.download.engine

    +
    +
    +
      +
    • + + + + + + + + + + + + +
      Interface Summary 
      InterfaceDescription
      IDownloadEngine +
      Defines the behavior that a class have to implement in order to have the ability to download resources on net.
      +
      +
    • +
    • + + + + + + + + + + + + + + + + + + + + +
      Class Summary 
      ClassDescription
      DownloadEngineFactory +
      Factory for creating IDownloadEngine objects.
      +
      DownloadHttpUrlConnection +
      Allows to download a resource identified by an url and save it in a local folder.
      +
      DownloadResult +
      It encapsulates the result of downloading a resource.
      +
      +
    • +
    • + + + + + + + + + + + + +
      Enum Summary 
      EnumDescription
      DownloadEngineType +
      Types of download engines
      +
      +
    • +
    +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/package-tree.html b/javadoc/org/josfranmc/gutenberg/download/engine/package-tree.html index ab68856..d42a571 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/package-tree.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/package-tree.html @@ -1,156 +1,155 @@ - - - - - - -org.josfranmc.gutenberg.download.engine Class Hierarchy - - - - - - - - - - - -
    -

    Hierarchy For Package org.josfranmc.gutenberg.download.engine

    -Package Hierarchies: - -
    -
    -

    Class Hierarchy

    - -

    Interface Hierarchy

    - -

    Enum Hierarchy

    -
      -
    • java.lang.Object -
        -
      • java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable) - -
      • -
      -
    • -
    -
    - - - - - - + + + + + +org.josfranmc.gutenberg.download.engine Class Hierarchy + + + + + + + + + + + +
    +

    Hierarchy For Package org.josfranmc.gutenberg.download.engine

    +Package Hierarchies: + +
    +
    +

    Class Hierarchy

    + +

    Interface Hierarchy

    + +

    Enum Hierarchy

    +
      +
    • java.lang.Object +
        +
      • java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable) + +
      • +
      +
    • +
    +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/engine/package-use.html b/javadoc/org/josfranmc/gutenberg/download/engine/package-use.html index 83298e4..a35dd20 100644 --- a/javadoc/org/josfranmc/gutenberg/download/engine/package-use.html +++ b/javadoc/org/josfranmc/gutenberg/download/engine/package-use.html @@ -2,10 +2,9 @@ - - + Uses of Package org.josfranmc.gutenberg.download.engine - + @@ -105,7 +104,7 @@

    DownloadEngineType -
    Tipos de motores de descarga
    +
    Types of download engines
    @@ -122,18 +121,17 @@

    DownloadEngineType -
    Tipos de motores de descarga
    +
    Types of download engines
    DownloadResult -
    Encapsula el resultado de la descarga de un recurso.
    +
    It encapsulates the result of downloading a resource.
    IDownloadEngine -
    Define el comportamiento que tiene que ofrecer toda clase que quiera implementar la capacidad de descargar - un recurso identificado por una URL
    +
    Defines the behavior that a class have to implement in order to have the ability to download resources on net.
    diff --git a/javadoc/org/josfranmc/gutenberg/download/package-frame.html b/javadoc/org/josfranmc/gutenberg/download/package-frame.html index d2a8683..afb6fa2 100644 --- a/javadoc/org/josfranmc/gutenberg/download/package-frame.html +++ b/javadoc/org/josfranmc/gutenberg/download/package-frame.html @@ -1,36 +1,23 @@ - - - - - - -org.josfranmc.gutenberg.download - - - - - -

    org.josfranmc.gutenberg.download

    - - - + + + + + +org.josfranmc.gutenberg.download + + + + + +

    org.josfranmc.gutenberg.download

    + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/package-summary.html b/javadoc/org/josfranmc/gutenberg/download/package-summary.html index 3fc4a9d..81719ee 100644 --- a/javadoc/org/josfranmc/gutenberg/download/package-summary.html +++ b/javadoc/org/josfranmc/gutenberg/download/package-summary.html @@ -1,223 +1,162 @@ - - - - - - -org.josfranmc.gutenberg.download - - - - - - - - - - - -
    -

    Package org.josfranmc.gutenberg.download

    -
    -
    -
      -
    • - - - - - - - - - - - - -
      Interface Summary 
      InterfaceDescription
      IGutenbergDownload -
      Establece el interfaz de uso que debe implementarse para llevar a cabo la gestión y desarrollo del proceso de descarga de los libros alojados - por el proyecto Gutenberg (http://www.gutenberg.org/)
      -
      -
    • -
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Class Summary 
      ClassDescription
      AbstractDownload -
      Encapsula el proceso que ha de seguirse para la descarga de un recurso.
      -
      DownloadFactory -
      Factoría que permite crear un objeto para realizar un tipo determinado de descarga
      -
      DownloadGreedy -
      Realiza el proceso de descarga de los libros de forma "avariciosa".
      -
      DownloadParams -
      Encapsula los parámetros que permiten configurar la aplicación.
      -
      DownloadSoft -
      Realiza el proceso de descarga de los libros de forma no "avariciosa".
      -
      JGutenbergDownload -
      Implementa el proceso y gestión de descarga de libros alojados por el proyecto Gutenberg (http://www.gutenberg.org)
      -
      JGutenbergDownloadFactory -
      Factoría que crea objetos de tipo IGutenbergDownload, los cuales implementan los servicios necesarios para la gestión y desarrollo - del proceso de descarga de libros alojados por el proyecto Gutenberg.
      -
      JGutenbergDownloadTest -
      Clase que implementa los test para probar los métodos de la clase JGutenbergDownloadTest
      -
      -
    • -
    • - - - - - - - - - - - - -
      Enum Summary 
      EnumDescription
      DownloadMode -
      Tipos de descarga.
      -
      -
    • -
    -
    - - - - - - + + + + + +org.josfranmc.gutenberg.download + + + + + + + + + + + +
    +

    Package org.josfranmc.gutenberg.download

    +
    +
    +
      +
    • + + + + + + + + + + + + + + + + + + + + + + + + +
      Class Summary 
      ClassDescription
      DownloadBooks +
      Allows to perform the file download process.
      +
      DownloadParams +
      Parameters used in the application.
      +
      DownloadThread +
      Downloads a resource.
      +
      JGutenbergDownload +
      It allows to download books from the Gutenberg project repositories.
      +
      +
    • +
    +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/package-tree.html b/javadoc/org/josfranmc/gutenberg/download/package-tree.html index cc0d147..ec68137 100644 --- a/javadoc/org/josfranmc/gutenberg/download/package-tree.html +++ b/javadoc/org/josfranmc/gutenberg/download/package-tree.html @@ -1,164 +1,140 @@ - - - - - - -org.josfranmc.gutenberg.download Class Hierarchy - - - - - - - - - - - -
    -

    Hierarchy For Package org.josfranmc.gutenberg.download

    -Package Hierarchies: - -
    -
    -

    Class Hierarchy

    - -

    Interface Hierarchy

    - -

    Enum Hierarchy

    -
      -
    • java.lang.Object -
        -
      • java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable) - -
      • -
      -
    • -
    -
    - - - - - - + + + + + +org.josfranmc.gutenberg.download Class Hierarchy + + + + + + + + + + + +
    +

    Hierarchy For Package org.josfranmc.gutenberg.download

    +Package Hierarchies: + +
    +
    +

    Class Hierarchy

    + +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/package-use.html b/javadoc/org/josfranmc/gutenberg/download/package-use.html index 480a4c4..28b8dbe 100644 --- a/javadoc/org/josfranmc/gutenberg/download/package-use.html +++ b/javadoc/org/josfranmc/gutenberg/download/package-use.html @@ -1,181 +1,159 @@ - - - - - - -Uses of Package org.josfranmc.gutenberg.download - - - - - - - - - - - -
    -

    Uses of Package
    org.josfranmc.gutenberg.download

    -
    -
    - -
    - - - - - - + + + + + +Uses of Package org.josfranmc.gutenberg.download + + + + + + + + + + + +
    +

    Uses of Package
    org.josfranmc.gutenberg.download

    +
    +
    + +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/engine/DownloadHttpUrlConnectionTest.html b/javadoc/org/josfranmc/gutenberg/engine/DownloadHttpUrlConnectionTest.html deleted file mode 100644 index b802717..0000000 --- a/javadoc/org/josfranmc/gutenberg/engine/DownloadHttpUrlConnectionTest.html +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - -DownloadHttpUrlConnectionTest - - - - - - - - - - - - -
    -
    org.josfranmc.gutenberg.engine
    -

    Class DownloadHttpUrlConnectionTest

    -
    -
    -
      -
    • java.lang.Object
    • -
    • -
        -
      • org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
      • -
      -
    • -
    -
    -
      -
    • -
      -
      -
      public class DownloadHttpUrlConnectionTest
      -extends java.lang.Object
      -
    • -
    -
    -
    -
      -
    • - - - -
        -
      • - - -

        Method Summary

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        All Methods Static Methods Instance Methods Concrete Methods 
        Modifier and TypeMethod and Description
        static voiddone() -
        Método ejecutado una vez después de la ejecución de todos los tests
        -
        voidgivenDownloadParametersWhenNullThenDownloadResultShoulbBeNotNull() -
        Si los parámetros de descarga (ruta del recurso a descargar y ruta donde guardar la descarga) son nulos, entonces se devuelve un objeto - resultado (DownloadResult) con valores a null.
        -
        voidgivenSavePathWhenNullThenReturnUserDir() -
        Si la ruta donde guardar las descargas no se ha especificado, entonces la carpeta de descarga debe ser la carpeta de ejecución del programa.
        -
        voidgivenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull() -
        Si se indica una dirección de descarga errónea, entonces la ruta donde se ha guardado la descarga debe ser null (en el objeto DownloadResult).
        -
        voidinit() -
        Método ejecutado antes de la ejecución de cada test
        -
        static voidsetUp() -
        Método ejecutado una vez antes de la ejecución de todos los tests
        -
        voidtearDown() -
        Método ejecutado después de la ejecución de cada test
        -
        voidtestDownload() -
        Comprobar que se ha descargado un fichero concreto en la carpeta de ejecución del programa.
        -
        -
          -
        • - - -

          Methods inherited from class java.lang.Object

          -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • -
        -
      • -
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Detail

        - - - -
          -
        • -

          DownloadHttpUrlConnectionTest

          -
          public DownloadHttpUrlConnectionTest()
          -
        • -
        -
      • -
      - -
        -
      • - - -

        Method Detail

        - - - -
          -
        • -

          setUp

          -
          public static void setUp()
          -
          Método ejecutado una vez antes de la ejecución de todos los tests
          -
        • -
        - - - -
          -
        • -

          init

          -
          public void init()
          -
          Método ejecutado antes de la ejecución de cada test
          -
        • -
        - - - -
          -
        • -

          tearDown

          -
          public void tearDown()
          -
          Método ejecutado después de la ejecución de cada test
          -
        • -
        - - - -
          -
        • -

          done

          -
          public static void done()
          -
          Método ejecutado una vez después de la ejecución de todos los tests
          -
        • -
        - - - -
          -
        • -

          givenSavePathWhenNullThenReturnUserDir

          -
          public void givenSavePathWhenNullThenReturnUserDir()
          -
          Si la ruta donde guardar las descargas no se ha especificado, entonces la carpeta de descarga debe ser la carpeta de ejecución del programa.
          -
        • -
        - - - -
          -
        • -

          givenDownloadParametersWhenNullThenDownloadResultShoulbBeNotNull

          -
          public void givenDownloadParametersWhenNullThenDownloadResultShoulbBeNotNull()
          -
          Si los parámetros de descarga (ruta del recurso a descargar y ruta donde guardar la descarga) son nulos, entonces se devuelve un objeto - resultado (DownloadResult) con valores a null.
          -
        • -
        - - - -
          -
        • -

          givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull

          -
          public void givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull()
          -
          Si se indica una dirección de descarga errónea, entonces la ruta donde se ha guardado la descarga debe ser null (en el objeto DownloadResult).
          -
        • -
        - - - -
          -
        • -

          testDownload

          -
          public void testDownload()
          -
          Comprobar que se ha descargado un fichero concreto en la carpeta de ejecución del programa.
          -
        • -
        -
      • -
      -
    • -
    -
    -
    - - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/engine/class-use/DownloadEngineFactoryTest.html b/javadoc/org/josfranmc/gutenberg/engine/class-use/DownloadEngineFactoryTest.html deleted file mode 100644 index b9b6fd3..0000000 --- a/javadoc/org/josfranmc/gutenberg/engine/class-use/DownloadEngineFactoryTest.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.engine.DownloadEngineFactoryTest - - - - - - - - - - - -
    -

    Uses of Class
    org.josfranmc.gutenberg.engine.DownloadEngineFactoryTest

    -
    -
    No usage of org.josfranmc.gutenberg.engine.DownloadEngineFactoryTest
    - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/engine/class-use/DownloadHttpUrlConnectionTest.html b/javadoc/org/josfranmc/gutenberg/engine/class-use/DownloadHttpUrlConnectionTest.html deleted file mode 100644 index 9d36cde..0000000 --- a/javadoc/org/josfranmc/gutenberg/engine/class-use/DownloadHttpUrlConnectionTest.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest - - - - - - - - - - - -
    -

    Uses of Class
    org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest

    -
    -
    No usage of org.josfranmc.gutenberg.engine.DownloadHttpUrlConnectionTest
    - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/engine/package-frame.html b/javadoc/org/josfranmc/gutenberg/engine/package-frame.html deleted file mode 100644 index b01c72c..0000000 --- a/javadoc/org/josfranmc/gutenberg/engine/package-frame.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -org.josfranmc.gutenberg.engine - - - - - -

    org.josfranmc.gutenberg.engine

    - - - diff --git a/javadoc/org/josfranmc/gutenberg/engine/package-summary.html b/javadoc/org/josfranmc/gutenberg/engine/package-summary.html deleted file mode 100644 index a9a8256..0000000 --- a/javadoc/org/josfranmc/gutenberg/engine/package-summary.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - -org.josfranmc.gutenberg.engine - - - - - - - - - - - -
    -

    Package org.josfranmc.gutenberg.engine

    -
    -
    - -
    - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/engine/package-tree.html b/javadoc/org/josfranmc/gutenberg/engine/package-tree.html deleted file mode 100644 index ca871b5..0000000 --- a/javadoc/org/josfranmc/gutenberg/engine/package-tree.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - -org.josfranmc.gutenberg.engine Class Hierarchy - - - - - - - - - - - -
    -

    Hierarchy For Package org.josfranmc.gutenberg.engine

    -Package Hierarchies: - -
    -
    -

    Class Hierarchy

    - -
    - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/util/FileManager.html b/javadoc/org/josfranmc/gutenberg/util/FileManager.html index bcd447a..353c0f8 100644 --- a/javadoc/org/josfranmc/gutenberg/util/FileManager.html +++ b/javadoc/org/josfranmc/gutenberg/util/FileManager.html @@ -1,364 +1,329 @@ - - - - - - -FileManager - - - - - - - - - - - - -
    -
    org.josfranmc.gutenberg.util
    -

    Class FileManager

    -
    -
    -
      -
    • java.lang.Object
    • -
    • -
        -
      • org.josfranmc.gutenberg.util.FileManager
      • -
      -
    • -
    -
    -
      -
    • -
      -
      -
      public class FileManager
      -extends java.lang.Object
      -
      Ofrece herramientas para el tratamiento de ficheros.
      -
      -
      Version:
      -
      1.0
      -
      Author:
      -
      Jose Francisco Mena Ceca
      -
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Summary

        - - - - - - - - -
        Constructors 
        Constructor and Description
        FileManager() 
        -
      • -
      - -
        -
      • - - -

        Method Summary

        - - - - - - - - - - - - - - - - - - - - - - -
        All Methods Static Methods Concrete Methods 
        Modifier and TypeMethod and Description
        static booleanfileExists(java.lang.String savePath, - java.lang.String link) -
        Comprueba si existe en una ruta del equipo local el fichero que se puede obtener con la descarga de un determinado enlace.
        -
        static java.lang.StringgetLocalFileName(java.lang.String str) -
        Devuelve el nombre del archivo contenido en una ruta.
        -
        static java.lang.StringgetLocalFilePathFromURL(java.lang.String savePath, - java.lang.String link) -
        Devuelve la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo.
        -
        static voidunzipFiles(java.lang.String inputPath, - java.lang.String outputPath) -
        Descomprime los ficheros comprimidos en formato zip de una determinada carpeta.
        -
        -
          -
        • - - -

          Methods inherited from class java.lang.Object

          -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • -
        -
      • -
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Detail

        - - - -
          -
        • -

          FileManager

          -
          public FileManager()
          -
        • -
        -
      • -
      - -
        -
      • - - -

        Method Detail

        - - - -
          -
        • -

          fileExists

          -
          public static boolean fileExists(java.lang.String savePath,
          -                                 java.lang.String link)
          -
          Comprueba si existe en una ruta del equipo local el fichero que se puede obtener con la descarga de un determinado enlace.
          -
          -
          Parameters:
          -
          savePath - ruta del equipo local
          -
          link - enlace del fichero
          -
          Returns:
          -
          true si en la ruta indicada existe el fichero del enlace indicado, false en caso contrario
          -
          -
        • -
        - - - -
          -
        • -

          getLocalFilePathFromURL

          -
          public static java.lang.String getLocalFilePathFromURL(java.lang.String savePath,
          -                                                       java.lang.String link)
          -
          Devuelve la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo.
          - La ruta completa del fichero se forma concatenando dos elementos: por un lado, la ruta de la carpeta donde se va a guardar, y por otro, - el nombre del fichero contenido en el enlace de descarga (el nombre de fichero es la parte final del enlace desde el último caracter separador de directorios)
          . - Si el nombre del fichero contiene los caracteres ? o &amp; se sustituyen por _ y & respectivamente.
          -
          -
          Parameters:
          -
          savePath - ruta de la carpeta en la que obtener la descarga
          -
          link - enlace del fichero a descargar
          -
          Returns:
          -
          la ruta del fichero en el equipo local
          -
          -
        • -
        - - - -
          -
        • -

          getLocalFileName

          -
          public static java.lang.String getLocalFileName(java.lang.String str)
          -
          Devuelve el nombre del archivo contenido en una ruta.
          -
          -
          Parameters:
          -
          str - ruta del archivo
          -
          Returns:
          -
          el nombre del archivo
          -
          -
        • -
        - - - -
          -
        • -

          unzipFiles

          -
          public static void unzipFiles(java.lang.String inputPath,
          -                              java.lang.String outputPath)
          -
          Descomprime los ficheros comprimidos en formato zip de una determinada carpeta.
          -
          -
          Parameters:
          -
          inputPath - ruta del directorio donde se encuentran los ficheros zip
          -
          outputPath - ruta del directorio en el que descomprimir los ficheros
          -
          -
        • -
        -
      • -
      -
    • -
    -
    -
    - - - - - - - + + + + + +FileManager + + + + + + + + + + + + +
    +
    org.josfranmc.gutenberg.util
    +

    Class FileManager

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • org.josfranmc.gutenberg.util.FileManager
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public class FileManager
      +extends java.lang.Object
      +
      Tools for managing files.
      +
      +
      Version:
      +
      2.0
      +
      Author:
      +
      Jose Francisco Mena Ceca
      +
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Method Summary

        + + + + + + + + + + + + + + + + + + + + + + +
        All Methods Static Methods Concrete Methods 
        Modifier and TypeMethod and Description
        static booleanfileExists(java.lang.String localPath, + java.lang.String url) +
        Checks if the file indicated by an url already exists in a local path.
        +
        static java.lang.StringgetLocalFileName(java.lang.String str) +
        Returns the name of file inside a path.
        +
        static java.lang.StringgetLocalFilePathFromURL(java.lang.String savePath, + java.lang.String link) +
        Returns the path a file must have when downloaded on the local machine.
        +
        static voidunzipFiles(java.lang.String inputPath, + java.lang.String outputPath) +
        Unzips files in format zip from a certain folder.
        +
        +
          +
        • + + +

          Methods inherited from class java.lang.Object

          +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • +
        +
      • +
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Method Detail

        + + + +
          +
        • +

          fileExists

          +
          public static boolean fileExists(java.lang.String localPath,
          +                                 java.lang.String url)
          +
          Checks if the file indicated by an url already exists in a local path.
          +
          +
          Parameters:
          +
          localPath - local path
          +
          url - download url
          +
          Returns:
          +
          true if the file indicated by the url exists in the local path, false otherwise
          +
          +
        • +
        + + + +
          +
        • +

          getLocalFilePathFromURL

          +
          public static java.lang.String getLocalFilePathFromURL(java.lang.String savePath,
          +                                                       java.lang.String link)
          +
          Returns the path a file must have when downloaded on the local machine.
          + The path is formed by concatenating two elements: on the one hand, tha path of the folder where the download will be saved, + on the other hand, the name of the file in the download url (file name is at the end of the url, from last separator character of folders).
          + If the name of the file contains ? and &amp; characters are replaced by _ and & respectively.
          +
          +
          Parameters:
          +
          savePath - path of the folder in which to get the download
          +
          link - download link
          +
          Returns:
          +
          la ruta del fichero en el equipo local
          +
          +
        • +
        + + + +
          +
        • +

          getLocalFileName

          +
          public static java.lang.String getLocalFileName(java.lang.String str)
          +
          Returns the name of file inside a path.
          +
          +
          Parameters:
          +
          str - file path
          +
          Returns:
          +
          the name of file inside str parameter
          +
          +
        • +
        + + + +
          +
        • +

          unzipFiles

          +
          public static void unzipFiles(java.lang.String inputPath,
          +                              java.lang.String outputPath)
          +
          Unzips files in format zip from a certain folder.
          +
          +
          Parameters:
          +
          inputPath - folder path with zip files
          +
          outputPath - folder path where unzip files
          +
          +
        • +
        +
      • +
      +
    • +
    +
    +
    + + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/util/FileManagerTest.html b/javadoc/org/josfranmc/gutenberg/util/FileManagerTest.html deleted file mode 100644 index 6e2de88..0000000 --- a/javadoc/org/josfranmc/gutenberg/util/FileManagerTest.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - -FileManagerTest - - - - - - - - - - - - -
    -
    org.josfranmc.gutenberg.util
    -

    Class FileManagerTest

    -
    -
    -
      -
    • java.lang.Object
    • -
    • -
        -
      • org.josfranmc.gutenberg.util.FileManagerTest
      • -
      -
    • -
    -
    -
      -
    • -
      -
      -
      public class FileManagerTest
      -extends java.lang.Object
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Summary

        - - - - - - - - -
        Constructors 
        Constructor and Description
        FileManagerTest() 
        -
      • -
      - -
        -
      • - - -

        Method Summary

        - - - - - - - - - - - - - - - - - - -
        All Methods Instance Methods Concrete Methods 
        Modifier and TypeMethod and Description
        voidgivenInputPathAndOutputPathWhenNullThenAvoidNullPointerException() -
        Si la ruta del directorio donde se encuentran los ficheros zip o la ruta del directorio en el que descomprimir los ficheros son null, - entonces el método FileManager.unzipFiles no debe lanzar NullPointerException
        -
        voidtestGetLocalFileName() -
        Comprobar si es correcto el nombre del archivo contenido en una ruta.
        -
        voidtestGetLocalFilePathFromURL() -
        Comprobar si es correcta la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo.
        -
        -
          -
        • - - -

          Methods inherited from class java.lang.Object

          -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • -
        -
      • -
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Detail

        - - - -
          -
        • -

          FileManagerTest

          -
          public FileManagerTest()
          -
        • -
        -
      • -
      - -
        -
      • - - -

        Method Detail

        - - - -
          -
        • -

          testGetLocalFilePathFromURL

          -
          public void testGetLocalFilePathFromURL()
          -
          Comprobar si es correcta la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo.
          -
        • -
        - - - -
          -
        • -

          testGetLocalFileName

          -
          public void testGetLocalFileName()
          -
          Comprobar si es correcto el nombre del archivo contenido en una ruta.
          -
        • -
        - - - -
          -
        • -

          givenInputPathAndOutputPathWhenNullThenAvoidNullPointerException

          -
          public void givenInputPathAndOutputPathWhenNullThenAvoidNullPointerException()
          -
          Si la ruta del directorio donde se encuentran los ficheros zip o la ruta del directorio en el que descomprimir los ficheros son null, - entonces el método FileManager.unzipFiles no debe lanzar NullPointerException
          -
        • -
        -
      • -
      -
    • -
    -
    -
    - - - - - - - diff --git a/javadoc/org/josfranmc/gutenberg/util/FileScraping.html b/javadoc/org/josfranmc/gutenberg/util/FileScraping.html index e05d6af..f41f4e2 100644 --- a/javadoc/org/josfranmc/gutenberg/util/FileScraping.html +++ b/javadoc/org/josfranmc/gutenberg/util/FileScraping.html @@ -1,292 +1,254 @@ - - - - - - -FileScraping - - - - - - - - - - - - -
    -
    org.josfranmc.gutenberg.util
    -

    Class FileScraping

    -
    -
    -
      -
    • java.lang.Object
    • -
    • -
        -
      • org.josfranmc.gutenberg.util.FileScraping
      • -
      -
    • -
    -
    -
      -
    • -
      -
      -
      public class FileScraping
      -extends java.lang.Object
      -
      Ofrece herramientas para analizar ficheros en busca de enlaces web.
      -
      -
      Version:
      -
      1.0
      -
      Author:
      -
      Jose Francisco Mena Ceca
      -
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Summary

        - - - - - - - - -
        Constructors 
        Constructor and Description
        FileScraping() -
        Constructor por defecto.
        -
        -
      • -
      - -
        -
      • - - -

        Method Summary

        - - - - - - - - - - -
        All Methods Static Methods Concrete Methods 
        Modifier and TypeMethod and Description
        static java.util.List<java.lang.String>getLinks(java.lang.String filePath) -
        Obtiene una lista con todos los enlaces contenidos dentro de un fichero HTML.
        -
        -
          -
        • - - -

          Methods inherited from class java.lang.Object

          -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • -
        -
      • -
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Detail

        - - - -
          -
        • -

          FileScraping

          -
          public FileScraping()
          -
          Constructor por defecto.
          -
        • -
        -
      • -
      - -
        -
      • - - -

        Method Detail

        - - - -
          -
        • -

          getLinks

          -
          public static java.util.List<java.lang.String> getLinks(java.lang.String filePath)
          -
          Obtiene una lista con todos los enlaces contenidos dentro de un fichero HTML.
          - Los enlaces son extraidos de los atributos href de los elementos <a>.
          -
          -
          Parameters:
          -
          filePath - ruta del fichero a analizar
          -
          Returns:
          -
          lista de enlaces
          -
          -
        • -
        -
      • -
      -
    • -
    -
    -
    - - - - - - - + + + + + +FileScraping + + + + + + + + + + + + +
    +
    org.josfranmc.gutenberg.util
    +

    Class FileScraping

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • org.josfranmc.gutenberg.util.FileScraping
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public class FileScraping
      +extends java.lang.Object
      +
      Tools for searching web links in files.
      +
      +
      Version:
      +
      2.0
      +
      Author:
      +
      Jose Francisco Mena Ceca
      +
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Method Summary

        + + + + + + + + + + +
        All Methods Static Methods Concrete Methods 
        Modifier and TypeMethod and Description
        static java.util.List<java.lang.String>getLinks(java.lang.String filePath) +
        Returns a list with all links within an html file.
        +
        +
          +
        • + + +

          Methods inherited from class java.lang.Object

          +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • +
        +
      • +
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Method Detail

        + + + +
          +
        • +

          getLinks

          +
          public static java.util.List<java.lang.String> getLinks(java.lang.String filePath)
          +
          Returns a list with all links within an html file.
          + The links are extracted from href attributes of <a> elements.
          +
          +
          Parameters:
          +
          filePath - path of file to analyze
          +
          Returns:
          +
          a List element with links
          +
          +
        • +
        +
      • +
      +
    • +
    +
    +
    + + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/download/DownloadSoft.html b/javadoc/org/josfranmc/gutenberg/util/GutenbergException.html similarity index 55% rename from javadoc/org/josfranmc/gutenberg/download/DownloadSoft.html rename to javadoc/org/josfranmc/gutenberg/util/GutenbergException.html index 2a7839e..70506ed 100644 --- a/javadoc/org/josfranmc/gutenberg/download/DownloadSoft.html +++ b/javadoc/org/josfranmc/gutenberg/util/GutenbergException.html @@ -1,267 +1,310 @@ - - - - - - -DownloadSoft - - - - - - - - - - - - -
    -
    org.josfranmc.gutenberg.download
    -

    Class DownloadSoft

    -
    -
    - -
    - -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Summary

        - - - - - - - - -
        Constructors 
        Constructor and Description
        DownloadSoft() -
        Constructor por defecto.
        -
        -
      • -
      - -
        -
      • - - -

        Method Summary

        - -
          -
        • - - -

          Methods inherited from class java.lang.Object

          -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • -
        -
      • -
      -
    • -
    -
    -
    -
      -
    • - -
        -
      • - - -

        Constructor Detail

        - - - -
          -
        • -

          DownloadSoft

          -
          public DownloadSoft()
          -
          Constructor por defecto.
          -
        • -
        -
      • -
      -
    • -
    -
    -
    - - - - - - - + + + + + +GutenbergException + + + + + + + + + + + + +
    +
    org.josfranmc.gutenberg.util
    +

    Class GutenbergException

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • java.lang.Throwable
      • +
      • +
          +
        • java.lang.Exception
        • +
        • +
            +
          • java.lang.RuntimeException
          • +
          • +
              +
            • org.josfranmc.gutenberg.util.GutenbergException
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
    +
      +
    • +
      +
      All Implemented Interfaces:
      +
      java.io.Serializable
      +
      +
      +
      +
      public class GutenbergException
      +extends java.lang.RuntimeException
      +
      It allows to capture exceptions in the application in the form of a RuntimeException.
      +
      +
      Version:
      +
      2.0
      +
      Author:
      +
      Jose Francisco Mena Ceca
      +
      See Also:
      +
      Serialized Form
      +
      +
    • +
    +
    +
    +
      +
    • + + + +
        +
      • + + +

        Method Summary

        +
          +
        • + + +

          Methods inherited from class java.lang.Throwable

          +addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
        • +
        +
          +
        • + + +

          Methods inherited from class java.lang.Object

          +equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
        • +
        +
      • +
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Constructor Detail

        + + + +
          +
        • +

          GutenbergException

          +
          public GutenbergException()
          +
        • +
        + + + +
          +
        • +

          GutenbergException

          +
          public GutenbergException(java.lang.String message,
          +                          java.lang.Throwable cause)
          +
        • +
        + + + +
          +
        • +

          GutenbergException

          +
          public GutenbergException(java.lang.String message)
          +
        • +
        + + + +
          +
        • +

          GutenbergException

          +
          public GutenbergException(java.lang.Throwable cause)
          +
        • +
        +
      • +
      +
    • +
    +
    +
    + + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/util/class-use/FileManager.html b/javadoc/org/josfranmc/gutenberg/util/class-use/FileManager.html index 0d81a6f..a27394d 100644 --- a/javadoc/org/josfranmc/gutenberg/util/class-use/FileManager.html +++ b/javadoc/org/josfranmc/gutenberg/util/class-use/FileManager.html @@ -1,125 +1,124 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.util.FileManager - - - - - - - - - - - -
    -

    Uses of Class
    org.josfranmc.gutenberg.util.FileManager

    -
    -
    No usage of org.josfranmc.gutenberg.util.FileManager
    - - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.util.FileManager + + + + + + + + + + + +
    +

    Uses of Class
    org.josfranmc.gutenberg.util.FileManager

    +
    +
    No usage of org.josfranmc.gutenberg.util.FileManager
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/util/class-use/FileScraping.html b/javadoc/org/josfranmc/gutenberg/util/class-use/FileScraping.html index c0dfa84..b557ad6 100644 --- a/javadoc/org/josfranmc/gutenberg/util/class-use/FileScraping.html +++ b/javadoc/org/josfranmc/gutenberg/util/class-use/FileScraping.html @@ -1,125 +1,124 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.util.FileScraping - - - - - - - - - - - -
    -

    Uses of Class
    org.josfranmc.gutenberg.util.FileScraping

    -
    -
    No usage of org.josfranmc.gutenberg.util.FileScraping
    - - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.util.FileScraping + + + + + + + + + + + +
    +

    Uses of Class
    org.josfranmc.gutenberg.util.FileScraping

    +
    +
    No usage of org.josfranmc.gutenberg.util.FileScraping
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/util/class-use/FileManagerTest.html b/javadoc/org/josfranmc/gutenberg/util/class-use/GutenbergException.html similarity index 73% rename from javadoc/org/josfranmc/gutenberg/util/class-use/FileManagerTest.html rename to javadoc/org/josfranmc/gutenberg/util/class-use/GutenbergException.html index 91d70ed..9e9c39c 100644 --- a/javadoc/org/josfranmc/gutenberg/util/class-use/FileManagerTest.html +++ b/javadoc/org/josfranmc/gutenberg/util/class-use/GutenbergException.html @@ -1,125 +1,124 @@ - - - - - - -Uses of Class org.josfranmc.gutenberg.util.FileManagerTest - - - - - - - - - - - -
    -

    Uses of Class
    org.josfranmc.gutenberg.util.FileManagerTest

    -
    -
    No usage of org.josfranmc.gutenberg.util.FileManagerTest
    - - - - - - + + + + + +Uses of Class org.josfranmc.gutenberg.util.GutenbergException + + + + + + + + + + + +
    +

    Uses of Class
    org.josfranmc.gutenberg.util.GutenbergException

    +
    +
    No usage of org.josfranmc.gutenberg.util.GutenbergException
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/util/package-frame.html b/javadoc/org/josfranmc/gutenberg/util/package-frame.html index 0a404aa..56fd848 100644 --- a/javadoc/org/josfranmc/gutenberg/util/package-frame.html +++ b/javadoc/org/josfranmc/gutenberg/util/package-frame.html @@ -1,23 +1,25 @@ - - - - - - -org.josfranmc.gutenberg.util - - - - - -

    org.josfranmc.gutenberg.util

    - - - + + + + + +org.josfranmc.gutenberg.util + + + + + +

    org.josfranmc.gutenberg.util

    +
    +

    Classes

    + +

    Exceptions

    + +
    + + diff --git a/javadoc/org/josfranmc/gutenberg/util/package-summary.html b/javadoc/org/josfranmc/gutenberg/util/package-summary.html index 4286ef7..f471847 100644 --- a/javadoc/org/josfranmc/gutenberg/util/package-summary.html +++ b/javadoc/org/josfranmc/gutenberg/util/package-summary.html @@ -1,155 +1,167 @@ - - - - - - -org.josfranmc.gutenberg.util - - - - - - - - - - - -
    -

    Package org.josfranmc.gutenberg.util

    -
    -
    -
      -
    • - - - - - - - - - - - - - - - - - - - - -
      Class Summary 
      ClassDescription
      FileManager -
      Ofrece herramientas para el tratamiento de ficheros.
      -
      FileManagerTest 
      FileScraping -
      Ofrece herramientas para analizar ficheros en busca de enlaces web.
      -
      -
    • -
    -
    - - - - - - + + + + + +org.josfranmc.gutenberg.util + + + + + + + + + + + +
    +

    Package org.josfranmc.gutenberg.util

    +
    +
    +
      +
    • + + + + + + + + + + + + + + + + +
      Class Summary 
      ClassDescription
      FileManager +
      Tools for managing files.
      +
      FileScraping +
      Tools for searching web links in files.
      +
      +
    • +
    • + + + + + + + + + + + + +
      Exception Summary 
      ExceptionDescription
      GutenbergException +
      It allows to capture exceptions in the application in the form of a RuntimeException.
      +
      +
    • +
    +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/util/package-tree.html b/javadoc/org/josfranmc/gutenberg/util/package-tree.html index f04c49d..4584014 100644 --- a/javadoc/org/josfranmc/gutenberg/util/package-tree.html +++ b/javadoc/org/josfranmc/gutenberg/util/package-tree.html @@ -1,140 +1,151 @@ - - - - - - -org.josfranmc.gutenberg.util Class Hierarchy - - - - - - - - - - - -
    -

    Hierarchy For Package org.josfranmc.gutenberg.util

    -Package Hierarchies: - -
    -
    -

    Class Hierarchy

    - -
    - - - - - - + + + + + +org.josfranmc.gutenberg.util Class Hierarchy + + + + + + + + + + + +
    +

    Hierarchy For Package org.josfranmc.gutenberg.util

    +Package Hierarchies: + +
    +
    +

    Class Hierarchy

    +
      +
    • java.lang.Object +
        +
      • org.josfranmc.gutenberg.util.FileManager
      • +
      • org.josfranmc.gutenberg.util.FileScraping
      • +
      • java.lang.Throwable (implements java.io.Serializable) +
          +
        • java.lang.Exception + +
        • +
        +
      • +
      +
    • +
    +
    + + + + + + diff --git a/javadoc/org/josfranmc/gutenberg/util/package-use.html b/javadoc/org/josfranmc/gutenberg/util/package-use.html index 964c3eb..6429231 100644 --- a/javadoc/org/josfranmc/gutenberg/util/package-use.html +++ b/javadoc/org/josfranmc/gutenberg/util/package-use.html @@ -1,125 +1,124 @@ - - - - - - -Uses of Package org.josfranmc.gutenberg.util - - - - - - - - - - - -
    -

    Uses of Package
    org.josfranmc.gutenberg.util

    -
    -
    No usage of org.josfranmc.gutenberg.util
    - - - - - - + + + + + +Uses of Package org.josfranmc.gutenberg.util + + + + + + + + + + + +
    +

    Uses of Package
    org.josfranmc.gutenberg.util

    +
    +
    No usage of org.josfranmc.gutenberg.util
    + + + + + + diff --git a/javadoc/overview-frame.html b/javadoc/overview-frame.html index aae6317..244d34b 100644 --- a/javadoc/overview-frame.html +++ b/javadoc/overview-frame.html @@ -1,26 +1,23 @@ - - - - - - -Overview List - - - - - - - -

     

    - - + + + + + +Overview List + + + + + + + +

     

    + + diff --git a/javadoc/overview-summary.html b/javadoc/overview-summary.html index 0e4f4f4..ca7832b 100644 --- a/javadoc/overview-summary.html +++ b/javadoc/overview-summary.html @@ -1,155 +1,146 @@ - - - - - - -Overview - - - - - - - - -
    - - - - - - - -
    - - -
    -

    JGutenbergDownload - JavaDoc

    -
    - - -
    - - - - - - - -
    - - - - + + + + + +Overview + + + + + + + + +
    + + + + + + + +
    + + +
    +

    JGutenbergDownload

    +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Packages 
    PackageDescription
    org.josfranmc.gutenberg.download 
    org.josfranmc.gutenberg.download.engine 
    org.josfranmc.gutenberg.util 
    +
    + +
    + + + + + + + +
    + + + + diff --git a/javadoc/overview-tree.html b/javadoc/overview-tree.html index 198f211..a29a841 100644 --- a/javadoc/overview-tree.html +++ b/javadoc/overview-tree.html @@ -1,179 +1,176 @@ - - - - - - -Class Hierarchy - - - - - - - - -
    - - - - - - - -
    - - - -
    -

    Class Hierarchy

    - -

    Interface Hierarchy

    - -

    Enum Hierarchy

    -
      -
    • java.lang.Object -
        -
      • java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable) - -
      • -
      -
    • -
    -
    - -
    - - - - - - - -
    - - - - + + + + + +Class Hierarchy + + + + + + + + +
    + + + + + + + +
    + + + +
    +

    Class Hierarchy

    + +

    Interface Hierarchy

    + +

    Enum Hierarchy

    +
      +
    • java.lang.Object +
        +
      • java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable) + +
      • +
      +
    • +
    +
    + +
    + + + + + + + +
    + + + + diff --git a/javadoc/package-list b/javadoc/package-list index 10c4d24..274399b 100644 --- a/javadoc/package-list +++ b/javadoc/package-list @@ -1,5 +1,3 @@ -org.josfranmc.gutenberg.download -org.josfranmc.gutenberg.download.client -org.josfranmc.gutenberg.download.engine -org.josfranmc.gutenberg.engine -org.josfranmc.gutenberg.util +org.josfranmc.gutenberg.download +org.josfranmc.gutenberg.download.engine +org.josfranmc.gutenberg.util diff --git a/javadoc/script.js b/javadoc/script.js index b346356..c3a1cae 100644 --- a/javadoc/script.js +++ b/javadoc/script.js @@ -1,30 +1,30 @@ -function show(type) -{ - count = 0; - for (var key in methods) { - var row = document.getElementById(key); - if ((methods[key] & type) != 0) { - row.style.display = ''; - row.className = (count++ % 2) ? rowColor : altColor; - } - else - row.style.display = 'none'; - } - updateTabs(type); -} - -function updateTabs(type) -{ - for (var value in tabs) { - var sNode = document.getElementById(tabs[value][0]); - var spanNode = sNode.firstChild; - if (value == type) { - sNode.className = activeTableTab; - spanNode.innerHTML = tabs[value][1]; - } - else { - sNode.className = tableTab; - spanNode.innerHTML = "" + tabs[value][1] + ""; - } - } -} +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/javadoc/org/josfranmc/gutenberg/engine/package-use.html b/javadoc/serialized-form.html similarity index 51% rename from javadoc/org/josfranmc/gutenberg/engine/package-use.html rename to javadoc/serialized-form.html index a65c72a..3764a8e 100644 --- a/javadoc/org/josfranmc/gutenberg/engine/package-use.html +++ b/javadoc/serialized-form.html @@ -1,125 +1,137 @@ - - - - - - -Uses of Package org.josfranmc.gutenberg.engine - - - - - - - - - - - -
    -

    Uses of Package
    org.josfranmc.gutenberg.engine

    -
    -
    No usage of org.josfranmc.gutenberg.engine
    - - - - - - + + + + + +Serialized Form + + + + + + + + +
    + + + + + + + +
    + + +
    +

    Serialized Form

    +
    +
    + +
    + +
    + + + + + + + +
    + + + + diff --git a/javadoc/stylesheet.css b/javadoc/stylesheet.css index 98055b2..b8dad08 100644 --- a/javadoc/stylesheet.css +++ b/javadoc/stylesheet.css @@ -1,574 +1,574 @@ -/* Javadoc style sheet */ -/* -Overall document style -*/ - -@import url('resources/fonts/dejavu.css'); - -body { - background-color:#ffffff; - color:#353833; - font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; - font-size:14px; - margin:0; -} -a:link, a:visited { - text-decoration:none; - color:#4A6782; -} -a:hover, a:focus { - text-decoration:none; - color:#bb7a2a; -} -a:active { - text-decoration:none; - color:#4A6782; -} -a[name] { - color:#353833; -} -a[name]:hover { - text-decoration:none; - color:#353833; -} -pre { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; -} -h1 { - font-size:20px; -} -h2 { - font-size:18px; -} -h3 { - font-size:16px; - font-style:italic; -} -h4 { - font-size:13px; -} -h5 { - font-size:12px; -} -h6 { - font-size:11px; -} -ul { - list-style-type:disc; -} -code, tt { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - padding-top:4px; - margin-top:8px; - line-height:1.4em; -} -dt code { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - padding-top:4px; -} -table tr td dt code { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - vertical-align:top; - padding-top:4px; -} -sup { - font-size:8px; -} -/* -Document title and Copyright styles -*/ -.clear { - clear:both; - height:0px; - overflow:hidden; -} -.aboutLanguage { - float:right; - padding:0px 21px; - font-size:11px; - z-index:200; - margin-top:-9px; -} -.legalCopy { - margin-left:.5em; -} -.bar a, .bar a:link, .bar a:visited, .bar a:active { - color:#FFFFFF; - text-decoration:none; -} -.bar a:hover, .bar a:focus { - color:#bb7a2a; -} -.tab { - background-color:#0066FF; - color:#ffffff; - padding:8px; - width:5em; - font-weight:bold; -} -/* -Navigation bar styles -*/ -.bar { - background-color:#4D7A97; - color:#FFFFFF; - padding:.8em .5em .4em .8em; - height:auto;/*height:1.8em;*/ - font-size:11px; - margin:0; -} -.topNav { - background-color:#4D7A97; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; - font-size:12px; -} -.bottomNav { - margin-top:10px; - background-color:#4D7A97; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; - font-size:12px; -} -.subNav { - background-color:#dee3e9; - float:left; - width:100%; - overflow:hidden; - font-size:12px; -} -.subNav div { - clear:left; - float:left; - padding:0 0 5px 6px; - text-transform:uppercase; -} -ul.navList, ul.subNavList { - float:left; - margin:0 25px 0 0; - padding:0; -} -ul.navList li{ - list-style:none; - float:left; - padding: 5px 6px; - text-transform:uppercase; -} -ul.subNavList li{ - list-style:none; - float:left; -} -.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { - color:#FFFFFF; - text-decoration:none; - text-transform:uppercase; -} -.topNav a:hover, .bottomNav a:hover { - text-decoration:none; - color:#bb7a2a; - text-transform:uppercase; -} -.navBarCell1Rev { - background-color:#F8981D; - color:#253441; - margin: auto 5px; -} -.skipNav { - position:absolute; - top:auto; - left:-9999px; - overflow:hidden; -} -/* -Page header and footer styles -*/ -.header, .footer { - clear:both; - margin:0 20px; - padding:5px 0 0 0; -} -.indexHeader { - margin:10px; - position:relative; -} -.indexHeader span{ - margin-right:15px; -} -.indexHeader h1 { - font-size:13px; -} -.title { - color:#2c4557; - margin:10px 0; -} -.subTitle { - margin:5px 0 0 0; -} -.header ul { - margin:0 0 15px 0; - padding:0; -} -.footer ul { - margin:20px 0 5px 0; -} -.header ul li, .footer ul li { - list-style:none; - font-size:13px; -} -/* -Heading styles -*/ -div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { - background-color:#dee3e9; - border:1px solid #d0d9e0; - margin:0 0 6px -8px; - padding:7px 5px; -} -ul.blockList ul.blockList ul.blockList li.blockList h3 { - background-color:#dee3e9; - border:1px solid #d0d9e0; - margin:0 0 6px -8px; - padding:7px 5px; -} -ul.blockList ul.blockList li.blockList h3 { - padding:0; - margin:15px 0; -} -ul.blockList li.blockList h2 { - padding:0px 0 20px 0; -} -/* -Page layout container styles -*/ -.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { - clear:both; - padding:10px 20px; - position:relative; -} -.indexContainer { - margin:10px; - position:relative; - font-size:12px; -} -.indexContainer h2 { - font-size:13px; - padding:0 0 3px 0; -} -.indexContainer ul { - margin:0; - padding:0; -} -.indexContainer ul li { - list-style:none; - padding-top:2px; -} -.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { - font-size:12px; - font-weight:bold; - margin:10px 0 0 0; - color:#4E4E4E; -} -.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { - margin:5px 0 10px 0px; - font-size:14px; - font-family:'DejaVu Sans Mono',monospace; -} -.serializedFormContainer dl.nameValue dt { - margin-left:1px; - font-size:1.1em; - display:inline; - font-weight:bold; -} -.serializedFormContainer dl.nameValue dd { - margin:0 0 0 1px; - font-size:1.1em; - display:inline; -} -/* -List styles -*/ -ul.horizontal li { - display:inline; - font-size:0.9em; -} -ul.inheritance { - margin:0; - padding:0; -} -ul.inheritance li { - display:inline; - list-style:none; -} -ul.inheritance li ul.inheritance { - margin-left:15px; - padding-left:15px; - padding-top:1px; -} -ul.blockList, ul.blockListLast { - margin:10px 0 10px 0; - padding:0; -} -ul.blockList li.blockList, ul.blockListLast li.blockList { - list-style:none; - margin-bottom:15px; - line-height:1.4; -} -ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { - padding:0px 20px 5px 10px; - border:1px solid #ededed; - background-color:#f8f8f8; -} -ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { - padding:0 0 5px 8px; - background-color:#ffffff; - border:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { - margin-left:0; - padding-left:0; - padding-bottom:15px; - border:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { - list-style:none; - border-bottom:none; - padding-bottom:0; -} -table tr td dl, table tr td dl dt, table tr td dl dd { - margin-top:0; - margin-bottom:1px; -} -/* -Table styles -*/ -.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { - width:100%; - border-left:1px solid #EEE; - border-right:1px solid #EEE; - border-bottom:1px solid #EEE; -} -.overviewSummary, .memberSummary { - padding:0px; -} -.overviewSummary caption, .memberSummary caption, .typeSummary caption, -.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { - position:relative; - text-align:left; - background-repeat:no-repeat; - color:#253441; - font-weight:bold; - clear:none; - overflow:hidden; - padding:0px; - padding-top:10px; - padding-left:1px; - margin:0px; - white-space:pre; -} -.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, -.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, -.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, -.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, -.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, -.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, -.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, -.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { - color:#FFFFFF; -} -.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, -.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - padding-bottom:7px; - display:inline-block; - float:left; - background-color:#F8981D; - border: none; - height:16px; -} -.memberSummary caption span.activeTableTab span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - margin-right:3px; - display:inline-block; - float:left; - background-color:#F8981D; - height:16px; -} -.memberSummary caption span.tableTab span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - margin-right:3px; - display:inline-block; - float:left; - background-color:#4D7A97; - height:16px; -} -.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { - padding-top:0px; - padding-left:0px; - padding-right:0px; - background-image:none; - float:none; - display:inline; -} -.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, -.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { - display:none; - width:5px; - position:relative; - float:left; - background-color:#F8981D; -} -.memberSummary .activeTableTab .tabEnd { - display:none; - width:5px; - margin-right:3px; - position:relative; - float:left; - background-color:#F8981D; -} -.memberSummary .tableTab .tabEnd { - display:none; - width:5px; - margin-right:3px; - position:relative; - background-color:#4D7A97; - float:left; - -} -.overviewSummary td, .memberSummary td, .typeSummary td, -.useSummary td, .constantsSummary td, .deprecatedSummary td { - text-align:left; - padding:0px 0px 12px 10px; -} -th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, -td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ - vertical-align:top; - padding-right:0px; - padding-top:8px; - padding-bottom:3px; -} -th.colFirst, th.colLast, th.colOne, .constantsSummary th { - background:#dee3e9; - text-align:left; - padding:8px 3px 3px 7px; -} -td.colFirst, th.colFirst { - white-space:nowrap; - font-size:13px; -} -td.colLast, th.colLast { - font-size:13px; -} -td.colOne, th.colOne { - font-size:13px; -} -.overviewSummary td.colFirst, .overviewSummary th.colFirst, -.useSummary td.colFirst, .useSummary th.colFirst, -.overviewSummary td.colOne, .overviewSummary th.colOne, -.memberSummary td.colFirst, .memberSummary th.colFirst, -.memberSummary td.colOne, .memberSummary th.colOne, -.typeSummary td.colFirst{ - width:25%; - vertical-align:top; -} -td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { - font-weight:bold; -} -.tableSubHeadingColor { - background-color:#EEEEFF; -} -.altColor { - background-color:#FFFFFF; -} -.rowColor { - background-color:#EEEEEF; -} -/* -Content styles -*/ -.description pre { - margin-top:0; -} -.deprecatedContent { - margin:0; - padding:10px 0; -} -.docSummary { - padding:0; -} - -ul.blockList ul.blockList ul.blockList li.blockList h3 { - font-style:normal; -} - -div.block { - font-size:14px; - font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; -} - -td.colLast div { - padding-top:0px; -} - - -td.colLast a { - padding-bottom:3px; -} -/* -Formatting effect styles -*/ -.sourceLineNo { - color:green; - padding:0 30px 0 0; -} -h1.hidden { - visibility:hidden; - overflow:hidden; - font-size:10px; -} -.block { - display:block; - margin:3px 10px 2px 0px; - color:#474747; -} -.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, -.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, -.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { - font-weight:bold; -} -.deprecationComment, .emphasizedPhrase, .interfaceName { - font-style:italic; -} - -div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, -div.block div.block span.interfaceName { - font-style:normal; -} - -div.contentContainer ul.blockList li.blockList h2{ - padding-bottom:0px; -} +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/pom.xml b/pom.xml index 45f676b..8df4a97 100644 --- a/pom.xml +++ b/pom.xml @@ -1,117 +1,151 @@ - - 4.0.0 - - org.josfranmc.gutenberg - JGutenbergDownload - 1.0 - jar - - JGutenbergDownload - Descarga de ficheros desde los repositorios del proyecto Gutenberg - http://maven.apache.org - - - - Jose Francisco Mena Ceca - org.josfranmc - - - - - 1.2.17 - 4.12 - 1.8 - 1.8 - 3.6.1 - UTF-8 - - - - - log4j - log4j - ${log4j.version} - - - junit - junit - ${junit.version} - test - - - - - JGutenbergDownload-1.0 - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.plugin.version} - - ${jdk.source.version} - ${jdk.target.version} - false - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - true - lib/ - org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy - package - - copy-dependencies - - - - ${project.build.directory}/lib - - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.3 - - - package - - shade - - - true - - - org.josfranmc.gutenberg.download.client.JGutenbergDownloadClient - - - - - - - - - - + + 4.0.0 + + org.josfranmc.gutenberg + JGutenbergDownload + 2.0 + jar + + JGutenbergDownload + This software allows you to download books from the Gutenberg project repositories. + https://github.com/josfranmc/JGutenbergDownload + + + + Jose Francisco Mena Ceca + org.josfranmc + + + + + 1.8 + 1.8 + UTF-8 + org.josfranmc.gutenberg.download.JGutenbergDownload + + + + + log4j + log4j + 1.2.17 + + + junit + junit + 4.12 + test + + + + + ${project.artifactId}-${project.version} + + + + src/main/resources + + + ${project.basedir} + + LICENSE + NOTICE + + META-INF + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + ${jdk.source.version} + ${jdk.target.version} + false + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + true + true + lib/ + ${main.class} + + + ${project.url} + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + package + + copy-dependencies + + + ${project.build.directory}/lib + junit,hamcrest-core + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + true + + + ${main.class} + + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + + prepare-agent + + + + report + test + + report + + + + + + + diff --git a/src/main/java/org/josfranmc/gutenberg/download/AbstractDownload.java b/src/main/java/org/josfranmc/gutenberg/download/AbstractDownload.java deleted file mode 100644 index 998d0fc..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/AbstractDownload.java +++ /dev/null @@ -1,214 +0,0 @@ -package org.josfranmc.gutenberg.download; - -import java.net.URL; - -import org.josfranmc.gutenberg.download.engine.DownloadResult; -import org.josfranmc.gutenberg.download.engine.IDownloadEngine; -import org.josfranmc.gutenberg.util.FileManager; - -/** - * Encapsula el proceso que ha de seguirse para la descarga de un recurso.
    - * Esta clase actúa como plantilla (template), de forma que las clases que hereden de ella deben implementar los métodos indicados para realizar las descargas. - * En concreo, se debe definir como se configuran los parámetros pasados y como se realiza el procesamiento de las páginas que exponen los enlaces a los - * libros del proyecto Gutenberg (http://www.gutenberg.org/) - * @author Jose Francisco Mena Ceca - * @version 1.0 - * @see DownloadParams - * @see IDownloadEngine - */ -public abstract class AbstractDownload { - - /** - * Motor de descarga utilizado - */ - protected IDownloadEngine downloadEngine; - - /** - * Dirección url inicial del recurso a obtener. Se guarda la dirección inicial de descarga ya que irá variando según se vayan descargando - * recursos. - */ - private URL urlBase; - - /** - * Ruta de la carpeta en la que obtener los recursos descargados - */ - private String savePath; - - /** - * Si se deben sobreescribir los archivos existentes por los descargados - */ - private boolean overwrite; - - /** - * Intervalo de espera entre descargas, en milisegundos - */ - private int delay; - - /** - * Número maximo de ficheros a descargar - */ - private int maxFilesToDownload; - - - /** - * Constructor por defecto. - */ - protected AbstractDownload() { - this.downloadEngine = null; - this.urlBase = null; - this.overwrite = false; - this.savePath = null; - this.delay = 2500; - } - - /** - * Ejecuta el proceso de desarga.
    Una vez realizada la configuración de los elementos necesarios, se realiza la descarga del recurso indicado - * en los parámetros pasados. Si el recurso obtenido es una página con enlaces de descarga se extraen estos enlaces - * para realizar la descarga de los recursos que se referencian. - * @param downloadParams parámetros de configuración de la descarga - * @see DownloadParams - * @throws IllegalStateException si se ha devuelto algún error al hacer las descargas - */ - public void executeDownload(DownloadParams downloadParams) { - configDownload(downloadParams); - DownloadResult downloadResult = downloadEngine.download(); - if (downloadResult.getError() == null) { - if (downloadResult.getContentType() != null && downloadResult.getContentType().equals("text/html")) { - processPage(downloadResult.getFileOutputPath()); - } - } else { - throw new IllegalStateException(downloadResult.getError()); - } - } - - /** - * Realiza la configuración necesaria para realizar las descargas. Recibe un objeto DownloadParams que encapsula los parámetros para llevar a cabo - * la inicialización del proceso. - * @param dp parametros de configuración de las descargas establecidos por el cliente - * @see DownloadParams - */ - protected abstract void configDownload(DownloadParams dp); - - /** - * Procesa un archivo que es una página web que contiene los enlaces a los zips de los libros que se quieren obtener.

    - * El último enlace es la dirección de la siguiente página a procesar, que contiene nuevos enlaces a libros. - * @param file nombre del fichero de la página web que contiene los enlaces de los zips a descargar - */ - protected abstract void processPage(String file); - - /** - * @return el tipo de algoritmo de descarga que utiliza la clase - * @see DownloadMode - */ - protected abstract DownloadMode getType(); - - /** - * Comprueba si debe descargarse un determinado recurso. El recurso puede descargarse si se cumple alguna de los siguientes condiciones: - *

      - *
    • es la primera vez que se descarga
    • - *
    • el enlace del recurso contiene la palabra harvest (es por tanto una página que contiene enlaces a recursos)
    • - *
    • se ha activado el parametro de sobreescribir recursos ya descargados
    • - *
    - * @param link enlace al recurso que se quiere descargar - * @return true si debe descargarse el recurso, false en caso contrario - */ - protected boolean createResource(String link) { - boolean result = false; - if (!resourceAlreadyDownloaded(link) || link.contains("harvest") || isOverwrite()) { - result = true; - } - return result; - } - - /** - * Comprueba si existe en el directorio en el que se descargan los recursos el fichero correspondiente al recurso indicado por un determinado enlace - * @param link enlace del recurso a descargar - * @return true si ya existe el recurso a descargar en el directorio donde se descargan los recursos, false en caso contrario - */ - protected boolean resourceAlreadyDownloaded(String link) { - return (FileManager.fileExists(downloadEngine.getSavePath(), link)); - } - - /** - * @return el tipo de motor de descarga utilizado - * @see IDownloadEngine - */ - protected IDownloadEngine getDownloadEngine() { - return downloadEngine; - } - - /** - * @return la dirección url inicial del recurso a obtener - */ - protected URL getUrlBase() { - return urlBase; - } - - /** - * Establece la dirección url inicial del recurso a obtener. - * @param urlBase dirección url - */ - protected void setUrlBase(URL urlBase) { - this.urlBase = urlBase; - } - - /** - * @return la ruta de la carpeta en la que obtener los recursos descargados - */ - protected String getSavePath() { - return savePath; - } - - /** - * Establece la ruta de la carpeta en la que obtener los recursos descargados. - * @param savePath ruta de la carpeta en la que obtener los recursos descargados - */ - protected void setSavePath(String savePath) { - this.savePath = savePath; - } - - /** - * @return true si se deben sobreescribir los archivos existentes por los descargados, false en caso contrario - */ - protected boolean isOverwrite() { - return overwrite; - } - - /** - * Establece si deben sobreescribirse los recursos existentes por las nuevas descargas - * @param overwrite true si se deben sobreescribir los archivos, false en caso contrario - */ - protected void setOverwrite(boolean overwrite) { - this.overwrite = overwrite; - } - - /** - * Establece el intervalo de espera entre descargas - * @param delay tiempo de espera, en milisegundos - */ - protected void setDelay(int delay) { - this.delay = delay; - } - - /** - * @return el intervalo de espera entre descargas, en milisegundos - */ - protected int getDelay() { - return delay; - } - - /** - * @return el número máximo de ficheros a descargar - */ - protected int getMaxFilesToDownload() { - return maxFilesToDownload; - } - - /** - * Establece el número máximo de ficheros a descargar. El valor cero indica descargar todos los ficheros disponibles. - * @param maxFilesToDownload número máximo de ficheros - */ - protected void setMaxFilesToDownload(int maxFilesToDownload) { - this.maxFilesToDownload = (maxFilesToDownload == 0) ? Integer.MAX_VALUE : maxFilesToDownload; - } -} diff --git a/src/main/java/org/josfranmc/gutenberg/download/DownloadBooks.java b/src/main/java/org/josfranmc/gutenberg/download/DownloadBooks.java new file mode 100644 index 0000000..0db4965 --- /dev/null +++ b/src/main/java/org/josfranmc/gutenberg/download/DownloadBooks.java @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + * + * This file includes software developed at + * The Apache Software Foundation (http://www.apache.org/). + */ +package org.josfranmc.gutenberg.download; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Iterator; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.apache.log4j.Logger; +import org.josfranmc.gutenberg.download.engine.DownloadEngineFactory; +import org.josfranmc.gutenberg.download.engine.DownloadResult; +import org.josfranmc.gutenberg.download.engine.IDownloadEngine; +import org.josfranmc.gutenberg.util.FileManager; +import org.josfranmc.gutenberg.util.FileScraping; + +/** + * Allows to perform the file download process. + * @author Jose Francisco Mena Ceca + * @version 2.0 + * @see JGutenbergDownload + * @see DownloadParams + */ +public class DownloadBooks { + + private static final Logger log = Logger.getLogger(DownloadBooks.class); + + private ExecutorService executorService; + + private DownloadParams parameters; + + private IDownloadEngine downloadEngine; + + private int finishedDownloads = 0; + + + public DownloadBooks(DownloadParams parameters) { + this.parameters = parameters; + this.executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 3); + } + + private void settingDownloadEngine() { + downloadEngine = DownloadEngineFactory.create(parameters.getEngineType()); + downloadEngine.setResource(parameters.getUrlBase()); + downloadEngine.setSavePath(parameters.getZipsPath()); + } + + /** + * Perfoms the book download process.

    + * The first download should be a file with links to the books to download. All existing links are downloaded. + * If there is a link to another page with more links, this page is downloaded and processed in the same way. + * This process continues until there are no more pages.

    + * All downloads run on separate threads. + */ + public void executeDownload() { + + settingDownloadEngine(); + + DownloadResult downloadResult = downloadEngine.download(); + if (downloadResult.getContentType().equals("text/html")) { + + processPage(downloadResult.getSavedFilePath()); + + try { + executorService.shutdown(); + while (!executorService.awaitTermination(2, TimeUnit.MINUTES)) {} + } catch (InterruptedException e) { + log.warn("InterruptedException shutting down executorService. " + e.getMessage()); + Thread.currentThread().interrupt(); + } + } + } + + /** + * It process a file with links that are the urls to the books to download. Existing links are extracted and then downloaded.
    + * The last link could be the link to another page with more links. If so, we process the new file calling this method again. + * @param file file with links to the books to download + */ + private void processPage(String file) { + Iterator it = FileScraping.getLinks(file).iterator(); + while (it.hasNext() && getFinishedDownloads() < getMaxFilesToDownload()) { + String link = it.next(); + if (createResource(link)) { + try { + getBook(link); + } catch (MalformedURLException e) { + try { + DownloadResult downloadResult = getNewPageWithBookLinks(link); + if (downloadResult.getContentType().equals("text/html")) { + processPage(downloadResult.getSavedFilePath()); + } + } catch (MalformedURLException ex) { + log.error("Cannot get url for " + link); + log.error(" Url Base = " + getUrlBase()); + } + } + } + } + } + + /** + * Downloads a book. The download is runned in a new thread. + * @param link download url + * @throws MalformedURLException + */ + private void getBook(String link) throws MalformedURLException { + URL newURLToDownload = new URL(link); + delayDownload(); + executorService.submit(new DownloadThread(newURLToDownload, parameters)); + incrementFinishedDownloads(); + } + + private DownloadResult getNewPageWithBookLinks(String link) throws MalformedURLException { + URL newURLToDownload = new URL(getUrlBase(), link.replace("&", "&")); + downloadEngine.setResource(newURLToDownload); + log.info("New url " + newURLToDownload.toString()); + return downloadEngine.download(); + } + + /** + * Checks if one resource must be downloaded. The resource can be downloaded if any of the following conditions are fulfilled: + *

      + *
    • it is the first time the resource is downloaded
    • + *
    • overwrite resources parameter is active
    • + *
    • the resource link contains the word harvest (it is a link to a page with more book links)
    • + *
    + * @param link link to the resource to download + * @return true if the resource must be downloaded, false otherwise + */ + private boolean createResource(String link) { + boolean result = false; + if (!resourceAlreadyDownloaded(link) || isOverwrite() || link.contains("harvest")) { + result = true; + } + return result; + } + + /** + * Checks if the file corresponding to the resource indicated by a certain link exists in the directory where the resources are downloaded + * @param link resource link to download + * @return true if the resource to download already exists, false otherwise + */ + private boolean resourceAlreadyDownloaded(String link) { + return (FileManager.fileExists(downloadEngine.getSavePath(), link)); + } + + private boolean isOverwrite() { + return parameters.isOverwrite(); + } + + private int getDelay() { + return parameters.getDelay(); + } + + private URL getUrlBase() { + return parameters.getUrlBase(); + } + + private int getMaxFilesToDownload() { + return parameters.getMaxFilesToDownload(); + } + + private int getFinishedDownloads() { + return finishedDownloads; + } + + private void incrementFinishedDownloads() { + this.finishedDownloads++; + } + + private void delayDownload() { + if (getDelay() > 0) { + try { + Thread.sleep(getDelay()); + } catch (InterruptedException e) { + log.error("InterruptedException delayDownload. " + e); + Thread.currentThread().interrupt(); + } + } + } +} diff --git a/src/main/java/org/josfranmc/gutenberg/download/DownloadFactory.java b/src/main/java/org/josfranmc/gutenberg/download/DownloadFactory.java deleted file mode 100644 index 5f87c17..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/DownloadFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.josfranmc.gutenberg.download; - -/** - * Factoría que permite crear un objeto para realizar un tipo determinado de descarga - * @author Jose Francisco Mena Ceca - * @version 1.0 - * @see AbstractDownload - * @see DownloadMode - */ -public class DownloadFactory { - - /** - * Crea un objeto concreto para realizar descargas - * @param type tipo de descarga según DownloadType - * @return objeto para realizar descargas - */ - public static AbstractDownload create(DownloadMode type) { - AbstractDownload downloadtype = null; - - switch (type) { - case SOFT: - downloadtype = new DownloadSoft(); - break; - case GREEDY: - downloadtype = new DownloadGreedy(); - break; - default: - downloadtype = new DownloadSoft(); - break; - } - return downloadtype; - } -} \ No newline at end of file diff --git a/src/main/java/org/josfranmc/gutenberg/download/DownloadGreedy.java b/src/main/java/org/josfranmc/gutenberg/download/DownloadGreedy.java deleted file mode 100644 index 94c4f77..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/DownloadGreedy.java +++ /dev/null @@ -1,189 +0,0 @@ -package org.josfranmc.gutenberg.download; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Iterator; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.log4j.Logger; -import org.josfranmc.gutenberg.download.engine.DownloadEngineFactory; -import org.josfranmc.gutenberg.download.engine.DownloadResult; -import org.josfranmc.gutenberg.util.FileScraping; - -/** - * Realiza el proceso de descarga de los libros de forma "avariciosa". La estrategia utilizada es la de ejecutar diversos hilos para realizar - * la descarga de los libros de forma concurrrente y sin realizar ninguna pausa entre las descargas.
    - * Este método de descarga es más eficiente, desde el punto de vista de la velocidad de las descargas, que el usado por el tipo DownloadSoft - * pero no respeta las condiciones de uso del servicio ofrecido por el proyecto Gutenberg ya que se hace un uso abusivo de las mismas. Utilizar este - * modo de descarga puede suponer que nuestra dirección ip sea bloqueada, impidiéndonos el acceso a los servidores.

    - * Más info: http://www.gutenberg.org/wiki/Gutenberg:Information_About_Robot_Access_to_our_Pages - * @author Jose Francisco Mena Ceca - * @version 1.0 - * @see AbstractDownload - * @see DownloadParams - */ -public class DownloadGreedy extends AbstractDownload implements Runnable { - - private static final Logger log = Logger.getLogger(DownloadGreedy.class); - - /** - * Control de los hilos a ejecutar. - */ - private static ExecutorService executorService; - - /** - * Conjunto de parámetros recibido - */ - private DownloadParams parameters; - - /** - * Número de libros descargados - */ - private AtomicInteger finishedDownload; - - - /** - * Constructor por defecto. - */ - public DownloadGreedy() { - super(); - finishedDownload = new AtomicInteger(); - } - - /** - * Constructor. Se usa para inicializar, desde dentro de la clase, los objetos creados para ejecutarse en un nuevo hilo. - * @param target dirección URL del recurso a descarga - * @param dp conjunto de parámetros de configuración - */ - private DownloadGreedy(URL target, DownloadParams dp) { - this.parameters = dp; - downloadEngine = DownloadEngineFactory.create(dp.getEngineType()); - downloadEngine.setResource(target); - downloadEngine.setSavePath(dp.getSavePath()); - setUrlBase(dp.getUrlBase()); - setSavePath(dp.getSavePath()); - setOverwrite(dp.isOverwrite()); - } - - /** - * Realiza la configuración inicial necesaria para realizar las descargas.
    - *

      - *
    • Se crea un motor de descarga y se le indica la url a descargar y la ruta de la carpeta en la que obtener el recuro.
    • - *
    • Se guarda la url inicial a descargar como url base para el resto de descargas si las hubiera
    • - *
    • Se indica si deben sobreescribirse los recursos ya existentes por los descargados en caso de ser los mismos
    • - * @param dp parametros de configuración de las descargas establecidos por el cliente - * @see DownloadParams - *
    - */ - @Override - protected void configDownload(DownloadParams dp) { - downloadEngine = DownloadEngineFactory.create(dp.getEngineType()); - downloadEngine.setResource(dp.getUrlBase()); - downloadEngine.setSavePath(dp.getSavePath()); - setUrlBase(dp.getUrlBase()); - setSavePath(dp.getSavePath()); - setOverwrite(dp.isOverwrite()); - setMaxFilesToDownload(dp.getMaxFilesToDownload()); - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 3); - this.parameters = dp; // guardamos los parámetros para poder pasárselos al próximo hilo - } - - /** - * Procesa un fichero que es una página web que contiene los enlaces a los zips de los libros a obtener.

    Recupera en una lista los enlaces de la - * página y luego los va descargando uno a uno. El último enlace leido es la dirección de la siguiente página a procesar. Cuando se lee este enlace - * se descaraga la siguiente página con enlaces a libros y se llama recursivamente al método para realizar su descargaa. El proceso continua - * hasta que no existen más páginas con enlaces que procesar.

    - * La descarga de cada enlace es realizada por un nuevo hilo de ejecución. - * @param file nombre del fichero de la página web que contiene los enlaces de los zips a descargar - */ - @Override - protected void processPage(String file) { - boolean error = false; - boolean isNewPage = false; - DownloadResult downloadResult = null; - URL newLinkToProcess = null; - - Iterator it = FileScraping.getLinks(file).iterator(); - while (it.hasNext() && getFinishedDownload() < getMaxFilesToDownload()) { - String link = it.next(); - if (createResource(link)) { - try { - error = false; - isNewPage = false; - newLinkToProcess = new URL(link); - } catch (MalformedURLException e) { - try { - // nueva página que contiene más enlaces. hay que cambiar los & por & para crear correctamente el nuevo enlace - newLinkToProcess = new URL(getUrlBase(), link.toString().replace("&", "&")); - isNewPage = true; - log.info("Nueva url " + newLinkToProcess.toString()); - } catch (MalformedURLException ex) { - error = true; - log.error(ex); - log.error("Imposible obtener URL para " + link); - log.error("newLinkToProcess = " + newLinkToProcess); - log.error("Url Base = " + getUrlBase()); - } - } - if (!error) { - if (!isNewPage) { - DownloadGreedy dg = new DownloadGreedy(newLinkToProcess, this.parameters); - executorService.submit(dg); - incrementFinishedDownload(); - } else { - // obtenemos la nueva página que contiene más enlaces - downloadEngine.setResource(newLinkToProcess); - downloadResult = downloadEngine.download(); - processPage(downloadResult.getFileOutputPath()); - - } - } - } else { - log.debug("Ya existe el recurso " + link + ". Omitiendo la descarga..."); - } - } - waitEnd(); - } - - /** - * Inicia un proceso de descarga. - */ - @Override - public void run() { - downloadEngine.download(); - } - - /** - * Espera a que terminen todos los hilos ejecutados - */ - private void waitEnd() { - try { - executorService.shutdown(); - while (!executorService.awaitTermination(2, TimeUnit.MINUTES)) {} - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * @return el número de libros descargados - */ - protected int getFinishedDownload() { - return finishedDownload.get(); - } - - /** - * @param finishedDownload the finishedDownload to set - */ - protected void incrementFinishedDownload() { - this.finishedDownload.incrementAndGet(); - } - - @Override - protected DownloadMode getType() { - return DownloadMode.GREEDY; - } -} diff --git a/src/main/java/org/josfranmc/gutenberg/download/DownloadMode.java b/src/main/java/org/josfranmc/gutenberg/download/DownloadMode.java deleted file mode 100644 index 7a47d30..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/DownloadMode.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.josfranmc.gutenberg.download; - -/** - * Tipos de descarga. - * @author Jose Francisco Mena Ceca - * @version 1.0 - */ -public enum DownloadMode { - /** - * Descarga normal (lenta) - */ - SOFT, - - /** - * Descarga concurrente de recursos (más rápida) - */ - GREEDY; -} \ No newline at end of file diff --git a/src/main/java/org/josfranmc/gutenberg/download/DownloadParams.java b/src/main/java/org/josfranmc/gutenberg/download/DownloadParams.java index 30f2ed9..e1c0bc7 100644 --- a/src/main/java/org/josfranmc/gutenberg/download/DownloadParams.java +++ b/src/main/java/org/josfranmc/gutenberg/download/DownloadParams.java @@ -1,168 +1,284 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + */ package org.josfranmc.gutenberg.download; +import java.net.MalformedURLException; import java.net.URL; import org.josfranmc.gutenberg.download.engine.DownloadEngineType; /** - * Encapsula los parámetros que permiten configurar la aplicación. Son los siguientes: + * Parameters used in the application. They are: *

      - *
    • urlBase: url del recurso a descargar
    • - *
    • savePath: ruta local donde descargar los recursos
    • - *
    • overwrite: indica si se deben sobreescribir recursos que ya están descargados
    • - *
    • delay: tiempo de espera entre descargas
    • - *
    • unzip: indica si los recursos descargados en formato zip deben o no descomprimirse
    • - *
    • engineType: tipo de motor a utilizar para la descarga
    • + *
    • fileType: the type of files to download (default txt)
    • + *
    • language: the language of files to download (default es)
    • + *
    • urlBase: initial download url
    • + *
    • savePath: path where to get downloaded resources (default System.getProperty("user.dir"))
    • + *
    • overwrite: if the existing files must be overwritten by the downloaded ones (default false)
    • + *
    • delay: delay between downloads, in milliseconds (default 2000)
    • + *
    • unzip: if downloaded files must be unzipping (default true)
    • + *
    • maxFilesToDownload: the maximum number of files to download (default 10, 0 for download all existing)
    • + *
    • engineType: the type of downloading engine to use (default DownloadEngineType.HTTP_CONNECTION)
    • *
    * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 * @see DownloadEngineType + * @see JGutenbergDownload */ public class DownloadParams { /** - * url del recurso a descargar + * Base URL of the Gutenberg project to download */ - private URL urlBase = null; + public static final String URL_BOOKS = "http://www.gutenberg.org/robot/"; - /** - * Ruta de la carpeta en la que obtener los recursos descargados. - */ - private String savePath = null; + private static final String FILE_SEPARATOR = System.getProperty("file.separator"); - /** - * Si deben sobreescribirse los recursos existentes por las nuevas descargas en caso de ser los mismos - */ - private boolean overwrite = false; + private String fileType; - /** - * Intervalo de espera entre descargas, en milisegundos - */ - private int delay = 2000; + private String language; + + private URL urlBase; + + private String savePath; + + private String zipsPath; + private boolean overwrite; + + private int delay; + + private boolean unzip; + + private int maxFilesToDownload; + + private DownloadEngineType engineType; + + /** - * Si se deben descomprimir los archivos descargados + * Main constructor. It initializes the object with default values: + *
      + *
    • fileType: txt
    • + *
    • language: es
    • + *
    • savePath: System.getProperty("user.dir")
    • + *
    • overwrite: false
    • + *
    • delay: 2000 milliseconds
    • + *
    • unzip: true
    • + *
    • maxFilesToDownload: 10 (0 for download all existing)
    • + *
    • engineType: DownloadEngineType.HTTP_CONNECTION
    • + *
    */ - private boolean unzip = true; + public DownloadParams() { + fileType = "txt"; + language = "es"; + buildHarvestURL(); + savePath = System.getProperty("user.dir") + FILE_SEPARATOR; + setZipsPath(); + overwrite = false; + delay = 2000; + unzip = true; + maxFilesToDownload = 10; + engineType = DownloadEngineType.HTTP_CONNECTION; + } + /** - * Número maximo de ficheros a descargar. El valor cero indica descargar todos los ficheros disponibles. + * @return the type of files to download */ - private int maxFilesToDownload = 10; - + public String getFileType() { + return fileType; + } + /** - * Tipo de motor de descarga a utilizar + * Sets the type of file to download. Valid types: txt, epub, html + * @param fileType type of file to download + * @throws GutenbergException if an invalid file type is indicated */ - DownloadEngineType engineType = DownloadEngineType.HTTP_CONNECTION; - - + public void setFileType(String fileType) { + if (!fileType.equals("txt") && !fileType.equals("epub") && !fileType.equals("html")) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: Wrong file type parameter"); + } + this.fileType = fileType; + buildHarvestURL(); + } + /** - * Constructor por defecto. + * @return the language of files to download */ - public DownloadParams() { } + public String getLanguage() { + return language; + } /** - * @return la dirección url inicial del recurso a obtener + * Sets the language of the files to download acording to Gutenberg nomeclature.
    + * Ej.: es - spanish, en - english, fr - french + * @param language type of language + */ + public void setLanguage(String language) { + this.language = language; + buildHarvestURL(); + } + + /** + * @return initial download url */ public URL getUrlBase() { return urlBase; } /** - * Establece la dirección url inicial del recurso a obtener - * @param urlBase dirección url + * Sets initial download url + * @param urlBase url address */ - public void setUrlBase(URL urlBase) { + private void setUrlBase(URL urlBase) { this.urlBase = urlBase; } /** - * @return la ruta de la carpeta en la que obtener los recursos descargados + * @return folder path where to get downloaded resources */ public String getSavePath() { return savePath; } /** - * Establece la ruta de la carpeta en la que obtener los recursos descargados. - * @param savePath ruta de la carpeta en la que obtener los recursos descargados + * Sets folder path where to get downloaded resources + * @param savePath folder path where to get downloaded resources + * @throws GutenbergException if the parameter is null */ public void setSavePath(String savePath) { - this.savePath = savePath; + if (savePath == null) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: The directory path where to save downloads cannot be null"); + } + String path = (!savePath.endsWith(FILE_SEPARATOR)) ? savePath.concat(FILE_SEPARATOR) : savePath; + this.savePath = path; + setZipsPath(); } /** - * @return true si se deben sobreescribir los archivos existentes por los descargados en caso de ser los mismos, false en caso contrario + * @return folder path where to get downloaded zips + */ + public String getZipsPath() { + return zipsPath; + } + + private void setZipsPath() { + this.zipsPath = savePath + "zips" + FILE_SEPARATOR; + } + + /** + * @return true if the existing files must be overwritten by the downloaded ones, false otherwise */ public boolean isOverwrite() { return overwrite; } /** - * Establece si deben sobreescribirse los recursos existentes por las nuevas descargas en caso de ser los mismos - * @param overwrite true si se deben sobreescribir los archivos, false en caso contrario + * Sets if the existing files must be overwritten by the downloaded ones + * @param overwrite true if the existing files must be overwritten, false otherwise */ public void setOverwrite(boolean overwrite) { this.overwrite = overwrite; } /** - * @return el intervalo de espera entre descargas, en milisegundos + * @return delay between downloads, in milliseconds */ public int getDelay() { return delay; } /** - * Establece el intervalo de espera entre descargas. - * @param delay tiempo de espera, en milisegundos + * Sets delay between downloads + * @param delay waiting time, in milliseconds + * @throws GutenbergException if a number less than zero is indicated */ public void setDelay(int delay) { + if (delay < 0) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: Delay parameter cannot be less than zero"); + } this.delay = delay; } /** - * @return true si se deben descomprimir los archivos descargados, false en caso contrario + * @return true if downloaded files must be unzipping, false otherwise */ public boolean isUnzip() { return unzip; } /** - * Establece si se deben descomprimir los archivos descargados - * @param unzip true si se deben descomprimir los archivos descargados, false en caso contrario + * Sets if downloaded files must be unzipping, + * @param unzip true if downloaded files must be unzipping, false otherwise */ public void setUnzip(boolean unzip) { this.unzip = unzip; } /** - * @return el número máximo de ficheros a descargar + * @return the maximum number of files to download */ public int getMaxFilesToDownload() { return maxFilesToDownload; } /** - * Establece el número máximo de ficheros a descargar. El valor cero indica descargar todos los ficheros disponibles. - * @param maxFilesToDownload número máximo de ficheros + * Sets the maximum number of files to download. The zero indicates downloading all available files. + * @param maxFilesToDownload files number + * @throws GutenbergException if a number less than zero is indicated */ public void setMaxFilesToDownload(int maxFilesToDownload) { - this.maxFilesToDownload = maxFilesToDownload; + if (maxFilesToDownload < 0) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: MaxFilesToDownload parameter cannot be less than zero"); + } + this.maxFilesToDownload = (maxFilesToDownload == 0) ? Integer.MAX_VALUE : maxFilesToDownload; } /** - * @return el tipo de motor de descarga a utilizar + * @return the type of downloading engine to use + * @see DownloadEngineType */ public DownloadEngineType getEngineType() { return engineType; } /** - * Establece el tipo de motor de descarga a utilizar - * @param engineType tipo de motor de descarga a utilizar + * Sets the type of downloading engine to use + * @param engineType engine type + * @see DownloadEngineType */ public void setEngineType(DownloadEngineType engineType) { this.engineType = engineType; } + + /** + * Build the main url from which to download the books + */ + private void buildHarvestURL() { + String queryParams = "harvest?filetypes[]=" + getFileType() + "&langs[]=" + getLanguage(); + String url = URL_BOOKS + queryParams; + try { + setUrlBase(new URL(url)); + } catch (MalformedURLException e) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: Wrong base URL: " + url); + } catch (Exception e) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: Cannot create base URL: " + url); + } + } } diff --git a/src/main/java/org/josfranmc/gutenberg/download/DownloadSoft.java b/src/main/java/org/josfranmc/gutenberg/download/DownloadSoft.java deleted file mode 100644 index 0a980b5..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/DownloadSoft.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.josfranmc.gutenberg.download; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Iterator; - -import org.apache.log4j.Logger; -import org.josfranmc.gutenberg.download.engine.DownloadEngineFactory; -import org.josfranmc.gutenberg.download.engine.DownloadResult; -import org.josfranmc.gutenberg.util.FileScraping; - -/** - * Realiza el proceso de descarga de los libros de forma no "avariciosa". Es decir, los recursos se van descargando secuencialmente dejando un tiempo - * de espera entre cada descarga.
    - * Esta es la forma correcta de llevar a cabo el proceso de descarga de los libros alojados en los servidores del proyecto Gutenberg, no haciendo un - * uso abusivo de los recursos y servicios ofrecidos.

    - * Más info: http://www.gutenberg.org/wiki/Gutenberg:Information_About_Robot_Access_to_our_Pages - * @author Jose Francisco Mena Ceca - * @version 1.0 - * @see AbstractDownload - * @see DownloadParams - */ -public class DownloadSoft extends AbstractDownload { - - private static final Logger log = Logger.getLogger(DownloadSoft.class); - - /** - * Número de libros descargados - */ - private int finishedDownload = 0; - - - /** - * Constructor por defecto. - */ - public DownloadSoft() { - super(); - } - - /** - * Realiza la configuración necesaria para realizar las descargas.
    - *

      - *
    • Se crea un motor de descarga y se le indica la url a descargar y la ruta de la carpeta en la que obtener el recuro.
    • - *
    • Se guarda la url inicial a descargar como url base para el resto de descargas si las hubiera
    • - *
    • Se establece el tiempo de espera entre descargas
    • - *
    • Se indica si deben sobreescribirse los recursos ya existentes por los descargados en caso de ser los mismos
    • - * @param dp parametros de configuración de las descargas establecidos por el cliente - * @see DownloadParams - *
    - */ - @Override - protected void configDownload(DownloadParams dp) { - downloadEngine = DownloadEngineFactory.create(dp.getEngineType()); - downloadEngine.setResource(dp.getUrlBase()); - downloadEngine.setSavePath(dp.getSavePath()); - setUrlBase(dp.getUrlBase()); - setDelay(dp.getDelay()); - setOverwrite(dp.isOverwrite()); - setMaxFilesToDownload(dp.getMaxFilesToDownload()); - } - - /** - * Procesa un fichero que es una página web que contiene los enlaces a los zips de los libros a obtener.

    Recupera en una lista los enlaces de la - * página y luego los va descargando uno a uno. El último enlace leido es la dirección de la siguiente página a procesar. Cuando se lee este enlace - * se descarga la siguiente página con enlaces a libros y se llama recursivamente al método para realizar su descargaa. El proceso continua - * hasta que no existen más páginas con enlaces que procesar - * @param file nombre del fichero de la página web que contiene los enlaces de los zips a descargar - */ - @Override - protected void processPage(String file) { - boolean error = false; - boolean isNewPage = false; - DownloadResult downloadResult = null; - URL newLinkToProcess = null; - - Iterator it = FileScraping.getLinks(file).iterator(); - while (it.hasNext() && getFinishedDownload() < getMaxFilesToDownload()) { - String link = it.next(); - if (createResource(link)) { - try { - error = false; - isNewPage = false; - newLinkToProcess = new URL(link); - } catch (MalformedURLException e) { - try { - // nueva página que contiene más enlaces. hay que cambiar los & por & para crear correctamente el nuevo enlace - newLinkToProcess = new URL(getUrlBase(), link.toString().replace("&", "&")); - isNewPage = true; - log.info("Nueva url " + newLinkToProcess.toString()); - } catch (MalformedURLException ex) { - error = true; - log.error(ex); - log.error("Imposible obtener URL para " + link); - log.error("newLinkToProcess = " + newLinkToProcess); - log.error("Url Base = " + getUrlBase()); - } - } - if (!error) { - sleepProcess(); - downloadEngine.setResource(newLinkToProcess); - downloadResult = downloadEngine.download(); - if (isNewPage && (downloadResult.getContentType().equals("text/html"))) { - processPage(downloadResult.getFileOutputPath()); - } else { - incrementFinishedDownload(); - } - } - } else { - log.debug("Ya existe el recurso " + link + ". Omitiendo la descarga..."); - } - } - } - - /** - * Pausa la ejecución del proceso el tiempo fijado en el atributo de la clase delay. - */ - private void sleepProcess() { - if (getDelay() > 0) { - try { - Thread.sleep(getDelay()); - } catch (InterruptedException e) { - log.error("Imposible pausar. " + e); - } - } - } - - /** - * @return el número de libros descargados - */ - protected int getFinishedDownload() { - return finishedDownload; - } - - /** - * @param finishedDownload the finishedDownload to set - */ - protected void incrementFinishedDownload() { - this.finishedDownload++; - } - - /** - * @see DownloadMode - */ - @Override - protected DownloadMode getType() { - return DownloadMode.SOFT; - } -} \ No newline at end of file diff --git a/src/main/java/org/josfranmc/gutenberg/download/DownloadThread.java b/src/main/java/org/josfranmc/gutenberg/download/DownloadThread.java new file mode 100644 index 0000000..a5144ea --- /dev/null +++ b/src/main/java/org/josfranmc/gutenberg/download/DownloadThread.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + */ +package org.josfranmc.gutenberg.download; + +import java.net.URL; + +import org.josfranmc.gutenberg.download.engine.DownloadEngineFactory; +import org.josfranmc.gutenberg.download.engine.IDownloadEngine; + +/** + * Downloads a resource.
    + * Objects of this class can be runned in separate threads. + * @author Jose Francisco Mena Ceca + * @version 2.0 + */ +public class DownloadThread implements Runnable { + + private IDownloadEngine downloadEngine; + + /** + * @param target download url + * @param parameters settings + */ + public DownloadThread(URL target, DownloadParams parameters) { + downloadEngine = DownloadEngineFactory.create(target, parameters.getZipsPath(), parameters.getEngineType()); + } + + @Override + public void run() { + downloadEngine.download(); + } + +} diff --git a/src/main/java/org/josfranmc/gutenberg/download/GutenbergException.java b/src/main/java/org/josfranmc/gutenberg/download/GutenbergException.java new file mode 100644 index 0000000..b34188b --- /dev/null +++ b/src/main/java/org/josfranmc/gutenberg/download/GutenbergException.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + */ +package org.josfranmc.gutenberg.download; + +/** + * It allows to capture exceptions in the application in the form of a RuntimeException. + * @author Jose Francisco Mena Ceca + * @version 2.0 + */ +@SuppressWarnings("serial") +public class GutenbergException extends RuntimeException { + + public GutenbergException() { + super(); + } + + public GutenbergException(String message, Throwable cause) { + super(message, cause); + } + + public GutenbergException(String message) { + super(message); + } + + public GutenbergException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/org/josfranmc/gutenberg/download/IGutenbergDownload.java b/src/main/java/org/josfranmc/gutenberg/download/IGutenbergDownload.java deleted file mode 100644 index de66691..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/IGutenbergDownload.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.josfranmc.gutenberg.download; - -import org.josfranmc.gutenberg.download.engine.DownloadEngineType; - -/** - * Establece el interfaz de uso que debe implementarse para llevar a cabo la gestión y desarrollo del proceso de descarga de los libros alojados - * por el proyecto Gutenberg (http://www.gutenberg.org/) - * @author Jose Francisco Mena Ceca - * @version 1.0 - * @see DownloadMode - * @see DownloadEngineType - */ -public interface IGutenbergDownload { - - /** - * Desacarga libros - */ - public void downloadBooks(); - - /** - * @return el modo de descarga utilizado - */ - public DownloadMode getDownloadMode(); - - /** - * Establece el mode de realizar las descargas - * @param mode tipo de descarga DownloadMode - * @see DownloadMode - */ - public void setDownloadMode(DownloadMode mode); - - /** - * Establece el tiempo de espera entre descargas, en milisegundos - * @param delay tiempo de espera entre descargas - */ - public void setDelay(int delay); - - /** - * @return el tiempo de espera entre descargas - */ - public int getDelay(); - - /** - * Establece si se deben sobreescribir los ficheros ya existentes en la carpeta especificada por las nuevas descargas en caso de ser los mismos - * @param value true si se deben sobreescribir los archivos, false en caso contrario - */ - public void setOverwrite(boolean value); - - /** - * @return si está activado/desactivado el indicador de sobreescribir ficheros ya descargados - */ - public boolean isOverwrite(); - - /** - * @return la dirección URL desde donde realizar la descarga de los archivos - */ - public String getUrlBase(); - - /** - * Establece la ruta de la carpeta en la que guardar los archivos descargados - * @param savePath ruta de la carpeta en la que guardar los archivos descargados - */ - public void setSavePath(String savePath); - - /** - * @return la ruta en la que guardar los archivos descargados - */ - public String getSavePath(); - - /** - * Establece si se deben descomprimir los ficheros una vez descargados - * @param value true si se deben descomprimir los archivos descargados, false en caso contrario - */ - public void setUnzip(boolean value); - - /** - * @return true si se deben descomprimir los archivos descargados, false en caso contrario - */ - public boolean isUnzip(); - - /** - * Establece el tipo de ficheros a descargar. Tipos válidos: txt, epub, html - * @param fileType tipo de fichero a desrgargar - * @return una referencia al propio objeto que hace la llamada - * @see IGutenbergDownload - */ - public IGutenbergDownload setFileType(String fileType); - - /** - * @return el tipo de fichero configurado para descargar. - */ - public String getFileType(); - - /** - * Establece el idioma de los ficheros a descargar, según la nomenclatura usada por el proyecto Gutenberg. Ej.: es - español, en - inglés, fr - francés

    - * Más info: http://www.gutenberg.org/catalog/ - * @param language tipod e idioma - * @return una referencia al propio objeto que hace la llamada - * @see IGutenbergDownload - */ - public IGutenbergDownload setLanguage(String language); - - /** - * @return el idioma configurado de los ficheros para descargar. - */ - public String getLanguage(); - - /** - * @return el número máximo de ficheros a descargar - */ - public int getMaxFilesToDownload(); - - /** - * Establece el número máximo de ficheros a descargar - * @param maxFilesToDownload número máximo de ficheros - */ - public void setMaxFilesToDownload(int maxFilesToDownload); - - /** - * Establece el tipo de motor a utilizar para realizar las descargas - * @param engineType tipode motor DownloadEngineType - * @see DownloadEngineType - */ - public void setEngineType(DownloadEngineType engineType); - - /** - * @return el tipo de motor que se está utilizando para realizar las descargas - * @see DownloadEngineType - */ - public DownloadEngineType getEngineType(); -} \ No newline at end of file diff --git a/src/main/java/org/josfranmc/gutenberg/download/JGutenbergDownload.java b/src/main/java/org/josfranmc/gutenberg/download/JGutenbergDownload.java index daad49c..feba99b 100644 --- a/src/main/java/org/josfranmc/gutenberg/download/JGutenbergDownload.java +++ b/src/main/java/org/josfranmc/gutenberg/download/JGutenbergDownload.java @@ -1,8 +1,27 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + * + * This file includes software developed at + * The Apache Software Foundation (http://www.apache.org/). + */ package org.josfranmc.gutenberg.download; import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -12,382 +31,316 @@ import org.josfranmc.gutenberg.util.FileManager; /** - * Implementa el proceso y gestión de descarga de libros alojados por el proyecto Gutenberg (http://www.gutenberg.org) + * It allows to download books from the Gutenberg project repositories.
    + * (http://www.gutenberg.org) * @author Jose Francisco Mena Ceca - * @version 1.0 - * @see IGutenbergDownload + * @version 2.0 * @see DownloadParams - * @see DownloadMode * @see DownloadEngineType + * @see GutenbergException */ -public class JGutenbergDownload implements IGutenbergDownload{ +public class JGutenbergDownload { private static final Logger log = Logger.getLogger(JGutenbergDownload.class); + + private DownloadParams parameters; - /** - * URL base del proyecto Gutenberg para realizar las descargas - */ - private static final String URL_BOOKS = "http://www.gutenberg.org/robot/"; /** - * Nombre de la carpeta dentro de la carpeta base donde guardar los ficheros zips descargados + * Main constructor. It initializes the application with default values. + * @see DownloadParams */ - private static final String ZIP_DIRECTORY = "zips"; + public JGutenbergDownload() { + parameters = new DownloadParams(); + } /** - * Tipo de los ficheros a descargar + * @return an object with the current parameters + * @see DownloadParams */ - private String fileType; + public DownloadParams getParameters() { + return parameters; + } /** - * Idioma de los ficheros a descargar + * Sets the application parameters through a DownloadParams object + * @param parameters application parameters + * @see DownloadParams */ - private String language; + public void setParameters(DownloadParams parameters) { + this.parameters = parameters; + } /** - * Ruta base de la carpeta pasada por parámetro en la que realizar las descargas. - * A lo largo del proceso de descarga la carpeta donde realizarlas puede variar. Esta variable guardar la carpeta inicial del proceso + * Begins the process of downloading books.

    + * If there is any problem It can be thrown GutenbergException + * @throws GutenbergException + * @see GutenbergException */ - private String rootSavePath; + public void downloadBooks() { + printParameters(); + createDirectoriesForDownloads(); + log.info("BEGIN BOOKS DOWNLOAD " + getCurrentTime()); + DownloadBooks downloader = new DownloadBooks(parameters); + log.info("Downloading..."); + downloader.executeDownload(); + if (parameters.isUnzip()) { + log.info("Unzipping files... "); + FileManager.unzipFiles(parameters.getZipsPath(), parameters.getSavePath()); + } + log.info("END BOOKS DOWNLOAD " + getCurrentTime()); + } - /** - * Modo de realizar las descargas - */ - private AbstractDownload downloadMode = null; + private void createDirectoriesForDownloads() { + createBaseDirectory(); + createZipsDirectory(); + } - /** - * Encapsula los parámetros de configuración a usar. Recoge los parámetros pasados y es enviado a los componentes - * encargados de realizar las descargas - */ - private DownloadParams parameters = null; + private void createBaseDirectory() { + File dirPath = new File(parameters.getSavePath()); + if (!dirPath.exists()) { + log.warn("Path doesn't exist. Creating new directory."); + dirPath.mkdirs(); + if (!dirPath.exists()) { + throw new IllegalStateException("Cannot create directory for downloads"); + } + } + } - /** - * Constructor principal. Establece los parámetros de configuración que usa la apliación con valores por defecto. Concretamente: - *

      - *
    • Se establece como carpeta base de descarga la carpeta desde la que se ejecuta el programa
    • - *
    • Se fija un tiempo de demora entre descargas de 2 segundos
    • - *
    • Se establece que no se sobreescriban ficheros previamente descargados
    • - *
    • Se establece que se descompriman los ficheros zips descargados
    • - *
    • Se indica que se utilice un motor de descarga del tipo DownloadEngineType.HTTP_CONNECTION
    • - *
    • Se indica que las descargas se realicen usando un modo DownloadMode.SOFT
    • - *
    • Se indica que se descarguen todos los ficheros disponibles
    • - *
    - * @see DownloadParams - * @see DownloadEngineType - * @see DownloadMode - */ - public JGutenbergDownload() { - parameters = new DownloadParams(); - setSavePath(System.getProperty("user.dir")); - setDelay(2000); - setOverwrite(false); - setUnzip(true); - setEngineType(DownloadEngineType.HTTP_CONNECTION); - setMaxFilesToDownload(10); - setDownloadMode(DownloadMode.SOFT); + private void createZipsDirectory() { + File dirPath = new File(parameters.getZipsPath()); + if (!dirPath.exists()) { + dirPath.mkdirs(); + if (!dirPath.exists()) { + throw new IllegalStateException("Cannot create directory for zips"); + } + } } /** - * Inicia el proceso de descarga de los libros.
    - * Crea una carpeta para guardar los zip descargados dentro de la carpeta indicada para almacenar descargar las descargas. - * - * Se comprueba si se ha indicado el tipo de ficheros a descargar y el idioma de los mismos. - * Si no se se han indicado no se puede realizar la descarga. - * @throws IllegalArgumentException si no se ha indicado tipo de fichero e idioma + * @return the type of files to download */ - @Override - public void downloadBooks() { - if (isUrlParameters()) { - buildHarvestURL(); - log.info("INICIO DESCARGA LIBROS " + getCurrentTime()); - writeParamsLog(); - download(); - if (parameters.isUnzip()) { - unzipFiles(); - } - log.info("FIN DESCARGA LIBROS " + getCurrentTime()); - } else { - log.error("Es necesario indicar tipo de fichero e idioma"); - throw new IllegalArgumentException("Es necesario indicar tipo de fichero e idioma"); - } + public String getFileType() { + return parameters.getFileType(); } /** - * Construye la URL principal a partir de la cual realizar las descargas de los libros + * Sets the type of file to download. Valid types: txt, epub, html + * @param fileType type of file to download + * @throws IllegalArgumentException if an invalid file type is indicated */ - private void buildHarvestURL() { - String queryParam = "harvest?filetypes[]=".concat(getFileType()).concat("&langs[]=").concat(getLanguage()); - String url = URL_BOOKS.concat(queryParam); - try { - parameters.setUrlBase(new URL(url)); - } catch (MalformedURLException e) { - log.warn("URL base errónea: " + url); - } catch (Exception e) { - log.error("Imposible inicializar URL base " + url); - e.printStackTrace(); - } + public void setFileType(String fileType) { + parameters.setFileType(fileType); } - + /** - * Lleva a cabo las descargas.
    Primero crea dentro de la carpeta raíz de descargas una nueva carpeta en la que obtener los ficheros - * comprimidos (esta nueva carpeta es la que se le pasa al motor de descargas para guardar los ficheros descargados). - * Después se inicia el proceso de descargas pasándole los parámetros establecidos. + * @return the language of files to download */ - private void download() { - // creamos carpeta para la descarga dentro de la carpeta raíz y la establecemos como parámetro - setSavePathParam(createDirectoryInRootPath(ZIP_DIRECTORY)); - log.info("Descargando..."); - downloadMode.executeDownload(parameters); - // recuperamos la carpeta raíz de descargas como parámetro - setSavePathParam(getRootSavePath()); + public String getLanguage() { + return parameters.getLanguage(); } - + /** - * Descomprime los ficheros zip obtenidos en una nueva carpeta dentro de la carpeta raíz de descargas.
    + * Sets the language of the files to download acording to Gutenberg nomeclature.
    + * Ej.: es - spanish, en - english, fr - french + * @param language type of language */ - private void unzipFiles() { - String zipPath = getRootSavePath().concat(ZIP_DIRECTORY); - String unZipPath = getRootSavePath(); - log.info("DESCOMPRIMIR FICHEROS"); - log.info("Ruta archivos zip: " + zipPath); - log.info("Ruta donde extraer: " + unZipPath); - log.info("Descomprimiendo... "); - FileManager.unzipFiles(zipPath, unZipPath); + public void setLanguage(String language) { + parameters.setLanguage(language); } /** - * Comprueba si se han establecido los parámetros de descarga de tipo de fichero e idioma - * @return true si se han indicado ambos parámetros, false si alguno o ambos no se han indicado + * @return initial download url */ - private boolean isUrlParameters() { - return (fileType != null && language != null && !fileType.isEmpty() && !language.isEmpty()); + public String getUrlBase() { + return parameters.getUrlBase().toString(); } /** - * @return el modo de descarga utilizado + * @return folder path where to get downloaded resources */ - @Override - public DownloadMode getDownloadMode() { - return downloadMode.getType(); + public String getSavePath() { + return parameters.getSavePath(); } /** - * Establece el mode de realizar las descargas - * @see DownloadMode + * Sets folder path where to get downloaded resources + * @param savePath folder path where to get downloaded resources + * @throws IllegalArgumentException if the parameter is null */ - @Override - public void setDownloadMode(DownloadMode mode) { - if (mode == null) { - throw new IllegalArgumentException("El modo de descargar no puede ser null"); - } - downloadMode = DownloadFactory.create(mode); + public void setSavePath(String savePath) { + parameters.setSavePath(savePath); } - + /** - * Establece el tiempo de espera entre descargas, en milisegundos. - * @see DownloadParams + * @return true if the existing files must be overwritten by the downloaded ones, false otherwise */ - @Override - public void setDelay(int delay) { - parameters.setDelay(delay); + public boolean isOverwrite() { + return parameters.isOverwrite(); } /** - * Obtiene el tiempo de espera entre descargas establecido, en milisegundos. - * @return el tiempo de espera entre descargas + * Sets if the existing files must be overwritten by the downloaded ones + * @param value true if the existing files must be overwritten, false otherwise */ - @Override - public int getDelay() { - return parameters.getDelay(); - } - - @Override public void setOverwrite(boolean value) { parameters.setOverwrite(value); } - @Override - public boolean isOverwrite() { - return parameters.isOverwrite(); - } - - @Override - public String getUrlBase() { - String url = null; - if (parameters.getUrlBase() != null) { - url = parameters.getUrlBase().toString(); - } else { - url = "No se ha establecido URL."; - } - return url; - } - /** - * @return la ruta base de la carpeta inicial en la que realizar las descargas + * @return delay between downloads, in milliseconds */ - private String getRootSavePath() { - return rootSavePath; - } - - /** - * Establece la ruta base de la carpeta en la que realizar las descargas. La carpeta indicada será la carpeta raiz del proceso - * @param rootSavePath ruta de la carpeta - */ - private void setRootSavePath(String rootSavePath) { - this.rootSavePath = rootSavePath; + public int getDelay() { + return parameters.getDelay(); } /** - * Establece la ruta de la carpeta en la que guardar los archivos descargados. Se añade el caracter separador de directorios a la final de la - * ruta en caso de que no lo lleve.
    Esta ruta se añade a los parámetros de la aplicación y se establece como ruta raiz del proceso. - * @param savePath ruta de la carpeta - * @throws IllegalArgumentException ruta errónea + * Sets delay between downloads + * @param delay waiting time, in milliseconds */ - @Override - public void setSavePath(String savePath) { - if (savePath == null) { - throw new IllegalArgumentException("La ruta del directorio donde guardar las descargas no puede ser null"); - } - File f = new File(savePath); - if (!f.exists()) { - log.warn("Ruta donde guardar las descargas inexistente. Creando nuevo directorio."); - f.mkdirs(); - if (!f.exists()) { - throw new IllegalArgumentException("Imposible crear direcotrio para descargas"); - } - } - - String fileSeparator = System.getProperty("file.separator"); - String path = (!savePath.endsWith(fileSeparator)) ? savePath.concat(fileSeparator) : savePath; - setSavePathParam(path); - setRootSavePath(path); + public void setDelay(int delay) { + parameters.setDelay(delay); } - + /** - * Asigna al objeto DownloadParams la ruta de una carpeta en la que guardar las descargas. - * @param path ruta de la carpeta - * @see DownloadParams + * @return true if downloaded files must be unzipping, false otherwise */ - private void setSavePathParam(String path) { - parameters.setSavePath(path); - } - - @Override - public String getSavePath() { - return getRootSavePath(); - } - - @Override public boolean isUnzip() { return parameters.isUnzip(); } - @Override + /** + * Sets if downloaded files must be unzipping, + * @param value true if downloaded files must be unzipping, false otherwise + */ public void setUnzip(boolean value) { parameters.setUnzip(value); } - - @Override - public String getFileType() { - return fileType; - } - - @Override - public JGutenbergDownload setFileType(String fileType) { - this.fileType = fileType; - return this; - } - - @Override - public String getLanguage() { - return language; - } - - @Override - public JGutenbergDownload setLanguage(String language) { - this.language = language; - return this; - } /** - * @return el número máximo de ficheros a descargar + * @return the maximum number of files to download */ - @Override public int getMaxFilesToDownload() { return parameters.getMaxFilesToDownload(); } /** - * Establece el número máximo de ficheros a descargar - * @param maxFilesToDownload número máximo de ficheros - * @throws IllegalArgumentException si se indica un número inferior a cero + * Sets the maximum number of files to download. The zero indicates downloading all available files. + * @param maxFilesToDownload files number + * @throws IllegalArgumentException if a number less than zero is indicated */ - @Override public void setMaxFilesToDownload(int maxFilesToDownload) { - if (maxFilesToDownload < 0) { - throw new IllegalArgumentException("maxFilesToDownload no puede ser inferior a cero"); - } parameters.setMaxFilesToDownload(maxFilesToDownload); } /** + * @return the type of downloading engine to use * @see DownloadEngineType */ - @Override public DownloadEngineType getEngineType() { return parameters.getEngineType(); } /** - * Establece el tipo de motor a utilizar para realizar las descargas.
    - * Lo asigna al atributo que encapsula los parámetros de la aplicación + * Sets the type of downloading engine to use + * @param engineType engine type * @see DownloadEngineType */ - @Override public void setEngineType(DownloadEngineType engineType) { parameters.setEngineType(engineType); } + + private String getCurrentTime() { + Date date = new Date(); + DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy"); + return hourFormat.format(date); + } + + private void printParameters() { + log.info("PARAMETERS:"); + log.info(" urlBase = " + parameters.getUrlBase().toString()); + log.info(" savePath = " + parameters.getSavePath()); + log.info(" overwrite = " + parameters.isOverwrite()); + log.info(" delay = " + parameters.getDelay()); + log.info(" unzip = " + parameters.isUnzip()); + String max = (parameters.getMaxFilesToDownload() == 0) ? "all" : Integer.toString(parameters.getMaxFilesToDownload()); + log.info(" maxDownloads = " + max); + } /** - * Crea un nuevo directorio dentro de la carpeta base especificada para guardar las descargas. - * La carpeta creada se convierte en la nueva carpeta base. apuntada por el parámetro savePath y actualiza dicho parámetro - * con la nueva ruta - * @param nameDirectory nombre del directorio a crear + * Main method for running the application. + * @param args list of arguments with application parameters */ - private String createDirectoryInRootPath(String nameDirectory) { - String fileSeparator = System.getProperty("file.separator"); - String savePath = getRootSavePath(); // parameters.getSavePath(); - if (savePath != null) { - savePath = savePath.concat(nameDirectory).concat(fileSeparator); + public static void main(String [] args){ + if (args.length == 0 || (args[0].equals("-h") || args[0].equals("-help"))) { + showHelp(); } else { - savePath = System.getProperty("user.dir").concat(nameDirectory).concat(fileSeparator); + DownloadParams params = getParametersFromCommandLine(args); + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setParameters(params); + jg.downloadBooks(); } - File dirPath = new File(savePath); - dirPath.mkdirs(); - if (!dirPath.exists()) { - log.warn("Imposible crear ruta " + savePath); - return null; - } - //parameters.setSavePath(savePath); - return savePath; } - private String getCurrentTime() { - Date date = new Date(); - DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy"); - return hourFormat.format(date); + /** + * Reads settings parameters from command line.
    + * Throws an Exception if there is any error. + * @param args list of parameters obtained from the command line + * @return a DownloadParams object. + */ + private static DownloadParams getParametersFromCommandLine(String [] args) { + DownloadParams params = new DownloadParams(); + int i = 0; + int step = 0; + while (i < args.length) { + try { + if (args[i].startsWith("-f")) { + params.setFileType(args[i+1]); + step = 2; + } else if (args[i].equals("-l")) { + params.setLanguage(args[i+1]); + step = 2; + } else if (args[i].equals("-s")) { + params.setSavePath(args[i+1]); + step = 2; + } else if (args[i].equals("-d")) { + params.setDelay(Integer.parseInt(args[i+1])); + step = 2; + } else if (args[i].equals("-m")) { + params.setMaxFilesToDownload(Integer.parseInt(args[i+1])); + step = 2; + } else if (args[i].equals("-o")) { + params.setOverwrite(true); + step = 1; + } else if (args[i].equals("-z")) { + params.setUnzip(false); + step = 1; + } else { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: Parameter " + args[i]); + } + } catch (ArrayIndexOutOfBoundsException a) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: Parameter " + args[i]); + } catch (Exception e) { + throw e; + } + i+=step; + } + return params; } - private void writeParamsLog() { - log.info("Parámetros:"); - log.info(" urlBase = " + parameters.getUrlBase().toString()); - log.info(" savePath = " + parameters.getSavePath()); - log.info(" overwrite = " + parameters.isOverwrite()); - if (downloadMode.getType() == DownloadMode.SOFT) { - log.info(" delay = " + parameters.getDelay()); - } - log.info(" unzip = " + parameters.isUnzip()); - log.info(" engineType = " + parameters.getEngineType().toString()); - log.info(" downloadType = " + downloadMode.getType()); + private static void showHelp() { + log.info(""); + log.info("Usage: java -jar JGutenbergDownload [options]"); + log.info("Options:"); + log.info(" -f xxx (xxx type of files to download, default: txt)"); + log.info(" -l xx (xx language of books to download, default: es)"); + log.info(" -s xxx (xxx download path on local machine, default: program folder)"); + log.info(" -d xxx (xxx delay between downloads in milliseconds, default 2000)"); + log.info(" -m xx (xx max number of downloads (default 10, 0 for dowload all)"); + log.info(" -o ( overwrite existing files, default: false)"); + log.info(" -z ( don't unzip downloads, default: true)"); + log.info(""); + log.info("(only -h to show options list)"); + log.info(""); } } diff --git a/src/main/java/org/josfranmc/gutenberg/download/JGutenbergDownloadFactory.java b/src/main/java/org/josfranmc/gutenberg/download/JGutenbergDownloadFactory.java deleted file mode 100644 index cf46b64..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/JGutenbergDownloadFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.josfranmc.gutenberg.download; - -/** - * Factoría que crea objetos de tipo IGutenbergDownload, los cuales implementan los servicios necesarios para la gestión y desarrollo - * del proceso de descarga de libros alojados por el proyecto Gutenberg. - * @author Jose Francisco Mena Ceca - * @version 1.0 - * @see IGutenbergDownload - * @see JGutenbergDownload - */ -public class JGutenbergDownloadFactory { - - /** - * Crea un objeto JGutenbergDownload que implementa toda la funcionalidad necesaria para la descarga de libros - * @return objeto del tipo IGutenbergDownload - * @see IGutenbergDownload - */ - public static IGutenbergDownload create() { - return new JGutenbergDownload(); - } -} diff --git a/src/main/java/org/josfranmc/gutenberg/download/client/JGutenbergDownloadClient.java b/src/main/java/org/josfranmc/gutenberg/download/client/JGutenbergDownloadClient.java deleted file mode 100644 index 890d312..0000000 --- a/src/main/java/org/josfranmc/gutenberg/download/client/JGutenbergDownloadClient.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.josfranmc.gutenberg.download.client; - -import org.apache.log4j.Logger; -import org.josfranmc.gutenberg.download.DownloadMode; -import org.josfranmc.gutenberg.download.DownloadParams; -import org.josfranmc.gutenberg.download.IGutenbergDownload; -import org.josfranmc.gutenberg.download.JGutenbergDownloadFactory; -import org.josfranmc.gutenberg.download.engine.DownloadEngineType; - -/** - * Clase que permite ejecutar un progrma cliente para realiza descargas de libros desde los repositorios del proyecto Gutenberg. - * @author Jose Francisco Mena Ceca - * @version 1.0 - */ -public class JGutenbergDownloadClient { - - private static final Logger log = Logger.getLogger(JGutenbergDownloadClient.class); - - private static IGutenbergDownload jg = null; - - private static String fileType = null; - - private static String language = null; - - private static DownloadMode downloadMode = null; - - private static DownloadParams params = null; - - - /** - * Método principal de ejecución. - * @param args lista de argumentos pasados en la invocación del programa - */ - public static void main(String [] args){ - - if (readParameters(args)) { - jg = JGutenbergDownloadFactory.create(); - - fileType = (fileType == null) ? "txt" : fileType; - jg.setFileType(fileType); - language = (language == null) ? "en" : language; - jg.setLanguage(language); - jg.setSavePath(params.getSavePath()); - jg.setOverwrite(params.isOverwrite()); - jg.setDelay(params.getDelay()); - jg.setUnzip(params.isUnzip()); - jg.setMaxFilesToDownload(params.getMaxFilesToDownload()); - jg.setEngineType(params.getEngineType()); - if (downloadMode != null) { - jg.setDownloadMode(downloadMode); - } - - jg.downloadBooks(); - } - System.exit(0); - } - - /** - * Lee los parámetros de configuración pasados como argumentos. - * @param args lista de parámetros con los valores que toman - * @return true si no hay ningún error, false en caso contrario - */ - private static boolean readParameters(String [] args) { - log.debug("Total parámetros: " + args.length); - boolean result = true; - if (args.length == 0 || (args[0].equals("-h") || args[0].equals("-help"))) { - showHelp(); - result = false; - } else { - params = new DownloadParams(); - for (int i = 0; i < args.length; i+=2) { - try { - log.debug("argumento " + args[i] + " valor " + args[i+1]); - if (args[i].startsWith("-t")) { - fileType = args[i+1]; - } else if (args[i].equals("-i")) { - language = args[i+1]; - } else if (args[i].equals("-d")) { - params.setDelay(Integer.parseInt(args[i+1])); - } else if (args[i].equals("-s")) { - params.setSavePath(args[i+1]); - } else if (args[i].equals("-m")) { - params.setMaxFilesToDownload(Integer.parseInt(args[i+1])); - } else if (args[i].equals("-z")) { - params.setUnzip(Boolean.valueOf(args[i+1])); - } else if (args[i].equals("-o")) { - params.setOverwrite(Boolean.valueOf(args[i+1])); - } else if (args[i].equals("-e")) { - params.setEngineType(DownloadEngineType.valueOf(args[i+1].toUpperCase())); - } else if (args[i].equals("-x")) { - downloadMode = DownloadMode.valueOf(args[i+1].toUpperCase()); - } else { - System.out.println("Parámetro: " + args[i] + " no reconocido. Ejecute JGutenbergDownloadClient -h para listar opciones."); - result = false; - } - } catch (ArrayIndexOutOfBoundsException a) { - result = false; - System.out.println("Error. Número incorrecto de parámetros"); - break; - } - catch (Exception e) { - result = false; - System.out.println("Error al leer parámetro " + i + ". Parámetro = " + args[i] + ", valor = " + args[i+1]); - e.printStackTrace(); - break; - } - } - } - return result; - } - - private static void showHelp() { - System.out.println("Opciones:"); - System.out.println(" -t tipo_fichero (por defecto txt)"); - System.out.println(" -i idioma (por defecto en)"); - System.out.println(" -d tiempo de espera en milisegundos (por defecto 2000)"); - System.out.println(" -s ruta donde depositar las descargas"); - System.out.println(" -m total ficheros a descargar (por defecto 10, el valor 0 descarga todo)"); - System.out.println(" -z descomprimir (true/false, por defecto true)"); - System.out.println(" -o sobreescribir existentes (true/false, por defecto false)"); - System.out.println(" -x modo de descarga (SOFT/GREEDY, por defecto SOFT)"); - System.out.println(""); - System.out.println("(indicar solo -h para mostrar lista de opciones)"); - System.out.println(""); - } -} diff --git a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.java b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.java index 1b8eaba..17debe3 100644 --- a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.java +++ b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineFactory.java @@ -1,91 +1,110 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + */ package org.josfranmc.gutenberg.download.engine; import java.net.URL; /** - * Factoría para la creación de objetos de tipo IDownloadEngine mediante el método create - * Este método está sobregargado, de forma que se puede invocar combinando tres parámetros: + * Factory for creating IDownloadEngine objects.
    + * It make use of the create method. This method is overloaded, so it can be invoked combining three parameters: *
      - *
    • target: recurso a descargar
    • - *
    • savePath: ruta local donde obtener el recurso
    • - *
    • type: tipo de motor a utilizar para la descarga (si no se indica ninguno por defecto se usa DownloadEngineType.HTTTP_CONNECTION)
    • + *
    • target: the url address to download
    • + *
    • savePath: local path where to save download
    • + *
    • type: engine type for downloading (for default DownloadEngineType.HTTTP_CONNECTION is used)
    • *
    * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 */ public class DownloadEngineFactory { + DownloadEngineFactory() { + throw new IllegalStateException("Cannot instantiate class"); + } + /** - * Crea un motor para realizar la descarga de recursos en red. El motor creado es de tipo DownloadEngineType.HTTP_CONNECTION - * @return un motor de descarga + * Creates an engine for downloading. Engine type is DownloadEngineType.HTTP_CONNECTION.
    + * @return a download engine */ public static IDownloadEngine create() { - return createDownloadEngine(null,null,DownloadEngineType.HTTP_CONNECTION); + return createDownloadEngine(null, null, DownloadEngineType.HTTP_CONNECTION); } /** - * Crea un motor determinado para realizar la descarga de recursos en red - * @param type tipo de motor a crear - * @return un motor de descarga + * Creates a download engine of the indicated type.
    + * The url to download and the path where to save are not initialized. + * @param type engine type for downloading + * @return a download engine in the form of a IDownloadEngine object */ public static IDownloadEngine create(DownloadEngineType type) { - return createDownloadEngine(null,null,type); + return createDownloadEngine(null, null, type); } /** - * Crea un motor determinado para realizar la descarga desde una determinada URL - * @param target dirección URL - * @param type tipo de motor a crear - * @return un motor de descarga + * Creates a download engine of the indicated type for downloading an url.
    + * The path where to save the download is not initialized. + * @param target the url address to download + * @param type engine type for downloading + * @return a download engine in the form of a IDownloadEngine object */ public static IDownloadEngine create(URL target, DownloadEngineType type) { - return createDownloadEngine(target,null,type); + return createDownloadEngine(target, null, type); } /** - * Crea un motor para realizar la descarga desde una determinada URL. El motor creado es de tipo DownloadEngineType.HTTP_CONNECTION - * @param target dirección URL - * @return un motor de descarga + * Creates an engine for downloading an url. Engine type is DownloadEngineType.HTTP_CONNECTION.
    + * @param target the url address to download + * @return a download engine in the form of a IDownloadEngine object */ public static IDownloadEngine create(URL target) { - return createDownloadEngine(target,null,DownloadEngineType.HTTP_CONNECTION); + return createDownloadEngine(target, null, DownloadEngineType.HTTP_CONNECTION); } /** - * Crea un motor determinado para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local - * @param target dirección URL - * @param savePath ruta donde obtener las descargas - * @param type tipo de motor a crear - * @return un motor de descarga + * Creates an engine for downloading. + * @param target the url address to download + * @param savePath local path where to save download + * @param type engine type for downloading + * @return a download engine in the form of a IDownloadEngine object */ public static IDownloadEngine create(URL target, String savePath, DownloadEngineType type) { - return createDownloadEngine(target,savePath,type); + return createDownloadEngine(target, savePath, type); } - + /** - * Crea un motor para realizar la descarga desde una determinada URL, guardando lo descargado en una ruta del equipo local. - * El motor creado es de tipo DownloadEngineType.HTTP_CONNECTION. - * @param target dirección URL - * @param savePath ruta donde obtener las descargas - * @return un motor de descarga + * Creates an engine for downloading. Engine type is DownloadEngineType.HTTP_CONNECTION.
    + * @param target the url address to download + * @param savePath local path where to save download + * @return a download engine in the form of a IDownloadEngine object */ public static IDownloadEngine create(URL target, String savePath) { - return createDownloadEngine(target,savePath,DownloadEngineType.HTTP_CONNECTION); + return createDownloadEngine(target, savePath, DownloadEngineType.HTTP_CONNECTION); } + /** + * Creates an engine for downloading.

    + * por ahora type solo puede tomar el valor DownloadEngineType.HTTP_CONNECTION por lo que creamos directamente un objeto de esta clase + * @param target the url address to download + * @param savePath local path where to save download + * @param type engine type for downloading + * @return a download engine in the form of a IDownloadEngine object + */ private static IDownloadEngine createDownloadEngine(URL target, String savePath, DownloadEngineType type) { - IDownloadEngine downloadEngine = null; - type = (type == null) ? DownloadEngineType.HTTP_CONNECTION : type; - - switch (type) { - case HTTP_CONNECTION: - downloadEngine = DownloadHttpUrlConnection.newInstance(target, savePath); - break; - - default: - downloadEngine = DownloadHttpUrlConnection.newInstance(target, savePath); - break; - } - return downloadEngine; + return DownloadHttpUrlConnection.newInstance(target, savePath); } } \ No newline at end of file diff --git a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineType.java b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineType.java index 0c6c6f5..2efe9f8 100644 --- a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineType.java +++ b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadEngineType.java @@ -1,14 +1,32 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + */ package org.josfranmc.gutenberg.download.engine; /** - * Tipos de motores de descarga + * Types of download engines * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 */ public enum DownloadEngineType { /** - * Descargas basadas en el objeto java.net.HttpURLConnection + * Downloads based on the java.net.HttpURLConnection object */ HTTP_CONNECTION; diff --git a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.java b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.java index 8af9286..95813f8 100644 --- a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.java +++ b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnection.java @@ -1,7 +1,27 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + * + * This file includes software developed at + * The Apache Software Foundation (http://www.apache.org/). + */ package org.josfranmc.gutenberg.download.engine; import java.io.BufferedOutputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -12,39 +32,36 @@ import java.net.UnknownHostException; import org.apache.log4j.Logger; +import org.josfranmc.gutenberg.download.GutenbergException; import org.josfranmc.gutenberg.util.FileManager; /** - * Permite realizar la descarga de un recurso identificado por una URL. Para ello se hace uso de la clase java.net.HttpURLConnection.
    - * El recurso descargado se guarda en la ruta que ha debido establecerse previamente a la descarga. + * Allows to download a resource identified by an url and save it in a local folder.
    + * It makes use of the java.net.HttpURLConnection class for downloading.
    * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 * @see IDownloadEngine + * @see GutenbergException */ public class DownloadHttpUrlConnection implements IDownloadEngine { private static final Logger log = Logger.getLogger(DownloadHttpUrlConnection.class); /** - * Dirección URL del recurso a descargar + * the url of the resource to download */ private URL resource; /** - * Ruta de la carpeta en la que obtener el recurso descargado + * local path where to save the resource to be download */ private String savePath; - /** - * Conexión establecida - */ - private HttpURLConnection httpConnection = null; - /** - * Constructor. Incializa el objeto con la dirección URL de un recurso a descargar y la ruta de la carpeta donde obtenerlo. - * @param target direccion URL del recurso a descargar - * @param savePath ruta de la carpeta en la qu obtener la descarga + * Initializes an object with the url of the resource to download and the path where to save it. + * @param target resource url to download + * @param savePath path where to save the download */ private DownloadHttpUrlConnection(URL target, String savePath) { setSavePath(savePath); @@ -52,10 +69,10 @@ private DownloadHttpUrlConnection(URL target, String savePath) { } /** - * Crea una instancia DownloadHttpUrlConnection de tipo IDownloadEngine. - * @param target direccion URL del recurso a descargar - * @param savePath ruta de la carpeta en la qu obtener la descarga - * @return una instancia de tipo IDownloadEngine + * Creates a DownloadHttpUrlConnection object which is an IDownloadEngine type instance. + * @param target resource url to download + * @param savePath path where to save the download + * @return an IDownloadEngine instance in the form of a DownloadHttpUrlConnection * @see IDownloadEngine */ public static IDownloadEngine newInstance(URL target, String savePath) { @@ -63,9 +80,10 @@ public static IDownloadEngine newInstance(URL target, String savePath) { } /** - * Configura los valores de la cabecera que se va a enviar en la petición. + * Sets up the header values that will be sended along with the request. + * @throws ProtocolException */ - private void configHeader() throws ProtocolException { + private void configHeader(HttpURLConnection httpConnection) throws ProtocolException { httpConnection.setRequestMethod("GET"); httpConnection.setRequestProperty("Content-Type", ""); httpConnection.setRequestProperty("Host", getResource().getHost()); @@ -80,76 +98,72 @@ private void configHeader() throws ProtocolException { } /** - * Ejecuta el proceso de descarga. Previamente se ha debido indicar la dirección del recurso a descargar y la ruta de la carpeta en la que obtenerlo.
    - * Si la descarga es correcta, se obtiene en la carpeta indicada un nuevo fichero cuyo nombre es el nombre delfichero contenido en el enlace de descarga - * (se toma desde el último caracter separador de directorios) - * @return el resultado de la descarga encapsulado en un objeto de tipo DownloadResult + * Runs a download.

    + * Previously, it has been necessary to indicate the url address of the resource to download and the path of the folder in which to save it.
    + * If the download is correct a new file in the indicated folder is obtained. The file name is extracted from download link, + * beginning from the last directory separator character. + * @return the result of the download in the form of a DownloadResult object + * @throws GutenbergException if there is any error downloading * @see DownloadResult */ @Override public DownloadResult download() { + DownloadResult downloadResult = new DownloadResult(); + if (getResource() != null && getSavePath() != null) { - BufferedOutputStream fileOutputStream = null; + + HttpURLConnection httpConnection = null; try { httpConnection = (HttpURLConnection) getResource().openConnection(); - configHeader(); - InputStream inputStream = null; - int offset = 0; - final byte[] buffer = new byte[2048]; - int read = 0; - - String fileOutputPath = FileManager.getLocalFilePathFromURL(getSavePath(), getResource().toString()); - inputStream = httpConnection.getInputStream(); - fileOutputStream = new BufferedOutputStream (new FileOutputStream(fileOutputPath)); + configHeader(httpConnection); + + String outputFilePath = FileManager.getLocalFilePathFromURL(getSavePath(), getResource().toString()); + + InputStream inputStream = httpConnection.getInputStream(); + + try (BufferedOutputStream outputFileStream = new BufferedOutputStream (new FileOutputStream(outputFilePath))) { + + copyResource(inputStream, outputFileStream); - log.debug("Download Desde: " + this.resource); - - while ((read = inputStream.read(buffer)) >= 0) { - fileOutputStream.write(buffer, offset, read); - fileOutputStream.flush(); - } - - downloadResult.setHeaders(httpConnection); - downloadResult.setFileOutputPath(fileOutputPath); - - log.debug("Descargado \"" + FileManager.getLocalFileName(fileOutputPath) + "\" en " + getSavePath()); + downloadResult.setHeaders(httpConnection); + downloadResult.setSavedFilePath(outputFilePath); + } + log.debug("Descargado \"" + FileManager.getLocalFileName(outputFilePath) + "\" en " + getSavePath()); log.debug("Tipo: " + downloadResult.getContentType() + " Longitud: " + downloadResult.getContentLength()); - } catch (ConnectException e) { - log.error("Tiempo de espera superado"); - downloadResult.setFileOutputPath(null); - } catch (UnknownHostException e) { - log.error("No puede obtenerse dirección IP del recurso a descarga"); - downloadResult.setFileOutputPath(null); - downloadResult.setError("No puede obtenerse dirección IP del recurso a descarga"); - } catch (FileNotFoundException e) { - log.error("Recurso desconocido... " + getResource().toString()); - downloadResult.setFileOutputPath(null); - downloadResult.setError("Recurso desconocido... " + getResource().toString()); + } catch (ConnectException e) { + log.warn("Download timeout exceeded"); + } catch (UnknownHostException e) { + log.error("[ERROR] UnknownHostException in download engine"); + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: UnknownHostException in download engine", e); } catch (IOException e) { - log.error("Error download " + resource.toString()); - downloadResult.setError("Error download " + resource.toString()); + log.error("[ERROR] IOException in download engine"); + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: IOException in download engine", e); } finally { - httpConnection.disconnect(); - if (fileOutputStream != null) { - try { - fileOutputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - System.exit(0); - } + if (httpConnection != null) { + httpConnection.disconnect(); } } } else { - log.warn("DOWNLOAD Debe indicarse recurso y ruta donde obtener la descarga"); + log.warn("[WARN] ENGINE It must be indicated resource and route where to obtain the download"); } return downloadResult; } + private void copyResource(InputStream inputStream, BufferedOutputStream outputFileStream) throws IOException { + int offset = 0; + final byte[] buffer = new byte[2048]; + int read = 0; + while ((read = inputStream.read(buffer)) >= 0) { + outputFileStream.write(buffer, offset, read); + outputFileStream.flush(); + } + } + /** - * Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL - * @param resource dirección url + * Sets the resource of the url to download, in the form of a URL object + * @param resource url address */ @Override public void setResource(URL resource) { @@ -157,8 +171,7 @@ public void setResource(URL resource) { } /** - * Obtiene la dirección del recurso a descargar como un objeto de tipo URL - * @return dirección del recurso a descargar + * @return the resource of the url to download, in the form of a URL object */ @Override public URL getResource() { @@ -166,8 +179,8 @@ public URL getResource() { } /** - * Establece la ruta donde guardar el recurso a descargar - * @param savePath ruta de la carpeta donde guardar + * Sets the local path where to save the resource to be download + * @param savePath local path */ @Override public void setSavePath(String savePath) { @@ -175,8 +188,7 @@ public void setSavePath(String savePath) { } /** - * Obtiene la ruta donde guardar el recursos a descargar - * @return la ruta de la carpeta donde guardar el recursos a descargar + * @return the local path where to save the resource to be download */ @Override public String getSavePath() { diff --git a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadResult.java b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadResult.java index be5d0eb..fa7d928 100644 --- a/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadResult.java +++ b/src/main/java/org/josfranmc/gutenberg/download/engine/DownloadResult.java @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + */ package org.josfranmc.gutenberg.download.engine; import java.net.URLConnection; @@ -5,108 +23,83 @@ import java.util.Map; /** - * Encapsula el resultado de la descarga de un recurso. Esta clase sirve para guardar juntos diferentes datos realacionados con la descarga - * de un recurso: la cabecera devuelta en la conexión y el nombre del fichero creado, junto con su ruta. Además, si se ha producido algún error - * puede indicarse un mensaje descriptivo del mismo. - * + * It encapsulates the result of downloading a resource. This class serves to save together different data related to the download: + * the header returned in the connection and the name of the file created, along with its path. * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 */ public class DownloadResult { /** - * Ruta del fichero descargado + * the path of the downloaded file on the local machine. */ - private String fileOutputPath; + private String savedFilePath; /** - * Conjunto de cabeceras obtenido como respuesta a una conexión establecida + * Header obtained in response to a connection */ private Map> headers; - - /** - * Mensaje de error - */ - private String error; - - /** - * Constructor principal. - */ + + public DownloadResult() { - fileOutputPath = null; + savedFilePath = null; headers = null; - error = null; } /** - * Establece la colección de campos de cabecera devuelta por una conexión realizada - * @param urlConnection conexión + * Sets the header obtained in response to a connection + * @param urlConnection connection made */ public void setHeaders(URLConnection urlConnection) { headers = urlConnection.getHeaderFields(); - /*Set keys = headers.keySet(); - for (String key : keys) { - String val = urlConnection.getHeaderField(key); - System.out.println(key+" | "+val); - }*/ +// Set keys = headers.keySet(); +// for (String key : keys) { +// String val = urlConnection.getHeaderField(key); +// System.out.println(key+" | "+val); +// } } /** * - * @return la colección de las cabeceras obtenidas + * @return the header obtained in response to a connection */ public Map> getHeaders() { return headers; } /** - * @return el valor del campo de la cebecera "Last-Modified" + * @return the value of the header field "Last-Modified" */ public String getLastModified() { - return (headers != null) ? headers.get("Last-Modified").get(0).toString() : null; + return (headers != null) ? headers.get("Last-Modified").get(0) : ""; } /** - * @return el valor del campo de la cebecera "Content-Type" + * @return the value of the header field "Content-Type" */ public String getContentType() { - return (headers != null) ? headers.get("Content-Type").get(0).toString() : null; + return (headers != null) ? headers.get("Content-Type").get(0) : ""; } /** - * @return el valor del campo de la cebecera "Content-Length" + * @return the value of the header field "Content-Length" */ public String getContentLength() { - return (headers != null) ? headers.get("Content-Length").get(0).toString() : null; + return (headers != null) ? headers.get("Content-Length").get(0) : ""; } /** - * Establece la ruta del fichero descargado. - * @param fileOutputPath ruta del fichero descargado + * Sets the path of the downloaded file on the local machine. + * @param fileOutputPath path of the downloaded file */ - public void setFileOutputPath(String fileOutputPath) { - this.fileOutputPath = fileOutputPath; + public void setSavedFilePath(String fileOutputPath) { + this.savedFilePath = fileOutputPath; } /** - * @return la ruta del fichero descargado - */ - public String getFileOutputPath() { - return fileOutputPath; - } - - /** - * @return el emnsaje de error establecido - */ - public String getError() { - return error; - } - - /** - * Establece un mensaje de error. - * @param error mensaje + * @return the path of the downloaded file on the local machine. */ - public void setError(String error) { - this.error = error; + public String getSavedFilePath() { + return savedFilePath; } } diff --git a/src/main/java/org/josfranmc/gutenberg/download/engine/IDownloadEngine.java b/src/main/java/org/josfranmc/gutenberg/download/engine/IDownloadEngine.java index c1495fb..84b2a2e 100644 --- a/src/main/java/org/josfranmc/gutenberg/download/engine/IDownloadEngine.java +++ b/src/main/java/org/josfranmc/gutenberg/download/engine/IDownloadEngine.java @@ -1,44 +1,63 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + */ package org.josfranmc.gutenberg.download.engine; import java.net.URL; +import org.josfranmc.gutenberg.download.GutenbergException; + /** - * Define el comportamiento que tiene que ofrecer toda clase que quiera implementar la capacidad de descargar - * un recurso identificado por una URL - * + * Defines the behavior that a class have to implement in order to have the ability to download resources on net. * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 + * @see IDownloadEngine + * @see GutenbergException */ public interface IDownloadEngine { /** - * Ejecuta el proceso de descarga. - * @return el resultado de la descarga encapsulado en un objeto de tipo DownloadResult + * Runs a download. + * @return the result of the download in the form of a DownloadResult object + * @throws GutenbergException if there is any error downloading * @see DownloadResult */ public DownloadResult download(); /** - * Establece la dirección del recurso a descargar, la cual se maneja como un objeto de tipo URL - * @param resource dirección del recurso que se quiere obtener + * Sets the resource of the url to download, in the form of a URL object + * @param resource url address */ public void setResource(URL resource); /** - * Obtiene la dirección del recurso a descargar como un objeto de tipo URL - * @return dirección del recurso a descargar + * @return the resource of the url to download, in the form of a URL object */ public URL getResource(); /** - * Establece la ruta donde guardar el recurso a descargar - * @param savePath ruta donde guardar + * Sets the local path where to save the resource to be download + * @param savePath local path */ public void setSavePath(String savePath); /** - * Obtiene la ruta donde guardar el recursos a descargar - * @return ruta donde guardar + * @return the local path where to save the resource to be download */ public String getSavePath(); diff --git a/src/main/java/org/josfranmc/gutenberg/util/FileManager.java b/src/main/java/org/josfranmc/gutenberg/util/FileManager.java index d3d7161..83c08e8 100644 --- a/src/main/java/org/josfranmc/gutenberg/util/FileManager.java +++ b/src/main/java/org/josfranmc/gutenberg/util/FileManager.java @@ -1,132 +1,168 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + * + * This file includes software developed at + * The Apache Software Foundation (http://www.apache.org/). + */ package org.josfranmc.gutenberg.util; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.log4j.Logger; +import org.josfranmc.gutenberg.download.GutenbergException; /** - * Ofrece herramientas para el tratamiento de ficheros. + * Tools for managing files. * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 * */ public class FileManager { - private final static Logger log = Logger.getLogger(FileManager.class); + private static final Logger log = Logger.getLogger(FileManager.class); + + private static final String FILE_SEPARATOR = System.getProperty("file.separator"); - private final static String FILE_SEPARATOR = System.getProperty("file.separator"); + FileManager() { + throw new IllegalStateException("Cannot instantiate class"); + } /** - * Comprueba si existe en una ruta del equipo local el fichero que se puede obtener con la descarga de un determinado enlace. - * @param savePath ruta del equipo local - * @param link enlace del fichero - * @return true si en la ruta indicada existe el fichero del enlace indicado, false en caso contrario + * Checks if the file indicated by an url already exists in a local path. + * @param localPath local path + * @param url download url + * @return true if the file indicated by the url exists in the local path, false otherwise */ - public static boolean fileExists(String savePath, String link) { - return new File(getLocalFilePathFromURL(savePath, link)).exists(); - } + public static boolean fileExists(String localPath, String url) { + return new File(getLocalFilePathFromURL(localPath, url)).exists(); + } /** - * Devuelve la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo.
    - * La ruta completa del fichero se forma concatenando dos elementos: por un lado, la ruta de la carpeta donde se va a guardar, y por otro, - * el nombre del fichero contenido en el enlace de descarga (el nombre de fichero es la parte final del enlace desde el último caracter separador de directorios)
    . - * Si el nombre del fichero contiene los caracteres ? o &amp; se sustituyen por _ y & respectivamente. - * @param savePath ruta de la carpeta en la que obtener la descarga - * @param link enlace del fichero a descargar + * Returns the path a file must have when downloaded on the local machine.
    + * The path is formed by concatenating two elements: on the one hand, tha path of the folder where the download will be saved, + * on the other hand, the name of the file in the download url (file name is at the end of the url, from last separator character of folders).
    + * If the name of the file contains ? and &amp; characters are replaced by _ and & respectively. + * @param savePath path of the folder in which to get the download + * @param link download link * @return la ruta del fichero en el equipo local */ public static String getLocalFilePathFromURL(String savePath, String link) { - String path = (!savePath.endsWith(FileManager.FILE_SEPARATOR)) ? savePath.concat(FileManager.FILE_SEPARATOR) : savePath; - String fileName = link.substring(link.lastIndexOf("/")+1, link.length()) + String path = (!savePath.endsWith(FILE_SEPARATOR)) ? savePath + FILE_SEPARATOR : savePath; + String fileName = link.substring(link.lastIndexOf('/')+1, link.length()) .replace("?", "_") .replace("&", "&"); return (path + fileName); } /** - * Devuelve el nombre del archivo contenido en una ruta. - * @param str ruta del archivo - * @return el nombre del archivo + * Returns the name of file inside a path. + * @param str file path + * @return the name of file inside str parameter */ public static String getLocalFileName(String str) { - return str.substring(str.lastIndexOf(FileManager.FILE_SEPARATOR)+1, str.length()) + return str.substring(str.lastIndexOf(FILE_SEPARATOR)+1, str.length()) .replace("?", "_") .replace("&", "&"); } /** - * Descomprime los ficheros comprimidos en formato zip de una determinada carpeta. - * @param inputPath ruta del directorio donde se encuentran los ficheros zip - * @param outputPath ruta del directorio en el que descomprimir los ficheros + * Unzips files in format zip from a certain folder. + * @param inputPath folder path with zip files + * @param outputPath folder path where unzip files */ public static void unzipFiles(String inputPath, String outputPath) { if (inputPath != null && outputPath != null) { - FileOutputStream fos = null; - String fileName = null; - byte[] buffer = new byte[1024]; - int len = 0; - int index = -1; - if (!outputPath.endsWith(FILE_SEPARATOR)) { - outputPath = outputPath.concat(FILE_SEPARATOR); - } - List zipFiles = getZipFiles(inputPath); - for (String zipFile : zipFiles) { - log.debug("Descomprimiendo " + zipFile); - try { - ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile)); + inputPath = checkAndFixPath(inputPath); + outputPath = checkAndFixPath(outputPath); + for (String zipFile : getZipFiles(inputPath)) { + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))) { ZipEntry zipEntry = zis.getNextEntry(); - while (zipEntry != null) { - fileName = zipEntry.getName(); - if ((index = fileName.lastIndexOf("/")) != -1) { - fileName = fileName.substring(index+1); - } - fos = new FileOutputStream(new File(outputPath.concat(fileName))); - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); - } - fos.close(); - zipEntry = zis.getNextEntry(); + while (zipEntry != null) { + String fileName = getFileName(zipEntry.getName()); + if (!fileName.isEmpty()) { + String targetFile = outputPath + fileName; + extractFile(zis, targetFile); + } + zipEntry = zis.getNextEntry(); } - zis.closeEntry(); - zis.close(); - log.debug("Obtenido " + outputPath + fileName); - } catch (FileNotFoundException e) { - log.error(e); - log.error("OutputPath: " + outputPath + " FileName: " + fileName); } catch (IOException e) { - log.error(e); - log.error("OutputPath: " + outputPath + " FileName: " + fileName); - } + log.error("IOException with zip file" + zipFile); + } } } else { log.warn("Rutas no válidas"); } } + private static String checkAndFixPath(String path) { + return (!path.endsWith(FILE_SEPARATOR)) ? (path + FILE_SEPARATOR) : path; + } + /** - * Devuelve una lista con las rutas de todos los ficheros con extensión .zip contenidos en un determinado directorio. - * @param path ruta del directorio en el que buscar los ficheros - * @return lista con las rutas de los ficheros + * Returns a List with the paths of all existing files with .zip extension in a given folder. + * @param path folder path where search files + * @return a List with the files paths */ private static List getZipFiles(String path) { - List zipFiles = new ArrayList(); - File folder = new File(path); - if (folder.exists()) { - for (File file : folder.listFiles()) { - if (file.getName().endsWith(".zip")) { - zipFiles.add(file.getAbsolutePath()); - } + List zipFiles = new ArrayList<>(); + try (DirectoryStream stream = Files.newDirectoryStream(Paths.get(path), "*.zip")) { + for (Path file: stream) { + zipFiles.add(file.toString()); } + } catch (IOException e) { + log.error(e); } return zipFiles; } + + private static String getFileName(String entryName) { + String fileName = entryName; + int index = -1; + if ((index = fileName.lastIndexOf('/')) != -1) { + fileName = fileName.substring(index+1); + if (fileName.contains("..")) { + throw new GutenbergException("org.josfranmc.gutenberg.GutenbergException: Entry is trying to leave the target dir: " + entryName); + } + } + return fileName; + } + + private static void extractFile(ZipInputStream zis, String targetFile) { + byte[] buffer = new byte[1024]; + int len = 0; + try (FileOutputStream fos = new FileOutputStream(new File(targetFile))) { + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } + } catch (IOException e) { + log.error("Error unzipping file " + targetFile); + } + } } diff --git a/src/main/java/org/josfranmc/gutenberg/util/FileScraping.java b/src/main/java/org/josfranmc/gutenberg/util/FileScraping.java index 5939960..51eddba 100644 --- a/src/main/java/org/josfranmc/gutenberg/util/FileScraping.java +++ b/src/main/java/org/josfranmc/gutenberg/util/FileScraping.java @@ -1,7 +1,29 @@ +/* + * Copyright (C) 2018-2019 Jose Francisco Mena Ceca + * + * This file is part of JGutenbergDownload. + * + * JGutenbergDownload is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JGutenbergDownload is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with JGutenbergDownload. If not, see . + * + * This file includes software developed at + * The Apache Software Foundation (http://www.apache.org/). + */ package org.josfranmc.gutenberg.util; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -15,57 +37,55 @@ import org.apache.log4j.Logger; /** - * Ofrece herramientas para analizar ficheros en busca de enlaces web. + * Tools for searching web links in files. * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 */ public class FileScraping { private static final Logger log = Logger.getLogger(FileScraping.class); /** - * Codificación del archivo a analizar + * Coding of the file to analyze */ - private static String ENCODING = "ISO-8859-1"; + private static final Charset ENCODING = StandardCharsets.ISO_8859_1; /** - * Patrón de la expresión regular a utilizar para detectar enlaces web + * Regular expression pattern for detecting web links */ - private static String PATTERN = ".*href=\"([^\"]*)\".*"; + private static final String PATTERN = ".*href=\"([^\"]*)\".*"; - /** - * Constructor por defecto. - */ - public FileScraping() {} + FileScraping() { + throw new IllegalStateException("Cannot instantiate class"); + } /** - * Obtiene una lista con todos los enlaces contenidos dentro de un fichero HTML.
    - * Los enlaces son extraidos de los atributos href de los elementos <a>. - * @param filePath ruta del fichero a analizar - * @return lista de enlaces + * Returns a list with all links within an html file.
    + * The links are extracted from href attributes of <a> elements. + * @param filePath path of file to analyze + * @return a List element with links */ public static List getLinks(String filePath) { - List links = new ArrayList(); + List links = new ArrayList<>(); if (filePath != null) { Path path = Paths.get(filePath); - links = new ArrayList(); - try (Stream stream = Files.lines(path, Charset.forName(ENCODING))) { - Pattern pattern = Pattern.compile(PATTERN); - Matcher matcher = null; - - Iterator it = stream.iterator(); - while (it.hasNext()) { - String line = it.next(); - matcher = pattern.matcher(line); - if (matcher.matches()) { - links.add(matcher.group(1)); - } - } + try (Stream stream = Files.lines(path, ENCODING)) { + Pattern pattern = Pattern.compile(PATTERN); + Matcher matcher = null; + + Iterator it = stream.iterator(); + while (it.hasNext()) { + String line = it.next(); + matcher = pattern.matcher(line); + if (matcher.matches()) { + links.add(matcher.group(1)); + } + } } catch (IOException e) { log.error(e); } - } + } return links; } } diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties index fd6375f..26daea2 100644 --- a/src/main/resources/log4j.properties +++ b/src/main/resources/log4j.properties @@ -1,31 +1,12 @@ -#log4j.logger.es.josfranmc.uned.colocare.download=ALL,CONSOLA,FILE -log4j.rootCategory=INFO,CONSOLA,FILE +log4j.rootLogger=INFO,CONSOLA,FILE log4j.appender.CONSOLA=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLA.layout=org.apache.log4j.PatternLayout -#log4j.appender.CONSOLA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n -log4j.appender.CONSOLA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n +log4j.appender.CONSOLA.layout.ConversionPattern=%m%n -#log4j.logger.es.josfranmc.uned.colocare.download=ALL,FILE log4j.appender.FILE=org.apache.log4j.FileAppender log4j.appender.FILE.ImmediateFlush=true -log4j.appender.FILE.file=log/gutenbergd.log +log4j.appender.FILE.File=log/gutenbergd.log log4j.appender.FILE.layout=org.apache.log4j.PatternLayout log4j.appender.FILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n -log4j.appender.FILE.append=false - - -#log4j.logger.es.josfranmc.uned.colocare.download=FILE,CONSOLA -# -#log4j.appender.FILE=org.apache.log4j.FileAppender -#log4j.appender.FILE.Threshold=INFO -#log4j.appender.FILE.ImmediateFlush=true -#log4j.appender.FILE.file=E:\Desarrollo\pruebas\gutenberg\febrero2\logdownload.log -#log4j.appender.FILE.layout=org.apache.log4j.PatternLayout -#log4j.appender.FILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n -#log4j.appender.FILE.append=false -# -#log4j.appender.CONSOLA=org.apache.log4j.ConsoleAppender -#log4j.appender.CONSOLA.Threshold=INFO -#log4j.appender.CONSOLA.layout=org.apache.log4j.PatternLayout -#log4j.appender.CONSOLA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file +log4j.appender.FILE.append=false \ No newline at end of file diff --git a/src/test/java/org/josfranmc/gutenberg/download/DownloadParamsTest.java b/src/test/java/org/josfranmc/gutenberg/download/DownloadParamsTest.java new file mode 100644 index 0000000..db7f598 --- /dev/null +++ b/src/test/java/org/josfranmc/gutenberg/download/DownloadParamsTest.java @@ -0,0 +1,69 @@ +package org.josfranmc.gutenberg.download; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.josfranmc.gutenberg.download.engine.DownloadEngineType; +import org.junit.Test; + +public class DownloadParamsTest { + + @Test + public void savePathTest() { + DownloadParams p = new DownloadParams(); + assertEquals("Valor Last-Modified incorrecto", p.getSavePath() + "zips" + System.getProperty("file.separator"), p.getZipsPath()); + + p.setSavePath("test"); + assertEquals("Valor Last-Modified incorrecto", p.getSavePath() + "zips" + System.getProperty("file.separator"), p.getZipsPath()); + } + + @Test(expected=GutenbergException.class) + public void maxDownloadsTest() { + DownloadParams p = new DownloadParams(); + p.setMaxFilesToDownload(0); + assertEquals("Valor Last-Modified incorrecto", Integer.MAX_VALUE, p.getMaxFilesToDownload()); + + p.setMaxFilesToDownload(-1); + } + + @Test + public void engineTypeTest() { + DownloadParams p = new DownloadParams(); + p.setEngineType(DownloadEngineType.HTTP_CONNECTION); + assertEquals("Engine type incorrecto", DownloadEngineType.HTTP_CONNECTION, p.getEngineType()); + } + + @Test + public void overwriteTest() { + DownloadParams p = new DownloadParams(); + p.setOverwrite(true); + assertTrue(p.isOverwrite()); + } + + @Test + public void unzipTest() { + DownloadParams p = new DownloadParams(); + p.setUnzip(false); + assertFalse(p.isUnzip()); + } + + @Test(expected=GutenbergException.class) + public void delayExceptionTest() { + DownloadParams p = new DownloadParams(); + p.setDelay(-1); + } + + @Test + public void delayTest() { + DownloadParams p = new DownloadParams(); + p.setDelay(5000); + assertEquals("Delay incorrecto", 5000, p.getDelay()); + } + + @Test(expected=GutenbergException.class) + public void fileTypeExceptionTest() { + DownloadParams p = new DownloadParams(); + p.setFileType("doc"); + } +} diff --git a/src/test/java/org/josfranmc/gutenberg/download/JGutenbergDownloadTest.java b/src/test/java/org/josfranmc/gutenberg/download/JGutenbergDownloadTest.java index 7869272..3a419e0 100644 --- a/src/test/java/org/josfranmc/gutenberg/download/JGutenbergDownloadTest.java +++ b/src/test/java/org/josfranmc/gutenberg/download/JGutenbergDownloadTest.java @@ -1,6 +1,7 @@ package org.josfranmc.gutenberg.download; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.File; @@ -9,85 +10,213 @@ import org.junit.Test; /** - * Clase que implementa los test para probar los métodos de la clase JGutenbergDownloadTest + * Clase que implementa los test para probar los métodos de la clase JGutenbergDownload * @author Jose Francisco Mena Ceca - * @version 1.0 + * @version 2.0 */ public class JGutenbergDownloadTest { + private static final String FILE_SEPARATOR = System.getProperty("file.separator"); /** - * Comprueba si los valores por defecto de los parámetros de descarga a la hora de crear un IGutenbergDownload son los correctos + * Comprueba los valores por defecto de la aplicación */ @Test - public void testParametersDefaultValue() { - IGutenbergDownload jg = JGutenbergDownloadFactory.create(); + public void parametersDefaultValueTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + assertEquals("Parámetro fileType valor por defecto no válido", "txt", jg.getFileType()); + assertEquals("Parámetro language valor por defecto no válido", "es", jg.getLanguage()); assertEquals("Parámetro delay valor por defecto no válido", 2000, jg.getDelay()); assertEquals("Parámetro engineType valor por defecto no válido", DownloadEngineType.HTTP_CONNECTION, jg.getEngineType()); assertEquals("Parámetro maxFiles valor por defecto no válido", 10, jg.getMaxFilesToDownload()); assertEquals("Parámetro savePath valor por defecto no válido", System.getProperty("user.dir").concat(System.getProperty("file.separator")), jg.getSavePath()); - assertEquals("Parámetro urlBase valor por defecto no válido", "No se ha establecido URL.", jg.getUrlBase()); + assertEquals("Parámetro urlBase valor por defecto no válido", "http://www.gutenberg.org/robot/harvest?filetypes[]=txt&langs[]=es", jg.getUrlBase()); assertEquals("Parámetro unzip valor por defecto no válido", true, jg.isUnzip()); - assertEquals("Parámetro downloadMode valor por defecto no válido", DownloadMode.SOFT, jg.getDownloadMode()); } - /** - * Si no se ha indicado tipo de fichero e idioma para realizar las descargas, entonces lanzar excepción IllegalArgumentException y mostrar mensaje - */ - @Test(expected=IllegalArgumentException.class) - public void givenUrlParametersWhenNullThenIllegalArgumentException() { - IGutenbergDownload jg = JGutenbergDownloadFactory.create(); - jg.downloadBooks(); - } + @Test + public void getParametersTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + assertNotNull(jg.getParameters()); + } + + @Test + public void setParametersTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + DownloadParams dp = new DownloadParams(); + dp.setOverwrite(true); + jg.setParameters(dp); + assertTrue(jg.isOverwrite()); + } + /** - * Si no se ha indicado tipo de fichero e idioma para realizar las descargas, entonces lanzar excepción IllegalArgumentException y mostrar mensaje + * Si el parámetro fileType es un valor no válido, entonces lanzar excepción IllegalArgumentException */ - @Test(expected=IllegalArgumentException.class) - public void givenUrlParametersWhenEmptyThenIllegalArgumentException() { - IGutenbergDownload jg = JGutenbergDownloadFactory.create(); - jg.setFileType("").setLanguage(""); - jg.downloadBooks(); - } + @Test(expected=GutenbergException.class) + public void givenFileTypeWhenWrongValueThenIllegalArgumentException() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setFileType("bad"); + } /** * Si la ruta indicada para guardar las descargas es null, entonces lanzar excepción IllegalArgumentException */ - @Test(expected=IllegalArgumentException.class) + @Test(expected=GutenbergException.class) public void givenSavePathWhenNullThenIllegalArgumentException() { - IGutenbergDownload jg = JGutenbergDownloadFactory.create(); + JGutenbergDownload jg = new JGutenbergDownload(); jg.setSavePath(null); } - /** - * Si la ruta indicada para guardar las descargas no existe, entonces crear nuevos directorios - */ @Test - public void givenSavePathWhenNoExistsThenIllegalArgumentException() { - IGutenbergDownload jg = JGutenbergDownloadFactory.create(); - jg.setSavePath("xopakeuj/sfukeo"); - File file = new File("xopakeuj/sfukeo"); - assertTrue("No existe directorio", file.exists()); - file.delete(); - file = new File("xopakeuj"); - file.delete(); + public void savePathTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setSavePath("books"); + assertEquals("Ruta no correcta [1]", "books".concat(System.getProperty("file.separator")), jg.getSavePath()); + jg.setSavePath("temp\\"); + assertEquals("Ruta no correcta [2]", "temp".concat(System.getProperty("file.separator")), jg.getSavePath()); + } + + @Test + public void givenLanguageThenUrlTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setLanguage("en"); + assertEquals("URL no correcta", DownloadParams.URL_BOOKS + "harvest?filetypes[]=" + jg.getFileType() + "&langs[]=" + jg.getLanguage(), jg.getUrlBase()); + } + + @Test + public void givenFileTypeThenUrlTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setFileType("html"); + assertEquals("URL no correcta", DownloadParams.URL_BOOKS + "harvest?filetypes[]=" + jg.getFileType() + "&langs[]=" + jg.getLanguage(), jg.getUrlBase()); } /** * Si el parámetro MaxFilesToDownload es menor de cero, entonces lanzar excepción IllegalArgumentException */ - @Test(expected=IllegalArgumentException.class) + @Test(expected=GutenbergException.class) public void givenMaxFilesToDownloadWhenMinusZeroThenIllegalArgumentException() { - IGutenbergDownload jg = JGutenbergDownloadFactory.create(); + JGutenbergDownload jg = new JGutenbergDownload(); jg.setMaxFilesToDownload(-1); } - /** - * Si el parámetro DownloadMode es null, entonces lanzar excepción IllegalArgumentException - */ - @Test(expected=IllegalArgumentException.class) - public void givenDownloadModeWhenNullThenIllegalArgumentException() { - IGutenbergDownload jg = JGutenbergDownloadFactory.create(); - jg.setDownloadMode(null); - } + @Test + public void downloadOneBookTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setSavePath("testdownload"); + jg.setDelay(0); + jg.setMaxFilesToDownload(1); + jg.downloadBooks(); + + File dirZip = new File(jg.getSavePath() + "zips"); + assertEquals("Número de archivos descargados incorrectos", 2, dirZip.listFiles().length); + + deleteDownloadedFiles(jg); + } + + private void deleteDownloadedFiles(JGutenbergDownload jg) { + String saveDir = jg.getSavePath(); + String pageWithLinks = "harvest_filetypes[]=" + jg.getFileType() + "&langs[]=" + jg.getLanguage(); + + File page = new File(saveDir + "zips" + FILE_SEPARATOR + pageWithLinks); + assertTrue(page.exists()); + + File dirZip = new File(saveDir + "zips"); + File[] filesInZipDirectory = dirZip.listFiles(); + for(File f : filesInZipDirectory) { + if(f.exists()) { + f.delete(); + } + } + dirZip.delete(); + + File dirSave = new File(saveDir); + File[] filesInSaveDirectory = dirSave.listFiles(); + for(File f : filesInSaveDirectory) { + if(f.exists()) { + f.delete(); + } + } + dirSave.delete(); + } + + @Test + public void downloadOneBookWithMainMethodTest() { + String [] args = {"-d", "0", "-m", "1", "-s", "testdownload2"}; + + JGutenbergDownload.main(args); + + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setSavePath("testdownload2"); + jg.setDelay(0); + jg.setMaxFilesToDownload(1); + + File dirZip = new File(jg.getSavePath() + "zips"); + assertEquals("Número de archivos descargados incorrectos [2]", 2, dirZip.listFiles().length); + + deleteDownloadedFiles(jg); + } + + @Test(expected=GutenbergException.class) + public void wrongParameterskWithMainMethodTest() { + String [] args = {"-d", "0", "-w", "1", "-s", "testdownload3"}; + + JGutenbergDownload.main(args); + + File dirSave = new File("testdownload3"); + assertTrue(!dirSave.exists()); + } + + @Test + public void downloadTwoPagesTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setSavePath("testpages"); + jg.setDelay(0); + jg.setMaxFilesToDownload(110); + jg.downloadBooks(); + + deleteDownloadedFiles(jg); + assertTrue(true); + } + + @Test + public void noUnzipTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setSavePath("testdownload3"); + jg.setDelay(0); + jg.setUnzip(false); + jg.setMaxFilesToDownload(1); + jg.downloadBooks(); + + File dir = new File(jg.getSavePath()); + assertEquals("Número de archivos descargados incorrectos [3]", 1, dir.listFiles().length); + + deleteDownloadedFiles(jg); + } + + @Test + public void showHelpWithMainMethodTest() { + String [] args = {"-h"}; + JGutenbergDownload.main(args); + assertTrue(true); + } + + @Test(expected=GutenbergException.class) + public void wrongUrlTest() { + JGutenbergDownload jg = new JGutenbergDownload(); + jg.setSavePath("testdownload4"); + jg.setLanguage("http://"); + jg.setDelay(0); + jg.setUnzip(false); + jg.setMaxFilesToDownload(1); + try { + jg.downloadBooks(); + } catch (GutenbergException e) { + File dir = new File(jg.getSavePath() + "zips"); + dir.delete(); + dir = new File(jg.getSavePath()); + dir.delete(); + throw e; + } + } } \ No newline at end of file diff --git a/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadEngineFactoryTest.java b/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadEngineFactoryTest.java new file mode 100644 index 0000000..b0ad74e --- /dev/null +++ b/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadEngineFactoryTest.java @@ -0,0 +1,115 @@ +package org.josfranmc.gutenberg.download.engine; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.josfranmc.gutenberg.download.engine.DownloadEngineFactory; +import org.josfranmc.gutenberg.download.engine.DownloadEngineType; +import org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection; +import org.josfranmc.gutenberg.download.engine.IDownloadEngine; +import org.junit.Test; + +public class DownloadEngineFactoryTest { + + @Test(expected=IllegalStateException.class) + public void createObjectTest() { + new DownloadEngineFactory(); + } + + /** + * Si se indica DownloadEngineType con valor null, entonces se debe crear un IDownloadEngineType de tipo DownloadEngineType.HTTP_CONNECTION + */ + @Test + public void createEngineWithOnlyTypeParameter() { + DownloadEngineType type = null; + IDownloadEngine engine = DownloadEngineFactory.create(type); + if (!(engine instanceof DownloadHttpUrlConnection)) { + fail("No se ha creado el tipo de engine por defecto adecuado"); + } + assertEquals("Directorio para guardar incorrecto", System.getProperty("user.dir"), engine.getSavePath()); + } + + /** + * Si se indican parámetros con DownloadEngineType, entonces se debe crear un IDownloadEngineType de tipo DownloadEngineType.HTTP_CONNECTION + */ + @Test + public void createEngineWithoutParameters() { + IDownloadEngine engine = DownloadEngineFactory.create(); + if (!(engine instanceof DownloadHttpUrlConnection)) { + fail("No se ha creado el tipo de engine por defecto adecuado"); + } + assertEquals("Directorio para guardar incorrecto", System.getProperty("user.dir"), engine.getSavePath()); + } + + /** + * Si se indica solo el parámetro de la url, entonces se debe crear un IDownloadEngineType de tipo DownloadEngineType.HTTP_CONNECTION + */ + @Test + public void createEngineWithOnlyTargetParameter() { + IDownloadEngine engine = null; + try { + engine = DownloadEngineFactory.create(new URL("http://url_test")); + if (!(engine instanceof DownloadHttpUrlConnection)) { + fail("No se ha creado el tipo de engine por defecto adecuado"); + } + assertEquals("Directorio para guardar incorrecto", System.getProperty("user.dir"), engine.getSavePath()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + + } + + /** + * Si solo se indican los parámtros de la url y carpeta de destino, entonces se debe crear un IDownloadEngineType de tipo DownloadEngineType.HTTP_CONNECTION + */ + @Test + public void createEngineWithTargetAndPathParameters() { + IDownloadEngine engine = null; + try { + engine = DownloadEngineFactory.create(new URL("http://url_test"), "path_test"); + if (!(engine instanceof DownloadHttpUrlConnection)) { + fail("No se ha creado el tipo de engine por defecto adecuado"); + } + assertEquals("Directorio para guardar incorrecto", "path_test", engine.getSavePath()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + + } + + /** + * Si se indican los parámtros de la url y tipo de motor, la carpeta para guardar será aquella desde donde se ejecute el programa + */ + @Test + public void createEngineWithTargetAndTypeParameters() { + IDownloadEngine engine = null; + try { + engine = DownloadEngineFactory.create(new URL("http://url_test"), DownloadEngineType.HTTP_CONNECTION); + if (!(engine instanceof DownloadHttpUrlConnection)) { + fail("No se ha creado el tipo de engine por defecto adecuado"); + } + assertEquals("Directorio para guardar incorrecto", System.getProperty("user.dir"), engine.getSavePath()); + + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + + @Test + public void createEngineWithAllParameters() { + IDownloadEngine engine = null; + try { + engine = DownloadEngineFactory.create(new URL("http://url_test"), "path_test", DownloadEngineType.HTTP_CONNECTION); + if (!(engine instanceof DownloadHttpUrlConnection)) { + fail("No se ha creado el tipo de engine por defecto adecuado"); + } + assertEquals("Directorio para guardar incorrecto", "path_test", engine.getSavePath()); + assertEquals("Url de descarga incorrecta", "http://url_test", engine.getResource().toString()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/org/josfranmc/gutenberg/engine/DownloadHttpUrlConnectionTest.java b/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnectionTest.java similarity index 78% rename from src/test/java/org/josfranmc/gutenberg/engine/DownloadHttpUrlConnectionTest.java rename to src/test/java/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnectionTest.java index 5e7b332..2aa1db3 100644 --- a/src/test/java/org/josfranmc/gutenberg/engine/DownloadHttpUrlConnectionTest.java +++ b/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadHttpUrlConnectionTest.java @@ -1,4 +1,4 @@ -package org.josfranmc.gutenberg.engine; +package org.josfranmc.gutenberg.download.engine; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -9,6 +9,7 @@ import java.net.MalformedURLException; import java.net.URL; +import org.josfranmc.gutenberg.download.GutenbergException; import org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection; import org.josfranmc.gutenberg.download.engine.DownloadResult; import org.josfranmc.gutenberg.download.engine.IDownloadEngine; @@ -37,17 +38,16 @@ public void givenDownloadParametersWhenNullThenDownloadResultShoulbBeNotNull() { DownloadResult dr = DownloadHttpUrlConnection.newInstance(null, null).download(); assertNotNull("No se ha obtenido objeto DownloadResult", dr); assertNull("El campo de cabeceras obtenidas no es null", dr.getHeaders()); - assertNull("La ruta del fichero descargado no es null", dr.getFileOutputPath()); + assertNull("La ruta del fichero descargado no es null", dr.getSavedFilePath()); } /** - * Si se indica una dirección de descarga errónea, entonces la ruta donde se ha guardado la descarga debe ser null (en el objeto DownloadResult). + * Si se indica una dirección de descarga errónea, se debe lanzar GutenbergException */ - @Test - public void givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull() { + @Test(expected=GutenbergException.class) + public void givenUrlWhenWrongAddressThenGutenbergException() { try { - DownloadResult dr = DownloadHttpUrlConnection.newInstance(new URL("http://www.qsctyhu.com/fake.img"), null).download(); - assertNull("La ruta del recurso descargado no es null", dr.getFileOutputPath()); + DownloadHttpUrlConnection.newInstance(new URL("http://www.qsctyhu.com/fake.img"), null).download(); } catch (MalformedURLException e) { e.printStackTrace(); } @@ -61,7 +61,7 @@ public void testDownload() { try { URL url = new URL("http://aleph.gutenberg.org/1/0/0/0/10002/10002.zip"); DownloadHttpUrlConnection.newInstance(url, null).download(); - File f = new File(System.getProperty("user.dir").concat(System.getProperty("file.separator")).concat("10002.zip")); + File f = new File(System.getProperty("user.dir") + System.getProperty("file.separator") + "10002.zip"); assertTrue("No se ha obtenido el recursos en la carpeta esperada", f.exists()); f.delete(); } catch (MalformedURLException e) { diff --git a/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadResultTest.java b/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadResultTest.java new file mode 100644 index 0000000..377647e --- /dev/null +++ b/src/test/java/org/josfranmc/gutenberg/download/engine/DownloadResultTest.java @@ -0,0 +1,16 @@ +package org.josfranmc.gutenberg.download.engine; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class DownloadResultTest { + + @Test + public void ifNoHeaderTest() { + DownloadResult r = new DownloadResult(); + assertEquals("Valor Last-Modified incorrecto", "", r.getLastModified()); + assertEquals("Valor Content-Type incorrecto", "", r.getContentType()); + assertEquals("Valor Content-Length incorrecto", "", r.getContentLength()); + } +} diff --git a/src/test/java/org/josfranmc/gutenberg/engine/DownloadEngineFactoryTest.java b/src/test/java/org/josfranmc/gutenberg/engine/DownloadEngineFactoryTest.java deleted file mode 100644 index 6f629bd..0000000 --- a/src/test/java/org/josfranmc/gutenberg/engine/DownloadEngineFactoryTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.josfranmc.gutenberg.engine; - -import static org.junit.Assert.fail; - -import org.josfranmc.gutenberg.download.engine.DownloadEngineFactory; -import org.josfranmc.gutenberg.download.engine.DownloadEngineType; -import org.josfranmc.gutenberg.download.engine.DownloadHttpUrlConnection; -import org.josfranmc.gutenberg.download.engine.IDownloadEngine; -import org.junit.Test; - -public class DownloadEngineFactoryTest { - - /** - * Si se indica DownloadEngineType con valor null, entonces se debe crear un IDownloadEngineType de tipo DownloadEngineType.HTTP_CONNECTION - */ - @Test - public void givenUrlWhenWrongAddressThenFileOutputPathShoulbBeNull() { - DownloadEngineType type = null; - IDownloadEngine engine = DownloadEngineFactory.create(type); - if (!(engine instanceof DownloadHttpUrlConnection)) { - fail("No se ha creado el tipo de engine por defecto adecuado"); - } - } -} diff --git a/src/test/java/org/josfranmc/gutenberg/util/FileManagerTest.java b/src/test/java/org/josfranmc/gutenberg/util/FileManagerTest.java index 1883a5d..7cd3a64 100644 --- a/src/test/java/org/josfranmc/gutenberg/util/FileManagerTest.java +++ b/src/test/java/org/josfranmc/gutenberg/util/FileManagerTest.java @@ -1,22 +1,43 @@ package org.josfranmc.gutenberg.util; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.io.File; +import java.net.URISyntaxException; + import org.junit.Test; public class FileManagerTest { + @Test(expected=IllegalStateException.class) + public void createObjectTest() { + new FileManager(); + } + + @Test + public void fileExistsTest() { + File zipFolder = null; + try { + zipFolder = new File(FileManagerTest.class.getResource("/zips").toURI()); + assertTrue(FileManager.fileExists(zipFolder.toString(), "http://aleph.gutenberg.org/1/0/2/9/10293/10293-8.zip")); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + } + /** * Comprobar si es correcta la ruta que debe tener en el equipo local un fichero que va a descargarse en dicho equipo. */ @Test - public void testGetLocalFilePathFromURL() { + public void getLocalFilePathFromURLTest() { String pathToSave = System.getProperty("user.dir"); String resource = "10002.zip"; String urlTest = "http://aleph.gutenberg.org/1/0/0/0/10002/"; - String path = FileManager.getLocalFilePathFromURL(pathToSave, urlTest.concat(resource)); - String expected = pathToSave.concat(System.getProperty("file.separator")).concat(resource); + + String path = FileManager.getLocalFilePathFromURL(pathToSave, urlTest + resource); + String expected = pathToSave + System.getProperty("file.separator") + resource; assertEquals("Ruta inválida", expected, path); } @@ -24,7 +45,7 @@ public void testGetLocalFilePathFromURL() { * Comprobar si es correcto el nombre del archivo contenido en una ruta. */ @Test - public void testGetLocalFileName() { + public void getLocalFileNameTest() { String testCad = "test" + System.getProperty("file.separator") + "book.txt"; String file = FileManager.getLocalFileName(testCad); String expected = "book.txt"; @@ -47,5 +68,32 @@ public void givenInputPathAndOutputPathWhenNullThenAvoidNullPointerException() { } catch (NullPointerException e) { fail("Las rutas de los directorios son null"); } + + try { + FileManager.unzipFiles("zips", null); + } catch (NullPointerException e) { + fail("Las rutas de los directorios son null"); + } + } + + @Test + public void unzipFilesTest() { + try { + File zipFolder = new File(FileManagerTest.class.getResource("/zips").toURI()); + File unzipFolder = new File(FileManagerTest.class.getResource("/zips").toURI()); + FileManager.unzipFiles(zipFolder.toString(), unzipFolder.toString()); + + File unzipFile = new File(FileManagerTest.class.getResource("/zips/10293-8.txt").toURI()); + assertTrue(unzipFile.exists()); + unzipFile.delete(); + + unzipFile = new File(FileManagerTest.class.getResource("/zips/10506-8.txt").toURI()); + assertTrue(unzipFile.exists()); + unzipFile.delete(); + } catch (NullPointerException e) { + fail("Las rutas de los directorios son null"); + } catch (URISyntaxException e) { + fail("URISyntaxException"); + } } } diff --git a/src/test/java/org/josfranmc/gutenberg/util/FileScrapingTest.java b/src/test/java/org/josfranmc/gutenberg/util/FileScrapingTest.java new file mode 100644 index 0000000..3b231ba --- /dev/null +++ b/src/test/java/org/josfranmc/gutenberg/util/FileScrapingTest.java @@ -0,0 +1,31 @@ +package org.josfranmc.gutenberg.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.net.URL; +import java.util.List; + +import org.junit.Test; + +public class FileScrapingTest { + + @Test(expected=IllegalStateException.class) + public void createObjectTest() { + new FileScraping(); + } + + @Test + public void getLinksWhenPathIsNull() { + List links = FileScraping.getLinks(null); + assertTrue(links.isEmpty()); + } + + @Test + public void getLinksTest() { + URL url = FileScrapingTest.class.getClassLoader().getResource("links_to_download.html"); + List links = FileScraping.getLinks(url.getPath().substring(1)); + assertTrue(!links.isEmpty()); + assertEquals("Link incorrecto", "http://aleph.gutenberg.org/1/0/2/9/10293/10293-8.zip", links.get(0)); + } +} diff --git a/src/test/resources/links_to_download.html b/src/test/resources/links_to_download.html new file mode 100644 index 0000000..e043208 --- /dev/null +++ b/src/test/resources/links_to_download.html @@ -0,0 +1,212 @@ + + + + + + All Files (offset: 0, filetypes: txt, languages: es) - Project Gutenberg + + +

    All Files (offset: 0, filetypes: txt, languages: es)

    http://aleph.gutenberg.org/1/0/2/9/10293/10293-8.zip

    + +

    http://aleph.gutenberg.org/1/0/2/9/10293/10293.zip

    + +

    http://aleph.gutenberg.org/1/0/5/0/10506/10506-8.zip

    + +

    http://aleph.gutenberg.org/1/0/5/0/10506/10506.zip

    + +

    http://aleph.gutenberg.org/1/0/8/1/10814/10814-8.zip

    + +

    http://aleph.gutenberg.org/1/0/8/1/10814/10814.zip

    + +

    http://aleph.gutenberg.org/1/0/8/2/10821/10821-8.zip

    + +

    http://aleph.gutenberg.org/1/0/8/2/10821/10821.zip

    + +

    http://aleph.gutenberg.org/1/0/8/2/10822/10822-8.zip

    + +

    http://aleph.gutenberg.org/1/0/8/2/10822/10822.zip

    + +

    http://aleph.gutenberg.org/1/0/8/2/10825/10825-8.zip

    + +

    http://aleph.gutenberg.org/1/0/9/0/10909/10909-8.zip

    + +

    http://aleph.gutenberg.org/1/0/9/0/10909/10909.zip

    + +

    http://aleph.gutenberg.org/1/1/0/4/11047/11047-8.zip

    + +

    http://aleph.gutenberg.org/1/1/0/4/11047/11047.zip

    + +

    http://aleph.gutenberg.org/1/1/0/7/11070/11070-8.zip

    + +

    http://aleph.gutenberg.org/1/1/0/7/11070/11070.zip

    + +

    http://aleph.gutenberg.org/1/1/0/7/11071/11071-8.zip

    + +

    http://aleph.gutenberg.org/1/1/0/7/11071/11071.zip

    + +

    http://aleph.gutenberg.org/1/1/0/8/11081/11081-8.zip

    + +

    http://aleph.gutenberg.org/1/1/0/8/11081/11081.zip

    + +

    http://aleph.gutenberg.org/1/1/3/0/11302/11302-8.zip

    + +

    http://aleph.gutenberg.org/1/1/5/2/11529/11529-8.zip

    + +

    http://aleph.gutenberg.org/1/1/5/2/11529/11529.zip

    + +

    http://aleph.gutenberg.org/1/1/5/9/11598/11598-8.zip

    + +

    http://aleph.gutenberg.org/1/1/5/9/11598/11598.zip

    + +

    http://aleph.gutenberg.org/1/1/6/5/11657/11657-8.zip

    + +

    http://aleph.gutenberg.org/1/1/6/5/11657/11657.zip

    + +

    http://aleph.gutenberg.org/1/1/6/6/11663/11663-8.zip

    + +

    http://aleph.gutenberg.org/1/1/6/6/11663/11663.zip

    + +

    http://aleph.gutenberg.org/1/1/6/6/11669/11669-8.zip

    + +

    http://aleph.gutenberg.org/1/1/6/6/11669/11669.zip

    + +

    http://aleph.gutenberg.org/1/2/2/7/12274/12274-8.zip

    + +

    http://aleph.gutenberg.org/1/2/2/7/12275/12275-8.zip

    + +

    http://aleph.gutenberg.org/1/2/2/7/12276/12276-8.zip

    + +

    http://aleph.gutenberg.org/1/2/5/0/12500/12500-8.zip

    + +

    http://aleph.gutenberg.org/1/2/5/0/12501/12501-8.zip

    + +

    http://aleph.gutenberg.org/1/2/5/0/12502/12502-8.zip

    + +

    http://aleph.gutenberg.org/1/2/5/0/12503/12503-8.zip

    + +

    http://aleph.gutenberg.org/1/2/3/6/12368/12368-8.zip

    + +

    http://aleph.gutenberg.org/1/2/3/6/12368/12368.zip

    + +

    http://aleph.gutenberg.org/1/2/4/3/12435/12435-8.zip

    + +

    http://aleph.gutenberg.org/1/2/4/3/12435/12435.zip

    + +

    http://aleph.gutenberg.org/1/2/4/5/12457/12457-8.zip

    + +

    http://aleph.gutenberg.org/1/2/4/5/12457/12457.zip

    + +

    http://aleph.gutenberg.org/1/2/6/2/12627/12627-8.zip

    + +

    http://aleph.gutenberg.org/1/2/6/2/12627/12627.zip

    + +

    http://aleph.gutenberg.org/1/2/8/4/12840/12840-8.zip

    + +

    http://aleph.gutenberg.org/1/2/8/4/12840/12840.zip

    + +

    http://aleph.gutenberg.org/1/2/8/4/12848/12848-8.zip

    + +

    http://aleph.gutenberg.org/1/3/2/1/13210/13210-8.zip

    + +

    http://aleph.gutenberg.org/1/3/2/1/13210/13210.zip

    + +

    http://aleph.gutenberg.org/1/3/2/1/13216/13216-8.zip

    + +

    http://aleph.gutenberg.org/1/3/2/1/13216/13216.zip

    + +

    http://aleph.gutenberg.org/1/3/2/6/13264/13264-8.zip

    + +

    http://aleph.gutenberg.org/1/3/2/6/13264/13264.zip

    + +

    http://aleph.gutenberg.org/1/3/4/5/13458/13458-8.zip

    + +

    http://aleph.gutenberg.org/1/3/4/7/13479/13479-8.zip

    + +

    http://aleph.gutenberg.org/1/3/4/7/13479/13479.zip

    + +

    http://aleph.gutenberg.org/1/3/4/9/13492/13492-8.zip

    + +

    http://aleph.gutenberg.org/1/3/4/9/13492/13492.zip

    + +

    http://aleph.gutenberg.org/1/3/5/0/13507/13507-8.zip

    + +

    http://aleph.gutenberg.org/1/3/5/0/13507/13507.zip

    + +

    http://aleph.gutenberg.org/1/3/5/1/13516/13516-8.zip

    + +

    http://aleph.gutenberg.org/1/3/5/1/13516/13516.zip

    + +

    http://aleph.gutenberg.org/1/3/5/1/13519/13519-8.zip

    + +

    http://aleph.gutenberg.org/1/3/5/1/13519/13519.zip

    + +

    http://aleph.gutenberg.org/1/3/6/0/13608/13608-8.zip

    + +

    http://aleph.gutenberg.org/1/3/6/0/13608/13608.zip

    + +

    http://aleph.gutenberg.org/1/3/9/0/13904/13904-8.zip

    + +

    http://aleph.gutenberg.org/1/4/2/3/14235/14235-8.zip

    + +

    http://aleph.gutenberg.org/1/4/2/3/14236/14236-8.zip

    + +

    http://aleph.gutenberg.org/1/4/3/0/14307/14307-8.zip

    + +

    http://aleph.gutenberg.org/1/4/3/0/14308/14308-8.zip

    + +

    http://aleph.gutenberg.org/1/4/3/1/14311/14311-8.zip

    + +

    http://aleph.gutenberg.org/1/4/3/1/14318/14318-8.zip

    + +

    http://aleph.gutenberg.org/1/4/3/2/14329/14329-8.zip

    + +

    http://aleph.gutenberg.org/1/4/7/2/14722/14722-8.zip

    + +

    http://aleph.gutenberg.org/1/4/7/6/14765/14765-8.zip

    + +

    http://aleph.gutenberg.org/1/4/7/9/14795/14795-8.zip

    + +

    http://aleph.gutenberg.org/1/4/7/9/14796/14796-8.zip

    + +

    http://aleph.gutenberg.org/1/4/8/3/14839/14839-8.zip

    + +

    http://aleph.gutenberg.org/1/4/9/4/14944/14944-8.zip

    + +

    http://aleph.gutenberg.org/1/4/9/9/14995/14995-8.zip

    + +

    http://aleph.gutenberg.org/1/5/0/2/15027/15027-8.zip

    + +

    http://aleph.gutenberg.org/1/5/0/4/15046/15046-8.zip

    + +

    http://aleph.gutenberg.org/1/5/0/5/15054/15054-8.zip

    + +

    http://aleph.gutenberg.org/1/5/0/6/15066/15066-8.zip

    + +

    http://aleph.gutenberg.org/1/5/1/1/15115/15115-8.zip

    + +

    http://aleph.gutenberg.org/1/5/1/2/15127/15127-8.zip

    + +

    http://aleph.gutenberg.org/1/5/1/2/15127/15127.zip

    + +

    http://aleph.gutenberg.org/1/5/2/0/15206/15206-8.zip

    + +

    http://aleph.gutenberg.org/1/5/3/3/15334/15334-8.zip

    + +

    http://aleph.gutenberg.org/1/5/3/5/15353/15353-8.zip

    + +

    http://aleph.gutenberg.org/1/5/3/5/15353/15353.zip

    + +

    http://aleph.gutenberg.org/1/5/4/2/15421/15421-8.zip

    + +

    http://aleph.gutenberg.org/1/5/5/3/15531/15531-8.zip

    + +

    http://aleph.gutenberg.org/1/5/5/3/15532/15532-8.zip

    + +

    http://aleph.gutenberg.org/1/5/5/3/15532/15532.zip

    + +

    http://aleph.gutenberg.org/1/5/6/3/15633/15633-8.zip

    + +

    Next Page

    + + + diff --git a/src/test/resources/zips/10293-8.zip b/src/test/resources/zips/10293-8.zip new file mode 100644 index 0000000..b9215a5 Binary files /dev/null and b/src/test/resources/zips/10293-8.zip differ diff --git a/src/test/resources/zips/10506-8.zip b/src/test/resources/zips/10506-8.zip new file mode 100644 index 0000000..a271d79 Binary files /dev/null and b/src/test/resources/zips/10506-8.zip differ