Java 8 JAXBSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JAXBSource class.

This code example shows how to use the following methods:
    public void transform(final JAXBElement source, final T target) {
        Transformer pooledObject;
        try { 
            pooledObject = xsltResourcePool.borrowObject();
            try { 
                pooledObject.transform(new JAXBSource(jaxbContext, source), new StreamResult(target));
            } catch (Exception e) {
                xsltResourcePool.invalidateObject(pooledObject);
                pooledObject = null;
                throw new XsltTransformationException("Failed while attempting XSLT transformation.", e);
            } finally { 
                if (pooledObject != null) {
                    xsltResourcePool.returnObject(pooledObject);
                } 
            } 
        } catch (XsltTransformationException e) {
            throw e;
        } catch (Exception e) {
            throw new XsltTransformationException("Failed to obtain a Transformer for XSLT transformation.", e);
        } 
6
CodeRank
This code example shows how to use the following methods:
                // This harness cheats and provides the input stream directly. 
                pooledObject.setURIResolver(inputStreamUriParameter);
                pooledObject.setParameter("absoluteURL", inputStreamUriParameter.getHref());
                final Limits limitsObject = new Limits();
                limitsObject.setRates(source.getRateLimitList());
                pooledObject.transform(new JAXBSource(jaxbContext, factory.createLimits(limitsObject)), resultWriter);
            } catch (Exception e) {
                objectPool.invalidateObject(pooledObject);
                pooledObject = null;
                throw new XsltTransformationException("Failed while attempting XSLT transformation.", e);
            } finally { 
                if (pooledObject != null) {
                    objectPool.returnObject(pooledObject);
                } 
            } 
        } catch (XsltTransformationException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("Failed to obtain a Transformer. Reason: {}", e.getLocalizedMessage());
            LOG.trace("", e);
5
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
  public static Comprobante newComprobante(InputStream in) throws Exception {
    return load(in);
  } 
 
  byte[] getOriginalBytes() throws Exception {
    JAXBSource in = new JAXBSource(context, document);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Result out = new StreamResult(baos);
    TransformerFactory factory = tf;
    if (factory == null) {
      factory = TransformerFactory.newInstance();
      factory.setURIResolver(new URIResolverImpl());
    }      
    Transformer transformer = factory
      .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
    transformer.transform(in, out);
    return baos.toByteArray();
  } 
   
  String getSignature(PrivateKey key) throws Exception {
    byte[] bytes = getOriginalBytes();
4
CodeRank
This code example shows how to use the following methods:
  public static Comprobante newComprobante(InputStream in) throws Exception {
    return load(in);
  } 
 
  byte[] getOriginalBytes() throws Exception {
    JAXBSource in = new JAXBSource(context, document);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Result out = new StreamResult(baos);
    TransformerFactory factory = tf;
    if (factory == null) {
      factory = TransformerFactory.newInstance();
      factory.setURIResolver(new URIResolverImpl());
    }      
    Transformer transformer = factory
      .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
    transformer.transform(in, out);
    return baos.toByteArray();
  } 
   
  String getSignature(PrivateKey key) throws Exception {
    byte[] bytes = getOriginalBytes();
4
CodeRank
This code example shows how to use the following methods:
     *  
     * @return A JAXB SAX source. 
     */ 
    public JAXBSource getJaxbSource() throws IOException {
        try { 
            return new JAXBSource(getContext(), getObject());
        } catch (JAXBException e) {
            throw new IOException(
                    "JAXBException while creating the JAXBSource: " 
                            + e.getMessage());
        } 
    } 
 
    /** 
     * Returns the optional namespace prefix mapper for marshalling. 
     *  
     * @return The optional namespace prefix mapper for marshalling. 
     */ 
    public NamespacePrefixMapper getNamespacePrefixMapper() { 
        return namespacePrefixMapper;
4
CodeRank
This code example shows how to use the following methods:
  TimbreFiscalDigital getTimbre() { 
    return tfd;
  } 
 
  byte[] getOriginalBytes() throws Exception {
    JAXBSource in = new JAXBSource(CONTEXT, tfd);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Result out = new StreamResult(baos);
    TransformerFactory factory = tf;
    if (factory == null) {
      factory = TransformerFactory.newInstance();
    }  
    Transformer transformer = factory
      .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
    transformer.transform(in, out);
    return baos.toByteArray();
  } 
     
  String getSignature(PrivateKey key) throws Exception {
    byte[] bytes = getOriginalBytes();
4
CodeRank
This code example shows how to use the following methods:
  TimbreFiscalDigital getTimbre() { 
    return tfd;
  } 
 
  byte[] getOriginalBytes() throws Exception {
    JAXBSource in = new JAXBSource(CONTEXT, tfd);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Result out = new StreamResult(baos);
    TransformerFactory factory = tf;
    if (factory == null) {
      factory = TransformerFactory.newInstance();
    }  
    Transformer transformer = factory
      .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
    transformer.transform(in, out);
    return baos.toByteArray();
  } 
     
  String getSignature(PrivateKey key) throws Exception {
    byte[] bytes = getOriginalBytes();
4
CodeRank
This code example shows how to use the following methods:
 
    public void testUnmarshalFromJAXBSource() throws Exception {
        File file = new File(ClassLoader.getSystemResource(CONTROL_XML_FILE_NAME).getFile());
        Object unmarshalledObject = unmarshaller.unmarshal(file);
 
        JAXBSource jaxbSource = new JAXBSource(jaxbContext.createMarshaller(), unmarshalledObject);
 
        Object objectFromSource = unmarshaller.unmarshal(jaxbSource);
        assertEquals(getControlObject(), objectFromSource);
    } 
 
    // Invalid sources tests============================================================= 
 
    public void testUnmarshalFromInvalidFile() throws Exception {
        File file = new File("blah.txt");
        try { 
            Object unmarshalledObject = unmarshaller.unmarshal(file);
        } catch (UnmarshalException e) {
            assertTrue(true);
            return; 
4
CodeRank
This code example shows how to use the following methods:
    } 
 
    // Implement ITransformable 
 
    public Source getSource() throws JAXBException, ScapException {
	return new JAXBSource(getJAXBContext(), getRootObject());
    } 
 
    public JAXBElement<SceResultsType> getRootObject() {
	return Script.FACTORY.createSceResults(result);
    } 
 
    public JAXBElement<SceResultsType> copyRootObject() throws Exception {
        Unmarshaller unmarshaller = getJAXBContext().createUnmarshaller();
        Object rootObj = unmarshaller.unmarshal(new DOMSource(DOMTools.toDocument(this).getDocumentElement()));
        if (rootObj instanceof JAXBElement && ((JAXBElement)rootObj).getValue() instanceof SceResultsType) {
	    @SuppressWarnings("unchecked") 
            JAXBElement<SceResultsType> result = (JAXBElement<SceResultsType>)rootObj;
            return result;
        } else { 
3
CodeRank
See Code Examples for Java 8 JAXBSource Methods: