All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.mpxj.mpp.MppBitFlag Maven / Gradle / Ivy

Go to download

Library that provides facilities to allow project information to be manipulated in Java and .Net. Supports a range of data formats: Microsoft Project Exchange (MPX), Microsoft Project (MPP,MPT), Microsoft Project Data Interchange (MSPDI XML), Microsoft Project Database (MPD), Planner (XML), Primavera (PM XML, XER, and database), Asta Powerproject (PP, MDB), Asta Easyplan (PP), Phoenix Project Manager (PPX), FastTrack Schedule (FTS), and the Standard Data Exchange Format (SDEF).

There is a newer version: 13.4.0
Show newest version

package net.sf.mpxj.mpp;

import net.sf.mpxj.FieldContainer;
import net.sf.mpxj.FieldType;

/**
 * Represents the type and location of a bit flag within a block of data.
 */
public class MppBitFlag
{
   /**
    * Constructor.
    *
    * @param type field type
    * @param offset offset in buffer
    * @param mask bit mask
    * @param zeroValue value to return if expression is zero
    * @param nonZeroValue value to return if expression is non-zero
    */
   public MppBitFlag(FieldType type, int offset, int mask, Object zeroValue, Object nonZeroValue)
   {
      m_type = type;
      m_offset = offset;
      m_mask = mask;
      m_zeroValue = zeroValue;
      m_nonZeroValue = nonZeroValue;
   }

   /**
    * Extracts the value of this bit flag from the supplied byte array
    * and sets the value in the supplied container.
    *
    * @param container container
    * @param data byte array
    */
   public void setValue(FieldContainer container, byte[] data)
   {
      if (data != null)
      {
         container.set(m_type, ((MPPUtility.getInt(data, m_offset) & m_mask) == 0) ? m_zeroValue : m_nonZeroValue);
      }
   }

   private final FieldType m_type;
   private final int m_offset;
   private final int m_mask;
   private final Object m_zeroValue;
   private final Object m_nonZeroValue;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy