Class Pointer

java.lang.Object
org.djutils.serialization.serializers.Pointer

public class Pointer extends Object
Container for an offset.

Copyright (c) 2019-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.

Version:
$Revision$, $LastChangedDate$, by $Author$,
Author:
Alexander Verbraeck, Peter Knoppers
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new Pointer with offset 0.
    Pointer(int initialOffset)
    Construct a new Pointer with specified initial offset.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    get()
    Retrieve the offset.
    int
    getAndIncrement(int increment)
    Retrieve the current value of offset and increment it.
    void
    inc(int increment)
    Increment the offset.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Pointer

      Pointer(int initialOffset)
      Construct a new Pointer with specified initial offset.
      Parameters:
      initialOffset - int; the initial offset
    • Pointer

      public Pointer()
      Construct a new Pointer with offset 0.
  • Method Details

    • get

      public int get()
      Retrieve the offset.
      Returns:
      int; the offset
    • getAndIncrement

      public int getAndIncrement(int increment)
      Retrieve the current value of offset and increment it. The returned value is the value before applying the increment.
      Parameters:
      increment - int; the amount by which the offset must be incremented
      Returns:
      int; the offset (before the increment was added)
    • inc

      public void inc(int increment)
      Increment the offset.
      Parameters:
      increment - int; the amount by which the offset must be incremented
    • toString

      public String toString()
      Overrides:
      toString in class Object