Skip to content

Commit 7062a06

Browse files
polishing
1 parent 508f8e7 commit 7062a06

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

SerialX-core/src/main/java/org/ugp/serialx/converters/DataConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ default CharSequence toString(ParserRegistry myHomeRegistry, Object obj, Object.
2929
{
3030
try
3131
{
32-
return (CharSequence) toString(new StringBuilder().append(0), myHomeRegistry, obj, args);
32+
return (CharSequence) toString(new StringBuilder(), myHomeRegistry, obj, args);
3333
}
3434
catch (IOException e)
3535
{

SerialX-json/src/main/java/org/ugp/serialx/json/JsonSerializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public ParserRegistry getParsers()
200200
* @since 1.3.2
201201
*/
202202
@Override
203-
protected Appendable appandVar(Appendable source, ParserRegistry parsersToUse, Entry<String, ?> varToSerialize, int tabs, boolean isLast, Object... args) throws IOException
203+
protected Appendable appandVar(Appendable source, ParserRegistry parsersToUse, Entry<String, ?> varToSerialize, int tabs, boolean isLast, Object[] args) throws IOException
204204
{
205205
if (format != 0)
206206
source.append(multilpy('\t', tabs));
@@ -211,7 +211,7 @@ protected Appendable appandVar(Appendable source, ParserRegistry parsersToUse, E
211211
}
212212

213213
@Override
214-
protected Appendable appandVal(Appendable source, ParserRegistry parsersToUse, Object objToSerialize, int tabs, boolean isLast, Object... args) throws IOException
214+
protected Appendable appandVal(Appendable source, ParserRegistry parsersToUse, Object objToSerialize, int tabs, boolean isLast, Object[] args) throws IOException
215215
{
216216
if (format != 0)
217217
source.append(multilpy('\t', tabs));

SerialX-juss/src/main/java/org/ugp/serialx/juss/JussSerializer.java

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,21 @@ public <T> String Var(String name, T value, boolean isValue)
253253
*/
254254
public String StaticMember(Class<?> cls, String staticMethodName, Object... args)
255255
{
256-
StringBuilder sb = new StringBuilder();
257-
for (int i = 0, len = args.length; i < len; i++)
258-
sb.append(getParsers().toString(args[i], this, 0, 0, getProtocols(), getFormat())).append(i < len-1 ? " " : "");
259-
return Code(cls.getName() + "::" + staticMethodName + (args.length <= 0 ? "" : " ") + sb);
256+
StringBuilder sb = new StringBuilder(cls.getName()).append("::").append(staticMethodName);
257+
for (int i = 0, len = args.length; i < len; i++)
258+
{
259+
sb.append(' ');
260+
261+
try
262+
{
263+
getParsers().toString(sb, args[i], this, 0, 0, getProtocols(), getFormat());
264+
}
265+
catch (IOException e)
266+
{
267+
throw new RuntimeException(e); // No...
268+
}
269+
}
270+
return Code(sb);
260271
}
261272

262273
/**
@@ -316,7 +327,7 @@ else if (args[1] instanceof Integer)
316327
{
317328
for (Entry<String, ?> var : variables.entrySet()) //Vars
318329
{
319-
appandVar(source, reg.toString(var, args), var, tabs, i >= varLen-1 && valuesLen <= 0);
330+
appandVar(source, reg, var, tabs, i >= varLen-1 && valuesLen <= 0, args);
320331
if (!(var.getValue() instanceof Scope) || ((Scope) var.getValue()).isEmpty())
321332
GenerateComment(source, reg, var);
322333

@@ -328,7 +339,7 @@ else if (format != 0)
328339
{
329340
for (Entry<String, ?> var : variables.entrySet()) //Vars
330341
{
331-
appandVar(source, reg.toString(var, args), var, tabs, i >= varLen-1 && valuesLen <= 0);
342+
appandVar(source, reg, var, tabs, i >= varLen-1 && valuesLen <= 0, args);
332343

333344
if (++i < varLen || valuesLen > 0)
334345
source.append('\n');
@@ -338,7 +349,7 @@ else if (format != 0)
338349
{
339350
for (Entry<String, ?> var : variables.entrySet()) //Vars
340351
{
341-
appandVar(source, reg.toString(var, args), var, tabs, i++ >= varLen-1 && valuesLen <= 0);
352+
appandVar(source, reg, var, tabs, i++ >= varLen-1 && valuesLen <= 0, args);
342353
}
343354
}
344355
}
@@ -350,10 +361,8 @@ else if (format != 0)
350361
if (i != 0)
351362
source.append('\n');
352363

353-
Object obj = objs.get(i);
354-
CharSequence serialized = reg.toString(obj, args);
355-
356-
appandVal(source, serialized, obj, tabs, i == valuesLen-1);
364+
Object obj;
365+
appandVal(source, reg, obj = objs.get(i), tabs, i == valuesLen-1, args);
357366
if (!(obj instanceof Scope) || ((Scope) obj).isEmpty())
358367
GenerateComment(source, reg, obj);
359368
}
@@ -365,16 +374,14 @@ else if (format != 0)
365374
if (i != 0)
366375
source.append('\n');
367376

368-
Object obj;
369-
appandVal(source, reg.toString(obj = objs.get(i), args), obj, tabs, i == valuesLen-1);
377+
appandVal(source, reg, objs.get(i), tabs, i == valuesLen-1, args);
370378
}
371379
}
372380
else // No formating
373381
{
374382
for (i = 0; i < valuesLen; i++) //Values
375383
{
376-
Object obj;
377-
appandVal(source, reg.toString(obj = objs.get(i), args), obj, tabs, i == valuesLen-1);
384+
appandVal(source, reg, objs.get(i), tabs, i == valuesLen-1, args);
378385
}
379386
}
380387

@@ -386,31 +393,31 @@ else if (format != 0)
386393
}
387394

388395
/**
389-
* This should append serializedVar into source based on arguments, add separator and return source!
396+
* his should stringify and append ({@link ParserRegistry#toString(Appendable, Object, Object...)}) varToSerialize into source based on arguments, add separator and return source!
390397
*
391398
* @since 1.3.2
392399
*/
393-
protected Appendable appandVar(Appendable source, CharSequence serializedVar, Entry<String, ?> var, int tabs, boolean isLast) throws IOException
400+
protected Appendable appandVar(Appendable source, ParserRegistry parsersToUse, Entry<String, ?> varToSerialize, int tabs, boolean isLast, Object[] args) throws IOException
394401
{
395402
if (format != 0)
396403
source.append(multilpy('\t', tabs));
397-
source.append(serializedVar);
404+
source.append((CharSequence) parsersToUse.toString(new StringBuilder(), varToSerialize, args));
398405
if (isLast)
399406
return source;
400407
return source.append(';');
401408
}
402409

403410
/**
404-
* This should append serializedVal into source based on arguments, add separator and return source!
411+
* This should stringify and append ({@link ParserRegistry#toString(Appendable, Object, Object...)}) objToSerialize into source based on arguments, add separator and return source!
405412
*
406413
* @since 1.3.2
407414
*/
408-
protected Appendable appandVal(Appendable source, CharSequence serializedVal, Object value, int tabs, boolean isLast) throws IOException
415+
protected Appendable appandVal(Appendable source, ParserRegistry parsersToUse, Object objToSerialize, int tabs, boolean isLast, Object[] args) throws IOException
409416
{
410417
if (format != 0)
411418
source.append(multilpy('\t', tabs));
412-
source.append(serializedVal);
413-
if (isLast || serializedVal != null && indexOfNotInObj(serializedVal, "//") != -1)
419+
source.append((CharSequence) parsersToUse.toString(new StringBuilder(), objToSerialize, args));
420+
if (isLast /*|| serializedVal != null && indexOfNotInObj(serializedVal, "//") != -1*/)
414421
return source;
415422
return source.append(';');
416423
}

0 commit comments

Comments
 (0)