home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2011 May / ME_2011_05.iso / Galileo-Video-Tutorial / system / player.swf / scripts / data / parser / ChapterParser.as < prev    next >
Encoding:
Text File  |  2010-11-30  |  1.6 KB  |  46 lines

  1. package data.parser
  2. {
  3.    import com.je.data.parser.IParser;
  4.    import com.je.model.ChapterList;
  5.    import com.je.model.LessonList;
  6.    import com.je.model.vo.Chapter;
  7.    import com.je.model.vo.DataTypeFactory;
  8.    import com.je.model.vo.IData;
  9.    import com.je.model.vo.LessonInformation;
  10.    
  11.    public class ChapterParser implements IParser
  12.    {
  13.       public function ChapterParser()
  14.       {
  15.          super();
  16.       }
  17.       
  18.       public function parse(param1:XMLList) : IData
  19.       {
  20.          var item:XML = null;
  21.          var info:LessonInformation = null;
  22.          var chapter:Chapter = null;
  23.          var id:int = 0;
  24.          var data:XMLList = param1;
  25.          var lessonParser:LessonParser = new LessonParser();
  26.          var infoParser:IParser = new LessonInfoParser();
  27.          var chapterList:IData = new ChapterList();
  28.          for each(item in data)
  29.          {
  30.             info = new LessonInformation();
  31.             info.description = item.info;
  32.             info.previewImagePath = !!item.hasOwnProperty("infoPic") ? item.infoPic : null;
  33.             chapter = Chapter(DataTypeFactory.getDataType(DataTypeFactory.CHAPTER));
  34.             chapter.id = item.@id;
  35.             id = int(String(item.label).indexOf(" "));
  36.             chapter.title = String(item.label).substr(id + 1,String(item.label).length);
  37.             chapter.info = info;
  38.             chapter.lessonList = LessonList(lessonParser.parse(item..lesson.(@type == "lesson")));
  39.             ChapterList(chapterList).addChapter(chapter);
  40.          }
  41.          return chapterList;
  42.       }
  43.    }
  44. }
  45.  
  46.