List of usage examples for org.xml.sax SAXException SAXException
public SAXException(Exception e)
From source file:net.sf.joost.stx.Processor.java
public void endElement(String uri, String lName, String qName) throws SAXException { if (DEBUG)/*from w w w .j ava 2s .c om*/ if (log.isDebugEnabled()) { log.debug(qName + " (skipDepth: " + skipDepth + ")"); // log.debug("eventStack: " + eventStack.toString()); // log.debug("dataStack: " + dataStack.toString()); } if (lastElement != null) processLastElement(false); if (collectedCharacters.length() != 0) processCharacters(); if (skipDepth == 1 && context.targetHandler != null && dataStack.peek().lastProcStatus == PR_CHILDREN) { // provisional fix for bug #765301 // (This whole external filter stuff needs to be rewritten to // enable the functionality for stx:process-siblings. Using // skipDepth isn't really a good idea ...) skipDepth = 0; endExternDocument(); } if (skipDepth == 0) { clearProcessSiblings(); Data data = dataStack.pop(); short prStatus = data.lastProcStatus; context.currentGroup = data.currentGroup; context.targetGroup = dataStack.peek().targetGroup; if (data.template == null) { // perform default action? if ((data.targetGroup.passThrough & PASS_THROUGH_ELEMENT) != 0) context.emitter.endElement(uri, lName, qName, data.targetGroup); } else if (prStatus == PR_CHILDREN || prStatus == PR_SELF) { context.position = data.contextPosition; // restore position context.localVars = data.localVars; AbstractInstruction inst = data.instruction; inst = doProcessLoop(inst, (SAXEvent) eventStack.peek(), true); if (DEBUG) if (log.isDebugEnabled()) log.debug("stop " + processStatus); switch (processStatus) { case PR_CHILDREN: case PR_SELF: { NodeBase start = inst.getNode(); context.errorHandler.error("Encountered '" + start.qName + "' after stx:process-" + // prStatus must be either PR_CHILDREN or PR_SELF, see above (prStatus == PR_CHILDREN ? "children" : "self"), start.publicId, start.systemId, start.lineNo, start.colNo); throw new SAXException("Non-recoverable error"); } case PR_SIBLINGS: dataStack.push(new Data(PR_SIBLINGS, data.template, inst, data.passedParams, context, (SAXEvent) eventStack.peek())); break; // case PR_ATTRIBUTES: won't happen case PR_ERROR: throw new SAXException("Non-recoverable error"); } } else { if (log != null) log.error("encountered 'else' " + prStatus); else System.err.println("Error - encountered 'else' " + prStatus); } } else { skipDepth--; if (context.targetHandler != null) { context.targetHandler.endElement(uri, lName, qName); if (skipDepth == 0) endExternDocument(); } } if (skipDepth == 0) { // look at the previous process status on the data stack if (dataStack.peek().lastProcStatus == PR_SELF) { endElement(uri, lName, qName); // recurse (process-self) } else { eventStack.pop(); inScopeNamespaces = (Hashtable) namespaceContext.pop(); } } }
From source file:it.greenvulcano.gvesb.datahandling.dbo.DBOCallSP.java
/** * @throws SAXException// w ww.j a va 2s .c o m */ @Override protected void executeStatement() throws SAXException { try { if (sqlStatementInfo != null) { super.executeStatement(); handleOutput(); } } catch (DBOException exc) { logger.error("Record parameters:\n" + dumpCurrentRowFields()); logger.error("SQL Statement Informations:\n" + sqlStatementInfo); logger.error("DBOException error on row " + getRowCounter() + ": " + exc.getMessage()); throw new SAXException(exc); } }
From source file:ca.sqlpower.wabit.dao.WorkspaceSAXHandler.java
/** * Throws an informative exception if the given value is null. * // w w w . j a v a 2 s. c o m * @param attName Name of the attribute that's supposed to contain the value * @param value The value actually recovered from the attribute (if any) * @throws SAXException If value is null. */ private void checkMandatory(String attName, Object value) throws SAXException { if (value == null) { throw new SAXException( "Missing mandatory attribute \"" + attName + "\" of element \"" + xmlContext.peek() + "\""); } }
From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandler.java
private void handleProperty(Property currProperty) throws SAXException { String eDataVal = getElementData(); if (eDataVal != null) { if (currProperty.value != null && eDataVal.length() > 0) { throw new SAXException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.element.has.both3", PROPERTY_ELMT, VALUE_ATTR, getLocationInfo())); } else if (currProperty.value == null) { currProperty.value = eDataVal; }//from w w w . ja v a2 s .c o m } notNull(currProperty.value, PROPERTY_ELMT, VALUE_ATTR); if (processingTNT4JProperties) { Map.Entry<String, String> p = new AbstractMap.SimpleEntry<>(currProperty.name, currProperty.value); currStream.output().setProperty(OutputProperties.PROP_TNT4J_PROPERTY, p); } else { if (currProperties == null) { currProperties = new HashMap<>(); } currProperties.put(currProperty.name, currProperty.value); } }
From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandler.java
private void handleFieldLocatorCDATA() throws SAXException { if (currLocatorData == null) { return;/*from w w w .ja v a2 s . c om*/ } String eDataVal = getElementData(); if (StringUtils.isNotEmpty(eDataVal)) { if (StringUtils.isNotEmpty(currLocatorData.locator) && eDataVal.length() > 0) { throw new SAXException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.element.has.both3", FIELD_LOC_ELMT, LOCATOR_ATTR, getLocationInfo())); } currLocatorData.locator = eDataVal; } }
From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandler.java
@SuppressWarnings("unchecked") private void handleFieldTransform(FieldTransformData currTransformData) throws SAXException { String eDataVal = getElementData(); if (eDataVal != null) { if (StringUtils.isNotEmpty(currTransformData.beanRef) && eDataVal.length() > 0) { throw new SAXException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.element.has.both3", FIELD_TRANSFORM_ELMT, BEAN_REF_ATTR, getLocationInfo())); } else if (currTransformData.scriptCode == null) { currTransformData.scriptCode = eDataVal; }/*from w w w . ja v a2 s . com*/ } if (StringUtils.isEmpty(currTransformData.beanRef) && StringUtils.isEmpty(currTransformData.scriptCode)) { throw new SAXParseException( StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.must.contain", FIELD_TRANSFORM_ELMT, BEAN_REF_ATTR, CDATA), currParseLocation); } ValueTransformation<Object, Object> transform; if (StringUtils.isNotEmpty(currTransformData.beanRef)) { Object tObj = javaObjectsMap.get(currTransformData.beanRef); if (tObj == null) { throw new SAXParseException(StreamsResources.getStringFormatted( StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.undefined.reference", FIELD_TRANSFORM_ELMT, currTransformData.beanRef), currParseLocation); } if (tObj instanceof ValueTransformation) { transform = (ValueTransformation<Object, Object>) tObj; } else { throw new SAXNotSupportedException( StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.not.extend.class", FIELD_TRANSFORM_ELMT, BEAN_REF_ATTR, tObj.getClass().getName(), ValueTransformation.class.getName(), getLocationInfo())); } } else { transform = AbstractScriptTransformation.createScriptTransformation(currTransformData.name, currTransformData.scriptLang, currTransformData.scriptCode); } if (currLocatorData != null) { currLocatorData.valueTransforms.add(transform); } else { currField.addTransformation(transform); } }
From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandler.java
private void validateActivityField(ActivityField aField, String qName) throws SAXException { if (CollectionUtils.isEmpty(aField.getLocators())) { throw new SAXException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.element.must.have", qName, LOCATOR_ATTR, VALUE_ATTR, FIELD_LOC_ELMT, getLocationInfo()));/*from w ww . j a v a 2 s .co m*/ } List<String> dynamicLocators = new ArrayList<>(); Utils.resolveCfgVariables(dynamicLocators, aField.getFieldTypeName(), aField.getValueType()); for (String dLoc : dynamicLocators) { if (!aField.hasDynamicLocator(dLoc)) { throw new SAXException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ConfigParserHandler.element.ref.missing", qName, FIELD_LOC_ELMT, dLoc, getLocationInfo())); } } }
From source file:mf.org.apache.xml.serialize.BaseMarkupSerializer.java
public void startDocument() throws SAXException { try {//from w w w . j a va 2 s .com prepare(); } catch (IOException except) { throw new SAXException(except.toString()); } }
From source file:mf.org.apache.xml.serialize.BaseMarkupSerializer.java
public void characters(char[] chars, int start, int length) throws SAXException { try {// w w w . ja v a 2s . c o m ElementState state = content(); int saveIndent; if (state.inCData || state.doCData) { if (!state.inCData) { this._printer.printText("<![CDATA["); state.inCData = true; } saveIndent = this._printer.getNextIndent(); this._printer.setNextIndent(0); int end = start + length; int index = start; while (index < end) { char ch = chars[index]; if (ch == ']' && index + 2 < end && chars[index + 1] == ']' && chars[index + 2] == '>') { this._printer.printText("]]]]><![CDATA[>"); index += 2; } else if (!XMLChar.isValid(ch)) { index++; if (index < end) { surrogates(ch, chars[index], true); } else { fatalError("The character '" + ch + "' is an invalid XML character"); } } else if ((ch >= ' ' && this._encodingInfo.isPrintable(ch) && ch != '\u007f') || ch == '\n' || ch == '\r' || ch == '\t') { this._printer.printText(ch); } else { this._printer.printText("]]>&#x"); this._printer.printText(Integer.toHexString(ch)); this._printer.printText(";<![CDATA["); } index++; } this._printer.setNextIndent(saveIndent); } else if (state.preserveSpace) { saveIndent = this._printer.getNextIndent(); this._printer.setNextIndent(0); printText(chars, start, length, true, state.unescaped); this._printer.setNextIndent(saveIndent); } else { printText(chars, start, length, false, state.unescaped); } } catch (IOException except) { throw new SAXException(except); } }
From source file:mf.org.apache.xml.serialize.BaseMarkupSerializer.java
public void ignorableWhitespace(char[] chars, int start, int length) throws SAXException { try {/*from w w w. j a v a2 s.c o m*/ content(); if (this._indenting) { this._printer.setThisIndent(0); int i = start; int length2 = length; while (true) { length = length2 - 1; if (length2 > 0) { this._printer.printText(chars[i]); i++; length2 = length; } else { return; } } } } catch (IOException except) { throw new SAXException(except); } }