|
@@ -1,5 +1,7 @@
|
|
|
package net.ranides.assira.reflection.walker;
|
|
package net.ranides.assira.reflection.walker;
|
|
|
|
|
|
|
|
|
|
+import net.ranides.assira.collection.arrays.ArrayUtils;
|
|
|
|
|
+import net.ranides.assira.collection.arrays.NativeArray;
|
|
|
import net.ranides.assira.reflection.IClass;
|
|
import net.ranides.assira.reflection.IClass;
|
|
|
import net.ranides.assira.reflection.walker.WalkerContexts.ArrayContext;
|
|
import net.ranides.assira.reflection.walker.WalkerContexts.ArrayContext;
|
|
|
import net.ranides.assira.reflection.walker.WalkerContexts.ObjectContext;
|
|
import net.ranides.assira.reflection.walker.WalkerContexts.ObjectContext;
|
|
@@ -9,10 +11,7 @@ import net.ranides.assira.text.FormatHex;
|
|
|
|
|
|
|
|
import javax.xml.datatype.XMLGregorianCalendar;
|
|
import javax.xml.datatype.XMLGregorianCalendar;
|
|
|
import java.time.temporal.Temporal;
|
|
import java.time.temporal.Temporal;
|
|
|
-import java.util.Collection;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
public class WalkerRules {
|
|
public class WalkerRules {
|
|
|
|
|
|
|
@@ -28,19 +27,19 @@ public class WalkerRules {
|
|
|
.match(ObjectContext::isNull)
|
|
.match(ObjectContext::isNull)
|
|
|
.term("{PATH} {typeName} = <null>")
|
|
.term("{PATH} {typeName} = <null>")
|
|
|
.rule()
|
|
.rule()
|
|
|
- .match(String.class)
|
|
|
|
|
- .term("{PATH} {actual.shortname} = '{value}'")
|
|
|
|
|
|
|
+ .match(CharSequence.class)
|
|
|
|
|
+ .term("{PATH} {actual.shortName} = '{value}'")
|
|
|
.rule()
|
|
.rule()
|
|
|
.match(byte[].class)
|
|
.match(byte[].class)
|
|
|
.format(ctx -> FormatHex.format(ctx.value()))
|
|
.format(ctx -> FormatHex.format(ctx.value()))
|
|
|
- .term("{PATH} {actual.shortname} = '{value}'")
|
|
|
|
|
|
|
+ .term("{PATH} {actual.shortName} = '{value}'")
|
|
|
.rule()
|
|
.rule()
|
|
|
.match(char[].class)
|
|
.match(char[].class)
|
|
|
.format(ctx -> String.valueOf(ctx.value()))
|
|
.format(ctx -> String.valueOf(ctx.value()))
|
|
|
- .term("{PATH} {actual.shortname} = '{value}'")
|
|
|
|
|
|
|
+ .term("{PATH} {actual.shortName} = '{value}'")
|
|
|
.rule()
|
|
.rule()
|
|
|
.match(ArrayContext.class::isInstance)
|
|
.match(ArrayContext.class::isInstance)
|
|
|
- .hint("{PATH} {actual.shortname}.size = {size}")
|
|
|
|
|
|
|
+ .hint("{PATH} {actual.shortName}.size = {size}")
|
|
|
.rule()
|
|
.rule()
|
|
|
.match(List.class)
|
|
.match(List.class)
|
|
|
.match(Collection.class)
|
|
.match(Collection.class)
|
|
@@ -53,10 +52,10 @@ public class WalkerRules {
|
|
|
.match(Temporal.class)
|
|
.match(Temporal.class)
|
|
|
.match(Number.class)
|
|
.match(Number.class)
|
|
|
.match(ObjectContext::isPrimitive)
|
|
.match(ObjectContext::isPrimitive)
|
|
|
- .term("{PATH} {actual.shortname} = {value}")
|
|
|
|
|
|
|
+ .term("{PATH} {actual.shortName} = {value}")
|
|
|
.rule()
|
|
.rule()
|
|
|
.match(Object.class)
|
|
.match(Object.class)
|
|
|
- .hint("{PATH} {actual.shortname} = {value}")
|
|
|
|
|
|
|
+ .hint("{PATH} {actual.shortName} = {value}")
|
|
|
.prepare();
|
|
.prepare();
|
|
|
|
|
|
|
|
public static final CollectRules<WalkerEntry> COLLECT = new CollectRules.Builder<WalkerEntry>()
|
|
public static final CollectRules<WalkerEntry> COLLECT = new CollectRules.Builder<WalkerEntry>()
|
|
@@ -70,7 +69,13 @@ public class WalkerRules {
|
|
|
.match(ObjectContext::isNull)
|
|
.match(ObjectContext::isNull)
|
|
|
.term(WalkerEntry::new)
|
|
.term(WalkerEntry::new)
|
|
|
.rule()
|
|
.rule()
|
|
|
- .match(String.class)
|
|
|
|
|
|
|
+ .match(byte[].class)
|
|
|
|
|
+ .term(WalkerEntry::new)
|
|
|
|
|
+ .rule()
|
|
|
|
|
+ .match(char[].class)
|
|
|
|
|
+ .term(WalkerEntry::new)
|
|
|
|
|
+ .rule()
|
|
|
|
|
+ .match(CharSequence.class)
|
|
|
.match(java.util.Date.class)
|
|
.match(java.util.Date.class)
|
|
|
.match(java.sql.Date.class)
|
|
.match(java.sql.Date.class)
|
|
|
.match(XMLGregorianCalendar.class)
|
|
.match(XMLGregorianCalendar.class)
|
|
@@ -145,6 +150,12 @@ public class WalkerRules {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String toString() {
|
|
public String toString() {
|
|
|
|
|
+ if(value instanceof char[]) {
|
|
|
|
|
+ return "{" + path + "=" + String.valueOf((char[])value) + "}";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(value!=null && value.getClass().isArray()) {
|
|
|
|
|
+ return "{" + path + "=<array>}";
|
|
|
|
|
+ }
|
|
|
return "{" + path + "=" + value + "}";
|
|
return "{" + path + "=" + value + "}";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|