/** * Constructor. * * @param zipFile * Path to the zip file which helds the chapter files */ public AdventureHandler(InputStreamCreator isCreator, List <Incidence> incidences) { this.isCreator = isCreator; assessmentPaths = new List <string>(); adaptationPaths = new List <string>(); getXMLFilePaths(isCreator, assessmentPaths, adaptationPaths); adventureData = new AdventureData(); this.incidences = incidences; chapters = new List <Chapter>(); }
/** * Default constructor */ public AdaptationHandler(InputStreamCreator isCreator, List<AdaptationRule> rules, AdaptedState iState) { initialState = iState; if (rules == null) externalRules = new List<AdaptationRule>(); else externalRules = rules; currentstring = string.Empty; vars = new List<string>(); flags = new List<string>(); this.isCreator = isCreator; }
/** * Loads the descriptor of the current ZIP adventure loaded * * @return The descriptor data of the game */ public static DescriptorData loadDescriptorData(InputStreamCreator isCreator, List <Incidence> incidences) { DescriptorData descriptorData = null; if (Loader.adventureData != null) { descriptorData = Loader.adventureData; } else { try { // Set the adventure handler DescriptorHandler descriptorParser = new DescriptorHandler(isCreator); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); // Read and close the inputstrea string descriptorIS = isCreator.buildInputStream("descriptor.xml"); //saxParser.parse(descriptorIS, descriptorParser); //descriptorIS.close(); descriptorParser.Parse(descriptorIS); // Store the adventure data descriptorData = descriptorParser.getGameDescriptor(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.IO"), e)); //} //catch (IllegalArgumentException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.NoDescriptor"), e)); //} } return(descriptorData); }
/** * Default constructor */ public AdaptationHandler(InputStreamCreator isCreator, List <AdaptationRule> rules, AdaptedState iState) { initialState = iState; if (rules == null) { externalRules = new List <AdaptationRule>(); } else { externalRules = rules; } currentstring = string.Empty; vars = new List <string>(); flags = new List <string>(); this.isCreator = isCreator; }
/* Methods */ /** * Default constructor */ public AssessmentHandler(InputStreamCreator isCreator, AssessmentProfile profile) { this.profile = profile; if (profile.getRules() == null) { assessmentRules = new List <AssessmentRule>(); } else { assessmentRules = profile.getRules(); } currentAssessmentRule = null; currentstring = string.Empty; vars = new List <string>(); flags = new List <string>(); profile.setFlags(flags); profile.setVars(vars); this.isCreator = isCreator; }
/** * Loads the adventure data from the given ZIP file. * * @param zipFile * Path to the zip file which holds the adventure * @return The adventure data, null if there was an error */ public static AdventureData loadAdventureData(InputStreamCreator isCreator, List <Incidence> incidences) { AdventureData adventureDataTemp = null; try { // Set the adventure handler AdventureHandler adventureParser = new AdventureHandler(isCreator, incidences); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); // Read and close the input stream string descriptorIS = isCreator.buildInputStream("descriptor.xml"); adventureParser.Parse(descriptorIS); //descriptorIS.close(); // Load the assessment and adaptation profiles. It must be after parse // the adventure data because the profile's load from xml inserts each profile // in each chapter. adventureParser.loadProfiles(); // Store the adventure data adventureDataTemp = adventureParser.getAdventureData(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.IO"), e)); //} //catch (IllegalArgumentException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.NoDescriptor"), e)); //} return(adventureDataTemp); }
private static void getXMLFilePaths(InputStreamCreator isCreator, List <string> assessmentPaths, List <string> adaptationPaths) { // Assessment foreach (string child in isCreator.listNames(assessmentFolderPath)) { if (child.ToLower().EndsWith(".xml")) { assessmentPaths.Add(assessmentFolderPath + "/" + child); } } // Adaptation foreach (string child in isCreator.listNames(adaptationFolderPath)) { if (child.ToLower().EndsWith(".xml")) { adaptationPaths.Add(adaptationFolderPath + "/" + child); } } }
/** * Constructor */ public DescriptorHandler(InputStreamCreator isCreator) { currentstring = string.Empty; gameDescriptor = new DescriptorData(); this.isCreator = isCreator; }
public AnimationHandler_(InputStreamCreator isCreator, ImageLoaderFactory imageloader) { this.factory = imageloader; }
/** * Loads the script data from the given XML file * * @param filename * Name of the XML file containing the script * @param validate * distinguish between if the load is made in editor or engine * @return The script stored as game data */ public static Chapter loadChapterData(InputStreamCreator isCreator, string fileName, List <Incidence> incidences) { // Create the chapter Chapter currentChapter = new Chapter(); bool chapterFound = false; if (Loader.adventureData != null) { foreach (Chapter chapter in adventureData.getChapters()) { if (chapter != null && chapter.getChapterPath() != null && chapter.getChapterPath().Equals(fileName)) { currentChapter = chapter; chapterFound = true; break; } else if (chapter != null && chapter.getChapterPath() == null) { currentChapter = chapter; chapterFound = true; currentChapter.setChapterPath("chapter1.xml"); break; } } } if (!chapterFound) { string chapterIS = null; //if (zipFile!=null){ chapterIS = isCreator.buildInputStream(fileName); currentChapter.setChapterPath(fileName); //} else{ // Then fileName is an absolutePath //string chapterPath = fileName.substring( Math.max (fileName.lastIndexOf( '\\' ), fileName.lastIndexOf( '/' ) ), fileName.length( )); //currentChapter.setName( chapterPath ); //try { // chapterIS = new FileInputStream( fileName ); //} catch (FileNotFoundException e) { //e.printStackTrace(); // incidences.add( Incidence.createChapterIncidence( TextConstants.getText( "Error.LoadData.IO" ), fileName ) ); //} //} // Open the file and load the data try { if (chapterIS != null) { // Set the chapter handler ChapterHandler chapterParser = new ChapterHandler(isCreator, currentChapter); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); //// Parse the data and close the data //saxParser.parse(chapterIS, chapterParser); //chapterIS.close(); chapterParser.Parse(chapterIS); } } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), fileName, e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), fileName, e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.IO"), fileName, e)); //} } //Debug.Log(currentChapter); return(currentChapter); }
/* Methods */ /** * Default constructor. * * @param chapter * Chapter in which the data will be stored */ public ChapterHandler(InputStreamCreator isCreator, Chapter chapter) { this.chapter = chapter; this.isCreator = isCreator; currentString = string.Empty; }
/** * Loads the assessment profile (set of assessment rules) stored in file * with path xmlFile in zipFile * * @param zipFile * @param xmlFile * @param incidences * @return */ public static AssessmentProfile loadAssessmentProfile(InputStreamCreator isCreator, string xmlFile, List<Incidence> incidences) { AssessmentProfile newProfile = null; if (Loader.adventureData != null) { foreach (Chapter chapter in Loader.adventureData.getChapters()) { if (chapter.getAssessmentProfiles().Count != 0) { foreach (AssessmentProfile profile in chapter.getAssessmentProfiles()) { if (profile.getName().Equals(xmlFile)) { //try //{ newProfile = (AssessmentProfile)profile; //} //catch (CloneNotSupportedException e) //{ // e.printStackTrace(); //} break; } } } } } else { // Open the file and load the data try { // Set the chapter handler AssessmentProfile profile = new AssessmentProfile(); string name = xmlFile; name = name.Substring(name.IndexOf("/") + 1); if (name.IndexOf(".") != -1) name = name.Substring(0, name.IndexOf(".")); profile.setName(name); AssessmentHandler assParser = new AssessmentHandler(isCreator, profile); //factory.setValidating(true); //SAXParser saxParser = factory.newSAXParser(); //// Parse the data and close the data string assessmentIS = isCreator.buildInputStream(xmlFile); //saxParser.parse(assessmentIS, assParser); //assessmentIS.close(); assParser.Parse(assessmentIS); // Finally add the new controller to the list // Create the new profile // Fill flags & vars newProfile = profile; } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createAssessmentIncidence(false, Language.GetText("Error.LoadAssessmentData.SAX"), xmlFile, e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createAssessmentIncidence(false, Language.GetText("Error.LoadAssessmentData.SAX"), xmlFile, e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createAssessmentIncidence(false, Language.GetText("Error.LoadAssessmentData.IO"), xmlFile, e)); //} } return newProfile; }
/** * Loads an animation from a filename * * @param filename * The xml descriptor for the animation * @return the loaded Animation */ public static Animation loadAnimation(InputStreamCreator isCreator, string filename, ImageLoaderFactory imageloader) { AnimationHandler_ animationHandler = new AnimationHandler_(isCreator, imageloader); // Create a new factory //factory.setValidating(false); //SAXParser saxParser; try { //saxParser = factory.newSAXParser(); // Read and close the input stream //File file = new File(filename); string descriptorIS = null; /*try { * System.out.println("FILENAME="+filename); * descriptorIS = ResourceHandler.getInstance( ).buildInputStream(filename); * System.out.println("descriptorIS==null?"+(descriptorIS==null)); * * //descriptorIS = new InputStream(ResourceHandler.getInstance().getResourceAsURLFromZip(filename)); * } catch (Exception e) { Debug.LogError(e); } { * e.printStackTrace(); * } * if (descriptorIS == null) { * descriptorIS = AssetsController.getInputStream(filename); * }*/ descriptorIS = isCreator.buildInputStream("Assets/Resources/CurrentGame/" + filename); if (!descriptorIS.EndsWith(".eaa")) { descriptorIS += ".eaa"; } animationHandler.Parse(descriptorIS); //saxParser.parse(descriptorIS, animationHandler); //descriptorIS.close(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // e.printStackTrace(); // System.err.println(filename); //} //catch (SAXException e) //{ // e.printStackTrace(); // System.err.println(filename); //} //catch (FileNotFoundException e) //{ // e.printStackTrace(); // System.err.println(filename); //} //catch (IOException e) //{ // e.printStackTrace(); // System.err.println(filename); //} if (animationHandler.getAnimation() != null) { return(animationHandler.getAnimation()); } else { return(new Animation("anim" + (new System.Random()).Next(1000), imageloader)); } }
/** * Loads the adventure data from the given ZIP file. * * @param zipFile * Path to the zip file which holds the adventure * @return The adventure data, null if there was an error */ public static AdventureData loadAdventureData(InputStreamCreator isCreator, List<Incidence> incidences) { AdventureData adventureDataTemp = null; try { // Set the adventure handler AdventureHandler adventureParser = new AdventureHandler(isCreator, incidences); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); // Read and close the input stream string descriptorIS = isCreator.buildInputStream("descriptor.xml"); adventureParser.Parse(descriptorIS); //descriptorIS.close(); // Load the assessment and adaptation profiles. It must be after parse // the adventure data because the profile's load from xml inserts each profile // in each chapter. adventureParser.loadProfiles(); // Store the adventure data adventureDataTemp = adventureParser.getAdventureData(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.IO"), e)); //} //catch (IllegalArgumentException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.NoDescriptor"), e)); //} return adventureDataTemp; }
/** * Loads an animation from a filename * * @param filename * The xml descriptor for the animation * @return the loaded Animation */ public static Animation loadAnimation(InputStreamCreator isCreator, string filename, ImageLoaderFactory imageloader) { AnimationHandler_ animationHandler = new AnimationHandler_(isCreator, imageloader); // Create a new factory //factory.setValidating(false); //SAXParser saxParser; try { //saxParser = factory.newSAXParser(); // Read and close the input stream //File file = new File(filename); string descriptorIS = null; /*try { System.out.println("FILENAME="+filename); descriptorIS = ResourceHandler.getInstance( ).buildInputStream(filename); System.out.println("descriptorIS==null?"+(descriptorIS==null)); //descriptorIS = new InputStream(ResourceHandler.getInstance().getResourceAsURLFromZip(filename)); } catch (Exception e) { Debug.LogError(e); } { e.printStackTrace(); } if (descriptorIS == null) { descriptorIS = AssetsController.getInputStream(filename); }*/ descriptorIS = isCreator.buildInputStream("Assets/Resources/" + filename); if (!descriptorIS.EndsWith(".eaa")) descriptorIS += ".eaa"; animationHandler.Parse(descriptorIS); //saxParser.parse(descriptorIS, animationHandler); //descriptorIS.close(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // e.printStackTrace(); // System.err.println(filename); //} //catch (SAXException e) //{ // e.printStackTrace(); // System.err.println(filename); //} //catch (FileNotFoundException e) //{ // e.printStackTrace(); // System.err.println(filename); //} //catch (IOException e) //{ // e.printStackTrace(); // System.err.println(filename); //} if (animationHandler.getAnimation() != null) return animationHandler.getAnimation(); else return new Animation("anim" + (new System.Random()).Next(1000), imageloader); }
/** * Constructor. * * @param zipFile * Path to the zip file which helds the chapter files */ public AdventureHandler(InputStreamCreator isCreator, List<Incidence> incidences) { this.isCreator = isCreator; assessmentPaths = new List<string>(); adaptationPaths = new List<string>(); getXMLFilePaths(isCreator, assessmentPaths, adaptationPaths); adventureData = new AdventureData(); this.incidences = incidences; chapters = new List<Chapter>(); }
private static void getXMLFilePaths(InputStreamCreator isCreator, List<string> assessmentPaths, List<string> adaptationPaths) { // Assessment foreach (string child in isCreator.listNames(assessmentFolderPath)) { if (child.ToLower().EndsWith(".xml")) { assessmentPaths.Add(assessmentFolderPath + "/" + child); } } // Adaptation foreach (string child in isCreator.listNames(adaptationFolderPath)) { if (child.ToLower().EndsWith(".xml")) { adaptationPaths.Add(adaptationFolderPath + "/" + child); } } }
/** * Loads the assessment profile (set of assessment rules) stored in file * with path xmlFile in zipFile * * @param zipFile * @param xmlFile * @param incidences * @return */ public static AssessmentProfile loadAssessmentProfile(InputStreamCreator isCreator, string xmlFile, List <Incidence> incidences) { AssessmentProfile newProfile = null; if (Loader.adventureData != null) { foreach (Chapter chapter in Loader.adventureData.getChapters()) { if (chapter.getAssessmentProfiles().Count != 0) { foreach (AssessmentProfile profile in chapter.getAssessmentProfiles()) { if (profile.getName().Equals(xmlFile)) { //try //{ newProfile = (AssessmentProfile)profile; //} //catch (CloneNotSupportedException e) //{ // e.printStackTrace(); //} break; } } } } } else { // Open the file and load the data try { // Set the chapter handler AssessmentProfile profile = new AssessmentProfile(); string name = xmlFile; name = name.Substring(name.IndexOf("/") + 1); if (name.IndexOf(".") != -1) { name = name.Substring(0, name.IndexOf(".")); } profile.setName(name); AssessmentHandler assParser = new AssessmentHandler(isCreator, profile); //factory.setValidating(true); //SAXParser saxParser = factory.newSAXParser(); //// Parse the data and close the data string assessmentIS = isCreator.buildInputStream(xmlFile); //saxParser.parse(assessmentIS, assParser); //assessmentIS.close(); assParser.Parse(assessmentIS); // Finally add the new controller to the list // Create the new profile // Fill flags & vars newProfile = profile; } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createAssessmentIncidence(false, Language.GetText("Error.LoadAssessmentData.SAX"), xmlFile, e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createAssessmentIncidence(false, Language.GetText("Error.LoadAssessmentData.SAX"), xmlFile, e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createAssessmentIncidence(false, Language.GetText("Error.LoadAssessmentData.IO"), xmlFile, e)); //} } return(newProfile); }
/* Methods */ /** * Default constructor */ public AssessmentHandler(InputStreamCreator isCreator, AssessmentProfile profile) { this.profile = profile; if (profile.getRules() == null) assessmentRules = new List<AssessmentRule>(); else assessmentRules = profile.getRules(); currentAssessmentRule = null; currentstring = string.Empty; vars = new List<string>(); flags = new List<string>(); profile.setFlags(flags); profile.setVars(vars); this.isCreator = isCreator; }
public AnimationHandler_(InputStreamCreator isCreator, ImageLoaderFactory imageloader) { this.factory = imageloader; this.isCreator = isCreator; }
/** * Loads the descriptor of the current ZIP adventure loaded * * @return The descriptor data of the game */ public static DescriptorData loadDescriptorData(InputStreamCreator isCreator, List<Incidence> incidences) { DescriptorData descriptorData = null; if (Loader.adventureData != null) { descriptorData = Loader.adventureData; } else { try { // Set the adventure handler DescriptorHandler descriptorParser = new DescriptorHandler(isCreator); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); // Read and close the inputstrea string descriptorIS = isCreator.buildInputStream("descriptor.xml"); //saxParser.parse(descriptorIS, descriptorParser); //descriptorIS.close(); descriptorParser.Parse(descriptorIS); // Store the adventure data descriptorData = descriptorParser.getGameDescriptor(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.IO"), e)); //} //catch (IllegalArgumentException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.NoDescriptor"), e)); //} } return descriptorData; }
/** * Loads the adaptation profile (set of adaptation rules + initial state) * stored in file with path xmlFile in zipFile * * @param zipFile * @param xmlFile * @param incidences * @return */ public static AdaptationProfile loadAdaptationProfile(InputStreamCreator isCreator, string xmlFile, List<Incidence> incidences) { AdaptationProfile newProfile = null; if (Loader.adventureData != null) { foreach (Chapter chapter in Loader.adventureData.getChapters()) { if (chapter.getAssessmentProfiles().Count != 0) { foreach (AdaptationProfile profile in chapter.getAdaptationProfiles()) if (profile.getName().Equals(xmlFile)) { newProfile = profile; break; } } } } else { // Open the file and load the data try { // Set the chapter handler List<AdaptationRule> rules = new List<AdaptationRule>(); AdaptedState initialState = new AdaptedState(); AdaptationHandler adpParser = new AdaptationHandler(isCreator, rules, initialState); //factory.setValidating(true); //SAXParser saxParser = factory.newSAXParser(); // Parse the data and close the data string adaptationIS = isCreator.buildInputStream(xmlFile); //saxParser.parse(adaptationIS, adpParser); //adaptationIS.close(); adpParser.Parse(adaptationIS); // Finally add the new controller to the list // Create the new profile string name = xmlFile; name = name.Substring(name.IndexOf("/") + 1); name = name.Substring(0, name.IndexOf(".")); newProfile = new AdaptationProfile(adpParser.getAdaptationRules(), adpParser.getInitialState(), name, adpParser.isScorm12(), adpParser.isScorm2004()); newProfile.setFlags(adpParser.getFlags()); newProfile.setVars(adpParser.getVars()); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createAdaptationIncidence(false, Language.GetText("Error.LoadAdaptationData.SAX"), xmlFile, e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createAdaptationIncidence(false, Language.GetText("Error.LoadAdaptationData.SAX"), xmlFile, e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createAdaptationIncidence(false, Language.GetText("Error.LoadAdaptationData.IO"), xmlFile, e)); //} } return newProfile; }
/** * Loads the script data from the given XML file * * @param filename * Name of the XML file containing the script * @param validate * distinguish between if the load is made in editor or engine * @return The script stored as game data */ public static Chapter loadChapterData(InputStreamCreator isCreator, string fileName, List<Incidence> incidences) { // Create the chapter Chapter currentChapter = new Chapter(); bool chapterFound = false; if (Loader.adventureData != null) { foreach (Chapter chapter in adventureData.getChapters()) { if (chapter != null && chapter.getChapterPath() != null && chapter.getChapterPath().Equals(fileName)) { currentChapter = chapter; chapterFound = true; break; } else if (chapter != null && chapter.getChapterPath() == null) { currentChapter = chapter; chapterFound = true; currentChapter.setChapterPath("chapter1.xml"); break; } } } if (!chapterFound) { string chapterIS = null; //if (zipFile!=null){ chapterIS = isCreator.buildInputStream(fileName); currentChapter.setChapterPath(fileName); //} else{ // Then fileName is an absolutePath //string chapterPath = fileName.substring( Math.max (fileName.lastIndexOf( '\\' ), fileName.lastIndexOf( '/' ) ), fileName.length( )); //currentChapter.setName( chapterPath ); //try { // chapterIS = new FileInputStream( fileName ); //} catch (FileNotFoundException e) { //e.printStackTrace(); // incidences.add( Incidence.createChapterIncidence( TextConstants.getText( "Error.LoadData.IO" ), fileName ) ); //} //} // Open the file and load the data try { if (chapterIS != null) { // Set the chapter handler ChapterHandler chapterParser = new ChapterHandler(isCreator, currentChapter); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); //// Parse the data and close the data //saxParser.parse(chapterIS, chapterParser); //chapterIS.close(); chapterParser.Parse(chapterIS); } } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), fileName, e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), fileName, e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.IO"), fileName, e)); //} } //Debug.Log(currentChapter); return currentChapter; }
/** * Loads the adaptation profile (set of adaptation rules + initial state) * stored in file with path xmlFile in zipFile * * @param zipFile * @param xmlFile * @param incidences * @return */ public static AdaptationProfile loadAdaptationProfile(InputStreamCreator isCreator, string xmlFile, List <Incidence> incidences) { AdaptationProfile newProfile = null; if (Loader.adventureData != null) { foreach (Chapter chapter in Loader.adventureData.getChapters()) { if (chapter.getAssessmentProfiles().Count != 0) { foreach (AdaptationProfile profile in chapter.getAdaptationProfiles()) { if (profile.getName().Equals(xmlFile)) { newProfile = profile; break; } } } } } else { // Open the file and load the data try { // Set the chapter handler List <AdaptationRule> rules = new List <AdaptationRule>(); AdaptedState initialState = new AdaptedState(); AdaptationHandler adpParser = new AdaptationHandler(isCreator, rules, initialState); //factory.setValidating(true); //SAXParser saxParser = factory.newSAXParser(); // Parse the data and close the data string adaptationIS = isCreator.buildInputStream(xmlFile); //saxParser.parse(adaptationIS, adpParser); //adaptationIS.close(); adpParser.Parse(adaptationIS); // Finally add the new controller to the list // Create the new profile string name = xmlFile; name = name.Substring(name.IndexOf("/") + 1); name = name.Substring(0, name.IndexOf(".")); newProfile = new AdaptationProfile(adpParser.getAdaptationRules(), adpParser.getInitialState(), name, adpParser.isScorm12(), adpParser.isScorm2004()); newProfile.setFlags(adpParser.getFlags()); newProfile.setVars(adpParser.getVars()); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createAdaptationIncidence(false, Language.GetText("Error.LoadAdaptationData.SAX"), xmlFile, e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createAdaptationIncidence(false, Language.GetText("Error.LoadAdaptationData.SAX"), xmlFile, e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createAdaptationIncidence(false, Language.GetText("Error.LoadAdaptationData.IO"), xmlFile, e)); //} } return(newProfile); }