View Javadoc
1   package nom.tam.util;
2   
3   /*
4    * #%L
5    * nom.tam FITS library
6    * %%
7    * Copyright (C) 1996 - 2024 nom-tam-fits
8    * %%
9    * This is free and unencumbered software released into the public domain.
10   *
11   * Anyone is free to copy, modify, publish, use, compile, sell, or
12   * distribute this software, either in source code form or as a compiled
13   * binary, for any purpose, commercial or non-commercial, and by any
14   * means.
15   *
16   * In jurisdictions that recognize copyright laws, the author or authors
17   * of this software dedicate any and all copyright interest in the
18   * software to the public domain. We make this dedication for the benefit
19   * of the public at large and to the detriment of our heirs and
20   * successors. We intend this dedication to be an overt act of
21   * relinquishment in perpetuity of all present and future rights to this
22   * software under copyright law.
23   *
24   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27   * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28   * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29   * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30   * OTHER DEALINGS IN THE SOFTWARE.
31   * #L%
32   */
33  
34  /**
35   * @deprecated (<i>for internal use</i>) It is a rusty-rail compatibility implementation only, unsafe for general use.
36   *                 No longer used within the FITS package itself. If you do attempt to use it with the deprecated APIs,
37   *                 beware that no data will be filled into the buffer of this object ever by the library, although its
38   *                 length and position fields may be updated to pretend as if the buffer were always hall full / half
39   *                 available...
40   *
41   * @see        BufferEncoder
42   * @see        BufferDecoder
43   */
44  @Deprecated
45  public class BufferPointer {
46  
47      /**
48       * The data buffer.
49       */
50      @Deprecated
51      protected byte[] buffer;
52  
53      /**
54       * The number of valid characters in the buffer
55       */
56      @Deprecated
57      protected int length;
58  
59      /**
60       * The current offset into the buffer
61       */
62      @Deprecated
63      protected int pos;
64  
65      /**
66       * Constructs a new buffer pointer with no associated buffer
67       * 
68       * @deprecated Rusty rail implementation only.
69       */
70      @Deprecated
71      public BufferPointer() {
72      }
73  
74      /**
75       * Constructs a new buffer pointer for the specified byte buffer
76       * 
77       * @param      buffer the array containing the bytes of the buffer.
78       * 
79       * @deprecated        Rusty rail implementation only.
80       */
81      @Deprecated
82      public BufferPointer(byte[] buffer) {
83          this();
84          this.buffer = buffer;
85      }
86  
87      /**
88       * (re)initializes the underlying buffer, creating a new buffer of the specified size
89       * 
90       * @param      bufferSize
91       * 
92       * @return                itself
93       * 
94       * @deprecated            Rusty rail implementation only.
95       */
96      @Deprecated
97      protected BufferPointer init(int bufferSize) {
98          buffer = new byte[bufferSize];
99          pos = 0;
100         length = 0;
101         return this;
102     }
103 
104     /**
105      * Invalidates the pointer, setting both the length and the position to zero.
106      */
107     @Deprecated
108     protected void invalidate() {
109         length = 0;
110         pos = 0;
111     }
112 
113     /**
114      * Returns the current buffer position
115      * 
116      * @return the current position
117      */
118     @Deprecated
119     public int position() {
120         return pos;
121     }
122 
123     /**
124      * Returns the current sizeof the buffer
125      * 
126      * @return the size (or accessible limit) of the buffer
127      */
128     @Deprecated
129     public int limit() {
130         return length;
131     }
132 }