home *** CD-ROM | disk | FTP | other *** search
- package data.parser
- {
- import com.je.data.parser.IParser;
- import com.je.model.ChapterList;
- import com.je.model.LessonList;
- import com.je.model.vo.Chapter;
- import com.je.model.vo.DataTypeFactory;
- import com.je.model.vo.IData;
- import com.je.model.vo.LessonInformation;
-
- public class ChapterParser implements IParser
- {
- public function ChapterParser()
- {
- super();
- }
-
- public function parse(param1:XMLList) : IData
- {
- var item:XML = null;
- var info:LessonInformation = null;
- var chapter:Chapter = null;
- var id:int = 0;
- var data:XMLList = param1;
- var lessonParser:LessonParser = new LessonParser();
- var infoParser:IParser = new LessonInfoParser();
- var chapterList:IData = new ChapterList();
- for each(item in data)
- {
- info = new LessonInformation();
- info.description = item.info;
- info.previewImagePath = !!item.hasOwnProperty("infoPic") ? item.infoPic : null;
- chapter = Chapter(DataTypeFactory.getDataType(DataTypeFactory.CHAPTER));
- chapter.id = item.@id;
- id = int(String(item.label).indexOf(" "));
- chapter.title = String(item.label).substr(id + 1,String(item.label).length);
- chapter.info = info;
- chapter.lessonList = LessonList(lessonParser.parse(item..lesson.(@type == "lesson")));
- ChapterList(chapterList).addChapter(chapter);
- }
- return chapterList;
- }
- }
- }
-
-