1 31 package org.pdfbox.util; 32 33 import org.pdfbox.cos.COSDictionary; 34 35 41 public class BitFlagHelper 42 { 43 private BitFlagHelper() 44 { 45 } 47 48 56 public static final void setFlag( COSDictionary dic, String field, int bitFlag, boolean value ) 57 { 58 int currentFlags = dic.getInt( field, 0 ); 59 if( value ) 60 { 61 currentFlags = currentFlags | bitFlag; 62 } 63 else 64 { 65 currentFlags = currentFlags &= ~bitFlag; 66 } 67 dic.setInt( field, currentFlags ); 68 } 69 70 80 public static final boolean getFlag(COSDictionary dic, String field, int bitFlag) 81 { 82 int ff = dic.getInt( field, 0 ); 83 return (ff & bitFlag) == bitFlag; 84 } 85 } | Popular Tags |