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:com.inkubator.hrm.util.StringsUtils.java

public static Boolean isHaveLowerCase(String str) {
    Boolean isCondition = Boolean.FALSE;
    for (int i = str.length() - 1; i >= 0; i--) {

        if (Character.isLowerCase(str.charAt(i))) {
            isCondition = Boolean.TRUE;
        }/*from   w w  w .  ja  v  a  2s. c o m*/
    }
    return isCondition;

}

From source file:Main.java

public static boolean writeDocumentToStream(Document doc, OutputStream os) {
    // Check if DOM Load and Save is supported

    if (!((doc.getFeature("Core", "3.0") != null) && (doc.getFeature("LS", "3.0") != null)))
        throw new RuntimeException("DOM Load and Save unsupported");

    // Grab the available implementation

    DOMImplementationLS DOMiLS = (DOMImplementationLS) (doc.getImplementation()).getFeature("LS", "3.0");

    // Create LS output destination

    LSOutput lso = DOMiLS.createLSOutput();
    lso.setByteStream(os);//  ww w  .  j av a 2  s . c  o m

    // Create a LS serializer
    // and tell it to make the output 'pretty'

    LSSerializer serializer = DOMiLS.createLSSerializer();
    serializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);

    // Serialize the xml to your output stream

    return serializer.write(doc, lso);
}

From source file:Main.java

public static String prettyFormat(String input) {
    try {/*from  w  w w. j  a v  a  2 s  .c  o  m*/
        final InputSource src = new InputSource(new StringReader(input));
        final Node document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(src)
                .getDocumentElement();
        final Boolean keepDeclaration = Boolean.valueOf(input.startsWith("<?xml"));
        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", keepDeclaration); // Set this to true if the declaration is needed to be outputted.

        return writer.writeToString(document);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static <T extends Object> void marshal(Class clz, T marshalObj) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(clz);
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    marshaller.marshal(marshalObj, System.out);

}

From source file:Main.java

public static void saveInstance(Writer output, Object instance)

        throws JAXBException, IOException {

    Marshaller marshaller = JAXBContext.newInstance(instance.getClass()).createMarshaller();

    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

    marshaller.setProperty(Marshaller.JAXB_ENCODING, ENCODING);

    marshaller.marshal(instance, output);

    output.flush();//  w ww.j  ava 2 s . co m

}

From source file:Main.java

/**
 * Marshal a JAXB element to a XML DOM document
 *
 * @param jaxbElement/*  w w  w .  j a v  a 2  s.c  o  m*/
 *            The root of content tree to be marshalled
 * @return XML DOM document
 * @throws Exception
 *             in error case
 */
public static Document doMarshallingJAXBObject(Object jaxbElement) throws Exception {
    if (jaxbElement == null) {
        throw new RuntimeException("No JAXB element to marshal (null)!");
    }
    Document doc = null;
    try {
        JAXBContext jaxbCtx = JAXBContext.newInstance(jaxbElement.getClass().getPackage().getName());
        Marshaller marshaller = jaxbCtx.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); // NOI18N
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        doc = db.newDocument();
        marshaller.marshal(jaxbElement, doc);
        doc.getDocumentElement().normalize();
    } catch (Exception e) {
        //            Logger.XMLEval.logState("Marshalling failed: " + e.getMessage(), LogLevel.Error);
        throw e;
    }

    return doc;
}

From source file:Main.java

public static XMLStreamReader createXMLStreamReader(File file)
        throws FileNotFoundException, XMLStreamException {

    XMLInputFactory factory = XMLInputFactory.newInstance();
    if (factory.isPropertySupported("javax.xml.stream.isValidating")) {
        factory.setProperty("javax.xml.stream.isValidating", Boolean.TRUE);
    }/*from ww  w  .ja  va 2 s  . c o  m*/

    XMLStreamReader reader = factory.createXMLStreamReader(new FileReader(file));

    return reader;
}

From source file:Main.java

public static <T extends Object> String marshalAsString(Class clz, T marshalObj) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(clz);
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    StringWriter writer = new StringWriter();
    marshaller.marshal(marshalObj, new BufferedWriter(writer));
    return writer.toString();

}

From source file:Main.java

public static final String prettyPrint(final Document aNode) throws Exception {
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();

    DOMImplementationLS impls = (DOMImplementationLS) registry.getDOMImplementation("LS");

    // Prepare the output
    LSOutput domOutput = impls.createLSOutput();
    domOutput.setEncoding(java.nio.charset.Charset.defaultCharset().name());
    StringWriter writer = new StringWriter();
    domOutput.setCharacterStream(writer);
    LSSerializer domWriter = impls.createLSSerializer();
    DOMConfiguration domConfig = domWriter.getDomConfig();
    domConfig.setParameter("format-pretty-print", true);
    domConfig.setParameter("element-content-whitespace", true);
    domWriter.setNewLine("\r\n");
    domConfig.setParameter("cdata-sections", Boolean.TRUE);
    // And finaly, write
    domWriter.write(aNode, domOutput);//w  w w.  j  a  va2  s  . c o  m
    return domOutput.getCharacterStream().toString();
}

From source file:Main.java

private static String toSelectionArg(Object arg) {
    if (Boolean.class.isInstance(arg)) {
        arg = (Boolean.TRUE.equals(arg)) ? 1 : 0;
    } else if (Enum.class.isInstance(arg)) {
        arg = ((Enum) arg).ordinal();
    }//w w  w.  jav  a2  s .c om
    return (arg == null) ? null : String.valueOf(arg);
}