Esempio n. 1
0
 /**
  * Method toMyString:
  *
  * @param verboseflag sets whether we want to list the results info inside the XML or not at all.
  * @return the XML String representing this requested Query Definition XML fields
  */
 public String toMyString(boolean verboseflag) {
   StringWriter outStringWriter = new StringWriter();
   WstxOutputFactory fout = new WstxOutputFactory();
   fout.configureForXmlConformance();
   SMOutputDocument doc = null;
   try {
     // output
     XMLStreamWriter2 sw = (XMLStreamWriter2) fout.createXMLStreamWriter(outStringWriter);
     doc = SMOutputFactory.createOutputDocument(sw, "1.0", "UTF-8", true);
     doc.setIndentation("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", 2, 1);
     createInfoInDocument(doc, null, verboseflag);
     doc.closeRoot();
   } catch (Exception e) {
     e.printStackTrace();
     return "Errors encountered while attempting to print this Query Definition!";
   }
   String retString = "";
   try {
     retString = outStringWriter.toString();
     outStringWriter.close();
   } catch (Exception e) {
     logger.error("Errors encountered while attempting to print this XML document!");
     e.printStackTrace();
   }
   return retString;
   //           StructuredTextDocument document = (StructuredTextDocument)
   // StructuredDocumentFactory.newStructuredDocument(new MimeMediaType("text/xml"),
   // IndexOfQueries.getQueryDefTag());
 }
Esempio n. 2
0
  /**
   * Write the instance of IndexOfModelMappings back to the corresponding file (Used for
   * persistence)
   */
  public static synchronized void writeIndexBackToFile() {
    // Write file from the Vector
    File outFile = new File(Model3dIndex.getIndexPath() + "modelIndex.xml");
    try {
      outFile
          .createNewFile(); // will create it if it does not exist, otherwise will return false (we
                            // don't care)
      FileWriter tmpoutWriter = new FileWriter(outFile);
      WstxOutputFactory fout = new WstxOutputFactory();
      fout.configureForXmlConformance();
      SMOutputDocument doc = null;
      SMOutputElement outputRootEl = null;
      SMOutputElement outputRootEl2 = null;

      // output
      XMLStreamWriter2 sw = (XMLStreamWriter2) fout.createXMLStreamWriter(tmpoutWriter);
      doc = SMOutputFactory.createOutputDocument(sw, "1.0", "UTF-8", true);
      doc.setIndentation("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", 2, 1);
      outputRootEl = doc.addElement(Model3dIndex.getRootIndexTag());

      for (int i = 0; i < Model3dIndex.getListofAllMetaEntries().size(); i++) {
        outputRootEl2 = outputRootEl.addElement(Model3dIndex.getMetaEntryTag());
        Model3dIndex.getListofAllMetaEntries().elementAt(i).createInfoInDocument(outputRootEl2);
      }

      doc.closeRoot();
      tmpoutWriter.close();
    } catch (Exception e) {
      return;
    }
  }
 /**
  * Method toString: no parameters
  *
  * @return the XML String representing this Style Numeric Case entry's XML fields
  */
 public String toString() {
   StringWriter outStringWriter = new StringWriter();
   WstxOutputFactory fout = new WstxOutputFactory();
   fout.configureForXmlConformance();
   SMOutputDocument doc = null;
   SMOutputElement outputRootEl = null;
   try {
     // output
     XMLStreamWriter2 sw = (XMLStreamWriter2) fout.createXMLStreamWriter(outStringWriter);
     doc = SMOutputFactory.createOutputDocument(sw, "1.0", "UTF-8", true);
     doc.setIndentation("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", 2, 1);
     outputRootEl = doc.addElement(Model3dStylesEntry.getNumericCaseTag());
     createInfoInDocument(outputRootEl);
     doc.closeRoot();
   } catch (Exception e) {
     return "";
   }
   String retString = "";
   try {
     retString = outStringWriter.toString();
     outStringWriter.close();
   } catch (Exception e) {
     logger.error("Errors encountered while attempting to print this XML document!");
     e.printStackTrace();
   }
   return retString;
 }