Example usage for javax.xml.parsers ParserConfigurationException printStackTrace

List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.parsers ParserConfigurationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.ale.scanner.zotero.web.zotero.ZoteroAPIClient.java

public static Document parseXML(String xml) {
    DocumentBuilder builder = null;
    Document doc = null;//from  w ww.j av a2s. c  o  m
    try {
        builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        ByteArrayInputStream encXML = new ByteArrayInputStream(xml.getBytes("UTF8"));
        doc = builder.parse(encXML);
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return doc;
}

From source file:org.b3mn.poem.Representation.java

protected static String erdfToJson(String erdf, String serverUrl) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);//from w  w w  .  ja  va  2  s  .  c  om
    DocumentBuilder builder;
    try {
        builder = factory.newDocumentBuilder();
        Document rdfDoc = builder.parse(new ByteArrayInputStream(erdfToRdf(erdf).getBytes(("UTF-8"))));
        return RdfJsonTransformation.toJson(rdfDoc, serverUrl).toString();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (TransformerException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:gov.tva.sparky.util.indexer.HBaseRestInterface.java

public static IndexBucket GetIndexBucket(int iPointID, long lBaseTimestamp) {

    long lBaseBucketTimestamp = Index.CalculateHourBlock(lBaseTimestamp);
    String strIndexRowKey = Index.CalculateIndexRowKeyString(iPointID, lBaseBucketTimestamp);

    byte[] arBucketBytes = null;

    try {/*from   w  ww .j ava2  s  .  c  o  m*/

        arBucketBytes = RestProxy.QueryHBaseForCell(Index.HBASE_TABLE_NAME, strIndexRowKey,
                Index.HBASE_INDEX_BUCKET_COL_NAME, Index.HBASE_INDEX_BUCKET_QUAL_NAME);

    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return IndexBucket.Deserialize(arBucketBytes, lBaseBucketTimestamp);

}

From source file:gov.tva.sparky.util.indexer.HBaseRestInterface.java

public static IndexBucket GetIndexBucketByKey(String strKey) throws Exception {

    byte[] arBucketBytes = null;
    long lBaseBucketTimestamp = ParseBaseTimestampFromKey(strKey);

    if (lBaseBucketTimestamp == -1) {
        throw new Exception("Invalid key format");
    }/*from   ww  w  .j  a  va  2  s .  c  om*/

    try {

        arBucketBytes = RestProxy.QueryHBaseForCell(Index.HBASE_TABLE_NAME, strKey,
                Index.HBASE_INDEX_BUCKET_COL_NAME, Index.HBASE_INDEX_BUCKET_QUAL_NAME);

    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return IndexBucket.Deserialize(arBucketBytes, lBaseBucketTimestamp);

}

From source file:eu.europeana.uim.sugarcrmclient.internal.helpers.ClientUtils.java

/**
 * Creates a SelectFields Soap Object given a List<String> fieldnames object
 * which sets the fields to be retrieved.
 * /* w  w w.j a va2s  .  c  om*/
 * @param fieldnames
 * @return
 */
public static SelectFields generatePopulatedSelectFields(List<String> fieldnames) {

    SelectFields selfields = new SelectFields();
    StringBuffer arrayType = new StringBuffer();
    arrayType.append("string[");
    arrayType.append(fieldnames.size());
    arrayType.append("]");
    CommonAttributes commonAttributes = new CommonAttributes();
    commonAttributes.setHref(arrayType.toString());
    selfields.setCommonAttributes(commonAttributes);

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder;
    try {
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = documentBuilder.newDocument();

        for (String fieldname : fieldnames) {
            Element element = document.createElement("string");
            Array array = new Array();
            array.getAnyList();
            selfields.setArray(array);
            element.appendChild(document.createTextNode(fieldname));
        }

    } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return null;
    }

    return selfields;

}

From source file:de.fraunhofer.iosb.ivct.IVCTcommander.java

private static Document parseXmlFile(final String fileName) {
    //get the factory
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    Document dom;//from w ww .j  a v  a 2  s  .c  om

    try {

        //Using factory get an instance of document builder
        DocumentBuilder db = dbf.newDocumentBuilder();

        //parse using builder to get DOM representation of the XML file
        dom = db.parse(fileName);
        return dom;

    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    return null;
}

From source file:eu.europeana.uim.sugarcrmclient.internal.helpers.ClientUtils.java

/**
 * Creates a NameValueList Soap Element given a List<String> namevalues
 * object which sets the fields to be retrieved.
 * /*from  ww w.j  a va  2  s .  co m*/
 * @param fieldnames
 * @return
 */
public static NameValueList generatePopulatedNameValueList(List<NameValue> namevalues) {

    NameValueList namevalueList = new NameValueList();
    StringBuffer arrayType = new StringBuffer();
    arrayType.append("name_value[");
    arrayType.append(namevalues.size());
    arrayType.append("]");
    Array array = new Array();
    ArrayType arrTypeObj = new ArrayType();
    arrTypeObj.setArrayType(arrayType.toString());

    ArrayAttributes atts = new ArrayAttributes();
    atts.setArrayType(arrTypeObj);

    namevalueList.setArrayAttributes(atts);
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder;
    try {
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = documentBuilder.newDocument();

        for (NameValue namevalue : namevalues) {
            Element name_value = document.createElement("name_value");

            Element name = document.createElement("name");
            Element value = document.createElement("value");

            name.appendChild(document.createTextNode(namevalue.getName()));
            value.appendChild(document.createTextNode(namevalue.getValue()));
            name_value.appendChild(name);
            name_value.appendChild(value);

            array.getAnyList().add(name_value);
        }

        namevalueList.setArray(array);
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return null;
    }

    return namevalueList;

}

From source file:com.bluexml.side.form.utils.DOMUtil.java

/**
 * Gets a namespace aware non-validating DocumentBuilder object. If non existent, the object is
 * created./*from   w  ww.j  a  v a 2 s .c  om*/
 * 
 * @return
 */
public static DocumentBuilder getDocumentBuilder() {
    if (documentBuilder == null) {
        try {
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            docBuilderFactory.setNamespaceAware(true); // @since 1.0.2
            docBuilderFactory.setValidating(false); // @since 1.0.2

            documentBuilder = docBuilderFactory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
            return null;
        }
    }
    return documentBuilder;
}

From source file:gov.tva.sparky.util.indexer.HistorianArchiveLookupTable.java

public static HistorianArchiveLookupTableEntry ForwardLookupEntry_ByHDFSFileID(String strFileID) {

    HistorianArchiveLookupTableEntry ret = new HistorianArchiveLookupTableEntry();

    ret._strForwardKey_FileID = strFileID;

    byte[] arPayloadBytes = null;

    try {//ww w.ja v a2 s.  co m

        // pulls hdfs-path from the forward lookup table
        arPayloadBytes = RestProxy.QueryHBaseForCell(HBASE_HDFSARCHIVELOOKUPTABLE_TABLE_NAME,
                ret._strForwardKey_FileID, HBASE_HDFSARCHIVELOOKUPTABLE_FILELOOKUP_COL_NAME,
                HBASE_HDFSARCHIVELOOKUPTABLE_FILELOOKUP_QUAL_FILENAME_NAME);

    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    ret.SetHdfsPath(new String(arPayloadBytes));

    return ret;

}

From source file:gov.tva.sparky.util.indexer.HistorianArchiveLookupTable.java

public static HistorianArchiveLookupTableEntry ReverseLookupEntry_ByPath(String strHdfsPath) {

    HistorianArchiveLookupTableEntry ret = new HistorianArchiveLookupTableEntry();
    ret.SetHdfsPath(strHdfsPath);//  ww  w . j  a  v a2s.  co m

    byte[] arPayloadBytes = null;

    try {

        arPayloadBytes = RestProxy.QueryHBaseForCell(HBASE_HDFSARCHIVE_REVERSE_LOOKUPTABLE_TABLE_NAME,
                ret.GetReverseKey(), HBASE_HDFSARCHIVE_REVERSE_LOOKUPTABLE_FILELOOKUP_COL_NAME,
                HBASE_HDFSARCHIVE_REVERSE_LOOKUPTABLE_FILELOOKUP_QUAL_FID_NAME);

    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if (null == arPayloadBytes) {
        return null;
    }

    ret._strForwardKey_FileID = new String(arPayloadBytes);

    return ForwardLookupEntry_ByHDFSFileID(ret.GetForwardKey());

}