本文整理汇总了Java中javax.xml.stream.events.Characters.isWhiteSpace方法的典型用法代码示例。如果您正苦于以下问题:Java Characters.isWhiteSpace方法的具体用法?Java Characters.isWhiteSpace怎么用?Java Characters.isWhiteSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.stream.events.Characters
的用法示例。
在下文中一共展示了Characters.isWhiteSpace方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCharacters
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
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())));
}
}
}
示例2: processCharacters
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
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)));
}
}
}
示例3: processCharacters
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
/**
* process a character event.
*
* @param characters chars to process
*/
private void processCharacters(final Characters characters) {
if (!characters.isWhiteSpace()) {
switch(currentElementType) {
case WAY_DEFINITION:
buildWayDefinition(characters.getData());
break;
case WAY_VISUALIZATION:
assignWayVisualizationDetail(characters.getData());
break;
case ZOOM_LEVEL_DATA:
assignWayWidth(characters.getData());
break;
default:
break;
}
}
}
示例4: read
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
/**
* 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;
}
}
}
示例5: read
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
/**
* Reads the specified node type.
*
* @throws ServiceXmlDeserializationException
* the service xml deserialization exception
* @throws XMLStreamException
* the xML stream exception
*/
public void read() 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(
Strings.UnexpectedEndOfXmlDocument);
} else {
XMLEvent event = xmlReader.nextEvent();
if (event.getEventType() == XMLStreamConstants.CHARACTERS) {
Characters characters = (Characters) event;
if (characters.isIgnorableWhiteSpace()
|| characters.isWhiteSpace())
continue;
}
this.prevEvent = this.presentEvent;
this.presentEvent = event;
break;
}
}
}
示例6: collectEventInfo
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
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);
}
示例7: characterEvent
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
/**
* Handle character events.
*
* @param xmlEvent
* @version 1.0.0
* @since 1.0.0
*/
public void characterEvent(XMLEvent xmlEvent) {
Characters characters = xmlEvent.asCharacters();
if (!characters.isWhiteSpace()) {
tagData = characters.getData();
}
}
示例8: addCharacters
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
private void addCharacters(XMLEvent xmlEvent) {
Characters characters = xmlEvent.asCharacters();
StaxEvent lastEvent = getLastEvent();
if (lastEvent instanceof BodyEvent) {
BodyEvent be = (BodyEvent) lastEvent;
be.append(characters.getData());
} else {
// ignore space only text if the previous event is not a BodyEvent
if(!characters.isWhiteSpace()) {
BodyEvent bodyEvent = new BodyEvent(characters.getData(), xmlEvent.getLocation());
eventList.add(bodyEvent);
}
}
}
示例9: parseCharacters
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
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);
}
}
示例10: parseXmlToMap
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
@Override
public Map<String, String> parseXmlToMap(String xml) {
Map<String, String> resultingMap = new HashMap<String, String>();
if(xml!=null&&!xml.isEmpty()){
XMLInputFactory factory = XMLInputFactory.newInstance();
String value = "";
String startName = "";
InputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
boolean isRootElement = true;
try {
XMLEventReader eventReader = factory.createXMLEventReader(stream);
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
Integer code = event.getEventType();
if (code == XMLStreamConstants.START_ELEMENT) {
StartElement startElement = event.asStartElement();
startName = startElement.getName().getLocalPart();
if (!isRootElement) {
resultingMap.put(startName, null);
} else {
isRootElement = false;
}
} else if (code == XMLStreamConstants.CHARACTERS) {
Characters characters = event.asCharacters();
if (!characters.isWhiteSpace()) {
StringBuilder valueBuilder;
if (value != null) {
valueBuilder = new StringBuilder(value).append(" ").append(characters.getData().toString());
} else {
valueBuilder = new StringBuilder(characters.getData().toString());
}
value = valueBuilder.toString();
}
} else if (code == XMLStreamConstants.END_ELEMENT) {
EndElement endElement = event.asEndElement();
String endName = endElement.getName().getLocalPart();
if (endName.equals(startName)) {
if (value != null) {
resultingMap.put(endName, value);
value = null;
}
} else {
LOGGER.trace("No value between xml tags, tag name : {0}", endName);
}
} else if (code == XMLStreamConstants.END_DOCUMENT) {
isRootElement = true;
}
}
} catch (XMLStreamException e) {
StringBuilder error = new StringBuilder("Xml stream exception wile parsing xml string")
.append(e.getLocalizedMessage());
throw new SystemException(error.toString());
}
}else {
LOGGER.trace("Input xml string null or empty.");
}
return resultingMap;
}
示例11: parseXmlToMap
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
@Override
public Map<String, String> parseXmlToMap(String xml) {
Map<String, String> resultingMap = new HashMap<String, String>();
if (xml != null && !xml.isEmpty()) {
XMLInputFactory factory = XMLInputFactory.newInstance();
String value = "";
String startName = "";
InputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
boolean isRootElement = true;
try {
XMLEventReader eventReader = factory.createXMLEventReader(stream);
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
Integer code = event.getEventType();
if (code == XMLStreamConstants.START_ELEMENT) {
StartElement startElement = event.asStartElement();
startName = startElement.getName().getLocalPart();
if (!isRootElement) {
resultingMap.put(startName, null);
} else {
isRootElement = false;
}
} else if (code == XMLStreamConstants.CHARACTERS) {
Characters characters = event.asCharacters();
if (!characters.isWhiteSpace()) {
StringBuilder valueBuilder;
if (value != null) {
valueBuilder = new StringBuilder(value).append(" ").append(characters.getData().toString());
} else {
valueBuilder = new StringBuilder(characters.getData().toString());
}
value = valueBuilder.toString();
}
} else if (code == XMLStreamConstants.END_ELEMENT) {
EndElement endElement = event.asEndElement();
String endName = endElement.getName().getLocalPart();
if (endName.equals(startName)) {
if (value != null) {
resultingMap.put(endName, value);
value = null;
}
} else {
LOGGER.trace("No value between xml tags, tag name : {0}", endName);
}
} else if (code == XMLStreamConstants.END_DOCUMENT) {
isRootElement = true;
}
}
} catch (XMLStreamException e) {
StringBuilder error = new StringBuilder("Xml stream exception wile parsing xml string")
.append(e.getLocalizedMessage());
throw new SystemException(error.toString());
}
} else {
LOGGER.trace("Input xml string null or empty.");
}
return resultingMap;
}
示例12: read
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
/**
* Reads the XMI file by using iterator-style.
*
* @param reader the reader to browse
*
* @throws XMLStreamException if there is an error with the underlying XML
*/
private void read(XMLEventReader reader) throws XMLStreamException {
readStartDocument();
while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
if (event.isStartElement()) {
StartElement element = event.asStartElement();
Iterable<Namespace> namespaces = element::getNamespaces;
for (Namespace ns : namespaces) {
readNamespace(ns.getPrefix(), ns.getNamespaceURI());
}
QName elementName = element.getName();
readStartElement(elementName.getNamespaceURI(), elementName.getLocalPart());
Iterable<Attribute> attributes = element::getAttributes;
for (Attribute attribute : attributes) {
QName attributeName = attribute.getName();
readAttribute(
attributeName.getPrefix(),
attributeName.getLocalPart(),
attribute.getValue());
}
flushStartElement();
}
else if (event.isEndElement()) {
readEndElement();
}
else if (event.isCharacters()) {
Characters characters = event.asCharacters();
if (!characters.isWhiteSpace() && !characters.isIgnorableWhiteSpace()) {
readCharacters(characters.getData());
}
}
}
readEndDocument();
}
示例13: writeCharacters
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
/**
* 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);
}
}