View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17
    18  /*
    19   * Sequence.java
    20   *
    21   */
    22
    23  package javax.jdo.datastore;
    24
    25
    26  /**
    27   *	Implementations of this interface can be used to obtain
    28   *	sequences. The behavior with regard to the transaction and
    29   *	rollover behavior are defined in the metadata.
    30   *
    31   *	@version 2.0
    32   *	@since 2.0
    33   */
    34  public interface Sequence {
    35
    36      /**
    37       * Returns the fully qualified name of the <code>Sequence</code>.
    38       * @return the name of the sequence
    39       */
    40      String getName ();
    41
    42      /**
    43       * Returns the next sequence value as an Object. If the next
    44       * sequence value is not available, throw JDODataStoreException.
    45       * @return the next value
    46       */
    47      Object next ();
    48
    49      /**
    50       * Provides a hint to the implementation that the application
    51       * will need <code>additional</code> sequence value objects in
    52       * short order. There is no externally visible behavior of this
    53       * method. It is used to potentially improve the efficiency of
    54       * the algorithm of obtaining additional sequence value objects.
    55       * @param additional the number of additional values to allocate
    56       */
    57      void allocate (int additional);
    58
    59      /**
    60       * Returns the current sequence value object if it is
    61       * available. It is intended to return a sequence value object
    62       * previously used. If the current sequence value is not available,
    63       * throw JDODataStoreException.
    64       * @return the current value
    65       */
    66      Object current ();
    67
    68      /**
    69       * Returns the next sequence value as a long. If the next
    70       * sequence value is not available or is not numeric, throw
    71       * JDODataStoreException.
    72       * @return the next value
    73       */
    74      long nextValue();
    75
    76      /**
    77       * Returns the current sequence value as a long. If the current
    78       * sequence value is not available or is not numeric, throw
    79       * JDODataStoreException.
    80       * @return the current value
    81       */
    82      long currentValue();
    83  }