com.google.ipc.invalidation.util.TextBuilder Java Examples

The following examples show how to use com.google.ipc.invalidation.util.TextBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Appends a description of the given internal {@code downcall} to the given {@code builder}. */
public static TextBuilder toCompactString(TextBuilder builder,
    InternalDowncall downcall) {
  if (downcall == null) {
    return builder;
  }
  builder.append(ProtocolIntents.INTERNAL_DOWNCALL_KEY).append("::");
  if (downcall.hasServerMessage()) {
    toCompactString(builder, downcall.getServerMessage());
  } else if (downcall.hasNetworkStatus()) {
    toCompactString(builder, downcall.getNetworkStatus());
  } else if (downcall.hasNetworkAddrChange()) {
    builder.append("newtworkAddrChange()");
  } else if (downcall.hasCreateClient()) {
    toCompactString(builder, downcall.getCreateClient());
  } else {
    builder.append(UNKNOWN_MESSAGE);
  }
  return builder;
}
 
Example #2
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Appends a description of the given client {@code downcall} to the given {@code builder}. */
public static TextBuilder toCompactString(TextBuilder builder,
    ClientDowncall downcall) {
  if (downcall == null) {
    return builder;
  }
  builder.append(ProtocolIntents.CLIENT_DOWNCALL_KEY).append("::");
  if (downcall.hasStart()) {
    builder.append("start()");
  } else if (downcall.hasStop()) {
    builder.append("stop()");
  } else if (downcall.hasAck()) {
    toCompactString(builder, downcall.getAck());
  } else if (downcall.hasRegistrations()) {
    toCompactString(builder, downcall.getRegistrations());
  } else {
    builder.append(UNKNOWN_MESSAGE);
  }
  return builder;
}
 
Example #3
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Appends a description of the given client {@code downcall} to the given {@code builder}. */
public static TextBuilder toCompactString(TextBuilder builder,
    ClientDowncall downcall) {
  if (downcall == null) {
    return builder;
  }
  builder.append(ProtocolIntents.CLIENT_DOWNCALL_KEY).append("::");
  if (downcall.hasStart()) {
    builder.append("start()");
  } else if (downcall.hasStop()) {
    builder.append("stop()");
  } else if (downcall.hasAck()) {
    toCompactString(builder, downcall.getAck());
  } else if (downcall.hasRegistrations()) {
    toCompactString(builder, downcall.getRegistrations());
  } else {
    builder.append(UNKNOWN_MESSAGE);
  }
  return builder;
}
 
Example #4
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Appends a description of the given {@code intent} to the given {@code builder}. If the intent
 * includes some recognized extras, formats the extra context as well.
 */
public static TextBuilder toCompactString(TextBuilder builder, Intent intent) {
  if (intent == null) {
    return builder;
  }
  builder.append("intent(");
  try {
    if (!tryParseExtra(builder, intent)) {
      builder.append(UNKNOWN_MESSAGE).append(", extras = ")
          .append(Joiner.on(", ").join(intent.getExtras().keySet()));
    }
  } catch (InvalidProtocolBufferException exception) {
    builder.append(ERROR_MESSAGE).append(" : ").append(exception);
  }
  return builder.append(")");
}
 
Example #5
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Appends a description of the given internal {@code downcall} to the given {@code builder}. */
public static TextBuilder toCompactString(TextBuilder builder,
    InternalDowncall downcall) {
  if (downcall == null) {
    return builder;
  }
  builder.append(ProtocolIntents.INTERNAL_DOWNCALL_KEY).append("::");
  if (downcall.hasServerMessage()) {
    toCompactString(builder, downcall.getServerMessage());
  } else if (downcall.hasNetworkStatus()) {
    toCompactString(builder, downcall.getNetworkStatus());
  } else if (downcall.hasNetworkAddrChange()) {
    builder.append("newtworkAddrChange()");
  } else if (downcall.hasCreateClient()) {
    toCompactString(builder, downcall.getCreateClient());
  } else {
    builder.append(UNKNOWN_MESSAGE);
  }
  return builder;
}
 
Example #6
Source File: ClientProtocol.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override public void toCompactString(TextBuilder builder) {
  builder.append("<ClientHeader:");
  builder.append(" protocol_version=").append(protocolVersion);
  if (hasClientToken()) {
    builder.append(" client_token=").append(clientToken);
  }
  if (registrationSummary != null) {
    builder.append(" registration_summary=").append(registrationSummary);
  }
  builder.append(" client_time_ms=").append(clientTimeMs);
  builder.append(" max_known_server_time_ms=").append(maxKnownServerTimeMs);
  if (hasMessageId()) {
    builder.append(" message_id=").append(messageId);
  }
  if (hasClientType()) {
    builder.append(" client_type=").append(clientType);
  }
  builder.append('>');
}
 
Example #7
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactStringForInvalidations(TextBuilder builder,
    final Collection<InvalidationP> invalidations) {
  if (invalidations == null) {
    return builder;
  }
  boolean first = true;
  for (InvalidationP invalidation : invalidations) {
    if (!first) {
      builder.append(", ");
    }
    toCompactString(builder, invalidation);
    first = false;
  }
  return builder;
}
 
Example #8
Source File: AndroidChannel.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override public void toCompactString(TextBuilder builder) {
  builder.append("<AndroidEndpointId:");
  if (hasC2DmRegistrationId()) {
    builder.append(" c2dm_registration_id=").append(c2DmRegistrationId);
  }
  if (hasClientKey()) {
    builder.append(" client_key=").append(clientKey);
  }
  if (hasSenderId()) {
    builder.append(" sender_id=").append(senderId);
  }
  if (channelVersion != null) {
    builder.append(" channel_version=").append(channelVersion);
  }
  if (hasPackageName()) {
    builder.append(" package_name=").append(packageName);
  }
  builder.append('>');
}
 
Example #9
Source File: JavaClient.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override public void toCompactString(TextBuilder builder) {
  builder.append("<ProtocolHandlerState:");
  if (hasMessageId()) {
    builder.append(" message_id=").append(messageId);
  }
  if (hasLastKnownServerTimeMs()) {
    builder.append(" last_known_server_time_ms=").append(lastKnownServerTimeMs);
  }
  if (hasNextMessageSendTimeMs()) {
    builder.append(" next_message_send_time_ms=").append(nextMessageSendTimeMs);
  }
  if (hasBatcherState()) {
    builder.append(" batcher_state=").append(batcherState);
  }
  builder.append('>');
}
 
Example #10
Source File: JavaClient.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override public void toCompactString(TextBuilder builder) {
  builder.append("<RecurringTaskState:");
  if (hasInitialDelayMs()) {
    builder.append(" initial_delay_ms=").append(initialDelayMs);
  }
  if (hasTimeoutDelayMs()) {
    builder.append(" timeout_delay_ms=").append(timeoutDelayMs);
  }
  if (hasScheduled()) {
    builder.append(" scheduled=").append(scheduled);
  }
  if (hasBackoffState()) {
    builder.append(" backoff_state=").append(backoffState);
  }
  builder.append('>');
}
 
Example #11
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    InfoMessage infoMessage) {
  if (infoMessage == null) {
    return builder;
  }
  builder.appendFormat("InfoMsg: Platform = %s, Is_summary_requested = %s, Perf counters: ",
      infoMessage.getClientVersion().getPlatform(),
      infoMessage.getServerRegistrationSummaryRequested());
  boolean first = true;
  for (PropertyRecord record : infoMessage.getPerformanceCounterList()) {
    if (!first) {
      builder.append(", ");
    }
    builder.appendFormat("%s = %d", record.getName(), record.getValue());
    first = false;
  }
  return builder;
}
 
Example #12
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Appends a description of the given {@code intent} to the given {@code builder}. If the intent
 * includes some recognized extras, formats the extra context as well.
 */
public static TextBuilder toCompactString(TextBuilder builder, Intent intent) {
  if (intent == null) {
    return builder;
  }
  builder.append("intent(");
  try {
    if (!tryParseExtra(builder, intent)) {
      builder.append(UNKNOWN_MESSAGE).append(", extras = ")
          .append(Joiner.on(", ").join(intent.getExtras().keySet()));
    }
  } catch (InvalidProtocolBufferException exception) {
    builder.append(ERROR_MESSAGE).append(" : ").append(exception);
  }
  return builder.append(")");
}
 
Example #13
Source File: AndroidService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override public void toCompactString(TextBuilder builder) {
  builder.append("<InternalDowncall:");
  builder.append(" version=").append(version);
  if (serverMessage != null) {
    builder.append(" server_message=").append(serverMessage);
  }
  if (networkStatus != null) {
    builder.append(" network_status=").append(networkStatus);
  }
  if (hasNetworkAddrChange()) {
    builder.append(" network_addr_change=").append(networkAddrChange);
  }
  if (createClient != null) {
    builder.append(" create_client=").append(createClient);
  }
  builder.append('>');
}
 
Example #14
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    InvalidationP invalidation) {
  if (invalidation == null) {
    return builder;
  }
  builder.append("(Inv: ");
  toCompactString(builder, invalidation.getObjectId());
  builder.append(", ");
  if (invalidation.getIsTrickleRestart()) {
    builder.append("<");
  }
  builder.append(invalidation.getVersion());
  if (invalidation.hasPayload()) {
    builder.append(", P:");
    toCompactString(builder, invalidation.getPayload());
  }
  builder.append(')');
  return builder;
}
 
Example #15
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    ErrorMessage errorMessage) {
  if (errorMessage == null) {
    return builder;
  }
  builder.appendFormat("ErrorMsg: %s, %s", errorMessage.getCode(), errorMessage.getDescription());
  return builder;
}
 
Example #16
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    InvalidationMessage invMessage) {
  if (invMessage == null) {
    return builder;
  }
  builder.appendFormat("InvMsg: ");
  toCompactStringForInvalidations(builder, invMessage.getInvalidationList());
  return builder;
}
 
Example #17
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns an object that lazily evaluates {@link #toCompactString} when {@link Object#toString}
 * is called.
 */
public static Object toLazyCompactString(final Intent intent) {
  return new Object() {
    @Override
    public String toString() {
      TextBuilder builder = new TextBuilder();
      AndroidStrings.toCompactString(builder, intent);
      return builder.toString();
    }
  };
}
 
Example #18
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static Object toLazyCompactString(final InfoMessage infoMessage) {
  return LazyString.toLazyCompactString(infoMessage, new Receiver<TextBuilder>() {
    @Override
    public void accept(TextBuilder builder) {
      toCompactString(builder, infoMessage);
    }
  });
}
 
Example #19
Source File: JavaClient.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override public void toCompactString(TextBuilder builder) {
  builder.append("<RegistrationManagerStateP:");
  builder.append(" registrations=[").append(registrations).append(']');
  if (lastKnownServerSummary != null) {
    builder.append(" last_known_server_summary=").append(lastKnownServerSummary);
  }
  builder.append(" pending_operations=[").append(pendingOperations).append(']');
  builder.append('>');
}
 
Example #20
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * If {@code printHighFrequencyMessages} is true, logs sub-messages that are exchanged at a high
 * frequency between the client and the registrar (if they are the only messages present),
 * e.g., invalidation message.
 */
public static TextBuilder toCompactString(TextBuilder builder,
    ServerToClientMessage msg, boolean printHighFrequencyMessages) {
  // Print the header and any sub-messages in the message.

  toCompactString(builder, msg.getHeader());
  builder.append(',');

  if (msg.hasTokenControlMessage()) {
    toCompactString(builder, msg.getTokenControlMessage());
    builder.append(',');
  }
  if (printHighFrequencyMessages && msg.hasInvalidationMessage()) {
    toCompactString(builder, msg.getInvalidationMessage());
    builder.append(',');
  }
  if (msg.hasErrorMessage()) {
    toCompactString(builder, msg.getErrorMessage());
    builder.append(',');
  }
  if (msg.hasRegistrationSyncRequestMessage()) {
    toCompactString(builder, msg.getRegistrationSyncRequestMessage());
    builder.append(',');
  }
  if (msg.hasRegistrationStatusMessage()) {
    toCompactString(builder, msg.getRegistrationStatusMessage());
    builder.append(',');
  }
  if (msg.hasInfoRequestMessage()) {
    toCompactString(builder, msg.getInfoRequestMessage());
    builder.append(',');
  }
  if (msg.hasConfigChangeMessage()) {
    toCompactString(builder, msg.getConfigChangeMessage());
    builder.append(',');
  }
  return builder;
}
 
Example #21
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Appends a description of the given {@code failure} upcall to the given {@code builder}. */
public static TextBuilder toCompactString(TextBuilder builder,
    RegistrationFailureUpcall failure) {
  if (failure == null) {
    return builder;
  }
  builder.append("registrationFailure(objectId = ");
  CommonProtoStrings2.toCompactString(builder, failure.getObjectId());
  return builder.append(", isTransient = ").append(failure.getTransient()).append(")");
}
 
Example #22
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    ConfigChangeMessage configChangeMessage) {
  if (configChangeMessage == null) {
    return builder;
  }
  builder.appendFormat("ConfigChangeMsg: %d", configChangeMessage.getNextMessageDelayMs());
  return builder;
}
 
Example #23
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Appends a description of the given {@code createClient} command to the given {@code builder}.
 */
public static TextBuilder toCompactString(TextBuilder builder,
    CreateClient createClient) {
  if (createClient == null) {
    return builder;
  }
  return builder.append("createClient(type = ").append(createClient.getClientType())
      .append(", name = ").append(createClient.getClientName()).append(", skipStartForTest = ")
      .append(createClient.getSkipStartForTest()).append(")");
}
 
Example #24
Source File: AndroidStrings.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Appends a description of the given {@code networkStatus} to the given {@code builder}. */
public static TextBuilder toCompactString(TextBuilder builder,
    NetworkStatus networkStatus) {
  if (networkStatus == null) {
    return builder;
  }
  return builder.append("networkStatus(isOnline = ").append(networkStatus.getIsOnline())
      .append(")");
}
 
Example #25
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static Object toLazyCompactStringForRegistrations(
    final Collection<RegistrationP> registrations) {
  return LazyString.toLazyCompactString(registrations, new Receiver<TextBuilder>() {
    @Override
    public void accept(TextBuilder builder) {
      toCompactStringForRegistrations(builder, registrations);
    }
  });
}
 
Example #26
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    InitializeMessage initializeMessage) {
  if (initializeMessage == null) {
    return builder;
  }
  builder.appendFormat("InitMsg: Client Type: %d, ", initializeMessage.getClientType());
  toCompactString(builder, initializeMessage.getApplicationClientId());
  return builder;
}
 
Example #27
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    InitializeMessage initializeMessage) {
  if (initializeMessage == null) {
    return builder;
  }
  builder.appendFormat("InitMsg: Client Type: %d, ", initializeMessage.getClientType());
  toCompactString(builder, initializeMessage.getApplicationClientId());
  return builder;
}
 
Example #28
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** See spec in implementation notes. */
public static TextBuilder toCompactString(TextBuilder builder,
    TokenControlMessage tokenControlMessage) {
  if (tokenControlMessage == null) {
    return builder;
  }
  builder.append("TokenMsg: ");
  toCompactString(builder, tokenControlMessage.getNewToken());
  return builder;
}
 
Example #29
Source File: CommonProtoStrings2.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static TextBuilder toCompactString(TextBuilder builder,
    ProtocolVersion protocolVersion) {
  if (protocolVersion == null) {
    return builder;
  }
  builder.appendFormat("%d.%d", protocolVersion.getVersion().getMajorVersion(),
      protocolVersion.getVersion().getMinorVersion());
  return builder;
}
 
Example #30
Source File: AndroidService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override public void toCompactString(TextBuilder builder) {
  builder.append("<RegistrationFailureUpcall:");
  builder.append(" object_id=").append(objectId);
  builder.append(" transient=").append(transient_);
  builder.append(" message=").append(message);
  builder.append('>');
}