当前位置: 首页>>代码示例>>Java>>正文


Java Characters.getData方法代码示例

本文整理汇总了Java中javax.xml.stream.events.Characters.getData方法的典型用法代码示例。如果您正苦于以下问题:Java Characters.getData方法的具体用法?Java Characters.getData怎么用?Java Characters.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.stream.events.Characters的用法示例。


在下文中一共展示了Characters.getData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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())));
        }

    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:ExternalAttachmentsUnmarshaller.java

示例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)));
        }

    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:XmlPolicyModelUnmarshaller.java

示例3: 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);
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:19,代码来源:XmlParser.java

示例4: testEventReader

import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
@Test(dataProvider = "xml-data")
public void testEventReader(String xml, int chunkSize, int expectedNumOfChunks, boolean withinLimit) throws Exception {
    XMLInputFactory xif = XMLInputFactory.newInstance();
    xif.setProperty("http://java.sun.com/xml/stream/properties/report-cdata-event", true);
    if (chunkSize > 0) {
        xif.setProperty(CDATA_CHUNK_SIZE, chunkSize);
    }
    XMLEventReader reader = xif.createXMLEventReader(new StringReader(xml));

    StringBuilder cdata = new StringBuilder();
    int numOfChunks = 0;
    boolean isWithinLimit = true;
    while (reader.hasNext()) {
        XMLEvent event = reader.nextEvent();
        //All text events get reported as Characters events
        if (event.getEventType() == XMLStreamConstants.CHARACTERS) {
            Characters cdataEvent = (Characters) event;
            if (cdataEvent.isCData()) {
                String text = cdataEvent.getData();
                numOfChunks++;
                if (text.length() > chunkSize) {
                    isWithinLimit = false;
                }
                debugPrint("\nCDATA: " + text.length());
                cdata.append(text);
            }
        }
    }
    debugPrint("CData in single chunk:" + cdata.toString().length());
    Assert.assertEquals(numOfChunks, expectedNumOfChunks);
    Assert.assertEquals(isWithinLimit, withinLimit);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:CDataChunkSizeTest.java

示例5: 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();
    }

}
 
开发者ID:bodastage,项目名称:boda-bulkcmparser,代码行数:15,代码来源:BodaBulkCMParser.java

示例6: 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);
    }
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:16,代码来源:StaxEventRecorder.java

示例7: parse

import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
public String parse(XMLEventReader xmlEventReader, StartElement start)
        throws GraphIOException {

    try {
        String str = null;

        while (xmlEventReader.hasNext()) {

            XMLEvent event = xmlEventReader.nextEvent();
            if (event.isStartElement()) {

                // Parse the unknown element.
                getUnknownParser().parse(xmlEventReader, event
                        .asStartElement());
            } else if (event.isEndElement()) {
                EndElement end = (EndElement) event;
                verifyMatch(start, end);
                break;
            } else if (event.isCharacters()) {
                Characters characters = (Characters) event;
                str = characters.getData();
            }
        }

        return str;

    } catch (Exception e) {
        ExceptionConverter.convert(e);
    }

    return null;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:33,代码来源:StringElementParser.java

示例8: 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);
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:8,代码来源:EdfiRecordParserImpl.java

示例9: parse

import javax.xml.stream.events.Characters; //导入方法依赖的package包/类
public void parse() throws Exception {


        XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
        InputStream is = IOUtils.getInputStream(getInputFileName());
        XMLEventReader xmlEventReader = xmlInputFactory
                .createXMLEventReader(is);

        boolean isDoc = false;
        boolean isFacet = false;
        boolean isArr = false;
        int lstCounter = 0;
        String currentValue = "";
        String currentName = "";
        List<String> possibleStartElements = Arrays.asList("date,arr,str,bool,double,float,long,int".split(","));

        while (xmlEventReader.hasNext()) {
            XMLEvent xmlEvent = xmlEventReader.nextEvent();
            if (xmlEvent.isStartElement()) {
                StartElement startElement = xmlEvent.asStartElement();
                if (startElement.getAttributeByName(new QName("name")) != null) {
                    currentName = startElement.getAttributeByName(
                            new QName("name")).getValue();

                }
                if (startElement.getName().getLocalPart().equals("doc")) {
                    isDoc = true;
                }
                if (startElement.getName().getLocalPart().equals("lst")) {
                    lstCounter ++;
                    if(isFacet)
                    if("facet_fields".equals(currentName)) {
                        isFacet = true;
                    }

                }
            } else if (xmlEvent.isEndElement()) {
                EndElement endElement = xmlEvent.asEndElement();
                if (endElement.getName().getLocalPart().equals("doc")) {
                    isDoc = false;
                    endDocument();
                } else if (endElement.getName().getLocalPart().equals("arr")) {
                    currentName = "";
                } else if (isDoc && possibleStartElements.contains(endElement.getName().getLocalPart())) {
                    if (currentName != null && !"".equals(currentName)) {
                        field(currentName, currentValue);
                    }
                    currentValue = "";
                } else if (endElement.getName().getLocalPart().equals("lst")) {
                    lstCounter--;
                } else {
                }
            } else if (xmlEvent.isCharacters()) {
                Characters characters = xmlEvent.asCharacters();
                currentValue = characters.getData();
            }
        }
        is.close();
        xmlEventReader.close();

    }
 
开发者ID:tblsoft,项目名称:solr-cmd-utils,代码行数:62,代码来源:SolrXmlParser.java


注:本文中的javax.xml.stream.events.Characters.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。