KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > indexing > Pointer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.indexing;
12
13 class Pointer {
14     protected Buffer buffer; // contents
15
protected int offset; // offset of the field within the buffer
16

17     /**
18      * Constructor for a new Pointer.
19      */

20     public Pointer(Buffer buffer, int offset) {
21         this.buffer = buffer;
22         this.offset = offset;
23     }
24
25     public Pointer dec(int n) {
26         offset -= n;
27         return this;
28     }
29
30     public FieldArray getArray(int length, int stride, int count) {
31         return new FieldArray(buffer, offset, length, stride, count);
32     }
33
34     public Field getField(int offset, int length) {
35         return new Field(buffer, this.offset + offset, length);
36     }
37
38     public Pointer inc(int n) {
39         offset += n;
40         return this;
41     }
42
43     public Pointer put(byte[] bytes) {
44         buffer.put(offset, bytes);
45         return this;
46     }
47 }
48
Popular Tags