58 private static final int POOL_FIELD = 0x07;
59 private static final int POOL_SIGNATURE = 0x08;
60 private static final int POOL_NODE_SOURCE_POSITION = 0x09;
61 private static final int POOL_NODE = 0x0a;
62
63 private static final int PROPERTY_POOL = 0x00;
64 private static final int PROPERTY_INT = 0x01;
65 private static final int PROPERTY_LONG = 0x02;
66 private static final int PROPERTY_DOUBLE = 0x03;
67 private static final int PROPERTY_FLOAT = 0x04;
68 private static final int PROPERTY_TRUE = 0x05;
69 private static final int PROPERTY_FALSE = 0x06;
70 private static final int PROPERTY_ARRAY = 0x07;
71 private static final int PROPERTY_SUBGRAPH = 0x08;
72
73 private static final int KLASS = 0x00;
74 private static final int ENUM_KLASS = 0x01;
75
76 private static final byte[] MAGIC_BYTES = {'B', 'I', 'G', 'V'};
77
78 private final ConstantPool constantPool;
79 private final ByteBuffer buffer;
80 private final WritableByteChannel channel;
81 private final boolean embedded;
82 final int versionMajor;
83 final int versionMinor;
84 private boolean printing;
85
86 GraphProtocol(WritableByteChannel channel, int major, int minor, boolean embedded) throws IOException {
87 if (major > 6 || (major == 6 && minor > 0)) {
88 throw new IllegalArgumentException("Unrecognized version " + major + "." + minor);
89 }
90 this.versionMajor = major;
91 this.versionMinor = minor;
92 this.constantPool = new ConstantPool();
93 this.buffer = ByteBuffer.allocateDirect(256 * 1024);
94 this.channel = channel;
95 this.embedded = embedded;
96 if (!embedded) {
97 writeVersion();
98 flushEmbedded();
99 }
100 }
101
102 GraphProtocol(GraphProtocol<?, ?, ?, ?, ?, ?, ?, ?, ?, ?> parent) {
103 this.versionMajor = parent.versionMajor;
104 this.versionMinor = parent.versionMinor;
105 this.constantPool = parent.constantPool;
106 this.buffer = parent.buffer;
107 this.channel = parent.channel;
|
58 private static final int POOL_FIELD = 0x07;
59 private static final int POOL_SIGNATURE = 0x08;
60 private static final int POOL_NODE_SOURCE_POSITION = 0x09;
61 private static final int POOL_NODE = 0x0a;
62
63 private static final int PROPERTY_POOL = 0x00;
64 private static final int PROPERTY_INT = 0x01;
65 private static final int PROPERTY_LONG = 0x02;
66 private static final int PROPERTY_DOUBLE = 0x03;
67 private static final int PROPERTY_FLOAT = 0x04;
68 private static final int PROPERTY_TRUE = 0x05;
69 private static final int PROPERTY_FALSE = 0x06;
70 private static final int PROPERTY_ARRAY = 0x07;
71 private static final int PROPERTY_SUBGRAPH = 0x08;
72
73 private static final int KLASS = 0x00;
74 private static final int ENUM_KLASS = 0x01;
75
76 private static final byte[] MAGIC_BYTES = {'B', 'I', 'G', 'V'};
77
78 private static final int MAJOR_VERSION = 6;
79 private static final int MINOR_VERSION = 1;
80
81 private final ConstantPool constantPool;
82 private final ByteBuffer buffer;
83 private final WritableByteChannel channel;
84 private final boolean embedded;
85 final int versionMajor;
86 final int versionMinor;
87 private boolean printing;
88
89 GraphProtocol(WritableByteChannel channel, int major, int minor, boolean embedded) throws IOException {
90 if (major > MAJOR_VERSION || (major == MAJOR_VERSION && minor > MINOR_VERSION)) {
91 throw new IllegalArgumentException("Unrecognized version " + major + "." + minor);
92 }
93 this.versionMajor = major;
94 this.versionMinor = minor;
95 this.constantPool = new ConstantPool();
96 this.buffer = ByteBuffer.allocateDirect(256 * 1024);
97 this.channel = channel;
98 this.embedded = embedded;
99 if (!embedded) {
100 writeVersion();
101 flushEmbedded();
102 }
103 }
104
105 GraphProtocol(GraphProtocol<?, ?, ?, ?, ?, ?, ?, ?, ?, ?> parent) {
106 this.versionMajor = parent.versionMajor;
107 this.versionMinor = parent.versionMinor;
108 this.constantPool = parent.constantPool;
109 this.buffer = parent.buffer;
110 this.channel = parent.channel;
|