1 package fr.in2p3.jsaga.impl.namespace; 2 3 /* *************************************************** 4 * *** Centre de Calcul de l'IN2P3 - Lyon (France) *** 5 * *** http://cc.in2p3.fr/ *** 6 * *************************************************** 7 * File: JSAGAFlags 8 * Author: Sylvain Reynaud (sreynaud@in2p3.fr) 9 * Date: 30 oct. 2007 10 * *************************************************** 11 * Description: */ 12 /** 13 * 14 */ 15 public enum JSAGAFlags { 16 /** Bypass existence check */ 17 BYPASSEXIST(4096), 18 /** Preserve times */ 19 PRESERVETIMES(8192), 20 /** All flags */ 21 ALLFLAGS(4096 | 8192); 22 23 private int value; 24 25 JSAGAFlags(int value) { 26 this.value = value; 27 } 28 29 /** 30 * Returns the integer value of this enumeration literal. 31 * @return the integer value. 32 */ 33 public int getValue() { 34 return value; 35 } 36 37 /** 38 * Returns the result of or-ing this flag into an integer. 39 * @param val the value to OR this enumeration value into. 40 * @return the result of or-ing this flag into the integer parameter. 41 */ 42 public int or(int val) { 43 return val | value; 44 } 45 46 /** 47 * Tests for the presence of this flag in the specified value. 48 * @param val the value. 49 * @return <code>true</code> if this flag is present. 50 */ 51 public boolean isSet(int val) { 52 if (value == val) { 53 // Also tests for 0 (NONE) which is assumed to be set only when 54 // no other values are set. 55 return true; 56 } 57 return (val & value) != 0; 58 } 59 }