Android parses XML using SAX (2)

Source: Internet
Author: User
Tags clases

Package com. hzhi. my_sax; import java. util. arrayList; import android. OS. parcel; import android. OS. parcelable; public class school implements Parcelable {public static final String tag_name = "School"; public String name; public String code; public ArrayList <major> majors; public static final Parcelable. creator <school> CREATOR = new Parcelable. creator <school> () {@ Overridepublic school createFromParcel (Parcel in) {// TODO Auto-generated method stubreturn new school (in );} @ Overridepublic school [] newArray (int size) {// TODO Auto-generated method stubreturn new school [size] ;};@ Overridepublic int describeContents () {// TODO Auto-generated method stubreturn 0;} @ Overridepublic void writeToParcel (Parcel arg0, int arg1) {// TODO Auto-generated method stub} // implement Parcelable interface public school (Parcel in) {this. name = in. readString (); this. code = in. readString () ;}// constructor public school (String name, String code) {this. name = name; this. code = code; this. majors = new ArrayList <major> () ;}// Add a professional public void add_major (major m) {this. majors. add (m);} // returns the professional public ArrayList <major> get_majors () {return this. majors;} // rewrite toStringpublic String toString () {// TODO Auto-generated method stubreturn (getName ();} public String getName () {if (this. name = null) {return ("(Default)");} return (this. name );}}

Package com. hzhi. my_sax; import java. util. arrayList; import android. OS. parcel; import android. OS. parcelable; public class major implements Parcelable {public static final String tag_name = "Major"; public String name; public String code; public ArrayList <clas> clases; public static final Parcelable. creator <major> CREATOR = new Parcelable. creator <major> () {@ Overridepublic major createFromParcel (Parcel in) {// TODO Auto-generated method stubreturn new major (in );} @ Overridepublic major [] newArray (int size) {// TODO Auto-generated method stubreturn new major [size] ;}}; @ Overridepublic int describeContents () {// TODO Auto-generated method stubreturn 0;} @ Overridepublic void writeToParcel (Parcel dest, int flags) {// TODO Auto-generated method stubdest. writeString (this. name); dest. writeString (this. code);} // implement the Parcelable interface public major (Parcel in) {this. name = in. readString (); this. code = in. readString () ;}// constructor public major (String name, String code) {this. name = name; this. code = code; this. clases = new ArrayList <clas> ();} public String getCode () {return (this. code);} public void add_clas (clas c) {this. clases. add (c);} public ArrayList <clas> get_clases () {return this. clases;} // rewrite toStringpublic String toString () {// TODO Auto-generated method stubreturn (getName ();} public String getName () {if (this. name = null) {return ("(Default)");} return (this. name );}}

Package com. hzhi. my_sax; import android. OS. parcel; import android. OS. parcelable; public class clas implements Parcelable {public static final String tag_name = "Class"; public String name; public String code; public static final Parcelable. creator <clas> CREATOR = new Parcelable. creator <clas> () {@ Overridepublic clas createFromParcel (Parcel in) {// TODO Auto-generated method stubreturn new clas (in );} @ Overridepublic clas [] newArray (int size) {// TODO Auto-generated method stubreturn new clas [size] ;};@ Overridepublic int describeContents () {// TODO Auto-generated method stubreturn 0;} @ Overridepublic void writeToParcel (Parcel dest, int flags) {// TODO Auto-generated method stubdest. writeString (this. name); dest. writeString (this. code);} public clas (Parcel in) {this. name = in. readString (); this. code = in. readString ();} public clas (final String name, final String code) {this. name = name; this. code = code;} // rewrite toStringpublic String toString () {// TODO Auto-generated method stubreturn (getName ();} public String getName () {if (this. name = null) {return ("(Default)");} return (this. name );}}

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.