Skip to content

Commit 8dbccfd

Browse files
committed
Added INTVAR deserializer
1 parent 49d7820 commit 8dbccfd

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2015 Stanley Shyiko
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.github.shyiko.mysql.binlog.event;
17+
18+
/**
19+
* @author <a href="mailto:stanley.shyiko@gmail.com">Stanley Shyiko</a>
20+
*/
21+
public class IntVarEventData implements EventData {
22+
23+
/**
24+
* Type indicating whether the value is meant to be used for the LAST_INSERT_ID() invocation (should be equal 1) or
25+
* AUTO_INCREMENT column (should be equal 2).
26+
*/
27+
private int type;
28+
private long value;
29+
30+
public int getType() {
31+
return type;
32+
}
33+
34+
public void setType(int type) {
35+
this.type = type;
36+
}
37+
38+
public long getValue() {
39+
return value;
40+
}
41+
42+
public void setValue(long value) {
43+
this.value = value;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
final StringBuilder sb = new StringBuilder();
49+
sb.append("IntVarEventData");
50+
sb.append("{type=").append(type);
51+
sb.append(", value=").append(value);
52+
sb.append('}');
53+
return sb.toString();
54+
}
55+
56+
}

src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/EventDeserializer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ private void registerDefaultEventDataDeserializers() {
8484
new FormatDescriptionEventDataDeserializer());
8585
eventDataDeserializers.put(EventType.ROTATE,
8686
new RotateEventDataDeserializer());
87+
eventDataDeserializers.put(EventType.INTVAR,
88+
new IntVarEventDataDeserializer());
8789
eventDataDeserializers.put(EventType.QUERY,
8890
new QueryEventDataDeserializer());
8991
eventDataDeserializers.put(EventType.TABLE_MAP,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2015 Stanley Shyiko
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.github.shyiko.mysql.binlog.event.deserialization;
17+
18+
import com.github.shyiko.mysql.binlog.event.IntVarEventData;
19+
import com.github.shyiko.mysql.binlog.io.ByteArrayInputStream;
20+
21+
import java.io.IOException;
22+
23+
/**
24+
* @author <a href="mailto:stanley.shyiko@gmail.com">Stanley Shyiko</a>
25+
*/
26+
public class IntVarEventDataDeserializer implements EventDataDeserializer<IntVarEventData> {
27+
28+
@Override
29+
public IntVarEventData deserialize(ByteArrayInputStream inputStream) throws IOException {
30+
IntVarEventData event = new IntVarEventData();
31+
event.setType(inputStream.readInteger(1));
32+
event.setValue(inputStream.readLong(8));
33+
return event;
34+
}
35+
}

0 commit comments

Comments
 (0)