You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ByteUtil.java 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*
  2. Copyright (c) 2005 Health Market Science, Inc.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this library; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  14. USA
  15. You can contact Health Market Science at info@healthmarketscience.com
  16. or at the following address:
  17. Health Market Science
  18. 2700 Horizon Drive
  19. Suite 200
  20. King of Prussia, PA 19406
  21. */
  22. package com.healthmarketscience.jackcess;
  23. import java.io.FileWriter;
  24. import java.io.IOException;
  25. import java.io.OutputStream;
  26. import java.io.PrintWriter;
  27. import java.nio.ByteBuffer;
  28. import java.nio.ByteOrder;
  29. import java.util.Arrays;
  30. /**
  31. * Byte manipulation and display utilities
  32. * @author Tim McCune
  33. */
  34. public final class ByteUtil {
  35. private static final String[] HEX_CHARS = new String[] {
  36. "0", "1", "2", "3", "4", "5", "6", "7",
  37. "8", "9", "A", "B", "C", "D", "E", "F"};
  38. private static final int NUM_BYTES_PER_BLOCK = 4;
  39. private static final int NUM_BYTES_PER_LINE = 24;
  40. private ByteUtil() {}
  41. /**
  42. * Put an integer into the given buffer at the given offset as a 3-byte
  43. * integer.
  44. * @param buffer buffer into which to insert the int
  45. * @param val Int to convert
  46. */
  47. public static void put3ByteInt(ByteBuffer buffer, int val)
  48. {
  49. put3ByteInt(buffer, val, buffer.order());
  50. }
  51. /**
  52. * Put an integer into the given buffer at the given offset as a 3-byte
  53. * integer.
  54. * @param buffer buffer into which to insert the int
  55. * @param val Int to convert
  56. * @param order the order to insert the bytes of the int
  57. */
  58. public static void put3ByteInt(ByteBuffer buffer, int val, ByteOrder order)
  59. {
  60. int pos = buffer.position();
  61. put3ByteInt(buffer, val, pos, order);
  62. buffer.position(pos + 3);
  63. }
  64. /**
  65. * Put an integer into the given buffer at the given offset as a 3-byte
  66. * integer.
  67. * @param buffer buffer into which to insert the int
  68. * @param val Int to convert
  69. * @param offset offset at which to insert the int
  70. * @param order the order to insert the bytes of the int
  71. */
  72. public static void put3ByteInt(ByteBuffer buffer, int val, int offset,
  73. ByteOrder order) {
  74. int offInc = 1;
  75. if(order == ByteOrder.BIG_ENDIAN) {
  76. offInc = -1;
  77. offset += 2;
  78. }
  79. buffer.put(offset, (byte) (val & 0xFF));
  80. buffer.put(offset + (1 * offInc), (byte) ((val >>> 8) & 0xFF));
  81. buffer.put(offset + (2 * offInc), (byte) ((val >>> 16) & 0xFF));
  82. }
  83. /**
  84. * Read a 3 byte int from a buffer
  85. * @param buffer Buffer containing the bytes
  86. * @return The int
  87. */
  88. public static int get3ByteInt(ByteBuffer buffer) {
  89. return get3ByteInt(buffer, buffer.order());
  90. }
  91. /**
  92. * Read a 3 byte int from a buffer
  93. * @param buffer Buffer containing the bytes
  94. * @param order the order of the bytes of the int
  95. * @return The int
  96. */
  97. public static int get3ByteInt(ByteBuffer buffer, ByteOrder order) {
  98. int pos = buffer.position();
  99. int rtn = get3ByteInt(buffer, pos, order);
  100. buffer.position(pos + 3);
  101. return rtn;
  102. }
  103. /**
  104. * Read a 3 byte int from a buffer
  105. * @param buffer Buffer containing the bytes
  106. * @param offset Offset at which to start reading the int
  107. * @return The int
  108. */
  109. public static int get3ByteInt(ByteBuffer buffer, int offset) {
  110. return get3ByteInt(buffer, offset, buffer.order());
  111. }
  112. /**
  113. * Read a 3 byte int from a buffer
  114. * @param buffer Buffer containing the bytes
  115. * @param offset Offset at which to start reading the int
  116. * @param order the order of the bytes of the int
  117. * @return The int
  118. */
  119. public static int get3ByteInt(ByteBuffer buffer, int offset,
  120. ByteOrder order) {
  121. int offInc = 1;
  122. if(order == ByteOrder.BIG_ENDIAN) {
  123. offInc = -1;
  124. offset += 2;
  125. }
  126. int rtn = getUnsignedByte(buffer, offset);
  127. rtn += (getUnsignedByte(buffer, offset + (1 * offInc)) << 8);
  128. rtn += (getUnsignedByte(buffer, offset + (2 * offInc)) << 16);
  129. return rtn;
  130. }
  131. /**
  132. * Read an unsigned byte from a buffer
  133. * @param buffer Buffer containing the bytes
  134. * @return The unsigned byte as an int
  135. */
  136. public static int getUnsignedByte(ByteBuffer buffer) {
  137. int pos = buffer.position();
  138. int rtn = getUnsignedByte(buffer, pos);
  139. buffer.position(pos + 1);
  140. return rtn;
  141. }
  142. /**
  143. * Read an unsigned byte from a buffer
  144. * @param buffer Buffer containing the bytes
  145. * @param offset Offset at which to read the byte
  146. * @return The unsigned byte as an int
  147. */
  148. public static int getUnsignedByte(ByteBuffer buffer, int offset) {
  149. return asUnsignedByte(buffer.get(offset));
  150. }
  151. /**
  152. * Read an unsigned short from a buffer
  153. * @param buffer Buffer containing the short
  154. * @return The unsigned short as an int
  155. */
  156. public static int getUnsignedShort(ByteBuffer buffer) {
  157. int pos = buffer.position();
  158. int rtn = getUnsignedShort(buffer, pos);
  159. buffer.position(pos + 2);
  160. return rtn;
  161. }
  162. /**
  163. * Read an unsigned short from a buffer
  164. * @param buffer Buffer containing the short
  165. * @param offset Offset at which to read the short
  166. * @return The unsigned short as an int
  167. */
  168. public static int getUnsignedShort(ByteBuffer buffer, int offset) {
  169. return asUnsignedShort(buffer.getShort(offset));
  170. }
  171. /**
  172. * @param buffer Buffer containing the bytes
  173. * @param order the order of the bytes of the int
  174. * @return an int from the current position in the given buffer, read using
  175. * the given ByteOrder
  176. */
  177. public static int getInt(ByteBuffer buffer, ByteOrder order) {
  178. int offset = buffer.position();
  179. int rtn = getInt(buffer, offset, order);
  180. buffer.position(offset + 4);
  181. return rtn;
  182. }
  183. /**
  184. * @param buffer Buffer containing the bytes
  185. * @param offset Offset at which to start reading the int
  186. * @param order the order of the bytes of the int
  187. * @return an int from the given position in the given buffer, read using
  188. * the given ByteOrder
  189. */
  190. public static int getInt(ByteBuffer buffer, int offset, ByteOrder order) {
  191. ByteOrder origOrder = buffer.order();
  192. try {
  193. return buffer.order(order).getInt(offset);
  194. } finally {
  195. buffer.order(origOrder);
  196. }
  197. }
  198. /**
  199. * Writes an int at the current position in the given buffer, using the
  200. * given ByteOrder
  201. * @param buffer buffer into which to insert the int
  202. * @param val Int to insert
  203. * @param order the order to insert the bytes of the int
  204. */
  205. public static void putInt(ByteBuffer buffer, int val, ByteOrder order) {
  206. int offset = buffer.position();
  207. putInt(buffer, val, offset, order);
  208. buffer.position(offset + 4);
  209. }
  210. /**
  211. * Writes an int at the given position in the given buffer, using the
  212. * given ByteOrder
  213. * @param buffer buffer into which to insert the int
  214. * @param val Int to insert
  215. * @param offset offset at which to insert the int
  216. * @param order the order to insert the bytes of the int
  217. */
  218. public static void putInt(ByteBuffer buffer, int val, int offset,
  219. ByteOrder order)
  220. {
  221. ByteOrder origOrder = buffer.order();
  222. try {
  223. buffer.order(order).putInt(offset, val);
  224. } finally {
  225. buffer.order(origOrder);
  226. }
  227. }
  228. /**
  229. * Read an unsigned variable length int from a buffer
  230. * @param buffer Buffer containing the variable length int
  231. * @return The unsigned int
  232. */
  233. public static int getUnsignedVarInt(ByteBuffer buffer, int numBytes) {
  234. int pos = buffer.position();
  235. int rtn = getUnsignedVarInt(buffer, pos, numBytes);
  236. buffer.position(pos + numBytes);
  237. return rtn;
  238. }
  239. /**
  240. * Read an unsigned variable length int from a buffer
  241. * @param buffer Buffer containing the variable length int
  242. * @param offset Offset at which to read the value
  243. * @return The unsigned int
  244. */
  245. public static int getUnsignedVarInt(ByteBuffer buffer, int offset,
  246. int numBytes) {
  247. switch(numBytes) {
  248. case 1:
  249. return getUnsignedByte(buffer, offset);
  250. case 2:
  251. return getUnsignedShort(buffer, offset);
  252. case 3:
  253. return get3ByteInt(buffer, offset);
  254. case 4:
  255. return buffer.getInt(offset);
  256. default:
  257. throw new IllegalArgumentException("Invalid num bytes " + numBytes);
  258. }
  259. }
  260. /**
  261. * Reads an array of bytes from the given buffer
  262. * @param buffer Buffer containing the desired bytes
  263. * @param len length of the desired bytes
  264. * @return a new buffer with the given number of bytes from the current
  265. * position in the given buffer
  266. */
  267. public static byte[] getBytes(ByteBuffer buffer, int len)
  268. {
  269. byte[] bytes = new byte[len];
  270. buffer.get(bytes);
  271. return bytes;
  272. }
  273. /**
  274. * Reads an array of bytes from the given buffer at the given offset
  275. * @param buffer Buffer containing the desired bytes
  276. * @param offset Offset at which to read the bytes
  277. * @param len length of the desired bytes
  278. * @return a new buffer with the given number of bytes from the given
  279. * position in the given buffer
  280. */
  281. public static byte[] getBytes(ByteBuffer buffer, int offset, int len)
  282. {
  283. int origPos = buffer.position();
  284. try {
  285. buffer.position(offset);
  286. return getBytes(buffer, len);
  287. } finally {
  288. buffer.position(origPos);
  289. }
  290. }
  291. /**
  292. * Concatenates and returns the given byte arrays.
  293. */
  294. public static byte[] concat(byte[] b1, byte[] b2) {
  295. byte[] out = new byte[b1.length + b2.length];
  296. System.arraycopy(b1, 0, out, 0, b1.length);
  297. System.arraycopy(b2, 0, out, b1.length, b2.length);
  298. return out;
  299. }
  300. /**
  301. * Sets all bits in the given remaining byte range to 0.
  302. */
  303. public static void clearRemaining(ByteBuffer buffer)
  304. {
  305. if(!buffer.hasRemaining()) {
  306. return;
  307. }
  308. int pos = buffer.position();
  309. clearRange(buffer, pos, pos + buffer.remaining());
  310. }
  311. /**
  312. * Sets all bits in the given byte range to 0.
  313. */
  314. public static void clearRange(ByteBuffer buffer, int start,
  315. int end)
  316. {
  317. putRange(buffer, start, end, (byte)0x00);
  318. }
  319. /**
  320. * Sets all bits in the given byte range to 1.
  321. */
  322. public static void fillRange(ByteBuffer buffer, int start,
  323. int end)
  324. {
  325. putRange(buffer, start, end, (byte)0xff);
  326. }
  327. /**
  328. * Sets all bytes in the given byte range to the given byte value.
  329. */
  330. public static void putRange(ByteBuffer buffer, int start,
  331. int end, byte b)
  332. {
  333. for(int i = start; i < end; ++i) {
  334. buffer.put(i, b);
  335. }
  336. }
  337. /**
  338. * Matches a pattern of bytes against the given buffer starting at the given
  339. * offset.
  340. */
  341. public static boolean matchesRange(ByteBuffer buffer, int start,
  342. byte[] pattern)
  343. {
  344. for(int i = 0; i < pattern.length; ++i) {
  345. if(pattern[i] != buffer.get(start + i)) {
  346. return false;
  347. }
  348. }
  349. return true;
  350. }
  351. /**
  352. * Searches for a pattern of bytes in the given buffer starting at the
  353. * given offset.
  354. * @return the offset of the pattern if a match is found, -1 otherwise
  355. */
  356. public static int findRange(ByteBuffer buffer, int start, byte[] pattern)
  357. {
  358. byte firstByte = pattern[0];
  359. int limit = buffer.limit() - pattern.length;
  360. for(int i = start; i < limit; ++i) {
  361. if((firstByte == buffer.get(i)) && matchesRange(buffer, i, pattern)) {
  362. return i;
  363. }
  364. }
  365. return -1;
  366. }
  367. /**
  368. * Convert a byte buffer to a hexadecimal string for display
  369. * @param buffer Buffer to display, starting at offset 0
  370. * @param size Number of bytes to read from the buffer
  371. * @return The display String
  372. */
  373. public static String toHexString(ByteBuffer buffer, int size) {
  374. return toHexString(buffer, 0, size);
  375. }
  376. /**
  377. * Convert a byte array to a hexadecimal string for display
  378. * @param array byte array to display, starting at offset 0
  379. * @return The display String
  380. */
  381. public static String toHexString(byte[] array) {
  382. return toHexString(ByteBuffer.wrap(array), 0, array.length);
  383. }
  384. /**
  385. * Convert a byte buffer to a hexadecimal string for display
  386. * @param buffer Buffer to display, starting at offset 0
  387. * @param offset Offset at which to start reading the buffer
  388. * @param size Number of bytes to read from the buffer
  389. * @return The display String
  390. */
  391. public static String toHexString(ByteBuffer buffer, int offset, int size) {
  392. return toHexString(buffer, offset, size, true);
  393. }
  394. /**
  395. * Convert a byte buffer to a hexadecimal string for display
  396. * @param buffer Buffer to display, starting at offset 0
  397. * @param offset Offset at which to start reading the buffer
  398. * @param size Number of bytes to read from the buffer
  399. * @param formatted flag indicating if formatting is required
  400. * @return The display String
  401. */
  402. public static String toHexString(ByteBuffer buffer,
  403. int offset, int size, boolean formatted) {
  404. StringBuilder rtn = new StringBuilder();
  405. int position = buffer.position();
  406. buffer.position(offset);
  407. for (int i = 0; i < size; i++) {
  408. byte b = buffer.get();
  409. byte h = (byte) (b & 0xF0);
  410. h = (byte) (h >>> 4);
  411. h = (byte) (h & 0x0F);
  412. rtn.append(HEX_CHARS[h]);
  413. h = (byte) (b & 0x0F);
  414. rtn.append(HEX_CHARS[h]);
  415. int next = (i + 1);
  416. if(formatted && (next < size))
  417. {
  418. if((next % NUM_BYTES_PER_LINE) == 0) {
  419. rtn.append("\n");
  420. } else {
  421. rtn.append(" ");
  422. if ((next % NUM_BYTES_PER_BLOCK) == 0) {
  423. rtn.append(" ");
  424. }
  425. }
  426. }
  427. }
  428. buffer.position(position);
  429. return rtn.toString();
  430. }
  431. /**
  432. * Convert the given number of bytes from the given database page to a
  433. * hexidecimal string for display.
  434. */
  435. public static String toHexString(Database db, int pageNumber, int size)
  436. throws IOException
  437. {
  438. ByteBuffer buffer = db.getPageChannel().createPageBuffer();
  439. db.getPageChannel().readPage(buffer, pageNumber);
  440. return toHexString(buffer, size);
  441. }
  442. /**
  443. * Writes a sequence of hexidecimal values into the given buffer, where
  444. * every two characters represent one byte value.
  445. */
  446. public static void writeHexString(ByteBuffer buffer,
  447. String hexStr)
  448. throws IOException
  449. {
  450. char[] hexChars = hexStr.toCharArray();
  451. if((hexChars.length % 2) != 0) {
  452. throw new IOException("Hex string length must be even");
  453. }
  454. for(int i = 0; i < hexChars.length; i += 2) {
  455. String tmpStr = new String(hexChars, i, 2);
  456. buffer.put((byte)Long.parseLong(tmpStr, 16));
  457. }
  458. }
  459. /**
  460. * Writes a chunk of data to a file in pretty printed hexidecimal.
  461. */
  462. public static void toHexFile(
  463. String fileName,
  464. ByteBuffer buffer,
  465. int offset, int size)
  466. throws IOException
  467. {
  468. PrintWriter writer = new PrintWriter(
  469. new FileWriter(fileName));
  470. try {
  471. writer.println(toHexString(buffer, offset, size));
  472. } finally {
  473. writer.close();
  474. }
  475. }
  476. /**
  477. * @return the byte value converted to an unsigned int value
  478. */
  479. public static int asUnsignedByte(byte b) {
  480. return b & 0xFF;
  481. }
  482. /**
  483. * @return the short value converted to an unsigned int value
  484. */
  485. public static int asUnsignedShort(short s) {
  486. return s & 0xFFFF;
  487. }
  488. /**
  489. * Swaps the 4 bytes (changes endianness) of the bytes at the given offset.
  490. *
  491. * @param bytes buffer containing bytes to swap
  492. * @param offset offset of the first byte of the bytes to swap
  493. */
  494. public static void swap4Bytes(byte[] bytes, int offset)
  495. {
  496. byte b = bytes[offset + 0];
  497. bytes[offset + 0] = bytes[offset + 3];
  498. bytes[offset + 3] = b;
  499. b = bytes[offset + 1];
  500. bytes[offset + 1] = bytes[offset + 2];
  501. bytes[offset + 2] = b;
  502. }
  503. /**
  504. * Swaps the 2 bytes (changes endianness) of the bytes at the given offset.
  505. *
  506. * @param bytes buffer containing bytes to swap
  507. * @param offset offset of the first byte of the bytes to swap
  508. */
  509. public static void swap2Bytes(byte[] bytes, int offset)
  510. {
  511. byte b = bytes[offset + 0];
  512. bytes[offset + 0] = bytes[offset + 1];
  513. bytes[offset + 1] = b;
  514. }
  515. /**
  516. * Moves the position of the given buffer the given count from the current
  517. * position.
  518. * @return the new buffer position
  519. */
  520. public static int forward(ByteBuffer buffer, int count)
  521. {
  522. int newPos = buffer.position() + count;
  523. buffer.position(newPos);
  524. return newPos;
  525. }
  526. /**
  527. * Returns a copy of the given array of the given length.
  528. */
  529. public static byte[] copyOf(byte[] arr, int newLength)
  530. {
  531. return copyOf(arr, 0, newLength);
  532. }
  533. /**
  534. * Returns a copy of the given array of the given length starting at the
  535. * given position.
  536. */
  537. public static byte[] copyOf(byte[] arr, int offset, int newLength)
  538. {
  539. byte[] newArr = new byte[newLength];
  540. int srcLen = arr.length - offset;
  541. System.arraycopy(arr, offset, newArr, 0, Math.min(srcLen, newLength));
  542. return newArr;
  543. }
  544. /**
  545. * Utility byte stream similar to ByteArrayOutputStream but with extended
  546. * accessibility to the bytes.
  547. */
  548. public static class ByteStream extends OutputStream
  549. {
  550. private byte[] _bytes;
  551. private int _length;
  552. private int _lastLength;
  553. public ByteStream() {
  554. this(32);
  555. }
  556. public ByteStream(int capacity) {
  557. _bytes = new byte[capacity];
  558. }
  559. public int getLength() {
  560. return _length;
  561. }
  562. public byte[] getBytes() {
  563. return _bytes;
  564. }
  565. protected void ensureNewCapacity(int numBytes) {
  566. int newLength = _length + numBytes;
  567. if(newLength > _bytes.length) {
  568. byte[] temp = new byte[newLength * 2];
  569. System.arraycopy(_bytes, 0, temp, 0, _length);
  570. _bytes = temp;
  571. }
  572. }
  573. @Override
  574. public void write(int b) {
  575. ensureNewCapacity(1);
  576. _bytes[_length++] = (byte)b;
  577. }
  578. @Override
  579. public void write(byte[] b) {
  580. write(b, 0, b.length);
  581. }
  582. @Override
  583. public void write(byte[] b, int offset, int length) {
  584. ensureNewCapacity(length);
  585. System.arraycopy(b, offset, _bytes, _length, length);
  586. _length += length;
  587. }
  588. public byte get(int offset) {
  589. return _bytes[offset];
  590. }
  591. public void set(int offset, byte b) {
  592. _bytes[offset] = b;
  593. }
  594. public void writeFill(int length, byte b) {
  595. ensureNewCapacity(length);
  596. int oldLength = _length;
  597. _length += length;
  598. Arrays.fill(_bytes, oldLength, _length, b);
  599. }
  600. public void skip(int n) {
  601. ensureNewCapacity(n);
  602. _length += n;
  603. }
  604. public void writeTo(ByteStream out) {
  605. out.write(_bytes, 0, _length);
  606. }
  607. public byte[] toByteArray() {
  608. byte[] result = null;
  609. if(_length == _bytes.length) {
  610. result = _bytes;
  611. _bytes = null;
  612. } else {
  613. result = copyOf(_bytes, _length);
  614. if(_lastLength == _length) {
  615. // if we get the same result length bytes twice in a row, clear the
  616. // _bytes so that the next _bytes will be _lastLength
  617. _bytes = null;
  618. }
  619. }
  620. // save result length so we can potentially get the right length of the
  621. // next byte[] in reset()
  622. _lastLength = _length;
  623. return result;
  624. }
  625. public void reset() {
  626. _length = 0;
  627. if(_bytes == null) {
  628. _bytes = new byte[_lastLength];
  629. }
  630. }
  631. public void trimTrailing(byte minTrimCode, byte maxTrimCode)
  632. {
  633. int minTrim = ByteUtil.asUnsignedByte(minTrimCode);
  634. int maxTrim = ByteUtil.asUnsignedByte(maxTrimCode);
  635. int idx = _length - 1;
  636. while(idx >= 0) {
  637. int val = asUnsignedByte(get(idx));
  638. if((val >= minTrim) && (val <= maxTrim)) {
  639. --idx;
  640. } else {
  641. break;
  642. }
  643. }
  644. _length = idx + 1;
  645. }
  646. }
  647. }