List of usage examples for org.xml.sax SAXException SAXException
public SAXException(String message, Exception e)
From source file:org.accada.epcis.repository.capture.CaptureOperationsModule.java
/** * Parses the xml tree for epc nodes and returns a List of BizTransaction * URIs with their corresponding type./*from ww w . j a v a 2 s. c o m*/ * * @param bizNode * The parent Node from which BizTransaction URIs should be * extracted. * @return A List of BizTransaction. * @throws SAXException * If an unknown tag (no <epc>) is encountered. */ private List<BusinessTransaction> handleBizTransactions(Session session, Node bizNode) throws SAXException { List<BusinessTransaction> bizTransactionList = new ArrayList<BusinessTransaction>(); for (int i = 0; i < bizNode.getChildNodes().getLength(); i++) { Node curNode = bizNode.getChildNodes().item(i); if (curNode.getNodeName().equals("bizTransaction")) { String bizTransTypeUri = curNode.getAttributes().item(0).getTextContent(); String bizTransUri = curNode.getTextContent(); BusinessTransactionId bizTrans = (BusinessTransactionId) getOrInsertVocabularyElement(session, EpcisConstants.BUSINESS_TRANSACTION_ID, bizTransUri.toString()); BusinessTransactionTypeId type = (BusinessTransactionTypeId) getOrInsertVocabularyElement(session, EpcisConstants.BUSINESS_TRANSACTION_TYPE_ID, bizTransTypeUri.toString()); Criteria c0 = session.createCriteria(BusinessTransaction.class); c0.add(Restrictions.eq("bizTransaction", bizTrans)); c0.add(Restrictions.eq("type", type)); BusinessTransaction bizTransaction = (BusinessTransaction) c0.uniqueResult(); if (bizTransaction == null) { bizTransaction = new BusinessTransaction(); bizTransaction.setBizTransaction(bizTrans); bizTransaction.setType(type); session.save(bizTransaction); } bizTransactionList.add(bizTransaction); } else { if (!curNode.getNodeName().equals("#text") && !curNode.getNodeName().equals("#comment")) { throw new SAXException("Unknown XML tag: " + curNode.getNodeName(), null); } } } return bizTransactionList; }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Flush the stream.//from w w w. j a v a 2 s. c o m */ protected void flush() throws SAXException { try { this.out.flush(); } catch (IOException e) { throw new SAXException("I/O error flushing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Write an array of characters.// w w w. j a v a 2 s . c o m */ protected void write(char data[]) throws SAXException { try { this.out.write(data, 0, data.length); } catch (IOException e) { throw new SAXException("I/O error writing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Write a portion of an array of characters. *//*from ww w . j a va2 s. c o m*/ protected void write(char data[], int start, int length) throws SAXException { try { this.out.write(data, start, length); } catch (IOException e) { throw new SAXException("I/O error writing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Write a single character./* w ww .j a v a 2 s. c o m*/ */ protected void write(int c) throws SAXException { try { this.out.write(c); } catch (IOException e) { throw new SAXException("I/O error writing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Write a string./*from w w w .ja v a 2 s. co m*/ */ protected void write(String data) throws SAXException { try { this.out.write(data); } catch (IOException e) { throw new SAXException("I/O error writing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Write a portion of a string./*from w w w . j ava2 s . c om*/ */ protected void write(String data, int start, int length) throws SAXException { try { this.out.write(data, start, length); } catch (IOException e) { throw new SAXException("I/O error writing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Write a end-of-line character.//from www . jav a 2 s .co m */ protected void writeln() throws SAXException { try { this.out.write(S_EOL); } catch (IOException e) { throw new SAXException("I/O error writing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java
/** * Write a string and a end-of-line character. *//*from w ww . ja v a2 s . c om*/ protected void writeln(String data) throws SAXException { try { this.out.write(data); this.out.write(S_EOL); } catch (IOException e) { throw new SAXException("I/O error writing: " + e.getMessage(), e); } }
From source file:org.apache.cocoon.components.source.impl.XModuleSource.java
private Object getInputAttribute(String inputModuleName, String attributeName) throws SAXException { Object obj;//from w ww. ja v a 2 s . c o m ServiceSelector selector = null; InputModule inputModule = null; try { selector = (ServiceSelector) this.manager.lookup(InputModule.ROLE + "Selector"); inputModule = (InputModule) selector.select(inputModuleName); obj = inputModule.getAttribute(attributeName, null, this.objectModel); } catch (ServiceException e) { throw new SAXException("Could not find an InputModule of the type " + inputModuleName, e); } catch (ConfigurationException e) { throw new SAXException( "Could not find an attribute: " + attributeName + " from the InputModule " + inputModuleName, e); } finally { if (inputModule != null) selector.release(inputModule); this.manager.release(selector); } return obj; }