Java 8 LSSerializer - 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 LSSerializer class.

This code example shows how to use the following methods: getDomConfig, writeToString
        LSInput input = domLS.createLSInput();
        input.setStringData(xml);
        Document document = lsParser.parse(input);
 
        LSSerializer lsSerializer = domLS.createLSSerializer();
        lsSerializer.getDomConfig().setParameter("comments", Boolean.FALSE);
        lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
        return lsSerializer.writeToString(document);
    } 
 
    public static void compareXml(final String original, final String marshalled, final boolean ignoreNamespace) throws Exception {
        final String xmlOriginal;
        final String xmlMarshalled;
        if (ignoreNamespace) {
            xmlOriginal = XMLUtils.removeNamespace(original);
            xmlMarshalled = XMLUtils.removeNamespace(marshalled);
        } else { 
            xmlOriginal = original;
            xmlMarshalled = marshalled;
        } 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDomConfig, writeToString
This code example shows how to use the following methods: getDomConfig, write
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDomConfig, write
        } 
        if (domImpl.hasFeature("LS", "3.0") && domImpl.hasFeature("Core", "2.0"))
        { 
            final DOMImplementationLS domImplLS = (DOMImplementationLS) domImpl.getFeature("LS", "3.0");
            final LSSerializer lss = domImplLS.createLSSerializer();
            if (lss.getDomConfig().canSetParameter("format-pretty-print", true))
            { 
                lss.getDomConfig().setParameter("format-pretty-print", true);
                 
                final LSOutput lsOut = domImplLS.createLSOutput();
                lsOut.setEncoding("UTF-8");
                lsOut.setByteStream(out);
                 
                lss.write(node, lsOut);
            } 
            else 
            { 
                logger.warn("DOMConfiguration 'format-pretty-print' parameter isn't settable. Won't pretty print."); 
                write(node, out);
            } 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDomConfig, write
This code example shows how to use the following methods: writeToString
    public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonGenerationException
    { 
        if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS");    	
        LSSerializer writer = _domImpl.createLSSerializer();
        jgen.writeString(writer.writeToString(value));
    } 
 
	@Override 
    public JsonNode getSchema(SerializerProvider provider, java.lang.reflect.Type typeHint) {
        // Well... it is serialized as String 
        return createSchemaNode("string", true); 
    } 
 
    @Override 
    public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException {
        if (visitor != null) visitor.expectAnyFormat(typeHint);
    } 
} 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: writeToString
This code example shows how to use the following methods: getDomConfig, writeToString
                return from; 
            } 
 
            final DOMImplementationLS lsImpl = (DOMImplementationLS)e.getOwnerDocument().getImplementation().getFeature("LS", "3.0");
            LSSerializer serializer = lsImpl.createLSSerializer();
            serializer.getDomConfig().setParameter("xml-declaration", false); //by default its true, so set it to false to get String without xml-declaration
            final String str = serializer.writeToString(e);
 
            return JaxbUtils.unmarshal(clazz, str);
        } else { 
            LOG.error("Unsure how to determine which class to use for unmarshaling object type {}", from.getClass()); 
            throw new IllegalArgumentException("Unsure how to determine which class to use for unmarshaling object type " + from.getClass());
        } 
    } 
 
    @Override 
    public Object marshal(final Object from) throws Exception {
        LOG.trace("marshal: from = ({}){}", (from == null? null : from.getClass()), from); 
        if (from == null) return null; 
 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDomConfig, writeToString
	 
	protected static String asXML (org.w3c.dom.Element element) {
		 
		DOMImplementationLS impl = (DOMImplementationLS)element.getOwnerDocument().getImplementation();
		LSSerializer serializer = impl.createLSSerializer();
		serializer.getDomConfig().setParameter("xml-declaration", false);
		return serializer.writeToString(element);
	} 
	 
	public static DOMElement toDOM (org.dom4j.Element dom4jElement) throws DocumentException {
		 
		DOMElement domElement = null;
		if (dom4jElement instanceof DOMElement) {
			domElement = (DOMElement) dom4jElement;
		} else { 
			DOMDocument requestDocument = (DOMDocument)
				new DOMWriter().write(dom4jElement.getDocument());
			domElement = (DOMElement)requestDocument.getDocumentElement();
		} 
		return domElement;
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDomConfig
			docBuilder = dbf.newDocumentBuilder();
	 
			domImpl = new DOMImplementationImpl();
	 
			serializer = domImpl.createLSSerializer();
			DOMConfiguration config = serializer.getDomConfig();
			config.setParameter("comments", Boolean.valueOf(true));
		} catch (Exception e) {
			Log.e(TAG, "Failed to initialize", e);
			throw new DigSigException(e);
		} 
	} 
 
	private void doSign(Intent intent) {
		int selected = intent.getIntExtra(Sign.Params.IDENTITY, -1);
		if (selected==-1) {
			return; 
		} 
		Intent bcIntent = new Intent();
 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 LSSerializer Methods: