mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
b4e9161fd0
commit
07f9411345
1 changed files with 9 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.logstash;
|
package org.logstash;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -19,22 +20,19 @@ import org.logstash.bivalues.BiValue;
|
||||||
import org.logstash.bivalues.BiValues;
|
import org.logstash.bivalues.BiValues;
|
||||||
import org.logstash.ext.JrubyTimestampExtLibrary;
|
import org.logstash.ext.JrubyTimestampExtLibrary;
|
||||||
|
|
||||||
public class Valuefier {
|
public final class Valuefier {
|
||||||
private static final String PROXY_ERR_TEMPLATE = "Missing Valuefier handling for full class name=%s, simple name=%s, wrapped object=%s";
|
private static final String PROXY_ERR_TEMPLATE = "Missing Valuefier handling for full class name=%s, simple name=%s, wrapped object=%s";
|
||||||
private static final String ERR_TEMPLATE = "Missing Valuefier handling for full class name=%s, simple name=%s";
|
private static final String ERR_TEMPLATE = "Missing Valuefier handling for full class name=%s, simple name=%s";
|
||||||
|
|
||||||
private Valuefier(){}
|
private Valuefier(){}
|
||||||
|
|
||||||
private static Object convertJavaProxy(JavaProxy jp) {
|
private static Object convertJavaProxy(final JavaProxy jp) {
|
||||||
if(jp == null) {
|
final Object obj = JavaUtil.unwrapJavaObject(jp);
|
||||||
return BiValues.NULL_BI_VALUE;
|
|
||||||
}
|
|
||||||
Object obj = JavaUtil.unwrapJavaObject(jp);
|
|
||||||
if (obj instanceof IRubyObject[]) {
|
if (obj instanceof IRubyObject[]) {
|
||||||
return ConvertedList.newFromRubyArray((IRubyObject[]) obj);
|
return ConvertedList.newFromRubyArray((IRubyObject[]) obj);
|
||||||
}
|
}
|
||||||
if (obj instanceof List) {
|
if (obj instanceof List) {
|
||||||
return ConvertedList.newFromList((List<Object>) obj);
|
return ConvertedList.newFromList((Collection<?>) obj);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return BiValues.newBiValue(jp);
|
return BiValues.newBiValue(jp);
|
||||||
|
@ -44,16 +42,16 @@ public class Valuefier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object convertNonCollection(Object o) {
|
private static Object convertNonCollection(Object o) {
|
||||||
try {
|
try {
|
||||||
return o == null ? BiValues.NULL_BI_VALUE : BiValues.newBiValue(o);
|
return BiValues.newBiValue(o);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
final Class<?> cls = o.getClass();
|
final Class<?> cls = o.getClass();
|
||||||
throw new IllegalArgumentException(String.format(ERR_TEMPLATE, cls.getName(), cls.getSimpleName()), e);
|
throw new IllegalArgumentException(String.format(ERR_TEMPLATE, cls.getName(), cls.getSimpleName()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object convert(Object o) throws IllegalArgumentException {
|
public static Object convert(Object o) {
|
||||||
if (o instanceof RubyString) {
|
if (o instanceof RubyString) {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@ -100,6 +98,6 @@ public class Valuefier {
|
||||||
Timestamp ts = new Timestamp((DateTime) o);
|
Timestamp ts = new Timestamp((DateTime) o);
|
||||||
return convertNonCollection(ts);
|
return convertNonCollection(ts);
|
||||||
}
|
}
|
||||||
return convertNonCollection(o);
|
return o == null ? BiValues.NULL_BI_VALUE : convertNonCollection(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue