當前位置: 首頁>>代碼示例>>Java>>正文


Java Characters類代碼示例

本文整理匯總了Java中javax.xml.stream.events.Characters的典型用法代碼示例。如果您正苦於以下問題:Java Characters類的具體用法?Java Characters怎麽用?Java Characters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Characters類屬於javax.xml.stream.events包,在下文中一共展示了Characters類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getElementText

import javax.xml.stream.events.Characters; //導入依賴的package包/類
public String getElementText() throws XMLStreamException
{
    StringBuffer buffer = new StringBuffer();
    XMLEvent e = nextEvent();
    if (!e.isStartElement())
        throw new XMLStreamException(
        CommonResourceBundle.getInstance().getString("message.mustBeOnSTART_ELEMENT"));

    while(hasNext()) {
        e = nextEvent();
        if(e.isStartElement())
            throw new XMLStreamException(
            CommonResourceBundle.getInstance().getString("message.getElementTextExpectTextOnly"));
        if(e.isCharacters())
            buffer.append(((Characters) e).getData());
        if(e.isEndElement())
            return buffer.toString();
    }
    throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.END_ELEMENTnotFound"));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:StAXFilteredEvent.java

示例2: 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

示例3: 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

示例4: 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();
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:17,代碼來源:StaxEventXMLReader.java

示例5: nextTag

import javax.xml.stream.events.Characters; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public XMLEvent nextTag()
    throws XMLStreamException
{
    while ( hasNext() )
    {
        XMLEvent e = nextEvent();
        if ( e.isCharacters() && !( (Characters) e ).isWhiteSpace() )
        {
            throw new XMLStreamException( "Unexpected text" );
        }
        if ( e.isStartElement() || e.isEndElement() )
        {
            return e;
        }
    }
    throw new XMLStreamException( "Unexpected end of Document" );
}
 
開發者ID:mojohaus,項目名稱:versions-maven-plugin,代碼行數:21,代碼來源:ModifiedPomXMLEventReader.java

示例6: parseHeaderProp

import javax.xml.stream.events.Characters; //導入依賴的package包/類
/**
 * Parse prop elements in Header.
 *
 * @param element XML element.
 * @throws Exception when error happend.
 */
private void parseHeaderProp(StartElement element) throws Exception {
    String propType = getAttributeValue(element, "type");
    StringBuilder headerPropContent = new StringBuilder();

    while (true) {
        XMLEvent evt = xml.nextEvent();
        switch (evt.getEventType()) {
            case XMLEvent.END_ELEMENT:
                EndElement eleEnd = (EndElement) evt;
                if ("prop".equals(eleEnd.getName().getLocalPart())) {
                    header.props.put(propType, headerPropContent.toString());
                    return;
                }
                break;
            case XMLEvent.CHARACTERS:
                Characters ch = (Characters) evt;
                headerPropContent.append(ch.getData());
                break;
            default:
                break;
        }
    }
}
 
開發者ID:miurahr,項目名稱:tmpotter,代碼行數:30,代碼來源:TmxReader2.java

示例7: parseHeaderNote

import javax.xml.stream.events.Characters; //導入依賴的package包/類
private void parseHeaderNote(StartElement element) throws Exception {
    noteContent.setLength(0);

    while (true) {
        XMLEvent evt = xml.nextEvent();
        switch (evt.getEventType()) {
            case XMLEvent.END_ELEMENT:
                EndElement eleEnd = (EndElement) evt;
                if ("note".equals(eleEnd.getName().getLocalPart())) {
                    header.note = noteContent.toString();
                    return;
                }
                break;
            case XMLEvent.CHARACTERS:
                Characters ch = (Characters) evt;
                noteContent.append(ch.getData());
                break;
            default:
                break;
        }
    }
}
 
開發者ID:miurahr,項目名稱:tmpotter,代碼行數:23,代碼來源:TmxReader2.java

示例8: parseTuNote

import javax.xml.stream.events.Characters; //導入依賴的package包/類
private void parseTuNote(StartElement element) throws Exception {
    noteContent.setLength(0);

    while (true) {
        XMLEvent evt = xml.nextEvent();
        switch (evt.getEventType()) {
            case XMLEvent.END_ELEMENT:
                EndElement eleEnd = (EndElement) evt;
                if ("note".equals(eleEnd.getName().getLocalPart())) {
                    currentTu.note = noteContent.toString();
                    return;
                }
                break;
            case XMLEvent.CHARACTERS:
                Characters ch = (Characters) evt;
                noteContent.append(ch.getData());
                break;
            default:
                break;
        }
    }
}
 
開發者ID:miurahr,項目名稱:tmpotter,代碼行數:23,代碼來源:TmxReader2.java

示例9: parseTuProp

import javax.xml.stream.events.Characters; //導入依賴的package包/類
/**
 * Parse prop elements in Tu element.
 *
 * @param element XML element.
 * @throws Exception when error happened.
 */
private void parseTuProp(StartElement element) throws Exception {
    String propType = getAttributeValue(element, "type");
    propContent.setLength(0);

    while (true) {
        XMLEvent evt = xml.nextEvent();
        switch (evt.getEventType()) {
            case XMLEvent.END_ELEMENT:
                EndElement eleEnd = (EndElement) evt;
                if ("prop".equals(eleEnd.getName().getLocalPart())) {
                    currentTu.props.put(propType, propContent.toString());
                    return;
                }
                break;
            case XMLEvent.CHARACTERS:
                Characters ch = (Characters) evt;
                propContent.append(ch.getData());
                break;
            default:
                break;
        }
    }
}
 
開發者ID:miurahr,項目名稱:tmpotter,代碼行數:30,代碼來源:TmxReader2.java

示例10: parseSegOmegaT

import javax.xml.stream.events.Characters; //導入依賴的package包/類
/**
 * OmegaT TMX - just read full text.
 */
private void parseSegOmegaT() throws Exception {
    segContent.setLength(0);

    while (true) {
        XMLEvent evt = xml.nextEvent();
        switch (evt.getEventType()) {
            case XMLEvent.END_ELEMENT:
                EndElement eleEnd = (EndElement) evt;
                if ("seg".equals(eleEnd.getName().getLocalPart())) {
                    return;
                }
                break;
            case XMLEvent.CHARACTERS:
                Characters ch = (Characters) evt;
                segContent.append(ch.getData());
                break;
            default:
                break;
        }
    }
}
 
開發者ID:miurahr,項目名稱:tmpotter,代碼行數:25,代碼來源:TmxReader2.java

示例11: createNode

import javax.xml.stream.events.Characters; //導入依賴的package包/類
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	XMLEvent tab = eventFactory.createDTD("\t");
	// Create start node
	StartElement sElement = eventFactory.createStartElement("", "", name);
	eventWriter.add(tab);
	eventWriter.add(sElement);
	// Create Content
	Characters characters = eventFactory.createCharacters(value);
	eventWriter.add(characters);
	// Create End node
	EndElement eElement = eventFactory.createEndElement("", "", name);
	eventWriter.add(eElement);
	eventWriter.add(end);
}
 
開發者ID:JavaSummer,項目名稱:JavaMainRepo,代碼行數:17,代碼來源:EntityRepository.java

示例12: createNode

import javax.xml.stream.events.Characters; //導入依賴的package包/類
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {

		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		XMLEvent tab = eventFactory.createDTD("\t");

		StartElement sElement = eventFactory.createStartElement("", "", name);
		eventWriter.add(tab);
		eventWriter.add(sElement);

		Characters characters = eventFactory.createCharacters(value);
		eventWriter.add(characters);

		EndElement eElement = eventFactory.createEndElement("", "", name);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}
 
開發者ID:JavaSummer,項目名稱:JavaMainRepo,代碼行數:18,代碼來源:EntityRepository.java

示例13: createNode

import javax.xml.stream.events.Characters; //導入依賴的package包/類
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	XMLEvent tab = eventFactory.createDTD("\t");
	// Create Start node
	StartElement sElement = eventFactory.createStartElement("", "", name);
	eventWriter.add(tab);
	eventWriter.add(sElement);
	// Create Content
	Characters characters = eventFactory.createCharacters(value);
	eventWriter.add(characters);
	// Create End node
	EndElement eElement = eventFactory.createEndElement("", "", name);
	eventWriter.add(eElement);
	eventWriter.add(end);
}
 
開發者ID:JavaSummer,項目名稱:JavaMainRepo,代碼行數:17,代碼來源:EntityRepository.java

示例14: createNode

import javax.xml.stream.events.Characters; //導入依賴的package包/類
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {

		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		XMLEvent tab = eventFactory.createDTD("\t");

		// Create start node
		StartElement sElement = eventFactory.createStartElement("", "", name);
		eventWriter.add(tab);
		eventWriter.add(sElement);

		// Create content

		Characters characters = eventFactory.createCharacters(value);
		eventWriter.add(characters);

		// Create end node

		EndElement eElement = eventFactory.createEndElement("", "", name);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}
 
開發者ID:JavaSummer,項目名稱:JavaMainRepo,代碼行數:23,代碼來源:AnimalRepository.java

示例15: createNode

import javax.xml.stream.events.Characters; //導入依賴的package包/類
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {

			XMLEventFactory eventFactory = XMLEventFactory.newInstance();
			XMLEvent end = eventFactory.createDTD("\n");
			XMLEvent tab = eventFactory.createDTD("\t");

			// Create start node
			StartElement sElement = eventFactory.createStartElement("", "", name);
			eventWriter.add(tab);
			eventWriter.add(sElement);

			// Create content

			Characters characters = eventFactory.createCharacters(value);
			eventWriter.add(characters);

			// Create end node

			EndElement eElement = eventFactory.createEndElement("", "", name);
			eventWriter.add(eElement);
			eventWriter.add(end);
		}
 
開發者ID:JavaSummer,項目名稱:JavaMainRepo,代碼行數:23,代碼來源:EmployeeRepository.java


注:本文中的javax.xml.stream.events.Characters類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。