PageRenderTime 28ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/chronicle/src/main/java/com/higherfrequencytrading/chronicle/impl/WrappedExcerpt.java

http://github.com/peter-lawrey/Java-Chronicle
Java | 746 lines | 567 code | 161 blank | 18 comment | 0 complexity | 7f0be943d36f8d2f0fe4d4c9a52c0c08 MD5 | raw file
  1. /*
  2. * Copyright 2013 Peter Lawrey
  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.higherfrequencytrading.chronicle.impl;
  17. import com.higherfrequencytrading.chronicle.ByteStringAppender;
  18. import com.higherfrequencytrading.chronicle.Chronicle;
  19. import com.higherfrequencytrading.chronicle.Excerpt;
  20. import com.higherfrequencytrading.chronicle.StopCharTester;
  21. import com.higherfrequencytrading.chronicle.math.MutableDecimal;
  22. import org.jetbrains.annotations.NotNull;
  23. import org.jetbrains.annotations.Nullable;
  24. import java.io.InputStream;
  25. import java.io.OutputStream;
  26. import java.nio.ByteBuffer;
  27. import java.nio.ByteOrder;
  28. import java.util.Collection;
  29. import java.util.List;
  30. import java.util.Map;
  31. /**
  32. * @author peter.lawrey
  33. */
  34. public class WrappedExcerpt implements Excerpt {
  35. private final Excerpt excerpt;
  36. public WrappedExcerpt(Excerpt excerpt) {
  37. this.excerpt = excerpt;
  38. }
  39. @NotNull
  40. public Chronicle chronicle() {
  41. return excerpt.chronicle();
  42. }
  43. @Override
  44. public boolean hasNextIndex() {
  45. return excerpt.hasNextIndex();
  46. }
  47. public boolean nextIndex() {
  48. return excerpt.nextIndex();
  49. }
  50. public boolean index(long index) throws IndexOutOfBoundsException {
  51. return excerpt.index(index);
  52. }
  53. public void startExcerpt(int capacity) {
  54. excerpt.startExcerpt(capacity);
  55. }
  56. public void finish() {
  57. excerpt.finish();
  58. }
  59. public long index() {
  60. return excerpt.index();
  61. }
  62. @NotNull
  63. public Excerpt position(int position) {
  64. return excerpt.position(position);
  65. }
  66. public int position() {
  67. return excerpt.position();
  68. }
  69. public int capacity() {
  70. return excerpt.capacity();
  71. }
  72. public int remaining() {
  73. return excerpt.remaining();
  74. }
  75. public void readFully(@NotNull byte[] b) {
  76. excerpt.readFully(b);
  77. }
  78. public int skipBytes(int n) {
  79. return excerpt.skipBytes(n);
  80. }
  81. public void readFully(@NotNull byte[] b, int off, int len) {
  82. excerpt.readFully(b, off, len);
  83. }
  84. public boolean readBoolean() {
  85. return excerpt.readBoolean();
  86. }
  87. public boolean readBoolean(int offset) {
  88. return excerpt.readBoolean(offset);
  89. }
  90. public int readUnsignedByte() {
  91. return excerpt.readUnsignedByte();
  92. }
  93. public int readUnsignedByte(int offset) {
  94. return excerpt.readUnsignedByte(offset);
  95. }
  96. public int readUnsignedShort() {
  97. return excerpt.readUnsignedShort();
  98. }
  99. public int readUnsignedShort(int offset) {
  100. return excerpt.readUnsignedShort(offset);
  101. }
  102. public String readLine() {
  103. return excerpt.readLine();
  104. }
  105. public String readUTF() {
  106. return excerpt.readUTF();
  107. }
  108. @Override
  109. public boolean readUTF(@NotNull Appendable appendable) {
  110. return appendUTF(appendable);
  111. }
  112. @Override
  113. public boolean appendUTF(@NotNull Appendable appendable) {
  114. return excerpt.appendUTF(appendable);
  115. }
  116. public boolean readUTF(@NotNull StringBuilder stringBuilder) {
  117. return excerpt.readUTF(stringBuilder);
  118. }
  119. @NotNull
  120. public String parseUTF(@NotNull StopCharTester tester) {
  121. return excerpt.parseUTF(tester);
  122. }
  123. public void parseUTF(@NotNull Appendable builder, @NotNull StopCharTester tester) {
  124. excerpt.parseUTF(builder, tester);
  125. }
  126. public String readUTF(int offset) {
  127. return excerpt.readUTF(offset);
  128. }
  129. public short readCompactShort() {
  130. return excerpt.readCompactShort();
  131. }
  132. public int readCompactUnsignedShort() {
  133. return excerpt.readCompactUnsignedShort();
  134. }
  135. public int readInt24() {
  136. return excerpt.readInt24();
  137. }
  138. public int readInt24(int offset) {
  139. return excerpt.readInt24(offset);
  140. }
  141. public long readUnsignedInt() {
  142. return excerpt.readUnsignedInt();
  143. }
  144. public long readUnsignedInt(int offset) {
  145. return excerpt.readUnsignedInt(offset);
  146. }
  147. public int readCompactInt() {
  148. return excerpt.readCompactInt();
  149. }
  150. public long readCompactUnsignedInt() {
  151. return excerpt.readCompactUnsignedInt();
  152. }
  153. public long readInt48() {
  154. return excerpt.readInt48();
  155. }
  156. public long readInt48(int offset) {
  157. return excerpt.readInt48(offset);
  158. }
  159. public long readCompactLong() {
  160. return excerpt.readCompactLong();
  161. }
  162. @Override
  163. public long readStopBit() {
  164. return excerpt.readStopBit();
  165. }
  166. public double readCompactDouble() {
  167. return excerpt.readCompactDouble();
  168. }
  169. public void readByteString(@NotNull StringBuilder sb) {
  170. excerpt.readByteString(sb);
  171. }
  172. public int readByteString(int offset, @NotNull StringBuilder sb) {
  173. return excerpt.readByteString(offset, sb);
  174. }
  175. @NotNull
  176. public String readByteString() {
  177. return excerpt.readByteString();
  178. }
  179. public void readChars(@NotNull StringBuilder sb) {
  180. excerpt.readChars(sb);
  181. }
  182. @NotNull
  183. public String readChars() {
  184. return excerpt.readChars();
  185. }
  186. @Nullable
  187. @Override
  188. public <T> T readObject(Class<T> tClass) throws IllegalStateException {
  189. return excerpt.readObject(tClass);
  190. }
  191. @NotNull
  192. public ByteOrder order() {
  193. return excerpt.order();
  194. }
  195. public void read(@NotNull ByteBuffer bb) {
  196. excerpt.read(bb);
  197. }
  198. public void write(byte[] b) {
  199. excerpt.write(b);
  200. }
  201. public void writeBoolean(boolean v) {
  202. excerpt.writeBoolean(v);
  203. }
  204. public void writeBoolean(int offset, boolean v) {
  205. excerpt.writeBoolean(offset, v);
  206. }
  207. public void writeBytes(@NotNull String s) {
  208. excerpt.writeBytes(s);
  209. }
  210. public void writeBytes(@NotNull CharSequence s) {
  211. excerpt.writeBytes(s);
  212. }
  213. public void writeBytes(int offset, @NotNull CharSequence s) {
  214. excerpt.writeBytes(offset, s);
  215. }
  216. public void writeChars(@NotNull String s) {
  217. excerpt.writeChars(s);
  218. }
  219. public void writeChars(@NotNull CharSequence s) {
  220. excerpt.writeChars(s);
  221. }
  222. public void writeChars(int offset, @NotNull CharSequence s) {
  223. excerpt.writeChars(offset, s);
  224. }
  225. public void writeUTF(@Nullable String s) {
  226. excerpt.writeUTF(s);
  227. }
  228. public void writeUTF(@Nullable CharSequence str) {
  229. excerpt.writeUTF(str);
  230. }
  231. public void writeByte(int v) {
  232. excerpt.writeByte(v);
  233. }
  234. public void writeUnsignedByte(int v) {
  235. excerpt.writeUnsignedByte(v);
  236. }
  237. public void writeUnsignedByte(int offset, int v) {
  238. excerpt.writeUnsignedByte(offset, v);
  239. }
  240. public void write(int offset, byte[] b) {
  241. excerpt.write(offset, b);
  242. }
  243. public void write(byte[] b, int off, int len) {
  244. excerpt.write(b, off, len);
  245. }
  246. public void writeUnsignedShort(int v) {
  247. excerpt.writeUnsignedShort(v);
  248. }
  249. public void writeUnsignedShort(int offset, int v) {
  250. excerpt.writeUnsignedShort(offset, v);
  251. }
  252. public void writeCompactShort(int v) {
  253. excerpt.writeCompactShort(v);
  254. }
  255. public void writeCompactUnsignedShort(int v) {
  256. excerpt.writeCompactUnsignedShort(v);
  257. }
  258. public void writeInt24(int v) {
  259. excerpt.writeInt24(v);
  260. }
  261. public void writeInt24(int offset, int v) {
  262. excerpt.writeInt24(offset, v);
  263. }
  264. public void writeUnsignedInt(long v) {
  265. excerpt.writeUnsignedInt(v);
  266. }
  267. public void writeUnsignedInt(int offset, long v) {
  268. excerpt.writeUnsignedInt(offset, v);
  269. }
  270. public void writeCompactInt(int v) {
  271. excerpt.writeCompactInt(v);
  272. }
  273. public void writeCompactUnsignedInt(long v) {
  274. excerpt.writeCompactUnsignedInt(v);
  275. }
  276. public void writeInt48(long v) {
  277. excerpt.writeInt48(v);
  278. }
  279. public void writeInt48(int offset, long v) {
  280. excerpt.writeInt48(offset, v);
  281. }
  282. public void writeCompactLong(long v) {
  283. excerpt.writeCompactLong(v);
  284. }
  285. public void writeCompactDouble(double v) {
  286. excerpt.writeCompactDouble(v);
  287. }
  288. public void write(@NotNull ByteBuffer bb) {
  289. excerpt.write(bb);
  290. }
  291. public int length() {
  292. return excerpt.length();
  293. }
  294. @NotNull
  295. public ByteStringAppender append(@NotNull CharSequence s) {
  296. excerpt.append(s);
  297. return this;
  298. }
  299. @NotNull
  300. public ByteStringAppender append(@NotNull CharSequence s, int start, int end) {
  301. excerpt.append(s, start, end);
  302. return this;
  303. }
  304. @NotNull
  305. public ByteStringAppender append(Enum value) {
  306. excerpt.append(value);
  307. return this;
  308. }
  309. @NotNull
  310. public ByteStringAppender append(@NotNull byte[] str) {
  311. excerpt.append(str);
  312. return this;
  313. }
  314. @NotNull
  315. public ByteStringAppender append(@NotNull byte[] str, int offset, int len) {
  316. excerpt.append(str, offset, len);
  317. return this;
  318. }
  319. @NotNull
  320. public ByteStringAppender append(boolean b) {
  321. excerpt.append(b);
  322. return this;
  323. }
  324. @NotNull
  325. public ByteStringAppender append(char c) {
  326. excerpt.append(c);
  327. return this;
  328. }
  329. @NotNull
  330. public ByteStringAppender append(int num) {
  331. excerpt.append(num);
  332. return this;
  333. }
  334. @NotNull
  335. public ByteStringAppender append(long num) {
  336. excerpt.append(num);
  337. return this;
  338. }
  339. @NotNull
  340. @Override
  341. public ByteStringAppender appendDate(long timeInMS) {
  342. excerpt.appendDate(timeInMS);
  343. return this;
  344. }
  345. @NotNull
  346. @Override
  347. public ByteStringAppender appendDateTime(long timeInMS) {
  348. excerpt.appendDateTime(timeInMS);
  349. return this;
  350. }
  351. @NotNull
  352. public ByteStringAppender appendTime(long timeInMS) {
  353. excerpt.appendTime(timeInMS);
  354. return this;
  355. }
  356. @NotNull
  357. public ByteStringAppender append(double d) {
  358. excerpt.append(d);
  359. return this;
  360. }
  361. @NotNull
  362. public ByteStringAppender append(double d, int precision) {
  363. excerpt.append(d, precision);
  364. return this;
  365. }
  366. @NotNull
  367. @Override
  368. public ByteStringAppender append(@NotNull MutableDecimal md) {
  369. excerpt.append(md);
  370. return this;
  371. }
  372. public double parseDouble() {
  373. return excerpt.parseDouble();
  374. }
  375. public long parseLong() {
  376. return excerpt.parseLong();
  377. }
  378. @NotNull
  379. public InputStream inputStream() {
  380. return excerpt.inputStream();
  381. }
  382. @NotNull
  383. public OutputStream outputStream() {
  384. return excerpt.outputStream();
  385. }
  386. public <E> void writeEnum(E o) {
  387. excerpt.writeEnum(o);
  388. }
  389. public <E> E readEnum(@NotNull Class<E> aClass) {
  390. return excerpt.readEnum(aClass);
  391. }
  392. public <E> E parseEnum(@NotNull Class<E> aClass, @NotNull StopCharTester tester) {
  393. return excerpt.parseEnum(aClass, tester);
  394. }
  395. @Override
  396. public <E> void readEnums(@NotNull Class<E> eClass, @NotNull List<E> eList) {
  397. excerpt.readEnums(eClass, eList);
  398. }
  399. public <E> void writeEnums(@NotNull Collection<E> eList) {
  400. excerpt.writeEnums(eList);
  401. }
  402. public <K, V> void writeMap(@NotNull Map<K, V> map) {
  403. excerpt.writeMap(map);
  404. }
  405. @NotNull
  406. public <K, V> Map<K, V> readMap(@NotNull Class<K> aClass, @NotNull Class<V> aClass2) {
  407. return excerpt.readMap(aClass, aClass2);
  408. }
  409. public byte readByte() {
  410. return excerpt.readByte();
  411. }
  412. public byte readByte(int offset) {
  413. return excerpt.readByte(offset);
  414. }
  415. public short readShort() {
  416. return excerpt.readShort();
  417. }
  418. public short readShort(int offset) {
  419. return excerpt.readShort(offset);
  420. }
  421. public char readChar() {
  422. return excerpt.readChar();
  423. }
  424. public char readChar(int offset) {
  425. return excerpt.readChar(offset);
  426. }
  427. public int readInt() {
  428. return excerpt.readInt();
  429. }
  430. public int readInt(int offset) {
  431. return excerpt.readInt(offset);
  432. }
  433. public long readLong() {
  434. return excerpt.readLong();
  435. }
  436. public long readLong(int offset) {
  437. return excerpt.readLong(offset);
  438. }
  439. public float readFloat() {
  440. return excerpt.readFloat();
  441. }
  442. public float readFloat(int offset) {
  443. return excerpt.readFloat(offset);
  444. }
  445. public double readDouble() {
  446. return excerpt.readDouble();
  447. }
  448. public double readDouble(int offset) {
  449. return excerpt.readDouble(offset);
  450. }
  451. public void write(int b) {
  452. excerpt.write(b);
  453. }
  454. public void write(int offset, int b) {
  455. excerpt.write(offset, b);
  456. }
  457. public void writeShort(int v) {
  458. excerpt.writeShort(v);
  459. }
  460. public void writeShort(int offset, int v) {
  461. excerpt.writeShort(offset, v);
  462. }
  463. public void writeChar(int v) {
  464. excerpt.writeChar(v);
  465. }
  466. public void writeChar(int offset, int v) {
  467. excerpt.writeChar(offset, v);
  468. }
  469. public void writeInt(int v) {
  470. excerpt.writeInt(v);
  471. }
  472. public void writeInt(int offset, int v) {
  473. excerpt.writeInt(offset, v);
  474. }
  475. public void writeLong(long v) {
  476. excerpt.writeLong(v);
  477. }
  478. public void writeLong(int offset, long v) {
  479. excerpt.writeLong(offset, v);
  480. }
  481. @Override
  482. public void writeStopBit(long n) {
  483. excerpt.writeStopBit(n);
  484. }
  485. public void writeFloat(float v) {
  486. excerpt.writeFloat(v);
  487. }
  488. public void writeFloat(int offset, float v) {
  489. excerpt.writeFloat(offset, v);
  490. }
  491. public void writeDouble(double v) {
  492. excerpt.writeDouble(v);
  493. }
  494. public void writeDouble(int offset, double v) {
  495. excerpt.writeDouble(offset, v);
  496. }
  497. @Override
  498. public Object readObject() {
  499. return excerpt.readObject();
  500. }
  501. @Override
  502. public int read() {
  503. return excerpt.read();
  504. }
  505. @Override
  506. public int read(@NotNull byte[] b) {
  507. return excerpt.read(b);
  508. }
  509. @Override
  510. public int read(@NotNull byte[] b, int off, int len) {
  511. return excerpt.read(b, off, len);
  512. }
  513. @Override
  514. public long skip(long n) {
  515. return excerpt.skip(n);
  516. }
  517. @Override
  518. public int available() {
  519. return excerpt.available();
  520. }
  521. @Override
  522. public void close() {
  523. try {
  524. excerpt.close();
  525. } catch (Exception keepIntelliJHappy) {
  526. }
  527. }
  528. @Override
  529. public void writeObject(Object obj) {
  530. excerpt.writeObject(obj);
  531. }
  532. @Override
  533. public void flush() {
  534. excerpt.flush();
  535. }
  536. @Override
  537. public <E> void writeList(@NotNull Collection<E> list) {
  538. excerpt.writeList(list);
  539. }
  540. @Override
  541. public void readList(@NotNull Collection list) {
  542. excerpt.readList(list);
  543. }
  544. @Override
  545. public long size() {
  546. return excerpt.size();
  547. }
  548. @Override
  549. public boolean stepBackAndSkipTo(@NotNull StopCharTester tester) {
  550. return excerpt.stepBackAndSkipTo(tester);
  551. }
  552. @Override
  553. public boolean skipTo(@NotNull StopCharTester tester) {
  554. return excerpt.skipTo(tester);
  555. }
  556. @NotNull
  557. @Override
  558. public MutableDecimal parseDecimal(@NotNull MutableDecimal decimal) {
  559. return excerpt.parseDecimal(decimal);
  560. }
  561. @NotNull
  562. @Override
  563. public Excerpt toStart() {
  564. excerpt.toStart();
  565. return this;
  566. }
  567. @NotNull
  568. @Override
  569. public Excerpt toEnd() {
  570. excerpt.toEnd();
  571. return this;
  572. }
  573. @Override
  574. public boolean isFinished() {
  575. return excerpt.isFinished();
  576. }
  577. @Override
  578. public long findMatch(ExcerptComparator comparator) {
  579. return excerpt.findMatch(comparator);
  580. }
  581. @Override
  582. public void findRange(long[] startEnd, ExcerptComparator comparator) {
  583. excerpt.findRange(startEnd, comparator);
  584. }
  585. }