Validate sub ifd.

@param ifd the subifd
@param n the ifd number
17517
@SuppressWarnings("unused")
  @Deprecated
  private void validateSubIfd(IFD ifd, int n) {
    boolean thumbnail = ifd.getParent().getImageSize() > ifd.getImageSize();
    IfdTags metadata = ifd.getMetadata();

    checkRequiredTag(metadata, "ImageLength", 1, "SubIFD" + n);
    checkRequiredTag(metadata, "ImageWidth", 1, "SubIFD" + n);
    int spp = -1;
    if (checkRequiredTag(metadata, "SamplesPerPixel", 1, "SubIFD" + n)) {
      spp = (int) metadata.get("SamplesPerPixel").getFirstNumericValue();
      checkRequiredTag(metadata, "BitsPerSample", spp, "SubIFD" + n);
    }
    if (checkRequiredTag(metadata, "Compression", 1, "SubIFD" + n)) {
      int comp = (int) metadata.get("Compression").getFirstNumericValue();
      if (comp == 1)
        checkForbiddenTag(metadata, "CompressedBitsPerPixel", "IFD" + n);
    }
    checkRequiredTag(metadata, "XResolution", 1, "SubIFD" + n);
    checkRequiredTag(metadata, "YResolution", 1, "SubIFD" + n);
    checkForbiddenTag(metadata, "SubIFDs", "IFD" + n);
    if (thumbnail)
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[] {1}, "SubIFD" + n);
    else
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[] {0}, "SubIFD" + n);
    if (checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {1, 2, 6, 32803,
        32767}, "SubIFD" + n)) {
      int photo = (int) metadata.get("PhotometricInterpretation").getFirstNumericValue();
      if (photo != 6) {
        checkForbiddenTag(metadata, "YCbCrCoefficients", "SubIFD" + n);
        checkForbiddenTag(metadata, "YCbCrSubSampling", "SubIFD" + n);
        checkForbiddenTag(metadata, "YCbCrPositioning", "SubIFD" + n);
        checkForbiddenTag(metadata, "ReferenceBlackWhite", "SubIFD" + n);
      }
      if (photo == 2 || photo == 3) {
        if (spp != 3) {
          validation.addError("Invalid SampesPerPixel value fo TiffEP", "SubIFD" + n, spp);
        }
      } else if (photo == 1 || photo == 32803) {
        if (spp != 1) {
          validation.addError("Invalid SampesPerPixel value fo TiffEP", "SubIFD" + n, spp);
        }
        if (photo == 32803) {
          checkRequiredTag(metadata, "CFARepeatPatternDim", 2, "SubIFD" + n);
          checkRequiredTag(metadata, "CFAPattern", -1, "SubIFD" + n);
        }
      }
    }
    checkRequiredTag(metadata, "PlanarConfiguration", 1, new long[] {1, 2}, "SubIFD" + n);
    checkRequiredTag(metadata, "ResolutionUnit", 1, new long[] {1, 2, 3}, "SubIFD" + n);

    if (!thumbnail) {
      if (ifd.hasStrips()) {
        checkRequiredTag(metadata, "StripBYTECount", -1, "SubIFD" + n);
        checkRequiredTag(metadata, "StripOffsets", -1, "SubIFD" + n);
        checkRequiredTag(metadata, "RowsPerStrip", 1, "SubIFD" + n);
        if (ifd.hasTiles()) {
          validation.addErrorLoc("Image in both strips and tiles", "SubIFD");
        }
      } else if (ifd.hasTiles()) {
        checkRequiredTag(metadata, "TileLength", 1, "SubIFD" + n);
        checkRequiredTag(metadata, "TileOffsets", 1, "SubIFD" + n);
        checkRequiredTag(metadata, "TileWidth", -1, "SubIFD" + n);
      }
    } else {
      checkRequiredTag(metadata, "StripBYTECount", -1, "SubIFD" + n);
      checkRequiredTag(metadata, "StripOffsets", -1, "SubIFD" + n);
      checkRequiredTag(metadata, "RowsPerStrip", 1, "SubIFD" + n);
      checkForbiddenTag(metadata, "TileLength", "SubIFD" + n);
      checkForbiddenTag(metadata, "TileOffsets", "SubIFD" + n);
      checkForbiddenTag(metadata, "TileWidth", "SubIFD" + n);
    }

    int nycbcr = 0;
    if (metadata.containsTagId(TiffTags.getTagId("YCbCrCoefficients")))
      nycbcr++;
    if (metadata.containsTagId(TiffTags.getTagId("YCbCrSubSampling")))
      nycbcr++;
    if (metadata.containsTagId(TiffTags.getTagId("YCbCrPositioning")))
      nycbcr++;
    if (metadata.containsTagId(TiffTags.getTagId("ReferenceBlackWhite")))
      nycbcr++;
    if (nycbcr > 0 && nycbcr != 4) {
      checkRequiredTag(metadata, "YCbCrCoefficients", 3, "SubIFD" + n);
      checkRequiredTag(metadata, "YCbCrSubSampling", 2, "SubIFD" + n);
      checkRequiredTag(metadata, "YCbCrPositioning", 1, "SubIFD" + n);
      checkRequiredTag(metadata, "ReferenceBlackWhite", 6, "SubIFD" + n);
    }
    if (thumbnail) {
      checkForbiddenTag(metadata, "YCbCrCoefficients", "IFD" + n);
      checkForbiddenTag(metadata, "YCbCrSubSampling", "IFD" + n);
      checkForbiddenTag(metadata, "YCbCrPositioning", "IFD" + n);
      checkForbiddenTag(metadata, "ReferenceBlackWhite", "IFD" + n);
    }

    checkForbiddenTag(metadata, "PrimaryChromaticities", "IFD" + n);
    checkForbiddenTag(metadata, "WhitePoint", "IFD" + n);
    checkForbiddenTag(metadata, "TransferFunction", "IFD" + n);
  }
852074
@Override public void validate() { 
    if (id == null || id.isEmpty()) {
      throw new IllegalArgumentException("missing or empty id");
    }
    Query.validateId(id);
  }
94500
public static void validateId(final String id) {
    if (id == null || id.isEmpty()) {
      throw new IllegalArgumentException("The ID cannot be null or empty");
    }
    for (int i = 0; i < id.length(); i++) {
      final char c = id.charAt(i);
      if (!(Character.isLetterOrDigit(c))) {
        throw new IllegalArgumentException("Invalid id (\"" + id + 
            "\"): illegal character: " + c);
      }
    }
    if (id.length() == 1) {
      if (Character.isDigit(id.charAt(0))) {
        throw new IllegalArgumentException("The ID cannot be an integer");
      }
    }
  }
924753
function N(iid, name, val, flags) {
        var bFlags = decodeBitPattern(flags, 3); // [isArgument, isLocalSync, isCatchParam]
        // isLocalSync is only true when we sync variables inside a for-in loop
        var aret;

        if (bFlags[0]) {
            argIndex++;
        }
        if (!bFlags[1] && sandbox.analysis && sandbox.analysis.declare) {
            if (bFlags[0] && argIndex > 1) {
                aret = sandbox.analysis.declare(iid, name, val, bFlags[0], argIndex - 2, bFlags[2]);
            } else {
                aret = sandbox.analysis.declare(iid, name, val, bFlags[0], -1, bFlags[2]);
            }
            if (aret) {
                val = aret.result;
            }
        }
        return val;
    }
1236948
@Override
	public String isValidID(String id) {
		Data data;
		try {
			data = identities.find(id, identities.reuse());
		} catch (IOException e) {
			return getName() + " could not lookup " + id + ": " + e.getLocalizedMessage();
		}
		return data==null?id + "is not an Identity in " + getName():null;
	}
776661
private void validateIfdSD(IFD ifd, int p) {
    IfdTags metadata = ifd.getMetadata();

    if (p == 2) {
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[]{0});
    }
    checkRequiredTag(metadata, "ImageLength", 1);
    checkRequiredTag(metadata, "ImageWidth", 1);
    checkRequiredTag(metadata, "BitsPerSample", 1, new long[]{1});
    checkRequiredTag(metadata, "Compression", 1, new long[]{1,4,8});
    checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {5});
    checkRequiredTag(metadata, "StripOffsets", 1);
    if (p == 0) {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1,4,5,8});
    } else {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1});
    }
    if (p == 2) {
      checkRequiredTag(metadata, "SamplesPerPixel", 1, new long[]{1,4});
    }
    checkRequiredTag(metadata, "StripBYTECount", 1);
    checkRequiredTag(metadata, "XResolution", 1);
    checkRequiredTag(metadata, "YResolution", 1);
    checkRequiredTag(metadata, "PlanarConfiguration", 1, new long[]{2});
    if (p == 2) {
      checkRequiredTag(metadata, "ResolutionUnit", 1, new long[]{2, 3});
      checkRequiredTag(metadata, "NumberOfInks", 1, new long[]{4});
    }
    checkRequiredTag(metadata, "InkSet", 1, new long[]{1});
    checkRequiredTag(metadata, "BackgroundColorIndicator", 1, new long[]{0, 1, 2});
  }
1118061
public final void validate() {
    this.accept(new TreeVisitor() {
      @Override
      public boolean preVisit(TreeNode node) {
        node.validateInner();
        return true;
      }
    });
  }
387030
private void CheckCIELab(IfdTags metadata, int n) {
    // BitsPerSample
    if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
      validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
    } else {
      for (abstractTiffType vi : metadata.get(TiffTags.getTagId("BitsPerSample")).getValue()) {
        if (vi.toInt() != 8) {
          validation.addError("Invalid BitsPerSample", "IFD" + n, vi.toInt());
          break;
        }
      }
    }
  }
548882
private void readIFDs() {
    int offset0 = 0;
    try {
      // The pointer to the first IFD is located in bytes 4-7
      offset0 = data.readLong(4).toInt();
      tiffModel.setFirstIFDOffset(offset0);
      if (offset0 == 0)
        validation.addErrorLoc("There is no first IFD", "Header");
      else if (offset0 > data.size())
        validation.addErrorLoc("Incorrect offset", "Header");
    } catch (Exception ex) {
      validation.addErrorLoc("IO exception", "Header");
    }
      
    if (validation.isCorrect()) {
      int nifd = 1;
      try {
        IfdReader ifd0 = readIFD(offset0, true, 0);
        HashSet<Integer> usedOffsets = new HashSet<Integer>();
        usedOffsets.add(offset0);
        if (ifd0.getIfd() == null) {
          validation.addErrorLoc("Parsing error in first IFD", "IFD" + 0);
        } else {
          IFD iifd = ifd0.getIfd();
          iifd.setNextOffset(ifd0.getNextIfdOffset());
          tiffModel.addIfd0(iifd);

          IfdReader current_ifd = ifd0;

          // Read next IFDs
          boolean stop = false;
          while (current_ifd.getNextIfdOffset() > 0 && !stop) {
            if (usedOffsets.contains(current_ifd.getNextIfdOffset())) {
              // Circular reference
              validation.addErrorLoc("IFD offset already used", "IFD" + nifd);
              stop = true;
            } else if (current_ifd.getNextIfdOffset() > data.size()) {
              validation.addErrorLoc("Incorrect offset", "IFD" + nifd);
              stop = true;
            } else {
              usedOffsets.add(current_ifd.getNextIfdOffset());
              IfdReader next_ifd = readIFD(current_ifd.getNextIfdOffset(), true, nifd);
              if (next_ifd == null) {
                validation.addErrorLoc("Parsing error in IFD " + nifd, "IFD" + nifd);
                stop = true;
              } else {
                iifd = next_ifd.getIfd();
                iifd.setNextOffset(next_ifd.getNextIfdOffset());
                current_ifd.getIfd().setNextIFD(iifd);
                current_ifd = next_ifd;
              }
              nifd++;
            }
          }
        }
      } catch (Exception ex) {
        validation.addErrorLoc("IFD parsing error", "IFD" + nifd);
      }

      try {
        tiffModel.createMetadataDictionary();
      } catch (Exception ex) {
      }
    }
  }
1118142
protected boolean isInputValid(String filename, String line, String id, String msg) {
    return !filename.isEmpty() || !line.isEmpty() || !id.isEmpty() || !msg.isEmpty();
  }
1215246
@Override
    public void validate() {
        if (value == null) {
            throw new NoValueGivenException(getPath());
        }

        if (valids.size() != 0) {
            boolean ok = false;
            String valString = (value != null) ? value.toString() : "";

            for (int i = 0; i < valids.size(); i++) {
                if (valids.get(i).equals(valString)) {
                    ok = true;
                    break;
                }
            }

            if (!ok) {
                throw new NoValidValueException(getPath(), valString);
            }
        }

        setValid(true);
    }
481745
public void rTrim(int n) {
        super.rTrim(n);
        this.setQuality(this.quality.substring(0, this.quality.length() - n));
    }
88907
public static void validateNull( Object object, String identifier )
        throws PreConditionException
    {
        if( object == null )
        {
            return;
        }
        throw new PreConditionException( identifier + " was NOT NULL." );
    }
108602
static void checkInternalName(final String name, final String msg) {
        if (name == null || name.length() == 0) {
            throw new IllegalArgumentException("Invalid " + msg
                    + " (must not be null or empty)");
        }
        if (name.charAt(0) == '[') {
            checkDesc(name, false);
        } else {
            checkInternalName(name, 0, -1, msg);
        }
    }
514780
private static boolean isInteger( Number n ) {
      if( n instanceof Integer ){
         return true;
      }
      try{
         Integer.parseInt( String.valueOf( n ) );
         return true;
      }catch( NumberFormatException e ){
         return false;
      }
   }
1089211
public static void validate(final String iban) throws IbanFormatException,
            InvalidCheckDigitException, UnsupportedCountryException {
        try {
            validateEmpty(iban);
            validateCountryCode(iban);
            validateCheckDigitPresence(iban);

            final BbanStructure structure = getBbanStructure(iban);

            validateBbanLength(iban, structure);
            validateBbanEntries(iban, structure);

            validateCheckDigit(iban);
        } catch (Iban4jException e) {
            throw e;
        } catch (RuntimeException e) {
            throw new IbanFormatException(UNKNOWN, e.getMessage());
        }
    }
950684
def validateInterfaceName(n):
    
    try:
        if '.' not in n:
            raise Exception('At least two components required')
        if '..' in n:
            raise Exception('".." not allowed in interface names')
        if len(n) > 255:
            raise Exception('Name exceeds maximum length of 255')
        if n[0] == '.':
            raise Exception('Names may not begin with a "."')
        if n[0].isdigit():
            raise Exception('Names may not begin with a digit')
        if if_re.search(n):
            raise Exception(
                'Names contains a character outside the set [A-Za-z0-9_.]')
        if dot_digit_re.search(n):
            raise Exception(
                'No components of an interface name may begin with a digit')
    except Exception as e:
        raise MarshallingError('Invalid interface name "%s": %s' % (n, str(e)))