Examples of XCASSerializer


Examples of org.apache.uima.cas.impl.XCASSerializer

  private void writeXCas(CAS aCas, File name) throws IOException, SAXException {
    FileOutputStream out = null;

    try {
      out = new FileOutputStream(name);
      XCASSerializer ser = new XCASSerializer(aCas.getTypeSystem());
      XMLSerializer xmlSer = new XMLSerializer(out, false);
      ser.serialize(aCas, xmlSer.getContentHandler());
    } finally {
      if (out != null) {
        out.close();
      }
    }
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

  private void writeXCas(CAS aCas, String fileName) throws IOException, SAXException {
    File outFile = new File(outputDirectory, fileName + ".xcas");
    FileOutputStream out = null;
    try {
      out = new FileOutputStream(outFile);
      XCASSerializer ser = new XCASSerializer(aCas.getTypeSystem());
      XMLSerializer xmlSer = new XMLSerializer(out, false);
      ser.serialize(aCas, xmlSer.getContentHandler());
    }
    finally {
      if (out != null) {
        out.close();
      }
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

        MainFrame.this.xcasFileOpenDir = xcasFile.getParentFile();
        try {
          long time = System.currentTimeMillis();
          OutputStream outStream = new BufferedOutputStream(new FileOutputStream(xcasFile));
          XMLSerializer xmlSerializer = new XMLSerializer(outStream);
          XCASSerializer xcasSerializer = new XCASSerializer(MainFrame.this.cas.getTypeSystem());
          xcasSerializer.serialize(MainFrame.this.cas, xmlSerializer.getContentHandler());
          outStream.close();
          time = System.currentTimeMillis() - time;
          System.out.println("Time taken: " + new TimeSpan(time));
        } catch (IOException e) {
          handleException(e);
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

    // create FS
    createExampleFS(cas);

    // serialize
    XCASSerializer ser = new XCASSerializer(cas.getTypeSystem());
    OutputStream outputXCAS = new FileOutputStream(JUnitExtension
            .getFile("ExampleCas/newprimitives.xcas"));
    XMLSerializer xmlSer = new XMLSerializer(outputXCAS);
    ser.serialize(cas, xmlSer.getContentHandler());

    // reset
    cas.reset();

    // deserialize
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

      // Set the document text
      es.setLocalSofaData("this beer is good");

      // Test Multiple Sofas across XCAS serialization
      XCASSerializer ser = new XCASSerializer(this.cas.getTypeSystem());
      OutputStream outputXCAS = new FileOutputStream("Sofa.xcas");
      XMLSerializer xmlSer = new XMLSerializer(outputXCAS);
      try {
        ser.serialize(cas, xmlSer.getContentHandler());
        outputXCAS.close();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (SAXException e) {
        e.printStackTrace();
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

      // Set the document text
      es.setLocalSofaData("this beer is good");

      // Test Multiple Sofas across XCAS serialization
      XCASSerializer ser = new XCASSerializer(cas.getTypeSystem());
      OutputStream outputXCAS = new FileOutputStream("Sofa.xcas");
      XMLSerializer xmlSer = new XMLSerializer(outputXCAS);
      try {
        ser.serialize(cas, xmlSer.getContentHandler());
        outputXCAS.close();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (SAXException e) {
        e.printStackTrace();
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

          ParserConfigurationException, SAXException, ResourceInitializationException,
          CASRuntimeException {
    // generate XCAS events and pipe them to XCasToCasDataSaxHandler
    CasData casData = new CasDataImpl();
    XCasToCasDataSaxHandler handler = new XCasToCasDataSaxHandler(casData);
    XCASSerializer xcasSer = new XCASSerializer(aCAS.getTypeSystem());
    xcasSer.serialize(aCAS, handler);

    Assert.assertNotNull(casData);
    assertValidCasData(casData, aCAS.getTypeSystem());
    // System.out.println(casData);
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

          ParserConfigurationException, SAXException, ResourceInitializationException,
          CASRuntimeException {
    // generate XCAS events and pipe them to XCasToCasDataSaxHandler
    CasData casData = new CasDataImpl();
    XCasToCasDataSaxHandler handler = new XCasToCasDataSaxHandler(casData);
    XCASSerializer xcasSer = new XCASSerializer(aCAS.getTypeSystem());
    xcasSer.serialize(aCAS, handler);

    Assert.assertNotNull(casData);
    assertValidCasData(casData, aCAS.getTypeSystem());
    // System.out.println(casData);
View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

   * Serializes the {@link CAS} to the given {@link OutputStream} in the XCAS format.
   */
  public void serialize(OutputStream out) throws CoreException {

    if (DocumentFormat.XCAS.equals(format)) {
      XCASSerializer xcasSerializer = new XCASSerializer(mCAS.getTypeSystem());

      XMLSerializer xmlSerialzer = new XMLSerializer(out, true);

      try {
        xcasSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
      } catch (IOException e) {
        String message = e.getMessage() != null ? e.getMessage() : "";

        IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);

View Full Code Here

Examples of org.apache.uima.cas.impl.XCASSerializer

      // Set the document text
      es.setLocalSofaData("this beer is good");

      // Test Multiple Sofas across XCAS serialization
      XCASSerializer ser = new XCASSerializer(this.cas.getTypeSystem());
      OutputStream outputXCAS = new FileOutputStream("Sofa.xcas");
      XMLSerializer xmlSer = new XMLSerializer(outputXCAS);
      try {
        ser.serialize(cas, xmlSer.getContentHandler());
        outputXCAS.close();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (SAXException e) {
        e.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.