Warning: session_start(): open(/var/lib/php/sessions/sess_ve6ih5hjrec22s14dg4qada0dm, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sbool structure_showTiming, structure_checkTokenCount;
sS structure(O o) {
ret structure(o, new structure_Data);
}
sS structure(O o, structure_Data d) {
new StringWriter sw;
d.out = new PrintWriter(sw);
structure_go(o, d);
S s = str(sw);
if (structure_checkTokenCount) {
print("token count=" + d.n);
assertEquals("token count", l(javaTokC(s)), d.n);
}
ret s;
}
svoid structure_go(O o, structure_Data d) {
structure_1(o, d);
while (nempty(d.stack))
popLast(d.stack).run();
}
svoid structureToPrintWriter(O o, PrintWriter out, structure_Data d default new) {
d.out = out;
structure_go(o, d);
}
// leave to false, unless unstructure() breaks
static boolean structure_allowShortening = false;
// info on how to serialize objects of a certain class
sclass structure_ClassInfo {
Class c;
S shortName;
L fields;
Method customSerializer;
IVF1 serializeObject; // can be set by caller of structure function
bool special; // various special classes
bool nullInstances; // serialize all instances as null (e.g. lambdas/anonymous classes)
bool javafy; // always convert to "j ..."
O emptyInstance; // to grab default field values from
toString {
ret commaCombine(
"Class " + className(c),
stringIf(+special),
stringIf(+customSerializer != null),
stringIf(+javafy),
stringIf(+nullInstances),
);
}
void nullInstances(bool b) {
this.nullInstances = b;
if (b) set special;
}
void javafy(bool b) {
this.javafy = b;
if (b) set special;
}
// overridable - return true if you wrote the object
bool handle(A o) { false; }
}
sclass structure_Data {
PrintWriter out;
int stringSizeLimit;
int shareStringsLongerThan = 20;
bool noStringSharing;
bool storeBaseClasses;
bool honorFieldOrder = true;
S mcDollar = actualMCDollar();
settable bool warnIfUnpersistable = true;
settable bool stackTraceIfUnpersistable = true;
// skip a field if it has the default value defined in the class
// -slower, and may cause issues with schema evolution
// -OTOH, it can serialize null values for a field with default non-null value
settable bool skipDefaultValues;
structure_Data d() { this; }
swappable bool shouldIncludeField(Field f) { true; }
new IdentityHashMap seen;
//new BitSet refd;
new HashMap strings;
new HashSet concepts;
HashMap infoByClass = new HashMap;
// wrapper for _persistenceInfo field or _persistenceInfo method
// by class (taking the object instance)
new HashMap> persistenceInfo;
int n; // token count
new L stack;
// append single token
structure_Data append(S token) { out.print(token); ++n; ret this; }
structure_Data append(int i) { out.print(i); ++n; ret this; }
// append multiple tokens
structure_Data append(S token, int tokCount) { out.print(token); n += tokCount; ret this; }
// extend last token
structure_Data app(S token) { out.print(token); this; }
structure_Data app(int i) { out.print(i); this; }
structure_Data app(char c) { out.print(c); this; }
structure_ClassInfo infoForClass(Class c) {
structure_ClassInfo info = infoByClass.get(c);
if (info == null) info = newClass(c);
ret info;
}
S realShortName(S name) {
ret dropPrefix("main$",
dropPrefix("loadableUtils.utils$",
dropPrefix(mcDollar, name)));
}
// called when a new class is detected
// can be overridden by clients
structure_ClassInfo newClass(Class c) {
// special classes here!
var d = d();
bool isJavaXClass = isJavaXClassName(c.getName(), mcDollar);
printVars ifdef structure_debug("newClass", +c, +isJavaXClass);
if (c == S)
ret new structure_ClassInfo {
@Override bool handle(S o) {
S s = d.stringSizeLimit != 0 ? shorten((S) o, d.stringSizeLimit) : (S) o;
if (!d.noStringSharing) {
if (d.shareStringsLongerThan == Int.MAX_VALUE)
d.seen.put(o, d.n);
if (l(s) >= d.shareStringsLongerThan)
d.strings.put(s, d.n);
}
quoteToPrintWriter(s, d.out); d.n++;
true;
}
};
if (c == File)
ret new structure_ClassInfo {
@Override bool handle(File o) {
append("File ").append(quote(o.getPath()));
true;
}
};
if (!isJavaXClass) {
if (isSubClassOf(c, Set.class))
ret new structure_ClassInfo {
@Override bool handle(Set o) {
writeSet(o);
true;
}
};
if (isSubClassOf(c, Cl))
ret new structure_ClassInfo {
@Override bool handle(Cl o) {
writeCollection(o);
true;
}
};
if (isSubClassOf(c, Map))
ret new structure_ClassInfo