本文整理汇总了Java中javax.xml.stream.events.Characters.isIgnorableWhiteSpace方法的典型用法代码示例。如果您正苦于以下问题:Java Characters.isIgnorableWhiteSpace方法的具体用法?Java Characters.isIgnorableWhiteSpace怎么用?Java Characters.isIgnorableWhiteSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.stream.events.Characters
的用法示例。
在下文中一共展示了Characters.isIgnorableWhiteSpace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleCharacters
import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
private void handleCharacters(Characters characters) throws SAXException {
char[] data = characters.getData().toCharArray();
if (getContentHandler() != null && characters.isIgnorableWhiteSpace()) {
getContentHandler().ignorableWhitespace(data, 0, data.length);
return;
}
if (characters.isCData() && getLexicalHandler() != null) {
getLexicalHandler().startCDATA();
}
if (getContentHandler() != null) {
getContentHandler().characters(data, 0, data.length);
}
if (characters.isCData() && getLexicalHandler() != null) {
getLexicalHandler().endCDATA();
}
}
示例2: 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;
}
}
}
示例3: 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;
}
}
}
示例4: 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);
}
示例5: 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);
}
}
示例6: 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();
}
示例7: 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);
}
}