Java Code Examples for javax.xml.stream.events.Characters#isWhiteSpace()
The following examples show how to use
javax.xml.stream.events.Characters#isWhiteSpace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlPolicyModelUnmarshaller.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example 2
Source File: EwsXmlReader.java From ews-java-api with MIT License | 6 votes |
/** * Reads the specified node type. * * @param keepWhiteSpace Do not remove whitespace characters if true * @throws ServiceXmlDeserializationException the service xml deserialization exception * @throws XMLStreamException the XML stream exception */ private void read(boolean keepWhiteSpace) throws ServiceXmlDeserializationException, XMLStreamException { // The caller to EwsXmlReader.Read expects // that there's another node to // read. Throw an exception if not true. while (true) { if (!xmlReader.hasNext()) { throw new ServiceXmlDeserializationException("Unexpected end of XML document."); } else { XMLEvent event = xmlReader.nextEvent(); if (event.getEventType() == XMLStreamConstants.CHARACTERS) { Characters characters = (Characters) event; if (!keepWhiteSpace) if (characters.isIgnorableWhiteSpace() || characters.isWhiteSpace()) { continue; } } this.prevEvent = this.presentEvent; this.presentEvent = event; break; } } }
Example 3
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map) throws PolicyException { if (chars.isWhiteSpace()) { return; } else { final String data = chars.getData(); if ((currentElement != null) && URI.equals(currentElement.getName())) { processUri(chars, map); return; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation()))); } } }
Example 4
Source File: XmlPolicyModelUnmarshaller.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example 5
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map) throws PolicyException { if (chars.isWhiteSpace()) { return; } else { final String data = chars.getData(); if ((currentElement != null) && URI.equals(currentElement.getName())) { processUri(chars, map); return; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation()))); } } }
Example 6
Source File: XmlPolicyModelUnmarshaller.java From hottub with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example 7
Source File: XmlParser.java From secure-data-service with Apache License 2.0 | 6 votes |
private void collectEventInfo(Characters characters) { if (currentObjects.size() == 0) { return; } if (characters.isIgnorableWhiteSpace() || characters.isWhiteSpace()) { return; } String text = characters.getData(); if (currentObjects.peek().containsKey(parents.peek().getName().getLocalPart() + "_value")) { String oldText = (String) currentObjects.peek().get(parents.peek().getName().getLocalPart() + "_value"); text = oldText + text; } currentObjects.peek().put(parents.peek().getName().getLocalPart() + "_value", text); }
Example 8
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example 9
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map) throws PolicyException { if (chars.isWhiteSpace()) { return; } else { final String data = chars.getData(); if ((currentElement != null) && URI.equals(currentElement.getName())) { processUri(chars, map); return; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation()))); } } }
Example 10
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example 11
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map) throws PolicyException { if (chars.isWhiteSpace()) { return; } else { final String data = chars.getData(); if ((currentElement != null) && URI.equals(currentElement.getName())) { processUri(chars, map); return; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation()))); } } }
Example 12
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example 13
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map) throws PolicyException { if (chars.isWhiteSpace()) { return; } else { final String data = chars.getData(); if ((currentElement != null) && URI.equals(currentElement.getName())) { processUri(chars, map); return; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation()))); } } }
Example 14
Source File: XmlPolicyModelUnmarshaller.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example 15
Source File: ExternalAttachmentsUnmarshaller.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map) throws PolicyException { if (chars.isWhiteSpace()) { return; } else { final String data = chars.getData(); if ((currentElement != null) && URI.equals(currentElement.getName())) { processUri(chars, map); return; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation()))); } } }
Example 16
Source File: ExternalAttachmentsUnmarshaller.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map) throws PolicyException { if (chars.isWhiteSpace()) { return; } else { final String data = chars.getData(); if ((currentElement != null) && URI.equals(currentElement.getName())) { processUri(chars, map); return; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation()))); } } }
Example 17
Source File: EdfiRecordParserImpl.java From secure-data-service with Apache License 2.0 | 5 votes |
private void parseCharacters(Characters characters) { if (!characters.isIgnorableWhiteSpace() && !characters.isWhiteSpace()) { String text = characters.getData(); Object convertedValue = typeProvider.convertType(complexTypeStack.peek().getLeft().getType(), text); complexTypeStack.peek().getRight().put("_value", convertedValue); } }
Example 18
Source File: XmlFilterReader.java From knox with Apache License 2.0 | 5 votes |
private void processCharacters( Characters event ) { Level level = stack.peek(); Node node = stack.peek().node; if( event.isCData() ) { node.appendChild( document.createCDATASection( event.getData() ) ); } else { node.appendChild( document.createTextNode( event.getData() ) ); } if( !currentlyBuffering() ) { String value = event.getData(); if( !event.isWhiteSpace() ) { if( level.scopeConfig == null || level.scopeConfig.getSelectors().isEmpty() ) { value = filterText( extractQName( node ), value, null ); } else { UrlRewriteFilterPathDescriptor path = pickFirstMatchingPath( level ); if( path instanceof UrlRewriteFilterApplyDescriptor ) { String rule = ((UrlRewriteFilterApplyDescriptor)path).rule(); value = filterText( extractQName( node ), value, rule ); } } } if( event.isCData() ) { writer.write( "<![CDATA[" ); writer.write( value ); writer.write( "]]>" ); } else { writer.write( StringEscapeUtils.escapeXml11( value ) ); } } }
Example 19
Source File: BaseStreamWriter.java From woodstox with Apache License 2.0 | 4 votes |
/** * Method called by {@link javax.xml.stream.XMLEventWriter} * (instead of more generic * text output methods), so that we can verify (if necessary) that * this character output type is legal in this context. Specifically, * it's not acceptable to add non-whitespace content outside root * element (in prolog/epilog). *<p> * Note: cut'n pasted from the main <code>writeCharacters</code>; not * good... but done to optimize white-space cases. */ public void writeCharacters(Characters ch) throws XMLStreamException { // Need to finish an open start element? if (mStartElementOpen) { closeStartElement(mEmptyElement); } /* Not legal outside main element tree, except if it's all * white space */ if (mCheckStructure) { if (inPrologOrEpilog()) { if (!ch.isIgnorableWhiteSpace() && !ch.isWhiteSpace()) { reportNwfStructure(ErrorConsts.WERR_PROLOG_NONWS_TEXT); } } } if (mVldContent <= XMLValidator.CONTENT_ALLOW_WS) { if (mVldContent == XMLValidator.CONTENT_ALLOW_NONE) { // never ok reportInvalidContent(CHARACTERS); } else { // all-ws is ok... if (!ch.isIgnorableWhiteSpace() && !ch.isWhiteSpace()) { reportInvalidContent(CHARACTERS); } } } else if (mVldContent == XMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT) { if (mValidator != null) { /* Last arg is false, since we do not know if more text * may be added with additional calls */ mValidator.validateText(ch.getData(), false); } } // Ok, let's just write it out: try { mWriter.writeCharacters(ch.getData()); } catch (IOException ioe) { throw new WstxIOException(ioe); } }
Example 20
Source File: XmlRecordSource.java From nifi with Apache License 2.0 | 4 votes |
private XmlNode readNext(final StartElement startElement) throws XMLStreamException, IOException { // Parse everything until we encounter the end element final StringBuilder content = new StringBuilder(); final Map<String, XmlNode> childNodes = new LinkedHashMap<>(); while (xmlEventReader.hasNext()) { final XMLEvent xmlEvent = xmlEventReader.nextEvent(); if (xmlEvent.isEndDocument()) { throw new EOFException("Expected to encounter End-of-Element tag for start tag '" + startElement.getName() + "'"); } if (xmlEvent.isEndElement()) { break; } if (xmlEvent.isCharacters()) { final Characters characters = xmlEvent.asCharacters(); if (!characters.isWhiteSpace()) { content.append(characters.getData()); } } if (xmlEvent.isStartElement()) { final StartElement childStartElement = xmlEvent.asStartElement(); final XmlNode childNode = readNext(childStartElement); final String childName = childStartElement.getName().getLocalPart(); final XmlNode existingNode = childNodes.get(childName); if (existingNode == null) { childNodes.put(childName, childNode); } else if (existingNode.getNodeType() == XmlNodeType.ARRAY) { ((XmlArrayNode) existingNode).addElement(childNode); } else { final XmlArrayNode arrayNode = new XmlArrayNode(childStartElement.getName().getLocalPart()); arrayNode.addElement(existingNode); arrayNode.addElement(childNode); childNodes.put(childName, arrayNode); } } } final String nodeName = startElement.getName().getLocalPart(); if (childNodes.isEmpty()) { return new XmlTextNode(nodeName, content.toString().trim()); } else { return new XmlContainerNode(nodeName, childNodes); } }