List of usage examples for io.netty.buffer ByteBufUtil writeUtf8
public static int writeUtf8(ByteBuf buf, CharSequence seq)
From source file:org.opendaylight.ocpjava.protocol.impl.serialization.factories.HealthCheckInputFactory.java
License:Open Source License
@Override public void serialize(HealthCheckInput message, ByteBuf outBuffer) { LOG.debug("HealthCheckInputFactory - message = {}", message.toString()); StringBuilder seq = new StringBuilder(""); //Generate from DTO to XML string seq.append("<msg xmlns="); seq.append("\"http://uri.etsi.org/ori/002-2/v4.1.1\">"); seq.append("<header>"); seq.append("<msgType>REQ</msgType>"); seq.append("<msgUID>"); seq.append(message.getXid().toString()); seq.append("</msgUID>"); seq.append("</header>"); seq.append("<body>"); seq.append("<healthCheckReq>"); seq.append("<tcpLinkMonTimeout>"); seq.append(message.getTcpLinkMonTimeout().getValue().toString()); seq.append("</tcpLinkMonTimeout>"); seq.append("</healthCheckReq>"); seq.append("</body>"); seq.append("</msg>"); LOG.debug("HealthCheckInputFactory - composed xml-string = {}", seq); //write Xml string to ByteBuf by ByteBufUtil of netty-buffer ByteBufUtil.writeUtf8(outBuffer, seq); }
From source file:org.opendaylight.ocpjava.protocol.impl.serialization.factories.HelloInputFactory.java
License:Open Source License
@Override public void serialize(HelloInput message, ByteBuf outBuffer) { LOG.debug("HelloInputFactory - message = {}", message.toString()); StringBuilder seq = new StringBuilder(""); //Generate from DTO to XML string seq.append("<msg xmlns="); seq.append("\"http://uri.etsi.org/ori/002-2/v4.1.1\">"); seq.append("<header>"); seq.append("<msgType>ACK</msgType>"); seq.append("<msgUID>"); seq.append(message.getXid());//from w w w .ja v a 2 s .c o m seq.append("</msgUID>"); seq.append("</header>"); seq.append("<body>"); seq.append("<helloAck>"); seq.append("<result>"); seq.append(message.getResult().toString()); seq.append("</result>"); seq.append("</helloAck>"); seq.append("</body>"); seq.append("</msg>"); LOG.debug("HelloInputFactory - composed xml-string = {}", seq); ByteBufUtil.writeUtf8(outBuffer, seq); }
From source file:org.opendaylight.ocpjava.protocol.impl.serialization.factories.ModifyParamInputFactory.java
License:Open Source License
@Override public void serialize(ModifyParamInput message, ByteBuf outBuffer) { LOG.debug("ModifyParamInputFactory - message = {}", message.toString()); StringBuilder seq = new StringBuilder(""); //Generate from DTO to XML string seq.append("<msg xmlns="); seq.append("\"http://uri.etsi.org/ori/002-2/v4.1.1\">"); seq.append("<header>"); seq.append("<msgType>REQ</msgType>"); seq.append("<msgUID>"); seq.append(message.getXid().toString()); seq.append("</msgUID>"); seq.append("</header>"); seq.append("<body>"); seq.append("<"); seq.append(MESSAGE_TYPE);// w ww .ja va 2 s.c o m seq.append(">"); //Retrieve single object Id seq.append("<obj objID=\""); seq.append(message.getObjId().getValue().toString()); seq.append("\">"); //Retrieve name and result of params for (Param currParam : message.getParam()) { seq.append("<param name=\""); seq.append(currParam.getName()); seq.append("\">"); seq.append(currParam.getValue()); seq.append("</param>"); } seq.append("</obj>"); seq.append("</"); seq.append(MESSAGE_TYPE); seq.append(">"); seq.append("</body>"); seq.append("</msg>"); LOG.debug("ModifyParamInputFactory - composed xml-string = {}", seq); ByteBufUtil.writeUtf8(outBuffer, seq); }
From source file:org.opendaylight.ocpjava.protocol.impl.serialization.factories.ModifyStateInputFactory.java
License:Open Source License
@Override public void serialize(ModifyStateInput message, ByteBuf outBuffer) { LOG.debug("ModifyStateInputFactory - message = {}", message.toString()); StringBuilder seq = new StringBuilder(""); //Generate from DTO to XML string seq.append("<msg xmlns="); seq.append("\"http://uri.etsi.org/ori/002-2/v4.1.1\">"); seq.append("<header>"); seq.append("<msgType>REQ</msgType>"); seq.append("<msgUID>"); seq.append(message.getXid().toString()); seq.append("</msgUID>"); seq.append("</header>"); seq.append("<body>"); seq.append("<"); seq.append(MESSAGE_TYPE);//from w w w.j av a 2s . co m seq.append(">"); //Retrieve single object Id seq.append("<obj objID=\""); seq.append(message.getObjId().getValue().toString()); seq.append("\">"); //Retrieve single stateType seq.append("<state type=\""); seq.append(message.getStateType().toString()); seq.append("\">"); //Retrieve single stateValue //To fix YANG ENUM translation to Java code, it will remove the underline character if (message.getStateValue().toString().equals("PREOPERATIONAL")) { seq.append("PRE_OPERATIONAL"); } else if (message.getStateValue().toString().equals("NOTOPERATIONAL")) { seq.append("NOT_OPERATIONAL"); } else { seq.append(message.getStateValue()); } seq.append("</state>"); seq.append("</obj>"); seq.append("</"); seq.append(MESSAGE_TYPE); seq.append(">"); seq.append("</body>"); seq.append("</msg>"); LOG.debug("ModifyStateInputFactory - composed xml-string = {}", seq); ByteBufUtil.writeUtf8(outBuffer, seq); }
From source file:org.opendaylight.ocpjava.protocol.impl.serialization.factories.ReResetInputFactory.java
License:Open Source License
@Override public void serialize(ReResetInput message, ByteBuf outBuffer) { LOG.debug("ReResetInputFactory - message = {}", message.toString()); StringBuilder seq = new StringBuilder(""); //Generate from DTO to XML string seq.append("<msg xmlns="); seq.append("\"http://uri.etsi.org/ori/002-2/v4.1.1\">"); seq.append("<header>"); seq.append("<msgType>REQ</msgType>"); seq.append("<msgUID>"); seq.append(message.getXid().toString()); seq.append("</msgUID>"); seq.append("</header>"); seq.append("<body>"); seq.append("<resetReq/>"); seq.append("</body>"); seq.append("</msg>"); LOG.debug("ReResetInputFactory - composed xml-string = {}", seq); //write Xml string to ByteBuf by ByteBufUtil of netty-buffer ByteBufUtil.writeUtf8(outBuffer, seq); }
From source file:org.opendaylight.ocpjava.protocol.impl.serialization.factories.SetTimeInputFactory.java
License:Open Source License
@Override public void serialize(SetTimeInput message, ByteBuf outBuffer) { LOG.debug("SetTimeInputFactory - message = {}", message.toString()); StringBuilder seq = new StringBuilder(""); //Generate from DTO to XML string seq.append("<msg xmlns="); seq.append("\"http://uri.etsi.org/ori/002-2/v4.1.1\">"); seq.append("<header>"); seq.append("<msgType>REQ</msgType>"); seq.append("<msgUID>"); seq.append(message.getXid().toString()); seq.append("</msgUID>"); seq.append("</header>"); seq.append("<body>"); seq.append("<setTimeReq>"); seq.append("<newTime>"); seq.append(message.getNewTime().getValue().toString()); seq.append("</newTime>"); seq.append("</setTimeReq>"); seq.append("</body>"); seq.append("</msg>"); LOG.debug("SetTimeInputFactory - composed xml-string = {}", seq); //write Xml string to ByteBuf by ByteBufUtil of netty-buffer ByteBufUtil.writeUtf8(outBuffer, seq); }