Run through series of tests for JP2 box legality.

        This is non-exhaustive.
352853
def _validate_jp2_box_sequence(self, boxes):
        
        JP2_IDS = ['colr', 'cdef', 'cmap', 'jp2c', 'ftyp', 'ihdr', 'jp2h',
                   'jP  ', 'pclr', 'res ', 'resc', 'resd', 'xml ', 'ulst',
                   'uinf', 'url ', 'uuid']

        self._validate_signature_compatibility(boxes)
        self._validate_jp2h(boxes)
        self._validate_jp2c(boxes)
        if boxes[1].brand == 'jpx ':
            self._validate_jpx_box_sequence(boxes)
        else:
            # Validate the JP2 box IDs.
            count = self._collect_box_count(boxes)
            for box_id in count.keys():
                if box_id not in JP2_IDS:
                    msg = ("The presence of a '{0}' box requires that the "
                           "file type brand be set to 'jpx '.")
                    raise IOError(msg.format(box_id))

            self._validate_jp2_colr(boxes)
37385
private boolean checkExistingCertificate() {
		boolean alreadyexists = txt_PubCert.getDocument().getLength() > MIN_CERT_LENGTH;
		if (alreadyexists) {
			final int result = JOptionPane.showConfirmDialog(this,
					Constant.messages.getString("dynssl.message2.caalreadyexists")
					+ "\n"
					+ Constant.messages.getString("dynssl.message2.willreplace")
					+ "\n\n"
					+ Constant.messages.getString("dynssl.message2.wanttooverwrite"),
					Constant.messages.getString("dynssl.message2.title"),
					JOptionPane.YES_NO_OPTION);
			alreadyexists = !(result == JOptionPane.YES_OPTION);
		}
		return alreadyexists;
	}
1315823
private List<TestCaseDef> getBaseCases( FunctionInputDef inputDef, FunctionTestDef baseTests)
    {
    logger_.debug( "{}: Creating base test cases", inputDef);

    List<TestCaseDef> testCases = new ArrayList<TestCaseDef>();
    if( baseTests != null)
      {
      // For each base test case...
      for( Iterator<TestCase> baseCases = baseTests.getTestCases();
           baseCases.hasNext(); )
        {
        // Create the corresponding test case definition...
        TestCase baseTest = baseCases.next();
        TestCaseDef testCase = new TestCaseDef();
        testCase.setId( baseTest.getId());
        logger_.debug( "Adding base test={}", baseTest);

        // For each variable binding...
        for( Iterator<VarBinding> bindings = baseTest.getVarBindings();
             testCase != null && bindings.hasNext();)
          {
          VarBinding binding = bindings.next();
          VarDef var = inputDef.findVarDefPath( binding.getVar());
          VarValueDef value = var==null? null : var.getValue( binding.getValue());

          // Is variable still defined?
          if( var == null)
            {
            logger_.trace( "Var={} undefined", binding.getVar());
            }
          // Is value still defined?
          else if( value == null)
            {
            logger_.trace( "Value={} undefined", binding);
            }
          // Value type unchanged?
          else if( value.isValid() != binding.isValueValid())
            {
            // No, can't preserve this base test.
            logger_.debug
              ( "Can't add {}, {} changed to failure={}",
                new Object[]{ baseTest, binding, !value.isValid()});
            testCase = null;
            }
          else
            {
            // Add variable binding if still compatible.
            testCase.addCompatible( new Tuple( new VarBindingDef( var, value)));
            }
          }

        if( testCase != null && testCase.getVars().hasNext())
          {
          // Add new (possibly incomplete) test case definition for this base test.
          testCases.add( testCase);
          }
        }
      }
    
    logger_.debug( "{}: Completed {} base test cases", inputDef, testCases.size());
    return testCases;
    }
1301864
private static boolean isBundledInJre(String className) {
    if (className.startsWith("javax.accessibility.")
        || className.startsWith("javax.activation.")
        || className.startsWith("javax.activity.")
        || className.startsWith("javax.annotation.")
        || className.startsWith("javax.crypto.")
        || className.startsWith("javax.imageio.")
        || className.startsWith("javax.jws.")
        || className.startsWith("javax.lang.model.")
        || className.startsWith("javax.management.")
        || className.startsWith("javax.naming.")
        || className.startsWith("javax.net.")
        || className.startsWith("javax.print.")
        || className.startsWith("javax.rmi.")
        || className.startsWith("javax.script.")
        || className.startsWith("javax.security.")
        || className.startsWith("javax.sound.")
        || className.startsWith("javax.sql.")
        || className.startsWith("javax.swing.")
        || className.startsWith("javax.tools.")
        || className.startsWith("javax.transaction.")
        || className.startsWith("javax.xml.")) {
      return true;
    }
    return false;
  }
1288138
def _jnzero32(ins):
    
    value = ins.quad[1]
    if is_int(value):
        if int(value) != 0:
            return ['jp %s' % str(ins.quad[2])]  # Always true
        else:
            return []

    output = _32bit_oper(value)
    output.append('ld a, h')
    output.append('or l')
    output.append('or e')
    output.append('or d')
    output.append('jp nz, %s' % str(ins.quad[2]))
    return output
314060
def _validate_jpx_box_sequence(self, boxes):
        """"""
        self._validate_label(boxes)
        self._validate_jpx_compatibility(boxes, boxes[1].compatibility_list)
        self._validate_singletons(boxes)
        self._validate_top_level(boxes)
140006
public boolean guidMatches(Rule other) {
		if (other == null) {
			throw new IllegalArgumentException("other must be non-null");
		}

		boolean matches = true;

		matches &= (guid != null) ? guid.equals(other.getGuid()) : true;

		return matches;
	}
606834
private boolean matchLong(final ByteBuffer bbuf, final ByteOrder bo, final boolean needMask, final long lMask) throws IOException {
		bbuf.order(bo);
		long got;
		final String testContent = getContent();
		if (testContent.startsWith("0x")) {
			got = Long.parseLong(testContent.substring(2), 16);
		} else if (testContent.startsWith("&")) {
			got = Long.parseLong(testContent.substring(3), 16);
		} else {
			got = Long.parseLong(testContent);
		}

		long found = bbuf.getInt();

		if (needMask) {
			found = (short) (found & lMask);
		}

		if (got != found) {
			return false;
		}

		return true;
	}
668014
def validate(self):
    
    if self._validated_binaries:
      return

    with self._valid_executable('java') as java:
      if self._minimum_version:
        version = self._get_version(java)
        if version < self._minimum_version:
          raise self.Error('The java distribution at {} is too old; expecting at least {} and'
                           ' got {}'.format(java, self._minimum_version, version))
      if self._maximum_version:
        version = self._get_version(java)
        if version > self._maximum_version:
          raise self.Error('The java distribution at {} is too new; expecting no older than'
                           ' {} and got {}'.format(java, self._maximum_version, version))

    # We might be a JDK discovered by the embedded jre `java` executable.
    # If so reset the bin path to the true JDK home dir for full access to all binaries.
    self._bin_path = os.path.join(self.home, 'bin')

    try:
      self._validated_executable('javac')  # Calling purely for the check and cache side effects
      self._is_jdk = True
    except self.Error as e:
      if self._jdk:
        logger.debug('Failed to validate javac executable. Please check you have a JDK '
                      'installed. Original error: {}'.format(e))
        raise
1270730
@Override
  public void run() {
    List<CompactionVerifier> verifiers = this.suite.getMapReduceVerifiers();
    for (CompactionVerifier verifier : verifiers) {
      if (!verifier.verify(dataset).isSuccessful()) {
        log.error("Verification {} for {} is not passed.", verifier.getName(), dataset.datasetURN());
        this.onMRTaskComplete (false, new IOException("Compaction verification for MR is failed"));
        return;
      }
    }

    super.run();
  }
24870
public static void main(String[] args) {
        /*
         * Developers Notes:
         *
         * -No corresponding Junit test class currently
         * provided.  Test by eyeball of the output.
         *
         * -Add a menu with Help(About)
         * --> TBD.
         *
         * -Figure out some sane way to set initial default
         * column sizes.
         *
         * -Lots of inner classes here, done in order to keep
         * all the .class files easily identifiable.  Some of
         * this code is pretty ugly, very procedural in nature.
         * Lots of very tight coupling between all the classes,
         * thinly disguised switch statements, etc ..... This
         * code written on the fly, with almost no thought given
         * to OO design.
         *
         * -Also, I'm not really a GUI guy, so forgive any
         * transgressions.
         *
         */
            if ( args.length < 1 ) {
                System.err.println("File name is required!");
                usage();
                System.exit(1);
            }
        /*
         * Instantiate a DateTimeBrowser and invoke it's go method,
         * passing the input argument list.
         */
        new DateTimeBrowser().go( args );
    }
291238
private void verify() {
        Utils.require(!Utils.isEmpty(m_name), "Field name is required");
        Utils.require(m_type != null, "Field type is required");
        
        // If an 'inverse' or 'table' was specified, type must be LINK or XLINK.
        Utils.require(m_linkInverse == null || m_type.isLinkType(),
                      "'inverse' not allowed for this field type: " + m_name);
        Utils.require(m_linkExtent == null || m_type.isLinkType(),
                      "'table' not allowed for this field type: " + m_name);
        
        // LINK and XLINK require an 'inverse'.
        Utils.require(!m_type.isLinkType() || m_linkInverse != null,
                      "Missing 'inverse' option: " + m_name);
        
        // XLINK requires a junction field: default is "_ID".
        if (!Utils.isEmpty(m_junctionField)) {
            Utils.require(m_type == FieldType.XLINK, "'junction' is only allowed for xlinks");
        } else if (m_type == FieldType.XLINK) {
            m_junctionField = "_ID";
        }
        
        // If collection was not explicitly set, set to true for links and false for scalars
        if (!m_bIsCollection && m_type.isLinkType()) {
            m_bIsCollection = true;
        }
        
        // 'analyzer' can only be set for scalar field types, but don't verify value here.
        Utils.require(m_analyzerName == null || m_type.isScalarType(),
                      "'analyzer' can only be specified for scalar field types: " + m_analyzerName);
        
        // If this is a binary field, ensure "encoding" is set.
        if (m_encoding != null) {
            Utils.require(m_type == FieldType.BINARY, "'encoding' is only valid for binary fields");
        } else if (m_type == FieldType.BINARY) {
            m_encoding = EncodingType.getDefaultEncoding();
        }
        
        // Binary fields cannot be collections.
        Utils.require(m_type != FieldType.BINARY || !m_bIsCollection,
                      "Binary fields cannot be collections (multi-valued)");
    }
637306
def _validate(self, writing=False):
        """"""
        box_ids = [box.box_id for box in self.box]
        if len(box_ids) != 1 or box_ids[0] != 'flst':
            msg = ("Fragment table boxes must have a single fragment list "
                   "box as a child box.")
            self._dispatch_validation_error(msg, writing=writing)
1291480
def _get_default_jp2_boxes(self):
        """"""
        # Try to create a reasonable default.
        boxes = [JPEG2000SignatureBox(),
                 FileTypeBox(),
                 JP2HeaderBox(),
                 ContiguousCodestreamBox()]
        height = self.codestream.segment[1].ysiz
        width = self.codestream.segment[1].xsiz
        num_components = len(self.codestream.segment[1].xrsiz)
        if num_components < 3:
            colorspace = core.GREYSCALE
        else:
            if len(self.box) == 0:
                # Best guess is SRGB
                colorspace = core.SRGB
            else:
                # Take whatever the first jp2 header / color specification
                # says.
                jp2hs = [box for box in self.box if box.box_id == 'jp2h']
                colorspace = jp2hs[0].box[1].colorspace

        boxes[2].box = [ImageHeaderBox(height=height, width=width,
                                       num_components=num_components),
                        ColourSpecificationBox(colorspace=colorspace)]

        return boxes
1067731
@JsonIgnore
    public boolean isValid() {
        return StringUtils.isNotBlank(getMetadata())
            && StringUtils.isNotBlank(getSigningCertificate())
            && StringUtils.isNotBlank(getSigningKey())
            && StringUtils.isNotBlank(getEncryptionCertificate())
            && StringUtils.isNotBlank(getEncryptionKey());
    }
658749
def hacking_has_correct_license(physical_line, filename, lines, line_number):
    
    # don't work about init files for now
    # TODO(sdague): enforce license in init file if it's not empty of content

    # skip files that are < 10 lines, which isn't enough for a license to fit
    # this allows us to handle empty files, as well as not fail on the Okay
    # doctests.
    if line_number is 1 and len(lines) > 10 and _project_is_apache():
        for idx, line in enumerate(lines):
            column = line.find('Licensed under the Apache License')
            if (0 < column < 10 and not
                    _check_for_exact_apache(idx, lines)):
                if (line.find('SPDX-License-Identifier: Apache-2.0') <= 0):
                    return (column, "H103: Header does not match Apache 2.0 "
                            "License notice")
1294772
def run(self, path_or_tests, dot_env_path=None, mapping=None):
        
        if validator.is_testcase_path(path_or_tests):
            return self.run_path(path_or_tests, dot_env_path, mapping)
        elif validator.is_testcases(path_or_tests):
            return self.run_tests(path_or_tests)
        else:
            raise exceptions.ParamsError("Invalid testcase path or testcases: {}".format(path_or_tests))