本文整理汇总了Java中javax.xml.stream.XMLStreamWriter.writeEmptyElement方法的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamWriter.writeEmptyElement方法的具体用法?Java XMLStreamWriter.writeEmptyElement怎么用?Java XMLStreamWriter.writeEmptyElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.stream.XMLStreamWriter
的用法示例。
在下文中一共展示了XMLStreamWriter.writeEmptyElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportParameters
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* Extracts and exports normal parameters
*
* @param writer Writer object
* @param ob Object
* @throws XMLStreamException
*/
static void exportParameters(XMLStreamWriter writer,
Object ob) throws XMLStreamException {
Method[] mets = ob.getClass().getMethods();
for(Method m : mets) {
//lookup if the Method is marked as ExchangeParameter and NOT a setter
ExchangeParameter ep = m.getAnnotation(ExchangeParameter.class);
if(ep != null && m.getName().contains("get")) {
writer.writeEmptyElement("Parameter");
String paramName = m.getName().substring(3);
SimpleEntry<String, String> se = exportParamType(ob, m.getName());
writer.writeAttribute("name", paramName);
writer.writeAttribute("type", se.getKey());
writer.writeAttribute("value", se.getValue());
}
}
}
示例2: exportConstructParameters
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* Extracts and write out the AdditionalConstructionParameters to the writer
*
* @param writer Given Writer
* @param ob Object with annotations from AdditionalConstructParameter.class
* @throws XMLStreamException
*/
static void exportConstructParameters(XMLStreamWriter writer,
Object ob) throws XMLStreamException {
//Get the Construction Parameters
AdditionalConstructParameter acp = ob.getClass().getAnnotation(AdditionalConstructParameter.class);
if(acp != null) {
for(int i = 0; i < acp.parameterGetters().length; i++) {
writer.writeEmptyElement("ConstructParameter");
writer.writeAttribute("name", acp.parameterNames()[i]);
SimpleEntry<String, String> se = exportParamType(ob, acp.parameterGetters()[i]);
writer.writeAttribute("type", se.getKey());
writer.writeAttribute("value", se.getValue());
}
}
}
示例3: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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 (Equipment contains_Equipments : this.contains_Equipments){
try {
xmlsw.writeEmptyElement(CIMURI.CIMURI,"EquipmentContainer.Contains_Equipments");
xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
+ contains_Equipments.getId());
} catch (XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the reference to ");
errorMessage.append("EquipmentContainer ");
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;
}
示例4: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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;
}
示例5: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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 (TopologicalNode topologicalNode : this.topologicalNode){
try {
xmlsw.writeEmptyElement(CIMURI.CIMURI,"ConnectivityNodeContainer.TopologicalNode");
xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
+ topologicalNode.getId());
} catch (XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the reference to ");
errorMessage.append("ConnectivityNodeContainer ");
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;
}
示例6: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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 (SynchronousMachine initiallyUsedBySynchronousMachine : this.initiallyUsedBySynchronousMachine){
try {
xmlsw.writeEmptyElement(CIMURI.CIMURI,"ReactiveCapabilityCurve.InitiallyUsedBySynchronousMachine");
xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
+ initiallyUsedBySynchronousMachine.getId());
} catch (XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the reference to ");
errorMessage.append("ReactiveCapabilityCurve ");
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;
}
示例7: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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;
}
示例8: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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;
}
示例9: writeCurrentLimits
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
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();
}
}
}
示例10: handleMessage
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@SuppressWarnings("nls")
@Override
public void handleMessage(SoapMessage message) throws Fault
{
final UserState us = CurrentUser.getUserState();
XMLStreamWriterCallback obj = new XMLStreamWriterCallback()
{
@Override
public void write(XMLStreamWriter writer) throws Fault, XMLStreamException
{
writer.writeEmptyElement("equella");
writer.writeAttribute("session", us.getSessionID());
writer.writeAttribute("id", us.getUserBean().getUniqueID());
writer.writeAttribute("username", us.getUserBean().getUsername());
}
};
message.getHeaders().add(new Header(new QName("equella"), obj, new StaxDataBinding()));
}
示例11: exportMappings
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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+"");
}
}
示例12: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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 (idFossilFuels != null &&
!idFossilFuels.isEmpty()) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeEmptyElement(CIMURI.CIMURI,
"ThermalGeneratingUnit.FossilFuels");
xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
+ idFossilFuels);
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the resource attribute ");
errorMessage.append("FossilFuels");
errorMessage.append(" in class ");
errorMessage.append("ThermalGeneratingUnit ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
}
return;
}
示例13: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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 (idLoadResponse != null) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeEmptyElement(CIMURI.CIMURI,
"EnergyConsumer.LoadResponse");
xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
+ idLoadResponse);
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the resource attribute ");
errorMessage.append("LoadResponse");
errorMessage.append(" in class ");
errorMessage.append("EnergyConsumer ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
}
return;
}
示例14: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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;
}
示例15: writeClass
import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
* 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 (idDrivenBy_SynchronousMachine != null &&
!idDrivenBy_SynchronousMachine.isEmpty()) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeEmptyElement(CIMURI.CIMURI,
"HydroPump.DrivenBy_SynchronousMachine");
xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
+ idDrivenBy_SynchronousMachine);
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the resource attribute ");
errorMessage.append("DrivenBy_SynchronousMachine");
errorMessage.append(" in class ");
errorMessage.append("HydroPump ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
}
return;
}