當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。