Package org.jibx.runtime

Examples of org.jibx.runtime.IUnmarshallingContext


     * @see IUnmarshallingContext#unmarshalDocument(java.io.InputStream, String)
     */
    private Container toContainer(final String xml) throws Exception {
        ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes());
        IBindingFactory bfact = BindingDirectory.getFactory(Container.class);
        IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
        return (Container) uctx.unmarshalDocument(is, null);
    }
View Full Code Here


  // Unmarshalling

  @Override
  protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
    try {
      IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
      return unmarshallingContext.unmarshalDocument(inputStream, null);
    }
    catch (JiBXException ex) {
      throw convertJibxException(ex, false);
    }
  }
View Full Code Here

  }

  @Override
  protected Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
    try {
      IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
      return unmarshallingContext.unmarshalDocument(reader);
    }
    catch (JiBXException ex) {
      throw convertJibxException(ex, false);
    }
  }
View Full Code Here

            + piece.name().toLowerCase() + XML_EXT);

        IBindingFactory bfact = BindingDirectory
            .getFactory(PieceDef.class);

        IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
        PieceDef unmarshalledPiece = (PieceDef) uctx.unmarshalDocument(
            new BufferedReader(new InputStreamReader(piecePath
                .openStream())), null);
        pieceMap.put(piece, unmarshalledPiece);
      }
      return pieceMap.get(piece).clone();
View Full Code Here

      URL basiliskFile = new URL(
          "http://dragonchess.darkhelm.org/xml/pieces/basilisk.xml");

      IBindingFactory bfact = BindingDirectory.getFactory(PieceDef.class);

      IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
      PieceDef piece = (PieceDef) uctx.unmarshalDocument(new BufferedReader(
          new InputStreamReader(basiliskFile.openStream())), null);

      PrintWriter out = resp.getWriter();

      resp.setContentType("text/plain");
View Full Code Here

    URL boardPath = Boards.class.getResource(XML_PATH
        + board.name().toLowerCase() + XML_EXT);

    IBindingFactory bfact = BindingDirectory.getFactory(BoardDef.class);

    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    BoardDef ret = ((BoardDef) uctx.unmarshalDocument(new BufferedReader(
        new InputStreamReader(boardPath.openStream())), null)).clone();
    ret.set = set;
    return ret;
  }
View Full Code Here

  private BoardDef loadBoard(String pieceFile) throws JiBXException, IOException {
    URL boardPath = Boards.class.getResource("/xml/boards/" + pieceFile);

    IBindingFactory bfact = BindingDirectory.getFactory(BoardDef.class);

    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    return (BoardDef) uctx.unmarshalDocument(new BufferedReader(
        new InputStreamReader(boardPath.openStream())), null);
  }
View Full Code Here

         mctx.marshalDocument(newRepositoryServiceConfiguration, "ISO-8859-1", null, saveStream);
         saveStream.close();

         // 1st unmarshal
         factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
         IUnmarshallingContext uctx = factory.createUnmarshallingContext();
         RepositoryServiceConfiguration conf =
            (RepositoryServiceConfiguration)uctx
               .unmarshalDocument(PrivilegedFileHelper.fileInputStream(tempFile), null);

         // 1st check
         RepositoryEntry unmarshledRepositoryEntry =
            conf.getRepositoryConfiguration(repository.getConfiguration().getName());
         assertEquals(lockManagerTimeOut, unmarshledRepositoryEntry.getWorkspaceEntries().get(0).getLockManager()
            .getTimeout());

         // 2nd marshal configuration
         tempFile = PrivilegedFileHelper.createTempFile("test-config", "xml");
         PrivilegedFileHelper.deleteOnExit(tempFile);

         factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
         mctx = factory.createMarshallingContext();
         saveStream = new FileOutputStream(tempFile);
         repositoryEntries = new ArrayList<RepositoryEntry>();
         repositoryEntries.add(repository.getConfiguration());

         newRepositoryServiceConfiguration =
            new RepositoryServiceConfiguration(repositoryService.getConfig().getDefaultRepositoryName(),
               repositoryEntries);
         mctx.marshalDocument(newRepositoryServiceConfiguration, "ISO-8859-1", null, saveStream);
         saveStream.close();

         // 2nd unmarshal
         factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
         uctx = factory.createUnmarshallingContext();
         conf =
            (RepositoryServiceConfiguration)uctx
               .unmarshalDocument(PrivilegedFileHelper.fileInputStream(tempFile), null);

         // 2nd check
         unmarshledRepositoryEntry = conf.getRepositoryConfiguration(repository.getConfiguration().getName());
         assertEquals(lockManagerTimeOut, unmarshledRepositoryEntry.getWorkspaceEntries().get(0).getLockManager()
View Full Code Here

         saveStream.close();

         persiter.write(new ByteArrayInputStream(((ByteArrayOutputStream)saveStream).toByteArray()));

         IBindingFactory factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
         IUnmarshallingContext uctx = factory.createUnmarshallingContext();
         RepositoryServiceConfiguration storedConf =
            (RepositoryServiceConfiguration)uctx.unmarshalDocument(persiter.read(), null);

         for (int i = 0; i < theadsCount; i++)
         {
            // test if respository has been created
            ManageableRepository repository = threads[i].getRepository();
View Full Code Here

  private PieceDef loadPiece(String pieceFile) throws JiBXException, IOException {
    URL piecePath = Pieces.class.getResource("/xml/pieces/" + pieceFile);

    IBindingFactory bfact = BindingDirectory.getFactory(PieceDef.class);

    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    return (PieceDef) uctx.unmarshalDocument(new BufferedReader(
        new InputStreamReader(piecePath.openStream())), null);
  }
View Full Code Here

TOP

Related Classes of org.jibx.runtime.IUnmarshallingContext

Copyright © 2018 www.massapicom. 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.