List of usage examples for java.lang Boolean TRUE
Boolean TRUE
To view the source code for java.lang Boolean TRUE.
Click Source Link
From source file:Main.java
/** * Build a new XMLInputFactory./*from ww w . j a v a 2 s . c o m*/ * * @return XML input factory */ public static XMLInputFactory getXmlInputFactory() { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); return inputFactory; }
From source file:Main.java
/** * Marshal a JAXB element to a XML file// w w w. java 2s .com * * @param jaxbElement * The root of content tree to be marshalled * @param strXMLFilePath * XML output file path * @throws Exception * in error case */ public static void doMarshalling(Object jaxbElement, String strXMLFilePath) throws Exception { if (jaxbElement == null) { throw new RuntimeException("No JAXB element to marshal (null)!"); } if (strXMLFilePath == null) { throw new RuntimeException("No XML file path (null)!"); } FileOutputStream fos = 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); fos = new FileOutputStream(strXMLFilePath); marshaller.marshal(jaxbElement, fos);// System.out); } catch (Exception e) { // Logger.XMLEval.logState("Marshalling failed: " + e.getMessage(), LogLevel.Error); throw e; } finally { if (fos != null) { fos.close(); fos = null; } } }
From source file:Main.java
public static Marshaller createMarshaller(String pack, Schema schema) { JAXBContext jaxbContext = null; try {//from ww w. j a v a 2 s.co m jaxbContext = JAXBContext.newInstance(pack); Marshaller marsh = jaxbContext.createMarshaller(); if (schema != null) { marsh.setSchema(schema); // marsh.setEventHandler( new DefaultValidationEventHandler() { // @Override // public boolean handleEvent( ValidationEvent event ) { // return super.handleEvent( event ); // } // }); } marsh.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marsh.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); return marsh; } catch (JAXBException e) { e.printStackTrace(); } return null; }
From source file:Main.java
/** * Prints the document for debug./*from w ww. j a v a2 s .co m*/ * * @param model the model to be printed * @throws Exception for any errors encountered */ public static void printModel(Object model) throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance("gov.medicaid.domain.model"); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(model, System.out); }
From source file:Main.java
public static String formatXml(String xml) { try {// w ww.jav a 2s .c om final InputSource src = new InputSource(new StringReader(xml)); final Node document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(src) .getDocumentElement(); final Boolean keepDeclaration = Boolean.valueOf(xml.startsWith("<?xml")); //May need this: 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(); // Set this to true if the output needs to be beautified. writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); // Set this to true if the declaration is needed to be outputted. writer.getDomConfig().setParameter("xml-declaration", keepDeclaration); return writer.writeToString(document); } catch (Exception e) { System.err.println("Exception thrown"); throw new RuntimeException(e); } }
From source file:Main.java
/** * Adds HANDLES_ENABLE_STATE mark into component client properties. * * @param component/*from w ww . j av a 2 s . c o m*/ * component to process */ public static void setHandlesEnableStateMark(final JComponent component) { component.putClientProperty(HANDLES_ENABLE_STATE, Boolean.TRUE); }
From source file:Main.java
public static Boolean parseBooleanValue(String valueText) { if (valueText != null) { // if we have to check for value true if ("true".equals(valueText) || "enabled".equals(valueText) || "on".equals(valueText)) { return Boolean.TRUE; }//from ww w .ja v a2 s . c o m if ("false".equals(valueText) || "disabled".equals(valueText) || "off".equals(valueText)) { return Boolean.FALSE; } } return null; }
From source file:Main.java
public static Boolean parseBooleanValue(final String valueText) { if (valueText != null) { // if we have to check for value true if ("true".equals(valueText) || "enabled".equals(valueText) || "on".equals(valueText)) { return Boolean.TRUE; } else if ("false".equals(valueText) || "disabled".equals(valueText) || "off".equals(valueText)) { return Boolean.FALSE; }// w ww. ja va 2 s.c om } return null; }
From source file:Main.java
private static boolean canDisableExternalDtds(SAXParserFactory parserFactory) { if (canDisableExternalDtds == null) { try {/* w ww.j a va2 s.c o m*/ parserFactory.getFeature(XERCES_LOAD_EXTERNAL_DTD); canDisableExternalDtds = Boolean.TRUE; } catch (Exception ex) { canDisableExternalDtds = Boolean.FALSE; } } return canDisableExternalDtds.booleanValue(); }
From source file:Main.java
public static Transformer getTransformer(boolean standalone, boolean indent, int indentNumber, boolean omitXmlDeclaration) throws TransformerException { TransformerFactory f = TransformerFactory.newInstance(); f.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); if (indent) { f.setAttribute("indent-number", indentNumber); }/*ww w . ja v a 2s.co m*/ Transformer t = f.newTransformer(); if (standalone) { t.setOutputProperty(OutputKeys.STANDALONE, "yes"); } if (indent) { t.setOutputProperty(OutputKeys.INDENT, "yes"); t.setOutputProperty("{xml.apache.org/xslt}indent-amount", "" + indentNumber); } if (omitXmlDeclaration) { t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); } return t; }