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 Templates getTemplatesByName(File xslF) {

    Templates templates = null;/*ww w  .j a v  a 2s .  co  m*/
    TransformerFactory tfactory = TransformerFactory.newInstance();
    tfactory.setAttribute("http://xml.apache.org/xalan/features/incremental", java.lang.Boolean.TRUE);

    InputStream is = null;
    try {
        StreamSource ss = new StreamSource(xslF);
        is = ss.getInputStream();
        templates = tfactory.newTemplates(ss);
        if (is != null) {
            is.close();
            is = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            if (is != null) {
                is.close();
                is = null;
            }
        } catch (Throwable t) {
            System.out.println(t);
        }
    }

    return templates;
}

From source file:Main.java

public static String[] intersect(String[] arr1, String[] arr2) {
    Map<String, Boolean> map = new HashMap<String, Boolean>();
    LinkedList<String> list = new LinkedList<String>();
    for (String str : arr1) {
        if (!map.containsKey(str)) {
            map.put(str, Boolean.FALSE);
        }// w  ww.  j  av  a 2  s . co  m
    }

    for (String str : arr2) {
        if (map.containsKey(str)) {
            map.put(str, Boolean.TRUE);
        }
    }

    for (Map.Entry<String, Boolean> e : map.entrySet()) {
        if (e.getValue().equals(Boolean.TRUE)) {
            list.add(e.getKey());
        }
    }

    String[] result = {};
    return list.toArray(result);
}

From source file:Main.java

public static Boolean isEmpty(int[] arr) {
    if (arr == null || arr.length < 1) {
        return Boolean.TRUE;
    }/*  ww w  .  j a va  2 s.co  m*/
    return Boolean.FALSE;
}

From source file:Main.java

public static String[] intersect(String[] arr1, String[] arr2) {
    Map<String, Boolean> map = new HashMap<>();
    LinkedList<String> list = new LinkedList<>();
    for (String str : arr1) {
        if (!map.containsKey(str)) {
            map.put(str, Boolean.FALSE);
        }//from w w w.  java2s  .  c  o  m
    }

    for (String str : arr2) {
        if (map.containsKey(str)) {
            map.put(str, Boolean.TRUE);
        }
    }

    for (Map.Entry<String, Boolean> e : map.entrySet()) {
        if (e.getValue().equals(Boolean.TRUE)) {
            list.add(e.getKey());
        }
    }
    String[] result = {};
    return list.toArray(result);
}

From source file:Main.java

/**
 * Serializes the given document into a string
 * /*from   w w  w  .ja  v a2  s  . c om*/
 * @param doc The document to serialize
 * @return The XML document as a string (pretty-printed)
 */
public static String documentToString(Document doc) {
    if (doc == null)
        return "null";
    LSSerializer writer = impl.createLSSerializer();
    writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
    return writer.writeToString(doc);
}

From source file:Main.java

/**
 * <p>Checks if a {@code Boolean} value is {@code true},
 * handling {@code null} by returning {@code false}.</p>
 * <p>//from   w  w  w  .  j a  va2  s.c  om
 * <pre>
 *   BooleanUtils.isTrue(Boolean.TRUE)  = true
 *   BooleanUtils.isTrue(Boolean.FALSE) = false
 *   BooleanUtils.isTrue(null)          = false
 * </pre>
 *
 * @param bool the boolean to check, null returns {@code false}
 * @return {@code true} only if the input is non-null and true
 * @since 2.1
 */
public static boolean isTrue(final Boolean bool) {
    return Boolean.TRUE.equals(bool);
}

From source file:Main.java

public static void rwChildren(JPanel panel, Class<?>... classesToIgnore) {
    for (Component component : panel.getComponents()) {
        if (component instanceof JPanel) {
            rwChildren((JPanel) component, classesToIgnore);
        } else {/*ww  w  .j av a2s  .  co m*/
            if (!ignoreClasses(component, classesToIgnore)) {
                Method m = discover(component, "setEditable", boolean.class);
                invoke(m, component, new Object[] { Boolean.TRUE });
            }
        }
    }
}

From source file:Main.java

public static String convertObjectToXML(Object object) {
    JAXBContext jaxbContext = null;
    Marshaller jaxbMarshaller = null;
    StringWriter stringWriter = new StringWriter();
    try {/*from w w w . j a  v a2s.co  m*/
        jaxbContext = JAXBContext.newInstance(object.getClass());
        jaxbMarshaller = jaxbContext.createMarshaller();
        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        jaxbMarshaller.marshal(object, stringWriter);
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    String xmlString = stringWriter.toString();

    return xmlString;

}

From source file:Main.java

public static void saveInstance(OutputStream outputStream, 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, outputStream);

    outputStream.flush();//from w ww . j  a  v  a2  s  .c o  m

}

From source file:Main.java

public static String toXml(Object object) {
    final StringWriter out = new StringWriter();
    JAXBContext context = null;//from  ww w.  j a va  2 s  .co m
    try {
        context = JAXBContext.newInstance(object.getClass());
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.marshal(object, new StreamResult(out));
    } catch (PropertyException e) {
        e.printStackTrace();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    return out.toString();
}