Example usage for java.lang Boolean TRUE

List of usage examples for java.lang Boolean TRUE

Introduction

In this page you can find the example usage for java.lang Boolean TRUE.

Prototype

Boolean TRUE

To view the source code for java.lang Boolean TRUE.

Click Source Link

Document

The Boolean object corresponding to the primitive value true .

Usage

From source file:Main.java

public static String lsSerializePretty(Document doc) {
    DOMImplementation domImplementation = doc.getImplementation();
    if (domImplementation.hasFeature("LS", "3.0") && domImplementation.hasFeature("Core", "2.0")) {
        DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation.getFeature("LS",
                "3.0");
        LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
        DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
        if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
            lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
            LSOutput lsOutput = domImplementationLS.createLSOutput();
            lsOutput.setEncoding("UTF-8");
            StringWriter stringWriter = new StringWriter();
            lsOutput.setCharacterStream(stringWriter);
            lsSerializer.write(doc, lsOutput);
            return stringWriter.toString();
        } else {/*from  w w w .ja va 2 s . c  o  m*/
            throw new RuntimeException("DOMConfiguration 'format-pretty-print' parameter isn't settable.");
        }
    } else {
        throw new RuntimeException("DOM 3.0 LS and/or DOM 2.0 Core not supported.");
    }
}

From source file:Main.java

public static Boolean booleanValueOf(boolean b) {
    return (b ? Boolean.TRUE : Boolean.FALSE);
}

From source file:Main.java

public static String prettyPrintWithDOM3LS(Document document) {
    DOMImplementation domImplementation = document.getImplementation();
    if (domImplementation.hasFeature("LS", "3.0") && domImplementation.hasFeature("Core", "2.0")) {
        DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation.getFeature("LS",
                "3.0");
        LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
        DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
        if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
            lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
            LSOutput lsOutput = domImplementationLS.createLSOutput();
            lsOutput.setEncoding("UTF-8");
            StringWriter stringWriter = new StringWriter();
            lsOutput.setCharacterStream(stringWriter);
            lsSerializer.write(document, lsOutput);
            return stringWriter.toString();
        } else {//from w  ww.  java 2s.  c o  m
            throw new RuntimeException("DOMConfiguration 'format-pretty-print' parameter isn't settable.");
        }
    } else {
        throw new RuntimeException("DOM 3.0 LS and/or DOM 2.0 Core not supported.");
    }
}

From source file:Main.java

/**
 * //from   w ww. j ava  2 s .  co  m
 * @param contextPath
 * @return Marshaller
 * @throws JAXBException
 */
public static Marshaller getMarshaller(final String contextPath) throws JAXBException {
    final JAXBContext jaxbContext = JAXBContext.newInstance(contextPath);
    final Marshaller marshaller = jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    return marshaller;
}

From source file:Main.java

private static String parseXmlDocToString(Document xmlDoc)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    // Add formatting to the xml document in case we want to save to a file
    System.setProperty(DOMImplementationRegistry.PROPERTY,
            "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
    final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
    final LSSerializer writer = impl.createLSSerializer();
    writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); // Set this to true if the output needs to be beautified.
    writer.getDomConfig().setParameter("xml-declaration", true); // Set this to true if the declaration is needed to be outputted

    return writer.writeToString(xmlDoc);
}

From source file:Main.java

/**
 * Registers delegate RepaintManager for {@code JComponent}.
 *///from   w  w  w .  ja v a2 s . co  m
public static void setDelegateRepaintManager(JComponent component, RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY, Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY, repaintManager);
}

From source file:Main.java

public static void marshal(Object obj, OutputStream out, Class... boundClasses) {
    try {//  ww w . ja  va 2s . c om
        Marshaller m = JAXBContext.newInstance(boundClasses).createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        m.marshal(obj, out);
    } catch (Exception ex) {
    }
}

From source file:io.cloudslang.lang.entities.utils.ResultUtils.java

public static boolean isDefaultResult(Result result) {
    Validate.notNull(result);//from www . j ava 2 s .co  m
    Serializable rawValue = result.getValue() == null ? null : result.getValue().get();
    return rawValue == null || Boolean.TRUE.equals(rawValue);
}

From source file:Main.java

public static void writeDocumentToDisk(Document document, File directoryToWriteTo, String fileName) {
    DOMImplementation domImplementation = document.getImplementation();
    if (domImplementation.hasFeature("LS", "3.0") && domImplementation.hasFeature("Core", "2.0")) {
        DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation.getFeature("LS",
                "3.0");
        LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
        DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
        if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
            lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
            LSOutput lsOutput = domImplementationLS.createLSOutput();
            lsOutput.setEncoding("UTF-8");
            try {
                lsOutput.setByteStream(new FileOutputStream(new File(directoryToWriteTo, fileName)));
            } catch (FileNotFoundException e) {
                throw new IllegalStateException(e);
            }//w ww .j  a va 2s . co  m
            lsSerializer.write(document, lsOutput);
        }
    }

}

From source file:Main.java

public static String format(String xml) throws Exception {
    InputSource src = new InputSource(new StringReader(xml));
    Node document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(src).getDocumentElement();
    Boolean keepDeclaration = Boolean.valueOf(xml.startsWith("<?xml"));

    System.setProperty(DOMImplementationRegistry.PROPERTY,
            "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
    LSSerializer writer = impl.createLSSerializer();

    writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
    writer.getDomConfig().setParameter("xml-declaration", keepDeclaration);
    return writer.writeToString(document);
}