Package org.xorm

Source Code of org.xorm.Options

/*
    $Header: /cvsroot/xorm/xorm/src/org/xorm/Options.java,v 1.1 2002/09/21 23:29:45 wbiggs Exp $

    This file is part of XORM.

    XORM is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    XORM is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with XORM; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package org.xorm;

import java.io.Serializable;
import java.util.BitSet;

import javax.jdo.JDOUnsupportedOptionException;

/**
* This class encapsulates the JDO options associated with many
* JDO interfaces.  It can be extended or used via a wrapper pattern.
*
* @author Wes Biggs
*/
public class Options implements Cloneable, Serializable {
    public static final int
  NONTRANSACTIONAL_READ = 0,
  NONTRANSACTIONAL_WRITE = 1,
  RETAIN_VALUES = 2,
  OPTIMISTIC = 3,
  RESTORE_VALUES = 4;

    protected BitSet optionsFlags = new BitSet(5);

    /**
     * Returns a deep clone of this instance.
     */
    public Object clone() {
  Options clone = null;
  try {
      clone = (Options) super.clone();
      clone.optionsFlags = (BitSet) optionsFlags.clone();
  } catch (CloneNotSupportedException ignored) { }
  return clone;
    }

    public void setNontransactionalRead(boolean nontransactionalRead) {
  optionsFlags.set(NONTRANSACTIONAL_READ, nontransactionalRead);
    }

    public boolean getNontransactionalRead() {
  return optionsFlags.get(NONTRANSACTIONAL_READ);
    }

    public void setNontransactionalWrite(boolean nontransactionalWrite) {
  if (nontransactionalWrite) {
      throw new JDOUnsupportedOptionException();
  }
  optionsFlags.set(NONTRANSACTIONAL_WRITE, nontransactionalWrite);
    }

    public boolean getNontransactionalWrite() {
  return optionsFlags.get(NONTRANSACTIONAL_WRITE);
    }

    public void setRetainValues(boolean retainValues) {
  optionsFlags.set(RETAIN_VALUES, retainValues);
    }

    public boolean getRetainValues() {
  return optionsFlags.get(RETAIN_VALUES);
    }

    public void setOptimistic(boolean optimistic) {
  if (optimistic) {
      throw new JDOUnsupportedOptionException();
  }
  optionsFlags.set(OPTIMISTIC, optimistic);
    }

    public boolean getOptimistic() {
  return optionsFlags.get(OPTIMISTIC);
    }

    public void setRestoreValues(boolean restoreValues) {
  if (restoreValues) {
      throw new JDOUnsupportedOptionException();
  }
  optionsFlags.set(RESTORE_VALUES, restoreValues);
    }

    public boolean getRestoreValues() {
  return optionsFlags.get(RESTORE_VALUES);
    }
}
TOP

Related Classes of org.xorm.Options

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.