mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
0ea2be9732
commit
8153411c15
3 changed files with 0 additions and 61 deletions
|
@ -14,7 +14,6 @@ import org.jruby.RubySymbol;
|
||||||
import org.logstash.ackedqueue.Queueable;
|
import org.logstash.ackedqueue.Queueable;
|
||||||
import org.logstash.bivalues.BiValues;
|
import org.logstash.bivalues.BiValues;
|
||||||
import org.logstash.bivalues.NullBiValue;
|
import org.logstash.bivalues.NullBiValue;
|
||||||
import org.logstash.bivalues.TimeBiValue;
|
|
||||||
import org.logstash.bivalues.TimestampBiValue;
|
import org.logstash.bivalues.TimestampBiValue;
|
||||||
import org.logstash.ext.JrubyTimestampExtLibrary;
|
import org.logstash.ext.JrubyTimestampExtLibrary;
|
||||||
|
|
||||||
|
@ -311,8 +310,6 @@ public final class Event implements Cloneable, Queueable {
|
||||||
return new Timestamp((String) o);
|
return new Timestamp((String) o);
|
||||||
} else if (o instanceof RubyString) {
|
} else if (o instanceof RubyString) {
|
||||||
return new Timestamp(o.toString());
|
return new Timestamp(o.toString());
|
||||||
} else if (o instanceof TimeBiValue) {
|
|
||||||
return new Timestamp(((TimeBiValue) o).javaValue());
|
|
||||||
} else if (o instanceof JrubyTimestampExtLibrary.RubyTimestamp) {
|
} else if (o instanceof JrubyTimestampExtLibrary.RubyTimestamp) {
|
||||||
return ((JrubyTimestampExtLibrary.RubyTimestamp) o).getTimestamp();
|
return ((JrubyTimestampExtLibrary.RubyTimestamp) o).getTimestamp();
|
||||||
} else if (o instanceof Timestamp) {
|
} else if (o instanceof Timestamp) {
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
package org.logstash.bivalues;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.jruby.Ruby;
|
|
||||||
import org.jruby.RubyTime;
|
|
||||||
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
|
|
||||||
|
|
||||||
public class TimeBiValue extends BiValue<RubyTime, DateTime> {
|
|
||||||
|
|
||||||
public TimeBiValue(RubyTime rubyValue) {
|
|
||||||
this.rubyValue = rubyValue;
|
|
||||||
javaValue = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeBiValue(DateTime javaValue) {
|
|
||||||
this.javaValue = javaValue;
|
|
||||||
rubyValue = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TimeBiValue() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addRuby(Ruby runtime) {
|
|
||||||
rubyValue = RubyTime.newTime(runtime, javaValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addJava() {
|
|
||||||
javaValue = rubyValue.getDateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when object is to be serialized on a stream to allow the object to substitute a proxy for itself.
|
|
||||||
private Object writeReplace() throws ObjectStreamException {
|
|
||||||
return newProxy(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,14 +6,12 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.jruby.RubyBignum;
|
import org.jruby.RubyBignum;
|
||||||
import org.jruby.RubyBoolean;
|
import org.jruby.RubyBoolean;
|
||||||
import org.jruby.RubyFixnum;
|
import org.jruby.RubyFixnum;
|
||||||
import org.jruby.RubyFloat;
|
import org.jruby.RubyFloat;
|
||||||
import org.jruby.RubyInteger;
|
import org.jruby.RubyInteger;
|
||||||
import org.jruby.RubySymbol;
|
import org.jruby.RubySymbol;
|
||||||
import org.jruby.RubyTime;
|
|
||||||
import org.jruby.ext.bigdecimal.RubyBigDecimal;
|
import org.jruby.ext.bigdecimal.RubyBigDecimal;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.logstash.TestBase;
|
import org.logstash.TestBase;
|
||||||
|
@ -131,25 +129,6 @@ public class BiValueTest extends TestBase {
|
||||||
assertEquals(ruby.getNil(), subject.rubyValue(ruby));
|
assertEquals(ruby.getNil(), subject.rubyValue(ruby));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTimeBiValueFromRuby() {
|
|
||||||
DateTime t = DateTime.now();
|
|
||||||
RubyTime now = RubyTime.newTime(ruby, t);
|
|
||||||
TimeBiValue subject = new TimeBiValue(now);
|
|
||||||
assertTrue(subject.hasRubyValue());
|
|
||||||
assertFalse(subject.hasJavaValue());
|
|
||||||
assertEquals(t, subject.javaValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTimeBiValueFromJava() {
|
|
||||||
DateTime t = DateTime.now();
|
|
||||||
TimeBiValue subject = new TimeBiValue(t);
|
|
||||||
assertFalse(subject.hasRubyValue());
|
|
||||||
assertTrue(subject.hasJavaValue());
|
|
||||||
assertEquals(RubyTime.newTime(ruby, t), subject.rubyValue(ruby));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBigIntegerBiValueFromRuby() {
|
public void testBigIntegerBiValueFromRuby() {
|
||||||
BigInteger s = BigInteger.valueOf(12345678L);
|
BigInteger s = BigInteger.valueOf(12345678L);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue