001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2025 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas/ 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see https://www.gnu.org/licenses/. 027 */ 028 029package edu.wisc.ssec.mcidasv.data; 030 031import java.util.HashMap; 032 033/** 034 * @author tommyj 035 * 036 * Holds info to extract a Suomi NPP Quality Flag from a packed byte. 037 * Info is read from the appropriate XML Product Profile 038 * 039 */ 040 041public class QualityFlag { 042 043 private int bitOffset = -1; 044 private int numBits = -1; 045 private String name = null; 046 private String packedName = null; 047 private HashMap<String, String> hm = null; 048 049 /** 050 * @param bitOffset 051 * @param numBits 052 * @param name 053 */ 054 055 public QualityFlag(int bitOffset, int numBits, String name, HashMap<String, String> hm) { 056 this.bitOffset = bitOffset; 057 this.numBits = numBits; 058 this.name = name; 059 this.hm = hm; 060 } 061 062 /** 063 * @return the bitOffset 064 */ 065 public int getBitOffset() { 066 return bitOffset; 067 } 068 069 /** 070 * @param bitOffset the bitOffset to set 071 */ 072 public void setBitOffset(int bitOffset) { 073 this.bitOffset = bitOffset; 074 } 075 076 /** 077 * @return the numBits 078 */ 079 public int getNumBits() { 080 return numBits; 081 } 082 083 /** 084 * @param numBits the numBits to set 085 */ 086 public void setNumBits(int numBits) { 087 this.numBits = numBits; 088 } 089 090 /** 091 * @return the name 092 */ 093 public String getName() { 094 return name; 095 } 096 097 /** 098 * @param name the name to set 099 */ 100 public void setName(String name) { 101 this.name = name; 102 } 103 104 /** 105 * @return the packedName 106 */ 107 public String getPackedName() { 108 return packedName; 109 } 110 111 /** 112 * @param packedName the packedName to set 113 */ 114 public void setPackedName(String packedName) { 115 this.packedName = packedName; 116 } 117 118 /** 119 * @return the hm 120 */ 121 public HashMap<String, String> getHm() { 122 return hm; 123 } 124 125 /** 126 * @param hm the hm to set 127 */ 128 public void setHm(HashMap<String, String> hm) { 129 this.hm = hm; 130 } 131 132 /** 133 * @return the name for a discreet value for this flag 134 */ 135 public String getNameForValue(String valueStr) { 136 if (hm != null) { 137 if (hm.containsKey(valueStr)) { 138 return hm.get(valueStr); 139 } 140 } 141 return null; 142 } 143 144 /* (non-Javadoc) 145 * @see java.lang.Object#toString() 146 */ 147 @Override 148 public String toString() { 149 return "QualityFlag [bitOffset=" + bitOffset + ", numBits=" + numBits 150 + ", name=" + name + ", packedName=" + packedName + "]"; 151 } 152 153}