Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.XmlBuffer


   public String replace(NodeMasterInfo old, String xmlNew) {
      try {
         if (old == null || xmlNew == null) return "IllegalArgument";
        
         XmlBuffer sb = new XmlBuffer(xmlNew.length() + 128);
         sb.append("<clusternode id='").appendAttributeEscaped(getId()).append("'>");
         sb.append(xmlNew);
         sb.append("</clusternode>");
        
         ClusterNode clusterNodeDummy = new ClusterNode(this.fatherGlob, getNodeId(), this.sessionInfo);
         new NodeParser(this.fatherGlob, clusterNodeDummy, sb.toString());
         NodeMasterInfo newOne = clusterNodeDummy.getNodeMasterInfos()[0];
        
         synchronized (this.masterInfoMap) {
            old.shutdown(); // removes it from domainInfoMap
            addNodeMasterInfo(newOne);
View Full Code Here


   /**
    * Dump state of this object into a XML ASCII string.
    * @param extraOffset indenting of tags for nice output
    */
   public final String toXml(String extraOffset, Properties props) {
      XmlBuffer sb = new XmlBuffer(512);
      if (extraOffset == null) extraOffset = "";
      String offset = Constants.OFFSET + extraOffset;

      sb.append(offset).append("<clusternode id='").appendAttributeEscaped(getId()).append("'>");

      sb.append(getNodeInfo().toXml(extraOffset + Constants.INDENT, props));

      NodeMasterInfo[] infos = getNodeMasterInfos();
      for (int i=0; i<infos.length; i++) {
         NodeMasterInfo info = infos[i];
         sb.append(info.toXml(extraOffset + Constants.INDENT, false));
      }

      sb.append(getNodeStateInfo().toXml(extraOffset + Constants.INDENT));

      sb.append(offset).append("</clusternode>");

      return sb.toString();
   }
View Full Code Here

   public void setMeat(XBMeat meat) {
      this.meat = meat;
   }

   public String toXml(String offset) {
      XmlBuffer buf = new XmlBuffer(512);
      buf.append(offset).append("<xbref>\n");
      super.toXml(offset + "  ", buf);
      if (meatId != 0)
         buf.append(offset).append("  <meatId>").append(meatId).append("</meatId>\n");
      if (metaInfo != null)
         buf.append(offset).append("  <metaInfo>").appendEscaped(metaInfo).append("</metaInfo>\n");
      buf.append(offset).append("  <prio>").append(prio).append("</prio>\n");
      if (methodName != null)
         buf.append(offset).append("  <methodName>").append(methodName).append("</methodName>\n");
      if (meat != null)
         buf.append(meat.toXml(offset + "  "));
      buf.append(offset).append("</xbref>\n");
      return buf.toString();
   }
View Full Code Here

   public void setKey(String key) {
      this.key = key;
   }

   public String toXml(String offset) {
      XmlBuffer buf = new XmlBuffer(512);
      buf.append(offset).append("<xbmeat>\n");
      super.toXml(offset + "  ", buf);
      buf.append(offset).append("  <refCount>").append(refCount).append(
            "</refCount>\n");
      if (dataType != null)
         buf.append(offset).append("  <dataType>").appendEscaped(dataType).append(
               "</dataType>\n");
      if (qos != null)
         buf.append(offset).append("  <qos>").appendEscaped(qos).append("</qos>\n");
      // buf.append(offset).append("  <content>").append(content).append("</content>\n");
      if (key != null)
         buf.append(offset).append("  <key>").appendEscaped(key).append("</key>\n");
      buf.append(offset).append("</xbmeat>\n");
      return buf.toString();
   }
View Full Code Here

    * Only none default values are dumped for performance reasons
    * @param extraOffset indenting of tags for nice output
    * @return The xml representation
    */
   public final String toXml(String extraOffset, boolean forceAllAttributes) {
      XmlBuffer sb = new XmlBuffer(300);
      if (extraOffset == null) extraOffset = "";
      String offset = Constants.OFFSET + extraOffset;

      sb.append(offset).append("<master");
      if (forceAllAttributes || getStratum() > 0)
         sb.append(" stratum='").append(getStratum()).append("'");
      if (getRefId() != null)
         sb.append(" refId='").append(getRefId()).append("'");
      sb.append(" type='").appendAttributeEscaped(getType()).append("'");
      if (forceAllAttributes || !DEFAULT_version.equals(getVersion()))
          sb.append(" version='").append(getVersion()).append("'");
      if (forceAllAttributes || DEFAULT_acceptDefault != isAcceptDefault())
          sb.append(" acceptDefault='").append(isAcceptDefault()).append("'");
      if (forceAllAttributes || DEFAULT_acceptOtherDefault != isAcceptOtherDefault())
          sb.append(" acceptOtherDefault='").append(isAcceptOtherDefault()).append("'");
      if (forceAllAttributes || RouteInfo.DEFAULT_dirtyRead != isDirtyRead())
          sb.append(" dirtyRead='").append(isDirtyRead()).append("'");
      sb.append(">");

      QueryKeyData[] keyArr = getKeyMappings();
      for (int ii=0; ii<keyArr.length; ii++)
         sb.append(keyArr[ii].toXml(extraOffset+Constants.INDENT));

      AccessFilterQos[] filterArr = getAccessFilterArr();
      for (int ii=0; ii<filterArr.length; ii++)
         sb.append(filterArr[ii].toXml(extraOffset+Constants.INDENT));

      sb.append(offset).append("</master>");

      return sb.toString();
   }
View Full Code Here

    * Only none default values are dumped for performance reasons
    * @param extraOffset indenting of tags for nice output
    * @return The xml representation
    */
   public final String toXml(String extraOffset) {
      XmlBuffer sb = new XmlBuffer(1200);
      if (extraOffset == null) extraOffset = "";
      String offset = Constants.OFFSET + extraOffset;

      sb.append(offset).append("<").append(rootTag).append(" type='").appendAttributeEscaped(getType()).append("'");
      // For debugging only:
      //sb.append(" nodeId='").append(this.nodeId).append("'");
      //sb.append(" context='").append(this.context).append("'");
      //sb.append(" className='").append(this.className).append("'");
      //sb.append(" instanceName='").append(this.instanceName).append("'");
      //sb.append(" envPrefix='").append(this.envPrefix).append("'");
      if (this.version.isModified())
          sb.append(" version='").appendAttributeEscaped(getVersion()).append("'");
      if (this.bootstrapHostname.isModified())
          sb.append(" bootstrapHostname='").appendAttributeEscaped(getBootstrapHostname()).append("'");
      if (this.bootstrapPort.isModified())
          sb.append(" bootstrapPort='").append(getBootstrapPort()).append("'");
      if (this.sessionId.isModified())
          sb.append(" sessionId='").appendAttributeEscaped(getSecretSessionId()).append("'");
      if (this.pingInterval.isModified())
          sb.append(" pingInterval='").append(getPingInterval()).append("'");
      if (this.retries.isModified())
          sb.append(" retries='").append(getRetries()).append("'");
      if (this.delay.isModified())
          sb.append(" delay='").append(getDelay()).append("'");
      if (this.oneway.isModified())
          sb.append(" oneway='").append(oneway()).append("'");
      if (this.dispatcherActive.isModified())
          sb.append(" dispatcherActive='").append(isDispatcherActive()).append("'");
      if (this.useForSubjectQueue.isModified())
          sb.append(" useForSubjectQueue='").append(this.useForSubjectQueue.getValue()).append("'");
      if (this.dispatchPlugin.isModified())
         sb.append(" dispatchPlugin='").appendAttributeEscaped(this.dispatchPlugin.getValue()).append("'");
      if (this.stallOnPingTimeout.isModified())
         sb.append(" stallOnPingTimeout='").append(isStallOnPingTimeout()).append("'");
     
      sb.append(">");
      sb.append(offset).append(" ").append(getRawAddress());
      if (this.collectTime.isModified() || this.burstModeMaxEntries.isModified() || this.burstModeMaxBytes.isModified()) {
         sb.append(offset).append(" ").append("<burstMode");
         if (this.collectTime.isModified())
            sb.append(" collectTime='").append(getCollectTime()).append("'");
         if (this.burstModeMaxEntries.isModified())
            sb.append(" maxEntries='").append(getBurstModeMaxEntries()).append("'");
         if (this.burstModeMaxBytes.isModified())
            sb.append(" maxBytes='").append(getBurstModeMaxBytes()).append("'");
         sb.append("/>");
      }
      if (this.compressType.isModified())
         sb.append(offset).append(" ").append("<compress type='").appendAttributeEscaped(getCompressType()).append("' minSize='").append(getMinSize()).append("'/>");
      if (this.ptpAllowed.isModified()) {
         if (this.ptpAllowed.getValue()) {
            sb.append(offset).append(" ").append("<ptp/>");
         }
         else {
            sb.append(offset).append(" ").append("<ptp>").append(this.ptpAllowed.getValue()).append("</ptp>");
         }
      }
      if (this.pluginAttributes != null) {
         Iterator it = this.pluginAttributes.getClientPropertyMap().values().iterator();
         while (it.hasNext()) {
            Object obj = it.next();
            EncodableData cp = (EncodableData)obj;
            sb.append(cp.toXml(offset+" ", ClientProperty.ATTRIBUTE_TAG));
         }
      }
      sb.append(offset).append("</").append(rootTag).append(">");

      return sb.toString();
   }
View Full Code Here

    * <br>
    * @param extraOffset indenting of tags for nice output
    * @return The xml representation
    */
   public final String toXml(String extraOffset) {
      XmlBuffer sb = new XmlBuffer(256);
      if (extraOffset == null) extraOffset = "";
      String offset = Constants.OFFSET + extraOffset;

      checkConsistency();

      // open <queue ...
      sb.append(offset).append("<").append(getRootTagName());

      if (this.debug.isModified())
         sb.append(" debug='").append(getDebug()).append("'");

      sb.append(" relating='").appendAttributeEscaped(getRelating()).append("'");
      if (this.type.isModified())
         sb.append(" type='").appendAttributeEscaped(getType()).append("'");
      if (this.version.isModified())
         sb.append(" version='").appendAttributeEscaped(getVersion()).append("'");
      if (this.maxEntries.isModified())
         sb.append(" maxEntries='").append(getMaxEntries()).append("'");
      if (this.maxEntriesCache.isModified())
         sb.append(" maxEntriesCache='").append(getMaxEntriesCache()).append("'");
      if (this.maxBytes.isModified())
         sb.append(" maxBytes='").append(getMaxBytes()).append("'");
      if (this.maxBytesCache.isModified())
         sb.append(" maxBytesCache='").append(getMaxBytesCache()).append("'");

      /* Deactivated until implemented in queue framework
      if ((long)(DEFAULT_storeSwapLevelRatio*this.maxBytesCache.getValue()) != getStoreSwapLevel())
         sb.append(" storeSwapLevel='").append(getStoreSwapLevel()).append("'");
      if ((long)(DEFAULT_storeSwapBytesRatio*this.maxBytesCache.getValue()) != getStoreSwapBytes())
         sb.append(" storeSwapBytes='").append(getStoreSwapBytes()).append("'");
      if ((long)(DEFAULT_reloadSwapLevelRatio*this.maxBytesCache.getValue()) != getReloadSwapLevel())
         sb.append(" reloadSwapLevel='").append(getReloadSwapLevel()).append("'");
      if ((long)(DEFAULT_reloadSwapBytesRatio*this.maxBytesCache.getValue()) != getReloadSwapBytes())
         sb.append(" reloadSwapBytes='").append(getReloadSwapBytes()).append("'");
      */
      if (this.onOverflow.isModified())
         sb.append(" onOverflow='").appendAttributeEscaped(getOnOverflow()).append("'");
      if (this.onFailure.isModified())
         sb.append(" onFailure='").appendAttributeEscaped(getOnFailure()).append("'");

      if (addressArr.length > 0 && addressArr[0] != null) {
         sb.append(">");
         for (int ii=0; ii<addressArr.length; ii++) {
            AddressBase ad = addressArr[ii];
            sb.append(ad.toXml(extraOffset+Constants.INDENT));
         }
         sb.append(offset).append("</").append(getRootTagName()).append(">")// closing </queue>
      }
      else
         sb.append("/>");

      return sb.toString();
   }
View Full Code Here

    * <br>
    * @param extraOffset indenting of tags
    * @return XML state of SubscriptionInfo
    */
   public String toXml(String extraOffset) {
      XmlBuffer sb = new XmlBuffer(2048);
      if (extraOffset == null) extraOffset = "";
      String offset = Constants.OFFSET + extraOffset;

      sb.append(offset).append("<subscription id='").appendAttributeEscaped(getSubscriptionId()).append("'");
      SessionName sessionName = getSessionInfo().getSessionName();
      if (sessionName != null)
         sb.append(" sessionName='").appendAttributeEscaped(sessionName.toString()).append("'");
      if (topicHandler != null) {
         sb.append(" oid='").appendAttributeEscaped(topicHandler.getUniqueKey()).append("'");
      }
      if (querySub != null) {
         sb.append(" parent='").appendAttributeEscaped(querySub.getSubscriptionId()).append("'");
      }
      SubscriptionInfo[] childrenSubs = getChildrenSubscriptions();
      if (childrenSubs != null) {
         sb.append(" numChilds='").appendAttributeEscaped("" + childrenSubs.length).append("'");
      }
      sb.append(" creationTime='" + IsoDateParser.getUTCTimestamp(this.creationTime) + "'");
      sb.append(">");

      //sb.append(offset).append("<SubscriptionInfo id='").append(getSubscriptionId()).append("'>");
      //sb.append(offset + "   <keyData oid='" + (keyData==null ? "null" : keyData.getUniqueKey()) + "'/>");
      if (keyData != null)
         sb.append(keyData.toXml(extraOffset+Constants.INDENT));
      if (this.subscribeQos != null)
         sb.append(this.subscribeQos.toXml(extraOffset+Constants.INDENT));
      else
         sb.append(extraOffset+Constants.INDENT).append("<!-- subscribe qos is null ERROR -->");
      //sb.append(offset).append(" <topicHandler id='").append((topicHandler==null ? "null" : topicHandler.getUniqueKey())).append("'/>");
      //sb.append(offset).append(" <creationTime>").append(IsoDate...(this.creationTime)).append("</creationTime>");
      if (childrenSubs != null) {
         for (int ii=0; ii<childrenSubs.length; ii++) {
            sb.append(offset).append(" <child>").appendEscaped(childrenSubs[ii].getSubscriptionId()).append("</child>");
         }
      }
      sb.append(offset).append("</subscription>");
      return sb.toString();
   }
View Full Code Here

   public final String writeObject(StatusQosData statusQosData, String extraOffset, Properties props) {
      return writeObject_(statusQosData, extraOffset, props);
   }

   public static final String writeObject_(StatusQosData statusQosData, String extraOffset, Properties props) {
      XmlBuffer sb = new XmlBuffer(180);
      if (extraOffset == null) extraOffset = "";
      String offset = Constants.OFFSET + extraOffset;

      sb.append(offset).append("<qos>"); // <!-- SubscribeRetQos -->");
      if (!statusQosData.isOk() || statusQosData.hasStateInfo()) {
         sb.append(offset).append(" <state id='").append(statusQosData.getState());
         if (statusQosData.getStateInfo() != null)
            sb.append("' info='").appendAttributeEscaped(statusQosData.getStateInfo());
         sb.append("'/>");
      }
      if (statusQosData.getSubscriptionId() != null)
         sb.append(offset).append(" <").append(MethodName.SUBSCRIBE.getMethodName()).append(" id='").appendAttributeEscaped(statusQosData.getSubscriptionId()).append("'/>");
      if (statusQosData.getKeyOid() != null)
         sb.append(offset).append(" <key oid='").appendAttributeEscaped(statusQosData.getKeyOid()).append("'/>");

      if (statusQosData.getRcvTimestamp() != null)
         sb.append(statusQosData.getRcvTimestamp().toXml(extraOffset+Constants.INDENT, false));

      if (statusQosData.getMethod() == MethodName.ERASE) {
         sb.append(offset).append("<isErase/>");
      }
      else if (statusQosData.getMethod() == MethodName.PUBLISH) {
         sb.append(offset).append("<isPublish/>");
      }
      else if (statusQosData.getMethod() == MethodName.SUBSCRIBE) {
         sb.append(offset).append("<isSubscribe/>");
      }
      else if (statusQosData.getMethod() == MethodName.UNSUBSCRIBE) {
         sb.append(offset).append("<isUnSubscribe/>");
      }
      else if (statusQosData.getMethod() == MethodName.UPDATE) {
         sb.append(offset).append("<isUpdate/>");
      }
    
      sb.append(offset).append("</qos>");

      if (sb.length() < 16)
         return "<qos/>"// minimal footprint

      return sb.toString();
   }
View Full Code Here

    * <br>
    * @param extraOffset indenting of tags for nice output
    * @return internal state of the RequestBroker as a XML ASCII string
    */
   public final String writeObject(QueryKeyData queryKeyData, String extraOffset) {
      XmlBuffer sb = new XmlBuffer(256);
      if (extraOffset == null) extraOffset = "";
      String offset = Constants.OFFSET + extraOffset;

         sb.append(offset).append("<key");
      if (queryKeyData.getOid() != null)
         sb.append(" oid='").appendAttributeEscaped(queryKeyData.getOid()).append("'");
      if (queryKeyData.getContentMime() != null && !queryKeyData.getContentMime().equals(KeyData.CONTENTMIME_DEFAULT))
         sb.append(" contentMime='").appendAttributeEscaped(queryKeyData.getContentMime()).append("'");
      if (queryKeyData.getContentMimeExtended() != null && !queryKeyData.getContentMimeExtended().equals(KeyData.CONTENTMIMEEXTENDED_DEFAULT))
         sb.append(" contentMimeExtended='").appendAttributeEscaped(queryKeyData.getContentMimeExtended()).append("'");
      if (queryKeyData.getDomain() != null && queryKeyData.getDomain().length() > 0)
         sb.append(" domain='").appendAttributeEscaped(queryKeyData.getDomain()).append("'");
      if (queryKeyData.getQueryType() != null && !Constants.EXACT.equals(queryKeyData.getQueryType()))
         sb.append(" queryType='").append(queryKeyData.getQueryType()).append("'");

      boolean isClosed = false;
      if (queryKeyData.getQueryString() != null) {
         if (!isClosed) { sb.append(">"); isClosed=true; }
         sb.append(offset).append(Constants.INDENT).appendEscaped(queryKeyData.getQueryString());
      }
      AccessFilterQos[] list = queryKeyData.getAccessFilterArr();
      for (int ii=0; list != null && ii<list.length; ii++) {
         if (!isClosed) { sb.append(">"); isClosed=true; }
         sb.append(list[ii].toXml(extraOffset+Constants.INDENT));
      }

      if (!isClosed) {
         sb.append("/>");
      }
      else {
         sb.append(offset).append("</key>");
      }
      return sb.toString();
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.XmlBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.