Java Code Examples for org.jboss.forge.roaster.model.source.JavaClassSource#addMethod()

The following examples show how to use org.jboss.forge.roaster.model.source.JavaClassSource#addMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private static void adjustQuickSearch() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(QUICK_SEARCH_PATH));

    // Set all field public
    javaClass.getField("id").setPublic();
    javaClass.getField("name").setPublic();
    javaClass.getField("mode").setPublic();
    javaClass.getField("category").setPublic();
    javaClass.getField("keyword").setPublic();
    javaClass.getField("advanceSearch").setPublic();
    javaClass.getField("minRating").setPublic();
    javaClass.getField("pageFrom").setPublic();
    javaClass.getField("pageTo").setPublic();
    javaClass.getField("time").setPublic();

    javaClass.addMethod("\t@Override\n" +
            "\tpublic String toString() {\n" +
            "\t\treturn name;\n" +
            "\t}");

    FileWriter fileWriter = new FileWriter(QUICK_SEARCH_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 2
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private static void adjustQuickSearch() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(QUICK_SEARCH_PATH));

    // Set all field public
    javaClass.getField("id").setPublic();
    javaClass.getField("name").setPublic();
    javaClass.getField("mode").setPublic();
    javaClass.getField("category").setPublic();
    javaClass.getField("keyword").setPublic();
    javaClass.getField("advanceSearch").setPublic();
    javaClass.getField("minRating").setPublic();
    javaClass.getField("pageFrom").setPublic();
    javaClass.getField("pageTo").setPublic();
    javaClass.getField("time").setPublic();

    javaClass.addMethod("\t@Override\n" +
            "\tpublic String toString() {\n" +
            "\t\treturn name;\n" +
            "\t}");

    FileWriter fileWriter = new FileWriter(QUICK_SEARCH_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 3
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private static void adjustFilter() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(FILTER_PATH));
    // Set field public
    javaClass.getField("mode").setPublic();
    javaClass.getField("text").setPublic();
    javaClass.getField("enable").setPublic();
    // Add hashCode method and equals method
    javaClass.addImport("com.hippo.util.HashCodeUtils");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int hashCode() {\n" +
            "\t\treturn HashCodeUtils.hashCode(mode, text);\n" +
            "\t}");
    javaClass.addImport("com.hippo.yorozuya.ObjectUtils");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic boolean equals(Object o) {\n" +
            "\t\tif (!(o instanceof Filter)) {\n" +
            "\t\t\treturn false;\n" +
            "\t\t}\n" +
            "\n" +
            "\t\tFilter filter = (Filter) o;\n" +
            "\t\treturn filter.mode == mode && ObjectUtils.equal(filter.text, text);\n" +
            "\t}");

    FileWriter fileWriter = new FileWriter(FILTER_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 4
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private static void adjustFilter() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(FILTER_PATH));
    // Set field public
    javaClass.getField("mode").setPublic();
    javaClass.getField("text").setPublic();
    javaClass.getField("enable").setPublic();
    // Add hashCode method and equals method
    javaClass.addImport("com.hippo.util.HashCodeUtils");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int hashCode() {\n" +
            "\t\treturn HashCodeUtils.hashCode(mode, text);\n" +
            "\t}");
    javaClass.addImport("com.hippo.yorozuya.ObjectUtils");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic boolean equals(Object o) {\n" +
            "\t\tif (!(o instanceof Filter)) {\n" +
            "\t\t\treturn false;\n" +
            "\t\t}\n" +
            "\n" +
            "\t\tFilter filter = (Filter) o;\n" +
            "\t\treturn filter.mode == mode && ObjectUtils.equal(filter.text, text);\n" +
            "\t}");

    FileWriter fileWriter = new FileWriter(FILTER_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 5
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustDownloadInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(DOWNLOAD_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("state").setPublic();
    javaClass.getField("legacy").setPublic();
    javaClass.getField("time").setPublic();
    javaClass.getField("label").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeInt(this.state);\n" +
            "\t\tdest.writeInt(this.legacy);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t\tdest.writeString(this.label);\n" +
            "\t}");
    javaClass.addMethod("\tprotected DownloadInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.state = in.readInt();\n" +
            "\t\tthis.legacy = in.readInt();\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t\tthis.label = in.readString();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<DownloadInfo> CREATOR = new Creator<DownloadInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic DownloadInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new DownloadInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic DownloadInfo[] newArray(int size) {\n" +
            "\t\t\treturn new DownloadInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("android.os.Parcel");
    // Add download info stuff
    javaClass.addField("public static final int STATE_INVALID = -1");
    javaClass.addField("public static final int STATE_NONE = 0");
    javaClass.addField("public static final int STATE_WAIT = 1");
    javaClass.addField("public static final int STATE_DOWNLOAD = 2");
    javaClass.addField("public static final int STATE_FINISH = 3");
    javaClass.addField("public static final int STATE_FAILED = 4");
    javaClass.addField("public long speed");
    javaClass.addField("public long remaining");
    javaClass.addField("public int finished");
    javaClass.addField("public int downloaded");
    javaClass.addField("public int total");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic DownloadInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(DOWNLOAD_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 6
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustHistoryInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(HISTORY_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("mode").setPublic();
    javaClass.getField("time").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeInt(this.mode);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t}");
    javaClass.addMethod("\tprotected HistoryInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.mode = in.readInt();\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<HistoryInfo> CREATOR = new Creator<HistoryInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic HistoryInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new HistoryInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic HistoryInfo[] newArray(int size) {\n" +
            "\t\t\treturn new HistoryInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("com.axlecho.api.MHApiSource");
    javaClass.addImport("android.os.Parcel");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic HistoryInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.source = galleryInfo.getId().split(\"@\")[1];\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t\tthis.id = galleryInfo.getId();\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(HISTORY_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 7
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustLocalFavoriteInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(LOCAL_FAVORITE_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("time").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t\tdest.writeString(this.id);\n" +
            "\t}");
    javaClass.addMethod("\tprotected LocalFavoriteInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t\tthis.id = in.readString();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<LocalFavoriteInfo> CREATOR = new Creator<LocalFavoriteInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic LocalFavoriteInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new LocalFavoriteInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic LocalFavoriteInfo[] newArray(int size) {\n" +
            "\t\t\treturn new LocalFavoriteInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("android.os.Parcel");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic LocalFavoriteInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t\tthis.id=galleryInfo.getId();\n" +
            "\t\tthis.time = System.currentTimeMillis();\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(LOCAL_FAVORITE_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 8
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustBookmarkInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(BOOKMARK_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("page").setPublic();
    javaClass.getField("time").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeInt(this.page);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t}");
    javaClass.addMethod("\tprotected BookmarkInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.page = in.readInt();\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<BookmarkInfo> CREATOR = new Creator<BookmarkInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic BookmarkInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new BookmarkInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic BookmarkInfo[] newArray(int size) {\n" +
            "\t\t\treturn new BookmarkInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("android.os.Parcel");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic BookmarkInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(BOOKMARK_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 9
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustDownloadInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(DOWNLOAD_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("state").setPublic();
    javaClass.getField("legacy").setPublic();
    javaClass.getField("time").setPublic();
    javaClass.getField("label").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeInt(this.state);\n" +
            "\t\tdest.writeInt(this.legacy);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t\tdest.writeString(this.label);\n" +
            "\t}");
    javaClass.addMethod("\tprotected DownloadInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.state = in.readInt();\n" +
            "\t\tthis.legacy = in.readInt();\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t\tthis.label = in.readString();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<DownloadInfo> CREATOR = new Creator<DownloadInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic DownloadInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new DownloadInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic DownloadInfo[] newArray(int size) {\n" +
            "\t\t\treturn new DownloadInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("android.os.Parcel");
    // Add download info stuff
    javaClass.addField("public static final int STATE_INVALID = -1");
    javaClass.addField("public static final int STATE_NONE = 0");
    javaClass.addField("public static final int STATE_WAIT = 1");
    javaClass.addField("public static final int STATE_DOWNLOAD = 2");
    javaClass.addField("public static final int STATE_FINISH = 3");
    javaClass.addField("public static final int STATE_FAILED = 4");
    javaClass.addField("public long speed");
    javaClass.addField("public long remaining");
    javaClass.addField("public int finished");
    javaClass.addField("public int downloaded");
    javaClass.addField("public int total");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic DownloadInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(DOWNLOAD_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 10
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustHistoryInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(HISTORY_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("mode").setPublic();
    javaClass.getField("time").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeInt(this.mode);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t}");
    javaClass.addMethod("\tprotected HistoryInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.mode = in.readInt();\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<HistoryInfo> CREATOR = new Creator<HistoryInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic HistoryInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new HistoryInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic HistoryInfo[] newArray(int size) {\n" +
            "\t\t\treturn new HistoryInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("android.os.Parcel");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic HistoryInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(HISTORY_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 11
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustLocalFavoriteInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(LOCAL_FAVORITE_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("time").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t}");
    javaClass.addMethod("\tprotected LocalFavoriteInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<LocalFavoriteInfo> CREATOR = new Creator<LocalFavoriteInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic LocalFavoriteInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new LocalFavoriteInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic LocalFavoriteInfo[] newArray(int size) {\n" +
            "\t\t\treturn new LocalFavoriteInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("android.os.Parcel");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic LocalFavoriteInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(LOCAL_FAVORITE_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}
 
Example 12
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
private static void adjustBookmarkInfo() throws Exception {
    JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(BOOKMARK_INFO_PATH));
    // Remove field from GalleryInfo
    javaClass.removeField(javaClass.getField("gid"));
    javaClass.removeField(javaClass.getField("token"));
    javaClass.removeField(javaClass.getField("title"));
    javaClass.removeField(javaClass.getField("titleJpn"));
    javaClass.removeField(javaClass.getField("thumb"));
    javaClass.removeField(javaClass.getField("category"));
    javaClass.removeField(javaClass.getField("posted"));
    javaClass.removeField(javaClass.getField("uploader"));
    javaClass.removeField(javaClass.getField("rating"));
    javaClass.removeField(javaClass.getField("simpleLanguage"));
    // Set all field public
    javaClass.getField("page").setPublic();
    javaClass.getField("time").setPublic();
    // Add Parcelable stuff
    javaClass.addMethod("\t@Override\n" +
            "\tpublic int describeContents() {\n" +
            "\t\treturn 0;\n" +
            "\t}");
    javaClass.addMethod("\t@Override\n" +
            "\tpublic void writeToParcel(Parcel dest, int flags) {\n" +
            "\t\tsuper.writeToParcel(dest, flags);\n" +
            "\t\tdest.writeInt(this.page);\n" +
            "\t\tdest.writeLong(this.time);\n" +
            "\t}");
    javaClass.addMethod("\tprotected BookmarkInfo(Parcel in) {\n" +
            "\t\tsuper(in);\n" +
            "\t\tthis.page = in.readInt();\n" +
            "\t\tthis.time = in.readLong();\n" +
            "\t}").setConstructor(true);
    javaClass.addField("\tpublic static final Creator<BookmarkInfo> CREATOR = new Creator<BookmarkInfo>() {\n" +
            "\t\t@Override\n" +
            "\t\tpublic BookmarkInfo createFromParcel(Parcel source) {\n" +
            "\t\t\treturn new BookmarkInfo(source);\n" +
            "\t\t}\n" +
            "\n" +
            "\t\t@Override\n" +
            "\t\tpublic BookmarkInfo[] newArray(int size) {\n" +
            "\t\t\treturn new BookmarkInfo[size];\n" +
            "\t\t}\n" +
            "\t};");
    javaClass.addImport("android.os.Parcel");
    // Add from GalleryInfo constructor
    javaClass.addMethod("\tpublic BookmarkInfo(GalleryInfo galleryInfo) {\n" +
            "\t\tthis.gid = galleryInfo.gid;\n" +
            "\t\tthis.token = galleryInfo.token;\n" +
            "\t\tthis.title = galleryInfo.title;\n" +
            "\t\tthis.titleJpn = galleryInfo.titleJpn;\n" +
            "\t\tthis.thumb = galleryInfo.thumb;\n" +
            "\t\tthis.category = galleryInfo.category;\n" +
            "\t\tthis.posted = galleryInfo.posted;\n" +
            "\t\tthis.uploader = galleryInfo.uploader;\n" +
            "\t\tthis.rating = galleryInfo.rating;\n" +
            "\t\tthis.simpleTags = galleryInfo.simpleTags;\n" +
            "\t\tthis.simpleLanguage = galleryInfo.simpleLanguage;\n" +
            "\t}").setConstructor(true);
    javaClass.addImport("com.hippo.ehviewer.client.data.GalleryInfo");

    FileWriter fileWriter = new FileWriter(BOOKMARK_INFO_PATH);
    fileWriter.write(javaClass.toString());
    fileWriter.close();
}