當前位置: 首頁>>代碼示例>>Java>>正文


Java LSOutput.setByteStream方法代碼示例

本文整理匯總了Java中org.w3c.dom.ls.LSOutput.setByteStream方法的典型用法代碼示例。如果您正苦於以下問題:Java LSOutput.setByteStream方法的具體用法?Java LSOutput.setByteStream怎麽用?Java LSOutput.setByteStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.w3c.dom.ls.LSOutput的用法示例。


在下文中一共展示了LSOutput.setByteStream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: marshall

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * `
 * Serialize XML objects
 *
 * @param xmlObject : XACML or SAML objects to be serialized
 * @return serialized XACML or SAML objects
 * @throws EntitlementException
 */
private String marshall(XMLObject xmlObject) throws EntitlementException {

    try {
        doBootstrap();
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStream);
        writer.write(element, output);
        return byteArrayOutputStream.toString();
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new EntitlementException("Error Serializing the SAML Response", e);
    }
}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:34,代碼來源:WSXACMLMessageReceiver.java

示例2: marshall

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * Serializes the specified SAML 2.0 based XML content representation to its corresponding actual XML syntax
 * representation.
 *
 * @param xmlObject the SAML 2.0 based XML content object
 * @return a {@link String} representation of the actual XML representation of the SAML 2.0 based XML content
 * representation
 * @throws SSOException if an error occurs during the marshalling process
 */
public static String marshall(XMLObject xmlObject) throws SSOException {
    try {
        Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(xmlObject);
        Element element = null;
        if (marshaller != null) {
            element = marshaller.marshall(xmlObject);
        }
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS implementation = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = implementation.createLSSerializer();
        LSOutput output = implementation.createLSOutput();
        output.setByteStream(byteArrayOutputStream);
        writer.write(element, output);
        return new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);
    } catch (ClassNotFoundException | InstantiationException | MarshallingException | IllegalAccessException e) {
        throw new SSOException("Error in marshalling SAML 2.0 Assertion", e);
    }
}
 
開發者ID:wso2-extensions,項目名稱:tomcat-extension-samlsso,代碼行數:29,代碼來源:SSOUtils.java

示例3: transformNonTextNodeToOutputStream

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * Serializes a node using a certain character encoding.
 * 
 * @param node
 *            DOM node to serialize
 * @param os
 *            output stream, to which the node is serialized
 * @param omitXmlDeclaration
 *            indicator whether to omit the XML declaration or not
 * @param encoding
 *            character encoding, can be <code>null</code>, if
 *            <code>null</code> then "UTF-8" is used
 * @throws Exception
 */
public static void transformNonTextNodeToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration, String encoding)
    throws Exception { //NOPMD
    // previously we used javax.xml.transform.Transformer, however the JDK xalan implementation did not work correctly with a specified encoding
    // therefore we switched to DOMImplementationLS
    if (encoding == null) {
        encoding = "UTF-8";
    }
    DOMImplementationRegistry domImplementationRegistry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementationRegistry.getDOMImplementation("LS");
    LSOutput lsOutput = domImplementationLS.createLSOutput();
    lsOutput.setEncoding(encoding);
    lsOutput.setByteStream(os);
    LSSerializer lss = domImplementationLS.createLSSerializer();
    lss.getDomConfig().setParameter("xml-declaration", !omitXmlDeclaration);
    lss.write(node, lsOutput);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:31,代碼來源:XmlSignatureHelper.java

示例4: marshall

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * Serializing a SAML2 object into a String
 *
 * @param xmlObject object that needs to serialized.
 * @return serialized object
 * @throws SAMLSSOException
 */
public static String marshall(XMLObject xmlObject) throws SAMLSSOException {
    try {

        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration
                .getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString();
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new SAMLSSOException("Error Serializing the SAML Response", e);
    }
}
 
開發者ID:wso2-attic,項目名稱:carbon-identity,代碼行數:32,代碼來源:SSOUtils.java

示例5: marshall

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * Serializing a SAML2 object into a String
 *
 * @param xmlObject object that needs to serialized.
 * @return serialized object
 * @throws SAML2SSOUIAuthenticatorException
 */
public static String marshall(XMLObject xmlObject) throws SAML2SSOUIAuthenticatorException {

    try {
        doBootstrap();
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration
                .getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString();
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new SAML2SSOUIAuthenticatorException("Error Serializing the SAML Response", e);
    }
}
 
開發者ID:wso2-attic,項目名稱:carbon-identity,代碼行數:33,代碼來源:Util.java

示例6: marshall

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
private static String marshall(XMLObject xmlObject) throws org.wso2.carbon.identity.base.IdentityException {
    try {
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString("UTF-8");
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw IdentityException.error("Error Serializing the SAML Response", e);
    }
}
 
開發者ID:wso2-attic,項目名稱:carbon-identity,代碼行數:24,代碼來源:ErrorResponseBuilder.java

示例7: marshall

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * Serializing a SAML2 object into a String
 *
 * @param xmlObject object that needs to serialized.
 * @return serialized object
 * @throws Exception
 */
public static String marshall(XMLObject xmlObject) throws Exception {
    try {
        doBootstrap();
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                           "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString();
    } catch (Exception e) {
        throw new Exception("Error Serializing the SAML Response", e);
    }
}
 
開發者ID:wso2,項目名稱:carbon-commons,代碼行數:31,代碼來源:Util.java

示例8: serializeDOM_LS

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
protected void serializeDOM_LS(Element elt, OutputStream out, boolean pretty) throws LSException
{
    DOMImplementationLS impl = (DOMImplementationLS)XMLImplFinder.getDOMImplementation(); 
    
    // init and configure serializer
    LSSerializer serializer = impl.createLSSerializer();
    DOMConfiguration config = serializer.getDomConfig();
    config.setParameter("format-pretty-print", pretty);
    
    // wrap output stream
    LSOutput output = impl.createLSOutput();
    output.setByteStream(out);
    
    // launch serialization
    serializer.write(elt, output);
}
 
開發者ID:sensiasoft,項目名稱:lib-swe-common,代碼行數:17,代碼來源:XMLDocument.java

示例9: writeDocument

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * Writes a DOM Document to the given OutputStream using the "UTF-8"
 * encoding. The XML declaration is omitted.
 * 
 * @param outStream
 *            The destination OutputStream object.
 * @param doc
 *            A Document node.
 */
void writeDocument(OutputStream outStream, Document doc) {
    DOMImplementationRegistry domRegistry = null;
    try {
        domRegistry = DOMImplementationRegistry.newInstance();
    } catch (Exception e) {
        LOGR.warning(e.getMessage());
    }
    DOMImplementationLS impl = (DOMImplementationLS) domRegistry
            .getDOMImplementation("LS");
    LSSerializer writer = impl.createLSSerializer();
    writer.getDomConfig().setParameter("xml-declaration", false);
    writer.getDomConfig().setParameter("format-pretty-print", true);
    LSOutput output = impl.createLSOutput();
    output.setEncoding("UTF-8");
    output.setByteStream(outStream);
    writer.write(doc, output);
}
 
開發者ID:opengeospatial,項目名稱:teamengine,代碼行數:27,代碼來源:CoverageMonitor.java

示例10: elementToString

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
private static String elementToString(Element e) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DOMImplementationLS ls = (DOMImplementationLS) e.getOwnerDocument().getImplementation().getFeature("LS", "3.0"); // NOI18N
    LSOutput output = ls.createLSOutput();
    output.setByteStream(baos);
    LSSerializer ser = ls.createLSSerializer();
    ser.write(e, output);
    return baos.toString();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ProjectXMLManagerTest.java

示例11: writeNode

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/**
 * Writes a Node out to an OutputStream using the DOM, level 3, Load/Save serializer. The written content 
 * is encoded using the encoding specified in the output stream configuration.
 * 
 * @param node the node to write out
 * @param output the output stream to write the XML to
 * @param serializerParams parameters to pass to the {@link DOMConfiguration} of the serializer
 *         instance, obtained via {@link LSSerializer#getDomConfig()}. May be null.
 */
public static void writeNode(Node node, OutputStream output, Map<String, Object> serializerParams) {
    DOMImplementationLS domImplLS = getLSDOMImpl(node);
    
    LSSerializer serializer = getLSSerializer(domImplLS, serializerParams);

    LSOutput serializerOut = domImplLS.createLSOutput();
    serializerOut.setByteStream(output);

    serializer.write(node, serializerOut);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:XMLHelper.java

示例12: getGroupings

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
   private void getGroupings(Integer organisationId, HttpServletResponse response) throws IOException {
Document doc = OrganisationGroupServlet.docBuilder.newDocument();
Element groupsElement = doc.createElement("groups");
doc.appendChild(groupsElement);

List<OrganisationGrouping> groupings = userManagementService.findByProperty(OrganisationGrouping.class,
	"organisationId", organisationId);
for (OrganisationGrouping grouping : groupings) {
    Element groupingElement = doc.createElement("grouping");
    groupingElement.setAttribute("id", grouping.getGroupingId().toString());
    groupingElement.setAttribute("name", StringEscapeUtils.escapeXml(grouping.getName()));
    groupsElement.appendChild(groupingElement);
    for (OrganisationGroup group : grouping.getGroups()) {
	Element groupElement = doc.createElement("group");
	groupElement.setAttribute("id", group.getGroupId().toString());
	groupElement.setAttribute("name", StringEscapeUtils.escapeXml(group.getName()));
	groupingElement.appendChild(groupElement);
	for (User user : group.getUsers()) {
	    Element userElement = doc.createElement("user");
	    userElement.setAttribute("id", user.getUserId().toString());
	    userElement.setAttribute("firstname", StringEscapeUtils.escapeXml(user.getFirstName()));
	    userElement.setAttribute("lastname", StringEscapeUtils.escapeXml(user.getLastName()));
	    groupElement.appendChild(userElement);
	}
    }
}

response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");

DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
LSSerializer lsSerializer = domImplementation.createLSSerializer();
LSOutput lsOutput = domImplementation.createLSOutput();
lsOutput.setEncoding("UTF-8");
lsOutput.setByteStream(response.getOutputStream());
lsSerializer.write(doc, lsOutput);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:39,代碼來源:OrganisationGroupServlet.java

示例13: write

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
public void write(Document doc) {
	File file = getOutputFile(testClass);
	try (FileOutputStream outputStream = new FileOutputStream(file)) {
		DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
		DOMImplementationLS impl = (DOMImplementationLS) reg.getDOMImplementation("LS");
		LSSerializer serializer = impl.createLSSerializer();
		LSOutput output = impl.createLSOutput();
		output.setByteStream(outputStream);
		serializer.write(doc, output);
	} catch (Exception e) {
		throw new CucumberException(Constants.errorPrefix + "Failed to write document to disc", e);
	}
}
 
開發者ID:MicroFocus,項目名稱:octane-cucumber-jvm,代碼行數:14,代碼來源:OutputFile.java

示例14: write

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
public static void write(Document document, OutputStream stream)
{
	DOMImplementationLS impl = (DOMImplementationLS)REGISTRY.getDOMImplementation("LS");
	LSSerializer writer = impl.createLSSerializer();
	LSOutput output=impl.createLSOutput();
	output.setByteStream(stream);
	writer.write(document, output);
}
 
開發者ID:cycentum,項目名稱:birdsong-recognition,代碼行數:9,代碼來源:XmlUtils.java

示例15: createLSOutput

import org.w3c.dom.ls.LSOutput; //導入方法依賴的package包/類
/** Returns a <code>LSOutput</code> instance.
 * @param impl A <code>DOMImplementationLS</code> instance
 * @param os Optional <code>OutputStream</code> instance
 * @param encoding Optional character encoding, default is UTF-8
 * @return A <code>LSOutput</code> instance
 * @see <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/">DOM Level 3 Load and Save Specification</a>
 */
public static LSOutput createLSOutput(DOMImplementationLS impl, OutputStream os, String encoding) {
    LSOutput out = impl.createLSOutput();
    if (os != null) {
        out.setByteStream(os);
    }
    if (encoding != null) {
        out.setEncoding(encoding);
    }
    return out;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:18,代碼來源:UtilXml.java


注:本文中的org.w3c.dom.ls.LSOutput.setByteStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。