Java Learning -039-Source jar Package Two development extension instances (source modification)

Source: Internet
Author: User
Tags dateformat static class

Recently, when using some of the existing jar packages, it was found that some of the methods in the jar package could not meet some of their requirements, such as returning fixed format, string processing, etc., so that the corresponding class file in the original jar file should be expanded two times and repackaged the file to replace the original jar file. To meet the needs of test development itself.

The following is an example of how to modify the return style (as shown) for ${date} and ${time} in eclipse default comments.

The entire two-time development process is as follows:

0. Before modifying, the date and time display format of the generated note is as follows:


1, get the corresponding jar package file, I currently use the corresponding jar file in Eclipse is: {Eclipse installation directory}\plugins\org.eclipse.text_3.5.300.v20130515-1451.jar, and back up the org.eclipse.text_3.5.300.v20130515-1451.jar file

2. Unzip the Org.eclipse.text_3.5.300.v20130515-1451.jar file to the current directory org.eclipse.text_3.5.300.v20130515-1451

3. Decompile bytecode under directory {eclipase installation directory}\plugins\org.eclipse.text_3.5.300.v20130515-1451\org\eclipse\jface\text\templates Globaltemplatevariables.class, generate the Globaltemplatevariables.java file, use Jd-gui.exe to decompile the bytecode class file, and Globaltemplatevariables.class Backup.

4. Modify the Globaltemplatevariables.java file

-------------------------------------${date}: Date format modified, changed to public static class date extends as shown below simpletemplatevariableresolver{Public Date () {Super ("date", Texttemplatemessages.getstring ("GlobalVariables    . Variable.description.date "));         } protected String Resolve (Templatecontext context) {//Return dateformat.getdateinstance (). Format (new Date ());        Modify by AARON.FFP 2015-12-11 final SimpleDateFormat sdf = new SimpleDateFormat ("Yyyy-mm-dd");    Return Sdf.format (New Java.util.Date ()); }}-------------------------------------${time}: Time format modified, changed to the following public static class times extends simpletemplatevariableresolver{public Time () {Super ("Time", Texttemplatemessages.getstring ("GlobalVariables    . Variable.description.time ")); } protected String Resolve (Templatecontext context) {//Return dateformat.gettimeinstance (). Format (New Date (        )); Modify by AARON.FFP 2015-12-11 final SimpleDateFormat sdf = new SimpLedateformat ("HH:mm:ss.        SSS ");    Return Sdf.format (New Java.util.Date ()); }}

5. Compiling Globaltemplatevariables.java files

6. Packing

7. Replace the original org.eclipse.text_3.5.300.v20130515-1451.jar file

8. Verification

At this point, Java Learning -039-source jar Package Two development extension instances (source modification) successfully completed, I hope this article can give beginners javaweb you a reference.

Finally, very grateful to the pro-stop, I hope this article can be pro helpful. Warmly welcome the kiss to discuss together and progress together. Thank you so much! ^_^

Java Learning -039-Source jar Package Two development extension instances (source modification)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.