コード例 #1
0
  public void initializeFrom(Element element) throws DocumentSerializationException {
    state = null;

    for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) {
      Element childElement = (TextElement) e.nextElement();
      String tagName = (String) childElement.getKey();

      if (tagName.equals("peerID")) {
        String peerIDText = DocumentSerializableUtilities.getString(childElement);

        peerID = MetricUtilities.getPeerIdFromString(peerIDText);
      } else if (tagName.equals("state")) {
        state = DocumentSerializableUtilities.getString(childElement);
      } else if (tagName.equals("transitionTime")) {
        transitionTime = DocumentSerializableUtilities.getLong(childElement);
      } else if (tagName.equals("lastLeaseRenewalTime")) {
        lastLeaseRenewalTime = DocumentSerializableUtilities.getLong(childElement);
      } else if (tagName.equals("lease")) {
        lease = DocumentSerializableUtilities.getLong(childElement);
      } else if (tagName.equals("numConnects")) {
        numConnects = DocumentSerializableUtilities.getInt(childElement);
      } else if (tagName.equals("numLeaseRenewals")) {
        numLeaseRenewals = DocumentSerializableUtilities.getInt(childElement);
      } else if (tagName.equals("numDisconnects")) {
        numDisconnects = DocumentSerializableUtilities.getInt(childElement);
      } else if (tagName.equals("numConnectionsRefused")) {
        numConnectionsRefused = DocumentSerializableUtilities.getInt(childElement);
      } else if (tagName.equals("numErrorsAddingClient")) {
        numErrorsAddingClient = DocumentSerializableUtilities.getInt(childElement);
      } else if (tagName.equals("numUnableToRespondToConnectRequest")) {
        numUnableToRespondToConnectRequest = DocumentSerializableUtilities.getInt(childElement);
      } else if (tagName.equals("totalTimeConnected")) {
        totalTimeConnected = DocumentSerializableUtilities.getLong(childElement);
      }
    }
  }
コード例 #2
0
 public void serializeTo(Element element) throws DocumentSerializationException {
   if (peerID != null) {
     DocumentSerializableUtilities.addString(element, "peerID", peerID.toString());
   }
   if (state != null) {
     DocumentSerializableUtilities.addString(element, "state", state);
   }
   if (transitionTime != 0) {
     DocumentSerializableUtilities.addLong(element, "transitionTime", transitionTime);
   }
   if (lastLeaseRenewalTime != 0) {
     DocumentSerializableUtilities.addLong(element, "lastLeaseRenewalTime", lastLeaseRenewalTime);
   }
   if (lease != 0) {
     DocumentSerializableUtilities.addLong(element, "lease", lease);
   }
   if (numConnects != 0) {
     DocumentSerializableUtilities.addInt(element, "numConnects", numConnects);
   }
   if (numLeaseRenewals != 0) {
     DocumentSerializableUtilities.addInt(element, "numLeaseRenewals", numLeaseRenewals);
   }
   if (numDisconnects != 0) {
     DocumentSerializableUtilities.addInt(element, "numDisconnects", numDisconnects);
   }
   if (numConnectionsRefused != 0) {
     DocumentSerializableUtilities.addInt(element, "numConnectionsRefused", numConnectionsRefused);
   }
   if (numErrorsAddingClient != 0) {
     DocumentSerializableUtilities.addInt(element, "numErrorsAddingClient", numErrorsAddingClient);
   }
   if (numUnableToRespondToConnectRequest != 0) {
     DocumentSerializableUtilities.addInt(
         element, "numUnableToRespondToConnectRequest", numUnableToRespondToConnectRequest);
   }
   if (totalTimeConnected != 0) {
     DocumentSerializableUtilities.addLong(element, "totalTimeConnected", totalTimeConnected);
   }
 }