/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inr.numass.server;
import hep.dataforge.storage.api.StateLoader;
/**
*
* @author Alexander Nozik
*/
public class HandlerUtils {
public static String renderStates(StateLoader states) {
StringBuilder b = new StringBuilder();
b.append("
\n");
states.getValueStream().forEach(pair->{
String color;
switch (pair.getSecond().getType()) {
case NUMBER:
color = "blue";
break;
case BOOLEAN:
color = "red";
break;
case TIME:
color = "magenta";
break;
default:
color = "brown";
}
b.append(String.format("
%s : %s
%n",
pair.getFirst(), color, pair.getSecond().stringValue()));
});
b.append("
\n");
return b.toString();
}
public static void renderHTMLHeader(StringBuilder b) {
b.append("\n\n"
+ "\n"
+ "\n"
+ " \n"
+ " "
+ " Numass storage\n"
+ "\n"
+ " "
+ "\n");
}
public static void renderHTMLFooter(StringBuilder b) {
b.append("\n"
+ "");
}
public static void renderHeader(StringBuilder b, String header, int level) {
b.append(String.format("%s%n", level, header, level));
}
}