23 package com.realtime.crossfire.jxclient.metaserver;
25 import java.util.regex.Pattern;
26 import org.jetbrains.annotations.NotNull;
27 import org.jetbrains.annotations.Nullable;
116 public MetaserverEntry(
final int updateSeconds, @NotNull
final String
hostname,
final int players, @NotNull
final String
version, @NotNull
final String
comment,
final long bytesIn,
final long bytesOut,
final int uptimeSeconds, @NotNull
final String
archBase, @NotNull
final String
mapBase, @NotNull
final String
codeBase) {
241 return hostname.compareTo(o.hostname);
250 public boolean equals(@Nullable
final Object obj) {
254 if (obj.getClass() != getClass()) {
285 final StringBuilder sb =
new StringBuilder();
286 final char[] formatChars =
format.toCharArray();
288 while (i < formatChars.length) {
289 final char ch = formatChars[i++];
290 if (ch !=
'%' || i >= formatChars.length) {
293 switch (formatChars[i++]) {
348 sb.append(formatChars[i-1]);
353 return sb.toString();
362 private static String
breakLines(@NotNull
final String text) {
363 final StringBuilder sb =
new StringBuilder();
364 for (
final String line0 : text.split(
"\n")) {
365 final String line = line0.trim();
368 while (line.length() > index+80) {
369 int nextIndex = line.lastIndexOf(
' ', index+80);
370 if (nextIndex == -1 || nextIndex < index) {
371 nextIndex = line.indexOf(
' ', index+80);
372 if (nextIndex == -1 || nextIndex < index) {
373 nextIndex = line.length();
375 if (nextIndex > index+140) {
376 nextIndex = index+140;
379 if (sb.length() > 0) {
382 sb.append(line, index, nextIndex);
385 while (index < line.length() && line.charAt(index) ==
' ') {
389 if (sb.length() > 0) {
392 sb.append(line, index, line.length());
394 return sb.toString();