/** * @param xml * XML string * @param clearConstruction * true to clear construction before processing * @param isGgtFile * true for macro files * @param randomize * whether to randomize numbers * @throws Exception * if XML is invalid or there was a problem while processing */ public void processXMLString(String xml, boolean clearConstruction, boolean isGgtFile, boolean randomize) throws Exception { if (cons != null) { cons.setFileLoading(true); } if (!isGgtFile) { app.resetUniqueId(); } processXMLString(xml, clearConstruction, isGgtFile, true, randomize); if (cons != null) { cons.setFileLoading(false); } }
/** * Reads from a zipped input stream that includes only the construction * saved in xml format. * * @param is * input stream * @throws Exception * on parsing error */ public final void readZipFromMemory(InputStream is) throws Exception { ZipInputStream zip = new ZipInputStream(is); // get all entries from the zip archive ZipEntry entry = zip.getNextEntry(); if (entry != null && entry.getName().equals(XML_FILE)) { // process xml file kernel.getConstruction().setFileLoading(true); doParseXML(new XMLStreamInputStream(zip), true, false, true, true, false); kernel.getConstruction().setFileLoading(false); zip.close(); } else { zip.close(); throw new Exception(XML_FILE + " not found"); } }
/** * Creates new macro construction * * @param kernel * Kernel */ public MacroConstruction(MacroKernel kernel) { super(kernel, kernel.getParentKernel().getConstruction()); parentCons = kernel.getParentKernel().getConstruction(); reservedLabels = new HashSet<>(); // allow using reserved function names in marco constructions super.setFileLoading(true); }
/** * Processes XML * * @param strXML * XML string * @param isGGTOrDefaults * whether to treat the XML as defaults * @param info * EvalInfo (can be null) * @throws Exception * on trouble with parsing or running commands */ final public synchronized void processXML(String strXML, boolean isGGTOrDefaults, EvalInfo info) throws Exception { boolean randomize = info == null || info.updateRandom(); construction.setFileLoading(true); construction.setCasCellUpdate(true); construction.getXMLio().processXMLString(strXML, true, isGGTOrDefaults, true, randomize); construction.setFileLoading(false); construction.setCasCellUpdate(false); }