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


Java XMLEvent.CHARACTERS屬性代碼示例

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


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

示例1: fromXml

public static OverloadSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException {
    String text = null;
    while (xmlsr.hasNext()) {
        int eventType = xmlsr.next();
        switch (eventType) {
            case XMLEvent.CHARACTERS:
                text = xmlsr.getText();
                break;
            case XMLEvent.END_ELEMENT:
                if ("fx".equals(xmlsr.getLocalName())) {
                    return new OverloadSecurityIndex(contingencyId, Double.parseDouble(text));
                }
                break;
            default:
                break;
        }
    }
    throw new AssertionError("fx element not found");
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:19,代碼來源:OverloadSecurityIndex.java

示例2: handleEvent

private void handleEvent(XMLStreamReader xmlr, int eventType) {
    switch (eventType) {
        case XMLEvent.START_ELEMENT:
            handleStartElement(xmlr);
            break;
        case XMLEvent.END_ELEMENT:
            handleEndElement(xmlr);
            break;
        case XMLEvent.CHARACTERS:
            handleCharacters(xmlr);
            break;
        case XMLEvent.COMMENT:
            handleComment(xmlr);
            break;
        case XMLEvent.ENTITY_REFERENCE:
            break;
        case XMLEvent.ATTRIBUTE:
            break;
        case XMLEvent.DTD:
            break;
        case XMLEvent.CDATA:
            break;
        default:
            break;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:EntityTest.java

示例3: fromXml

public static UnderOverVoltageSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException {
    String text = null;
    while (xmlsr.hasNext()) {
        int eventType = xmlsr.next();
        switch (eventType) {
            case XMLEvent.CHARACTERS:
                text = xmlsr.getText();
                break;
            case XMLEvent.END_ELEMENT:
                if ("vx".equals(xmlsr.getLocalName())) {
                    return new UnderOverVoltageSecurityIndex(contingencyId, Double.parseDouble(text));
                }
                break;
            default:
                break;
        }
    }
    throw new AssertionError("vx element not found");
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:19,代碼來源:UnderOverVoltageSecurityIndex.java

示例4: hasText

/**
 * Return true if the current event has text, false otherwise The following
 * events have text: CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if (DEBUG) {
        pr("XMLReaderImpl#EVENT TYPE = " + fEventType);
    }
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if (name != null) {
            if (fScanner.foundBuiltInRefs) {
                return true;
            }

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if (en == null) {
                return false;
            }
            if (en.isExternal()) {
                return ((Entity.ExternalEntity) en).entityLocation.getExpandedSystemId() != null;
            } else {
                return ((Entity.InternalEntity) en).text != null;
            }
        } else {
            return false;
        }
    } else if (fEventType == XMLEvent.DTD) {
        return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:XMLStreamReaderImpl.java

示例5: getTextStart

/**
 * @return
 */
public int getTextStart() {
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
        return fScanner.getCharacterData().offset;
    } else {
        throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
                + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
                + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
                + " , " + getEventTypeString(XMLEvent.SPACE) + " valid for getTextStart() ");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:XMLStreamReaderImpl.java

示例6: fromXml

public static TsoOverloadSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException {
    String text = null;
    int overloadCount = -1;
    List<String> overloadedBranches = new ArrayList<>();
    boolean computationSucceed = true;
    while (xmlsr.hasNext()) {
        int eventType = xmlsr.next();
        switch (eventType) {
            case XMLEvent.CHARACTERS:
                text = xmlsr.getText();
                break;
            case XMLEvent.END_ELEMENT:
                switch (xmlsr.getLocalName()) {
                    case "overload-count":
                        overloadCount = Integer.parseInt(text);
                        break;

                    case "overloaded-branch":
                        overloadedBranches.add(text);
                        break;

                    case "computation-succeed":
                        computationSucceed = Boolean.parseBoolean(text);
                        break;

                    case "index":
                        return new TsoOverloadSecurityIndex(contingencyId, overloadCount, overloadedBranches, computationSucceed);

                    default:
                        break;
                }
                break;

            default:
                break;
        }
    }
    throw new AssertionError("index element not found");
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:39,代碼來源:TsoOverloadSecurityIndex.java

示例7: getTextCharacters

/**
 * @return
 */
public char[] getTextCharacters() {
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
        return fScanner.getCharacterData().ch;
    } else {
        throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
                + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
                + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
                + " , " + getEventTypeString(XMLEvent.SPACE) + " valid for getTextCharacters() ");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:XMLStreamReaderImpl.java

示例8: getTextLength

/**
 * @return
 */
public int getTextLength() {
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
        return fScanner.getCharacterData().length;
    } else {
        throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
                + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
                + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
                + " , " + getEventTypeString(XMLEvent.SPACE) + " valid for getTextLength() ");
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:XMLStreamReaderImpl.java

示例9: fromXml

public static TsoDisconnectedGenerator fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException {
    String text = null;
    Map<String, Float> disconnectedGenerators = new HashMap<>();
    String id = null;
    while (xmlsr.hasNext()) {
        int eventType = xmlsr.next();
        switch (eventType) {
            case XMLEvent.CHARACTERS:
                text = xmlsr.getText();
                break;

            case XMLEvent.START_ELEMENT:
                if ("generator".equals(xmlsr.getLocalName())) {
                    id = xmlsr.getAttributeValue(null, "id");
                }
                break;

            case XMLEvent.END_ELEMENT:
                switch (xmlsr.getLocalName()) {
                    case "generator":
                        if (id == null) {
                            throw new AssertionError();
                        }
                        float p = Float.parseFloat(text);
                        disconnectedGenerators.put(id, p);
                        id = null;
                        break;
                    case "index":
                        return new TsoDisconnectedGenerator(contingencyId, disconnectedGenerators);
                    default:
                        throw new AssertionError("Unexpected element: " + xmlsr.getLocalName());
                }
                break;

            default:
                break;
        }
    }
    throw new AssertionError("Should not happen");
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:40,代碼來源:TsoDisconnectedGenerator.java

示例10: getTextCharacters

/**
 * @return
 */
public char[] getTextCharacters() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
             || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
         return fScanner.getCharacterData().ch;
     } else{
         throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
         + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
                 + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
                 + " , " + getEventTypeString(XMLEvent.SPACE) +" valid for getTextCharacters() " ) ;
     }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:XMLStreamReaderImpl.java

示例11: hasValue

/**
 * @return
 */
public boolean hasValue() {
    if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
            || fEventType == XMLEvent.ENTITY_REFERENCE || fEventType == XMLEvent.PROCESSING_INSTRUCTION
            || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CHARACTERS) {
        return true;
    } else {
        return false;
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:XMLStreamReaderImpl.java

示例12: getTextStart

/**
 * @return
 */
public int getTextStart() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
         return  fScanner.getCharacterData().offset;
     } else{
         throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
         + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
                 + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
                 + " , " + getEventTypeString(XMLEvent.SPACE) +" valid for getTextStart() " ) ;
     }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:XMLStreamReaderImpl.java

示例13: getValue

/**
 * @return
 */
public String getValue() {
    if(fEventType == XMLEvent.PROCESSING_INSTRUCTION){
        return fScanner.getPIData().toString();
    } else if(fEventType == XMLEvent.COMMENT){
        return fScanner.getComment();
    } else if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT){
        return fScanner.getElementQName().localpart ;
    } else if(fEventType == XMLEvent.CHARACTERS){
        return fScanner.getCharacterData().toString();
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:XMLStreamReaderImpl.java

示例14: hasValue

/**
 * @return
 */
public boolean hasValue() {
    if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
    || fEventType == XMLEvent.ENTITY_REFERENCE || fEventType == XMLEvent.PROCESSING_INSTRUCTION
    || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CHARACTERS) {
        return true;
    } else {
        return false;
    }

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:XMLStreamReaderImpl.java

示例15: fromXml

public static MultiCriteriaVoltageStabilityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException {
    String text = null;
    Map<String, Float> lockedTapChangerLoads = new LinkedHashMap<>();
    Map<String, Float> stoppedTapChangerLoads = new LinkedHashMap<>();
    Map<String, Float> underVoltageAutomatonGenerators = new LinkedHashMap<>();
    Set<String> underVoltageBuses = new LinkedHashSet<>();
    String id = null;
    while (xmlsr.hasNext()) {
        int eventType = xmlsr.next();
        switch (eventType) {
            case XMLEvent.CHARACTERS:
                text = xmlsr.getText();
                break;
            case XMLEvent.START_ELEMENT:
                switch (xmlsr.getLocalName()) {
                    case TAG_LOCKED_TAP_CHANGER_LOAD:
                    case TAG_STOPPED_TAP_CHANGER_LOAD:
                    case TAG_UNDER_VOLTAGE_AUTOMATON_GENERATOR:
                        id = xmlsr.getAttributeValue(null, TAG_ID);
                        break;
                    case TAG_UNDER_BUS_VOLTAGE:
                    case TAG_INDEX:
                        // nothing to do
                        break;
                    default:
                        throw new AssertionError("Unexpected element: " + xmlsr.getLocalName());
                }
                break;

            case XMLEvent.END_ELEMENT:
                switch (xmlsr.getLocalName()) {
                    case TAG_LOCKED_TAP_CHANGER_LOAD:
                        if (id == null) {
                            throw new AssertionError();
                        }
                        lockedTapChangerLoads.put(id, Float.parseFloat(text));
                        id = null;
                        break;
                    case TAG_STOPPED_TAP_CHANGER_LOAD:
                        if (id == null) {
                            throw new AssertionError();
                        }
                        stoppedTapChangerLoads.put(id, Float.parseFloat(text));
                        id = null;
                        break;
                    case TAG_UNDER_VOLTAGE_AUTOMATON_GENERATOR:
                        if (id == null) {
                            throw new AssertionError();
                        }
                        underVoltageAutomatonGenerators.put(id, Float.parseFloat(text));
                        id = null;
                        break;
                    case TAG_UNDER_BUS_VOLTAGE:
                        underVoltageBuses.add(text);
                        break;
                    case TAG_INDEX:
                        return new MultiCriteriaVoltageStabilityIndex(contingencyId, lockedTapChangerLoads, stoppedTapChangerLoads,
                                                                      underVoltageAutomatonGenerators, underVoltageBuses);
                    default:
                        throw new AssertionError("Unexpected element: " + xmlsr.getLocalName());
                }
                break;

            default:
                break;
        }
    }
    throw new AssertionError("Should not happen");
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:69,代碼來源:MultiCriteriaVoltageStabilityIndex.java


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