java类javax.xml.stream.XMLStreamWriter的实例源码

TsoOvervoltageSecurityIndex.java 文件源码 项目:powsybl-core 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("index");
    xmlWriter.writeAttribute("name", XML_NAME);

    xmlWriter.writeStartElement("computation-succeed");
    xmlWriter.writeCharacters(Boolean.toString(computationSucceed));
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("overvoltage-count");
    xmlWriter.writeCharacters(Integer.toString(overvoltageCount));
    xmlWriter.writeEndElement();

    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
XMLStreamWriterTest.java 文件源码 项目:openjdk-jdk10 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Test of main method, of class TestXMLStreamWriter.
 */
@Test
public void testWriteComment() {
    try {
        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a:html href=\"http://java.sun.com\"><!--This is comment-->java.sun.com</a:html>";
        XMLOutputFactory f = XMLOutputFactory.newInstance();
        // f.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,
        // Boolean.TRUE);
        StringWriter sw = new StringWriter();
        XMLStreamWriter writer = f.createXMLStreamWriter(sw);
        writer.writeStartDocument("UTF-8", "1.0");
        writer.writeStartElement("a", "html", "http://www.w3.org/TR/REC-html40");
        writer.writeAttribute("href", "http://java.sun.com");
        writer.writeComment("This is comment");
        writer.writeCharacters("java.sun.com");
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.flush();
        sw.flush();
        StringBuffer sb = sw.getBuffer();
        System.out.println("sb:" + sb.toString());
        Assert.assertTrue(sb.toString().equals(xml));
    } catch (Exception ex) {
        Assert.fail("Exception: " + ex.getMessage());
    }
}
GeographicalRegion.java 文件源码 项目:powsybl-core 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Utility to return the content of this class into the CIM XML format
 *
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
private void writeClass(XMLStreamWriter xmlsw) {

    if (currentBitset.get(0)) {
  for (SubGeographicalRegion regions : this.regions){
           try {
             xmlsw.writeEmptyElement(CIMURI.CIMURI,"GeographicalRegion.Regions");
             xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                       + regions.getId());
           } catch (XMLStreamException e) {
             StringBuilder errorMessage = new StringBuilder(
                                "Error while trying to write the reference to ");
             errorMessage.append("GeographicalRegion ");
             errorMessage.append("which ID has been initialized to : ");
             errorMessage.append(getId());
             errorMessage.append(" in the subset ");
             errorMessage.append("Equipment");
             LOGGER.error(errorMessage.toString());
             LOGGER.error(e.toString(), e);
           }
  }
    }

    return;
}
ConnectivityNodeContainer.java 文件源码 项目:powsybl-core 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Utility to write the content into the CIM XML format
 *
 * @param writeID
 *            specifies whether to write the XML "id" attribute (this is used for describing concrete class)
 * @param xmlsw
 *            XMLStreamWriter where are stored the elements to write
 */
@Override
public void write(XMLStreamWriter xmlsw, boolean writeID) {

    /*
     * In previous versions, we used to check the consistency
     * of the instance in the context but this task is now
     * performed by the model before attempting to write.
     * Therefore each instance can now be written even if
     * it is not consistent !
     */

    writeClass(xmlsw);
    super.write(xmlsw, false);
    return;
}
XMLCodec.java 文件源码 项目:OpenJSharp 阅读 18 收藏 0 点赞 0 评论 0
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
EquivalentEquipment.java 文件源码 项目:powsybl-core 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Utility to write the content into the CIM XML format
 *
 * @param writeID
 *            specifies whether to write the XML "id" attribute (this is used for describing concrete class)
 * @param xmlsw
 *            XMLStreamWriter where are stored the elements to write
 */
@Override
public void write(XMLStreamWriter xmlsw, boolean writeID) {

    /*
     * In previous versions, we used to check the consistency
     * of the instance in the context but this task is now
     * performed by the model before attempting to write.
     * Therefore each instance can now be written even if
     * it is not consistent !
     */

    writeClass(xmlsw);
    super.write(xmlsw, false);
    return;
}
Conductor.java 文件源码 项目:powsybl-core 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Utility to write the content this class into the CIM/XML format according
 * to a subset
 *
 * @param subset
 *            the subset defining the context in which to write this class
 * @param writeID
 *            specifies whether to write the XML "id" attribute (this is used for describing concrete class)
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
@Override
public void write(XMLStreamWriter xmlsw, final Subset subset,
        boolean writeID) {

    /*
     * In previous versions, we used to check the consistency
     * of the instance in the context but this task is now
     * performed by the model before attempting to write.
     * Therefore each instance can now be written even if
     * it is not consistent !
     */

    // abstract class
    writeClass(xmlsw);
    super.write(xmlsw, subset, false);
    return;
}
Line.java 文件源码 项目:powsybl-core 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Utility to write the content this class into the CIM/XML format according
 * to a subset
 *
 * @param subset
 *            the subset defining the context in which to write this class
 * @param writeID
 *            specifies whether to write the XML "id" attribute (this is used for describing concrete class)
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
@Override
public void write(XMLStreamWriter xmlsw, final Subset subset,
        boolean writeID) {

    /*
     * In previous versions, we used to check the consistency
     * of the instance in the context but this task is now
     * performed by the model before attempting to write.
     * Therefore each instance can now be written even if
     * it is not consistent !
     */

    // abstract class
    writeClass(xmlsw);
    super.write(xmlsw, subset, false);
    return;
}
RegulatingCondEq.java 文件源码 项目:powsybl-core 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Utility to write the content this class into the CIM/XML format according
 * to a subset
 *
 * @param subset
 *            the subset defining the context in which to write this class
 * @param writeID
 *            specifies whether to write the XML "id" attribute (this is used for describing concrete class)
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
@Override
public void write(XMLStreamWriter xmlsw, final Subset subset,
        boolean writeID) {

    /*
     * In previous versions, we used to check the consistency
     * of the instance in the context but this task is now
     * performed by the model before attempting to write.
     * Therefore each instance can now be written even if
     * it is not consistent !
     */

    // abstract class
    writeClass(xmlsw);
    super.write(xmlsw, subset, false);
    return;
}
UnprefixedNameTest.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
@Test
public void testBoundPrefix() throws Exception {

    try {
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        XMLStreamWriter w = xof.createXMLStreamWriter(System.out);
        // here I'm trying to write
        // <bar xmlns="foo" />
        w.writeStartDocument();
        w.writeStartElement("foo", "bar", "http://namespace");
        w.writeCharacters("---");
        w.writeEndElement();
        w.writeEndDocument();
        w.close();

        // Expected success
        System.out.println("Expected success.");
    } catch (Exception exception) {
        // Unexpected Exception
        String FAIL_MSG = "Unexpected Exception: " + exception.toString();
        System.err.println(FAIL_MSG);
        Assert.fail(FAIL_MSG);
    }
}
Curve.java 文件源码 项目:powsybl-core 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Utility to return the content of this class into the CIM XML format
 *
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
private void writeClass(XMLStreamWriter xmlsw) {

    if (currentBitset.get(0)) {
  for (CurveData curveScheduleDatas : this.curveScheduleDatas){
           try {
             xmlsw.writeEmptyElement(CIMURI.CIMURI,"Curve.CurveScheduleDatas");
             xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                       + curveScheduleDatas.getId());
           } catch (XMLStreamException e) {
             StringBuilder errorMessage = new StringBuilder(
                                "Error while trying to write the reference to ");
             errorMessage.append("Curve ");
             errorMessage.append("which ID has been initialized to : ");
             errorMessage.append(getId());
             errorMessage.append(" in the subset ");
             errorMessage.append("${subsetModel.getSubset($class).getName()}");
             LOGGER.error(errorMessage.toString());
             LOGGER.error(e.toString(), e);
           }
  }
    }

    return;
}
VoltageControlZone.java 文件源码 项目:powsybl-core 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Utility to write the content into the CIM XML format
 *
 * @param writeID
 *            specifies whether to write the XML "id" attribute (this is used for describing concrete class)
 * @param xmlsw
 *            XMLStreamWriter where are stored the elements to write
 */
@Override
public void write(XMLStreamWriter xmlsw, boolean writeID) {

    /*
     * In previous versions, we used to check the consistency
     * of the instance in the context but this task is now
     * performed by the model before attempting to write.
     * Therefore each instance can now be written even if
     * it is not consistent !
     */

    writeClass(xmlsw);
    super.write(xmlsw, false);
    return;
}
PowerTransformer.java 文件源码 项目:powsybl-core 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Utility to return the content of this class into the CIM XML format
 *
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
private void writeClass(XMLStreamWriter xmlsw) {

    if (currentBitset.get(0)) {
  for (TransformerWinding contains_TransformerWindings : this.contains_TransformerWindings){
           try {
             xmlsw.writeEmptyElement(CIMURI.CIMURI,"PowerTransformer.Contains_TransformerWindings");
             xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                       + contains_TransformerWindings.getId());
           } catch (XMLStreamException e) {
             StringBuilder errorMessage = new StringBuilder(
                                "Error while trying to write the reference to ");
             errorMessage.append("PowerTransformer ");
             errorMessage.append("which ID has been initialized to : ");
             errorMessage.append(getId());
             errorMessage.append(" in the subset ");
             errorMessage.append("Equipment");
             LOGGER.error(errorMessage.toString());
             LOGGER.error(e.toString(), e);
           }
  }
    }

    return;
}
AbstractConnectableXml.java 文件源码 项目:powsybl-core 阅读 16 收藏 0 点赞 0 评论 0
public static void writeCurrentLimits(Integer index, CurrentLimits limits, XMLStreamWriter writer, String nsUri) throws XMLStreamException {
    if (!Float.isNaN(limits.getPermanentLimit())
        || !limits.getTemporaryLimits().isEmpty()) {
        if (limits.getTemporaryLimits().isEmpty()) {
            writer.writeEmptyElement(nsUri, CURRENT_LIMITS + indexToString(index));
        } else {
            writer.writeStartElement(nsUri, CURRENT_LIMITS + indexToString(index));
        }
        XmlUtil.writeFloat("permanentLimit", limits.getPermanentLimit(), writer);
        for (CurrentLimits.TemporaryLimit tl : limits.getTemporaryLimits()) {
            writer.writeEmptyElement(IIDM_URI, "temporaryLimit");
            writer.writeAttribute("name", tl.getName());
            XmlUtil.writeOptionalInt("acceptableDuration", tl.getAcceptableDuration(), Integer.MAX_VALUE, writer);
            XmlUtil.writeOptionalFloat("value", tl.getValue(), Float.MAX_VALUE, writer);
            XmlUtil.writeOptionalBoolean("fictitious", tl.isFictitious(), false, writer);
        }
        if (!limits.getTemporaryLimits().isEmpty()) {
            writer.writeEndElement();
        }
    }
}
MultiCriteriaVoltageStabilityIndex.java 文件源码 项目:powsybl-core 阅读 20 收藏 0 点赞 0 评论 0
@Override
protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement(TAG_INDEX);
    xmlWriter.writeAttribute(TAG_NAME, XML_NAME);
    toXml(xmlWriter, TAG_LOCKED_TAP_CHANGER_LOAD, lockedTapChangerLoads);
    toXml(xmlWriter, TAG_STOPPED_TAP_CHANGER_LOAD, stoppedTapChangerLoads);
    toXml(xmlWriter, TAG_UNDER_VOLTAGE_AUTOMATON_GENERATOR, underVoltageAutomatonGenerators);

    for (String underVoltageBus : underVoltageBuses) {
        xmlWriter.writeStartElement(TAG_UNDER_BUS_VOLTAGE);
        xmlWriter.writeCharacters(underVoltageBus);
        xmlWriter.writeEndElement();
    }
    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
TsoSynchroLossSecurityIndex.java 文件源码 项目:powsybl-core 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("index");
    xmlWriter.writeAttribute("name", XML_NAME);

    xmlWriter.writeStartElement("synchro-loss-count");
    xmlWriter.writeCharacters(Integer.toString(synchroLossCount));
    xmlWriter.writeEndElement();

    for (Map.Entry<String, Float> e : desynchronizedGenerators.entrySet()) {
        String id = e.getKey();
        float p = e.getValue();
        xmlWriter.writeStartElement(GENERATOR);
        xmlWriter.writeAttribute("id", id);
        xmlWriter.writeCharacters(Float.toString(p));
        xmlWriter.writeEndElement();
    }

    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
XMLExporter.java 文件源码 项目:alevin-svn2 阅读 25 收藏 0 点赞 0 评论 0
static void exportDemand(XMLStreamWriter writer, AbstractDemand ad, String type, String exportId) throws XMLStreamException {
    writer.writeStartElement(type);
    writer.writeAttribute("type", ad.getClass().getSimpleName());
    if (exportId != null)
        writer.writeAttribute("exportId", exportId);
    //Export additional construction parameters
    exportConstructParameters(writer, ad);
    exportParameters(writer, ad);
    exportMappings(writer, ad);
    writer.writeEndElement();//End of Demand
}
OldBridge.java 文件源码 项目:openjdk-jdk10 阅读 27 收藏 0 点赞 0 评论 0
public final void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,output);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
XMLExporter.java 文件源码 项目:alevin-svn2 阅读 21 收藏 0 点赞 0 评论 0
/**
 * This Method exports the Mappings
 * 
 * @param writer WriterObject
 * @param ad Demand
 * @throws XMLStreamException 
 */
static void exportMappings(XMLStreamWriter writer, AbstractDemand ad) throws XMLStreamException {
    for(Mapping map : ad.getMappings()) {
        String type = map.getResource().getClass().getSimpleName();
        long entityID = map.getResource().getOwner().getId();

        writer.writeEmptyElement("Mapping");
        writer.writeAttribute("resourceType", type);
        writer.writeAttribute("substrateEntity", entityID+"");
    }

}
NormalizedNodeXMLOutput.java 文件源码 项目:hashsdn-controller 阅读 18 收藏 0 点赞 0 评论 0
public static void toStream(OutputStream outStream, NormalizedNode<?, ?> node)
        throws XMLStreamException, IOException {
    XMLStreamWriter xmlWriter = XOF.createXMLStreamWriter(outStream);

    IndentingXMLStreamWriter indenting = new IndentingXMLStreamWriter(xmlWriter);
    try (NormalizedNodeStreamWriter streamWriter = XMLStreamNormalizedNodeStreamWriter.createSchemaless(
            indenting)) {
        NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(streamWriter);
        nodeWriter.write(node);
        nodeWriter.flush();
    }
}
DOMMessage.java 文件源码 项目:OpenJSharp 阅读 16 收藏 0 点赞 0 评论 0
public void writePayloadTo(XMLStreamWriter sw) {
    try {
        if (payload != null)
            DOMUtil.serializeNode(payload, sw);
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
}
PropertiesPlatformConfig.java 文件源码 项目:powsybl-core 阅读 17 收藏 0 点赞 0 评论 0
public static void writeXml(Path configDir, Path xmlFile) throws IOException, XMLStreamException {
    XMLOutputFactory output = XMLOutputFactory.newInstance();
    try (Writer writer = Files.newBufferedWriter(xmlFile, StandardCharsets.UTF_8)) {
        XMLStreamWriter xmlWriter = output.createXMLStreamWriter(writer);
        try {
            xmlWriter.writeStartDocument(StandardCharsets.UTF_8.toString(), "1.0");
            xmlWriter.writeStartElement("config");
            try (DirectoryStream<Path> ds = Files.newDirectoryStream(configDir, entry -> Files.isRegularFile(entry) && entry.getFileName().toString().endsWith(".properties"))) {
                for (Path file : ds) {
                    String fileName = file.getFileName().toString();
                    String fileNameWithoutExtension = fileName.substring(0, fileName.length() - 11);
                    xmlWriter.writeStartElement(fileNameWithoutExtension);
                    Properties properties = new Properties();
                    try (Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
                        properties.load(reader);
                    }
                    for (String name : properties.stringPropertyNames()) {
                        String value = properties.getProperty(name);
                        xmlWriter.writeStartElement(name);
                        xmlWriter.writeCharacters(value);
                        xmlWriter.writeEndElement();
                    }
                    xmlWriter.writeEndElement();
                }
            }
            xmlWriter.writeEndElement();
            xmlWriter.writeEndDocument();
        } finally {
            xmlWriter.close();
        }
    }
}
TableauMessageBodyGenerator.java 文件源码 项目:dremio-oss 阅读 13 收藏 0 点赞 0 评论 0
private void writeDatasource(final XMLStreamWriter xmlStreamWriter, DatasetConfig datasetConfig, String hostname, MediaType mediaType) throws XMLStreamException {
  xmlStreamWriter.writeStartElement("datasource");
  xmlStreamWriter.writeAttribute("inline", "true");

  if (WebServer.MediaType.APPLICATION_TDS_TYPE.equals(mediaType)) {
    writeConnection(xmlStreamWriter, datasetConfig, hostname);
  } else if (WebServer.MediaType.APPLICATION_TDS_DRILL_TYPE.equals(mediaType)) {
    writeNativeDrillConnection(xmlStreamWriter, datasetConfig, hostname);
  } else {
    throw new RuntimeException("Unsupported media type " + mediaType);
  }

  xmlStreamWriter.writeEndElement();
}
BusbarSection.java 文件源码 项目:powsybl-core 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Utility to return the content of this class into the CIM XML format
 *
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
private void writeClass(XMLStreamWriter xmlsw) {

    if (currentBitset.get(0)) {

/*
 * Careful here : we may write an association "twice" if
 * the association is 1..1 one and if
 * both ends belong to the same subset
 */

    if (idVoltageControlZone != null &&
            !idVoltageControlZone.isEmpty()) {

        try {
            // xmlsw.writeCharacters("\t");
            xmlsw.writeEmptyElement(CIMURI.CIMURI,
                    "BusbarSection.VoltageControlZone");
            xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                    + idVoltageControlZone);
            // xmlsw.writeCharacters("\n");
        } catch(XMLStreamException e) {
            StringBuilder errorMessage = new StringBuilder(
                    "Error while trying to write the resource attribute ");
            errorMessage.append("VoltageControlZone");
            errorMessage.append(" in class ");
            errorMessage.append("BusbarSection ");
            errorMessage.append("which ID has been initialized to : ");
            errorMessage.append(getId());
            LOGGER.error(errorMessage.toString());
            LOGGER.error(e.toString(), e);
        }
    }
    }

    return;
}
SourceUtils.java 文件源码 项目:openjdk-jdk10 阅读 28 收藏 0 点赞 0 评论 0
/**
 * sets undeclared prefixes on the writer
 * @param prefix
 * @param writer
 * @throws XMLStreamException
 */
private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException {
    String writerURI = null;
    if (writer.getNamespaceContext() != null) {
        writerURI = writer.getNamespaceContext().getNamespaceURI(prefix);
    }

    if (writerURI == null) {
        writer.setPrefix(prefix, readerURI != null ? readerURI : "");
        writer.writeNamespace(prefix, readerURI != null ? readerURI : "");
    }
}
CurrentLimit.java 文件源码 项目:powsybl-core 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Utility to return the content of this class into the CIM XML format
 *
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
private void writeClass(XMLStreamWriter xmlsw) {

    if (currentBitset.get(0)) {

    try {
        // xmlsw.writeCharacters("\t");
        xmlsw.writeStartElement(CIMURI.CIMURI,
                "CurrentLimit.value");
        xmlsw.writeCharacters(String.valueOf(getValue()));
        xmlsw.writeEndElement();
        // xmlsw.writeCharacters("\n");
    } catch(XMLStreamException e) {
        StringBuilder errorMessage = new StringBuilder(
                "Error while trying to write the value of the attribute ");
        errorMessage.append("Value");
        errorMessage.append(" in class ");
        errorMessage.append("CurrentLimit ");
        errorMessage.append("which ID has been initialized to : ");
        errorMessage.append(getId());
        LOGGER.error(errorMessage.toString());
        LOGGER.error(e.toString(), e);
    }
    }

    return;
}
DOMMessage.java 文件源码 项目:openjdk-jdk10 阅读 16 收藏 0 点赞 0 评论 0
public void writePayloadTo(XMLStreamWriter sw) {
    try {
        if (payload != null)
            DOMUtil.serializeNode(payload, sw);
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
}
DXMLPrinter.java 文件源码 项目:OpenJSharp 阅读 19 收藏 0 点赞 0 评论 0
/**
 * @param out Output stream.
 */
public DXMLPrinter(XMLStreamWriter out) {
    this.out = out;
    this.visitor = new DXMLPrinterVisitor();
    this.ncVisitor = new NameClassXMLPrinterVisitor();
    this.domPrinter = new DOMPrinter(out);
}
StreamWriterBufferProcessor.java 文件源码 项目:openjdk-jdk10 阅读 16 收藏 0 点赞 0 评论 0
public void process(XMLStreamWriter writer) throws XMLStreamException {
    if(_fragmentMode){
        writeFragment(writer);
    }else{
        write(writer);
    }
}
RegulatingCondEq.java 文件源码 项目:powsybl-core 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Utility to return the content of this class into the CIM XML format
 *
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
private void writeClass(XMLStreamWriter xmlsw) {

    if (currentBitset.get(0)) {
    if (idRegulatingControl != null) {
        try {
            // xmlsw.writeCharacters("\t");
            xmlsw.writeEmptyElement(CIMURI.CIMURI,
                    "RegulatingCondEq.RegulatingControl");
            xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                    + idRegulatingControl);
            // xmlsw.writeCharacters("\n");
        } catch(XMLStreamException e) {
            StringBuilder errorMessage = new StringBuilder(
                    "Error while trying to write the resource attribute ");
            errorMessage.append("RegulatingControl");
            errorMessage.append(" in class ");
            errorMessage.append("RegulatingCondEq ");
            errorMessage.append("which ID has been initialized to : ");
            errorMessage.append(getId());
            LOGGER.error(errorMessage.toString());
            LOGGER.error(e.toString(), e);
        }
    }
    }

    return;
}


问题


面经


文章

微信
公众号

扫码关注公众号