bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
private int getContextPosition(Node ctx) { int pos = 1; for (ctx = ctx.getPreviousSibling(); ctx != null; ctx = ctx.getPreviousSibling()) { pos++; } return pos; }
|
private int getContextPosition(Node ctx) { int pos = 1; for (ctx = ctx.getPreviousSibling(); ctx != null; ctx = ctx.getPreviousSibling()) { pos++; return pos;
| 16,090
|
private int getContextSize(Node ctx) { if (ctx.getNodeType() == Node.ATTRIBUTE_NODE) { Node parent = ((Attr) ctx).getOwnerElement(); return parent.getAttributes().getLength(); } Node parent = ctx.getParentNode(); if (parent != null) { return parent.getChildNodes().getLength(); } return 1; }
|
private int getContextSize(Node ctx) { if (ctx.getNodeType() == Node.ATTRIBUTE_NODE) { Node parent = ((Attr) ctx).getOwnerElement(); return parent.getAttributes().getLength(); } Node parent = ctx.getParentNode(); if (parent != null) { return parent.getChildNodes().getLength(); } return 1; }
| 16,091
|
private int getContextSize(Node ctx) { if (ctx.getNodeType() == Node.ATTRIBUTE_NODE) { Node parent = ((Attr) ctx).getOwnerElement(); return parent.getAttributes().getLength(); } Node parent = ctx.getParentNode(); if (parent != null) { return parent.getChildNodes().getLength(); } return 1; }
|
private int getContextSize(Node ctx) { if (ctx.getNodeType() == Node.ATTRIBUTE_NODE) { Node parent = ((Attr) ctx).getOwnerElement(); return parent.getAttributes().getLength(); } Node parent = ctx.getParentNode(); if (parent != null) { return parent.getChildNodes().getLength(); } return 1; }
| 16,092
|
public boolean matches(Node context) { short nodeType = context.getNodeType(); switch (axis) { case CHILD: if (nodeType == Node.ATTRIBUTE_NODE) { return false; } break; case ATTRIBUTE: case NAMESPACE: if (nodeType != Node.ATTRIBUTE_NODE) { return false; } break; case DESCENDANT_OR_SELF: return true; default: return false; } int tlen = tests.length; if (tlen > 0) { int pos = getContextPosition(context); int len = getContextSize(context); for (int j = 0; j < tlen && len > 0; j++) { Test test = tests[j]; if (!test.matches(context, pos, len)) { return false; } } } return true; }
|
public boolean matches(Node context) short nodeType = context.getNodeType(); switch (axis) case CHILD: if (nodeType == Node.ATTRIBUTE_NODE) return false; } break; case ATTRIBUTE: case NAMESPACE: if (nodeType != Node.ATTRIBUTE_NODE) return false; } break; case DESCENDANT_OR_SELF: return true; default: return false; } int tlen = tests.length; if (tlen > 0) int pos = getContextPosition(context); int len = getContextSize(context); for (int j = 0; j < tlen && len > 0; j++) Test test = tests[j]; if (!test.matches(context, pos, len)) return false; } } } return true; }
| 16,093
|
public boolean matches(Node context) { short nodeType = context.getNodeType(); switch (axis) { case CHILD: if (nodeType == Node.ATTRIBUTE_NODE) { return false; } break; case ATTRIBUTE: case NAMESPACE: if (nodeType != Node.ATTRIBUTE_NODE) { return false; } break; case DESCENDANT_OR_SELF: return true; default: return false; } int tlen = tests.length; if (tlen > 0) { int pos = getContextPosition(context); int len = getContextSize(context); for (int j = 0; j < tlen && len > 0; j++) { Test test = tests[j]; if (!test.matches(context, pos, len)) { return false; } } } return true; }
|
public boolean matches(Node context) { short nodeType = context.getNodeType(); switch (axis) { case CHILD: if (nodeType == Node.ATTRIBUTE_NODE) { return false; break; case ATTRIBUTE: case NAMESPACE: if (nodeType != Node.ATTRIBUTE_NODE) { return false; break; case DESCENDANT_OR_SELF: return true; default: return false; int tlen = tests.length; if (tlen > 0) { int pos = getContextPosition(context); int len = getContextSize(context); for (int j = 0; j < tlen && len > 0; j++) { Test test = tests[j]; if (!test.matches(context, pos, len)) { return false; return true;
| 16,094
|
public boolean references(QName var) { for (int i = 0; i < tests.length; i++) { if (tests[i].references(var)) { return true; } } return false; }
|
public boolean references(QName var) for (int i = 0; i < tests.length; i++) if (tests[i].references(var)) return true; } } return false; }
| 16,095
|
public boolean references(QName var) { for (int i = 0; i < tests.length; i++) { if (tests[i].references(var)) { return true; } } return false; }
|
public boolean references(QName var) { for (int i = 0; i < tests.length; i++) { if (tests[i].references(var)) { return true; return false;
| 16,096
|
public String toString() { StringBuffer buf = new StringBuffer(); switch (axis) { case ANCESTOR: buf.append("ancestor::"); break; case ANCESTOR_OR_SELF: buf.append("ancestor-or-self::"); break; case ATTRIBUTE: if (tests.length == 0 || (tests[0] instanceof NameTest)) { buf.append('@'); } else { buf.append("attribute::"); } break; case CHILD: //buf.append("child::"); break; case DESCENDANT: buf.append("descendant::"); break; case DESCENDANT_OR_SELF: buf.append("descendant-or-self::"); break; case FOLLOWING: buf.append("following::"); break; case FOLLOWING_SIBLING: buf.append("following-sibling::"); break; case NAMESPACE: buf.append("namespace::"); break; case PARENT: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return ".."; } buf.append("parent::"); break; case PRECEDING: buf.append("preceding::"); break; case PRECEDING_SIBLING: buf.append("preceding-sibling::"); break; case SELF: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return "."; } buf.append("self::"); break; } if (tests.length == 0) { buf.append('*'); } else { for (int i = 0; i < tests.length; i++) { buf.append(tests[i]); } } return buf.toString(); }
|
public String toString() StringBuffer buf = new StringBuffer(); switch (axis) case ANCESTOR: buf.append("ancestor::"); break; case ANCESTOR_OR_SELF: buf.append("ancestor-or-self::"); break; case ATTRIBUTE: if (tests.length == 0 || (tests[0] instanceof NameTest)) buf.append('@'); } else buf.append("attribute::"); } break; case CHILD: //buf.append("child::"); break; case DESCENDANT: buf.append("descendant::"); break; case DESCENDANT_OR_SELF: buf.append("descendant-or-self::"); break; case FOLLOWING: buf.append("following::"); break; case FOLLOWING_SIBLING: buf.append("following-sibling::"); break; case NAMESPACE: buf.append("namespace::"); break; case PARENT: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) return ".."; } buf.append("parent::"); break; case PRECEDING: buf.append("preceding::"); break; case PRECEDING_SIBLING: buf.append("preceding-sibling::"); break; case SELF: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) return "."; } buf.append("self::"); break; } if (tests.length == 0) buf.append('*'); } else for (int i = 0; i < tests.length; i++) buf.append(tests[i]); } } return buf.toString(); }
| 16,097
|
public String toString() { StringBuffer buf = new StringBuffer(); switch (axis) { case ANCESTOR: buf.append("ancestor::"); break; case ANCESTOR_OR_SELF: buf.append("ancestor-or-self::"); break; case ATTRIBUTE: if (tests.length == 0 || (tests[0] instanceof NameTest)) { buf.append('@'); } else { buf.append("attribute::"); } break; case CHILD: //buf.append("child::"); break; case DESCENDANT: buf.append("descendant::"); break; case DESCENDANT_OR_SELF: buf.append("descendant-or-self::"); break; case FOLLOWING: buf.append("following::"); break; case FOLLOWING_SIBLING: buf.append("following-sibling::"); break; case NAMESPACE: buf.append("namespace::"); break; case PARENT: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return ".."; } buf.append("parent::"); break; case PRECEDING: buf.append("preceding::"); break; case PRECEDING_SIBLING: buf.append("preceding-sibling::"); break; case SELF: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return "."; } buf.append("self::"); break; } if (tests.length == 0) { buf.append('*'); } else { for (int i = 0; i < tests.length; i++) { buf.append(tests[i]); } } return buf.toString(); }
|
public String toString() { StringBuffer buf = new StringBuffer(); switch (axis) { case ANCESTOR: buf.append("ancestor::"); break; case ANCESTOR_OR_SELF: buf.append("ancestor-or-self::"); break; case ATTRIBUTE: if (tests.length == 0 || (tests[0] instanceof NameTest)) { buf.append('@'); else { buf.append("attribute::"); break; case CHILD: //buf.append("child::"); break; case DESCENDANT: buf.append("descendant::"); break; case DESCENDANT_OR_SELF: buf.append("descendant-or-self::"); break; case FOLLOWING: buf.append("following::"); break; case FOLLOWING_SIBLING: buf.append("following-sibling::"); break; case NAMESPACE: buf.append("namespace::"); break; case PARENT: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return ".."; buf.append("parent::"); break; case PRECEDING: buf.append("preceding::"); break; case PRECEDING_SIBLING: buf.append("preceding-sibling::"); break; case SELF: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return "."; buf.append("self::"); break; if (tests.length == 0) { buf.append('*'); else { for (int i = 0; i < tests.length; i++) { buf.append(tests[i]); return buf.toString();
| 16,098
|
public String toString() { StringBuffer buf = new StringBuffer(); switch (axis) { case ANCESTOR: buf.append("ancestor::"); break; case ANCESTOR_OR_SELF: buf.append("ancestor-or-self::"); break; case ATTRIBUTE: if (tests.length == 0 || (tests[0] instanceof NameTest)) { buf.append('@'); } else { buf.append("attribute::"); } break; case CHILD: //buf.append("child::"); break; case DESCENDANT: buf.append("descendant::"); break; case DESCENDANT_OR_SELF: buf.append("descendant-or-self::"); break; case FOLLOWING: buf.append("following::"); break; case FOLLOWING_SIBLING: buf.append("following-sibling::"); break; case NAMESPACE: buf.append("namespace::"); break; case PARENT: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return ".."; } buf.append("parent::"); break; case PRECEDING: buf.append("preceding::"); break; case PRECEDING_SIBLING: buf.append("preceding-sibling::"); break; case SELF: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return "."; } buf.append("self::"); break; } if (tests.length == 0) { buf.append('*'); } else { for (int i = 0; i < tests.length; i++) { buf.append(tests[i]); } } return buf.toString(); }
|
public String toString() { StringBuffer buf = new StringBuffer(); switch (axis) { case ANCESTOR: buf.append("ancestor::"); break; case ANCESTOR_OR_SELF: buf.append("ancestor-or-self::"); break; case ATTRIBUTE: if (tests.length == 0 || (tests[0] instanceof NameTest)) { buf.append('@'); } else { buf.append("attribute::"); } break; case CHILD: //buf.append("child::"); break; case DESCENDANT: buf.append("descendant::"); break; case DESCENDANT_OR_SELF: buf.append("descendant-or-self::"); break; case FOLLOWING: buf.append("following::"); break; case FOLLOWING_SIBLING: buf.append("following-sibling::"); break; case NAMESPACE: buf.append("namespace::"); break; case PARENT: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return ".."; } buf.append("parent::"); break; case PRECEDING: buf.append("preceding::"); break; case PRECEDING_SIBLING: buf.append("preceding-sibling::"); break; case SELF: if (tests.length == 0 || (tests[0] instanceof NodeTypeTest && ((NodeTypeTest) tests[0]).type == 0)) { return "."; } buf.append("self::"); break; } if (tests.length == 0) { buf.append('*'); } else { for (int i = 0; i < tests.length; i++) { buf.append(tests[i]); } } return buf.toString(); }
| 16,099
|
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { if (! comboBox.isEditable()) { Object currentValue = comboBox.getSelectedItem(); boolean isPressed = arrowButton.getModel().isPressed(); if (currentValue != null) { Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, currentValue, -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); } comboBox.revalidate(); } else comboBox.getEditor().setItem(comboBox.getSelectedItem()); }
|
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { if (! comboBox.isEditable()) { Object currentValue = comboBox.getSelectedItem(); boolean isPressed = arrowButton.getModel().isPressed(); if (currentValue != null) { Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, currentValue, -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); } comboBox.revalidate(); } else comboBox.getEditor().setItem(comboBox.getSelectedItem()); }
| 16,100
|
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { if (! comboBox.isEditable()) { Object currentValue = comboBox.getSelectedItem(); boolean isPressed = arrowButton.getModel().isPressed(); if (currentValue != null) { Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, currentValue, -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); } comboBox.revalidate(); } else comboBox.getEditor().setItem(comboBox.getSelectedItem()); }
|
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { if (! comboBox.isEditable()) { Object currentValue = comboBox.getSelectedItem(); boolean isPressed = arrowButton.getModel().isPressed(); if (currentValue != null) { Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, (currentValue != null ? currentValue : ""), -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); } comboBox.revalidate(); } else comboBox.getEditor().setItem(comboBox.getSelectedItem()); }
| 16,101
|
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { if (! comboBox.isEditable()) { Object currentValue = comboBox.getSelectedItem(); boolean isPressed = arrowButton.getModel().isPressed(); if (currentValue != null) { Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, currentValue, -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); } comboBox.revalidate(); } else comboBox.getEditor().setItem(comboBox.getSelectedItem()); }
|
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { if (! comboBox.isEditable()) { Object currentValue = comboBox.getSelectedItem(); boolean isPressed = arrowButton.getModel().isPressed(); if (currentValue != null) { Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, currentValue, -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); comboBox.revalidate(); else comboBox.getEditor().setItem(comboBox.getSelectedItem());
| 16,102
|
public BasicArrowButton(int direction) { super(); setDirection(direction); setBorder(tmpBorder); }
|
public BasicArrowButton(int direction) { super(); setDirection(direction); }
| 16,103
|
public BasicComboBoxEditor() { editor = new JTextField(); editor.setBorder(null); editor.setColumns(9); listener = new ComboBoxEditorListener(); }
|
public BasicComboBoxEditor() { editor = new JTextField(); editor.setBorder(null); editor.setColumns(9); }
| 16,104
|
public BasicComboBoxRenderer() { setHorizontalAlignment(SwingConstants.LEFT); setBorder(noFocusBorder); }
|
public BasicComboBoxRenderer() { setOpaque(true); setBorder(noFocusBorder); }
| 16,105
|
public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; }
|
public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; }
| 16,106
|
public void remove(Component comp) { synchronized (getTreeLock ()) { for (int i = 0; i < ncomponents; ++i) { if (component[i] == comp) { remove(i); break; } } } }
|
public void remove(Component comp) { synchronized (getTreeLock ()) { for (int i = 0; i < ncomponents; ++i) { if (component[i] == comp) { remove(i); break; } } } }
| 16,107
|
public CertPathValidatorResult engineValidate(CertPath path, CertPathParameters params) throws CertPathValidatorException, InvalidAlgorithmParameterException { if (!(params instanceof PKIXParameters)) throw new InvalidAlgorithmParameterException("not a PKIXParameters object"); // First check if the certificate path is valid. // // This means that: // // (a) for all x in {1, ..., n-1}, the subject of certificate x is // the issuer of certificate x+1; // // (b) for all x in {1, ..., n}, the certificate was valid at the // time in question. // // Because this is the X.509 algorithm, we also check if all // cerificates are of type X509Certificate. PolicyNodeImpl rootNode = new PolicyNodeImpl(); Set initPolicies = ((PKIXParameters) params).getInitialPolicies(); rootNode.setValidPolicy(ANY_POLICY); rootNode.setCritical(false); rootNode.setDepth(0); if (initPolicies != null) rootNode.addAllExpectedPolicies(initPolicies); else rootNode.addExpectedPolicy(ANY_POLICY); List checks = ((PKIXParameters) params).getCertPathCheckers(); List l = path.getCertificates(); if (l == null || l.size() == 0) throw new CertPathValidatorException(); X509Certificate[] p = null; try { p = (X509Certificate[]) l.toArray(new X509Certificate[l.size()]); } catch (ClassCastException cce) { throw new CertPathValidatorException("invalid certificate path"); } String sigProvider = ((PKIXParameters) params).getSigProvider(); PublicKey prevKey = null; Date now = ((PKIXParameters) params).getDate(); if (now == null) now = new Date(); LinkedList policyConstraints = new LinkedList(); for (int i = p.length - 1; i >= 0; i--) { try { p[i].checkValidity(now); } catch (CertificateException ce) { throw new CertPathValidatorException(ce.toString()); } Set uce = getCritExts(p[i]); for (Iterator check = checks.iterator(); check.hasNext(); ) { try { ((PKIXCertPathChecker) check.next()).check(p[i], uce); } catch (Exception x) { } } PolicyConstraint constr = null; if (p[i] instanceof GnuPKIExtension) { Extension pcx = ((GnuPKIExtension) p[i]).getExtension (PolicyConstraint.ID); if (pcx != null) constr = (PolicyConstraint) pcx.getValue(); } else { byte[] pcx = p[i].getExtensionValue (PolicyConstraint.ID.toString()); if (pcx != null) { try { constr = new PolicyConstraint (pcx); } catch (Exception x) { } } } if (constr != null && constr.getRequireExplicitPolicy() >= 0) { policyConstraints.add (new int[] { p.length-i, constr.getRequireExplicitPolicy() }); } updatePolicyTree(p[i], rootNode, p.length-i, (PKIXParameters) params, checkExplicitPolicy (p.length-i, policyConstraints)); // The rest of the tests involve this cert's relationship with the // next in the path. If this cert is the end entity, we can stop. if (i == 0) break; basicSanity(p, i); PublicKey pubKey = null; try { pubKey = p[i].getPublicKey(); if (pubKey instanceof DSAPublicKey) { DSAParams dsa = ((DSAPublicKey) pubKey).getParams(); // If the DSA public key is missing its parameters, use those // from the previous cert's key. if (dsa == null || dsa.getP() == null || dsa.getG() == null || dsa.getQ() == null) { if (prevKey == null) throw new InvalidKeyException("DSA keys not chainable"); if (!(prevKey instanceof DSAPublicKey)) throw new InvalidKeyException("DSA keys not chainable"); dsa = ((DSAPublicKey) prevKey).getParams(); pubKey = new GnuDSAPublicKey(((DSAPublicKey) pubKey).getY(), dsa.getP(), dsa.getQ(), dsa.getG()); } } if (sigProvider == null) p[i-1].verify(pubKey); else p[i-1].verify(pubKey, sigProvider); prevKey = pubKey; } catch (Exception e) { throw new CertPathValidatorException(e.toString()); } if (!p[i].getSubjectDN().equals(p[i-1].getIssuerDN())) throw new CertPathValidatorException("issuer DN mismatch"); boolean[] issuerUid = p[i-1].getIssuerUniqueID(); boolean[] subjectUid = p[i].getSubjectUniqueID(); if (issuerUid != null && subjectUid != null) if (!Arrays.equals(issuerUid, subjectUid)) throw new CertPathValidatorException("UID mismatch"); // Check the certificate against the revocation lists. if (((PKIXParameters) params).isRevocationEnabled()) { X509CRLSelectorImpl selector = new X509CRLSelectorImpl(); try { selector.addIssuerName(p[i].getSubjectDN()); } catch (IOException ioe) { throw new CertPathValidatorException("error selecting CRLs"); } List certStores = ((PKIXParameters) params).getCertStores(); List crls = new LinkedList(); for (Iterator it = certStores.iterator(); it.hasNext(); ) { CertStore cs = (CertStore) it.next(); try { Collection c = cs.getCRLs(selector); crls.addAll(c); } catch (CertStoreException cse) { } } if (crls.isEmpty()) throw new CertPathValidatorException("no CRLs for issuer"); boolean certOk = false; for (Iterator it = crls.iterator(); it.hasNext(); ) { CRL crl = (CRL) it.next(); if (!(crl instanceof X509CRL)) continue; X509CRL xcrl = (X509CRL) crl; if (!checkCRL(xcrl, p, now, p[i], pubKey, certStores)) continue; if (xcrl.isRevoked(p[i-1])) throw new CertPathValidatorException("certificate is revoked"); else certOk = true; } if (!certOk) throw new CertPathValidatorException("certificate's validity could not be determined"); } } rootNode.setReadOnly(); // Now ensure that the first certificate in the chain was issued // by a trust anchor. Exception cause = null; Set anchors = ((PKIXParameters) params).getTrustAnchors(); for (Iterator i = anchors.iterator(); i.hasNext(); ) { TrustAnchor anchor = (TrustAnchor) i.next(); X509Certificate anchorCert = null; PublicKey anchorKey = null; if (anchor.getTrustedCert() != null) { anchorCert = anchor.getTrustedCert(); anchorKey = anchorCert.getPublicKey(); } else anchorKey = anchor.getCAPublicKey(); if (anchorKey == null) continue; try { if (anchorCert != null) anchorCert.checkValidity(now); p[p.length-1].verify(anchorKey); if (anchorCert != null && anchorCert.getBasicConstraints() >= 0 && anchorCert.getBasicConstraints() < p.length) continue; if (((PKIXParameters) params).isRevocationEnabled()) { X509CRLSelectorImpl selector = new X509CRLSelectorImpl(); if (anchorCert != null) try { selector.addIssuerName(anchorCert.getSubjectDN()); } catch (IOException ioe) { } else selector.addIssuerName(anchor.getCAName()); List certStores = ((PKIXParameters) params).getCertStores(); List crls = new LinkedList(); for (Iterator it = certStores.iterator(); it.hasNext(); ) { CertStore cs = (CertStore) it.next(); try { Collection c = cs.getCRLs(selector); crls.addAll(c); } catch (CertStoreException cse) { } } if (crls.isEmpty()) continue; for (Iterator it = crls.iterator(); it.hasNext(); ) { CRL crl = (CRL) it.next(); if (!(crl instanceof X509CRL)) continue; X509CRL xcrl = (X509CRL) crl; try { xcrl.verify(anchorKey); } catch (Exception x) { continue; } Date nextUpdate = xcrl.getNextUpdate(); if (nextUpdate != null && nextUpdate.compareTo(now) < 0) continue; if (xcrl.isRevoked(p[p.length-1])) throw new CertPathValidatorException("certificate is revoked"); } } // The chain is valid; return the result. return new PKIXCertPathValidatorResult(anchor, rootNode, p[0].getPublicKey()); } catch (Exception ignored) { cause = ignored; continue; } } // The path is not valid. CertPathValidatorException cpve = new CertPathValidatorException("path validation failed"); if (cause != null) cpve.initCause (cause); throw cpve; }
|
public CertPathValidatorResult engineValidate(CertPath path, CertPathParameters params) throws CertPathValidatorException, InvalidAlgorithmParameterException { if (!(params instanceof PKIXParameters)) throw new InvalidAlgorithmParameterException("not a PKIXParameters object"); // First check if the certificate path is valid. // // This means that: // // (a) for all x in {1, ..., n-1}, the subject of certificate x is // the issuer of certificate x+1; // // (b) for all x in {1, ..., n}, the certificate was valid at the // time in question. // // Because this is the X.509 algorithm, we also check if all // cerificates are of type X509Certificate. PolicyNodeImpl rootNode = new PolicyNodeImpl(); Set initPolicies = ((PKIXParameters) params).getInitialPolicies(); rootNode.setValidPolicy(ANY_POLICY); rootNode.setCritical(false); rootNode.setDepth(0); if (initPolicies != null) rootNode.addAllExpectedPolicies(initPolicies); else rootNode.addExpectedPolicy(ANY_POLICY); List checks = ((PKIXParameters) params).getCertPathCheckers(); List l = path.getCertificates(); if (l == null || l.size() == 0) throw new CertPathValidatorException(); X509Certificate[] p = null; try { p = (X509Certificate[]) l.toArray(new X509Certificate[l.size()]); } catch (ClassCastException cce) { throw new CertPathValidatorException("invalid certificate path"); } String sigProvider = ((PKIXParameters) params).getSigProvider(); PublicKey prevKey = null; Date now = ((PKIXParameters) params).getDate(); if (now == null) now = new Date(); LinkedList policyConstraints = new LinkedList(); for (int i = p.length - 1; i >= 0; i--) { try { p[i].checkValidity(now); } catch (CertificateException ce) { throw new CertPathValidatorException(ce.toString()); } Set uce = getCritExts(p[i]); for (Iterator check = checks.iterator(); check.hasNext(); ) { try { ((PKIXCertPathChecker) check.next()).check(p[i], uce); } catch (Exception x) { } } PolicyConstraint constr = null; if (p[i] instanceof GnuPKIExtension) { Extension pcx = ((GnuPKIExtension) p[i]).getExtension (PolicyConstraint.ID); if (pcx != null) constr = (PolicyConstraint) pcx.getValue(); } else { byte[] pcx = p[i].getExtensionValue (PolicyConstraint.ID.toString()); if (pcx != null) { try { constr = new PolicyConstraint (pcx); } catch (Exception x) { } } } if (constr != null && constr.getRequireExplicitPolicy() >= 0) { policyConstraints.add (new int[] { p.length-i, constr.getRequireExplicitPolicy() }); } updatePolicyTree(p[i], rootNode, p.length-i, (PKIXParameters) params, checkExplicitPolicy (p.length-i, policyConstraints)); // The rest of the tests involve this cert's relationship with the // next in the path. If this cert is the end entity, we can stop. if (i == 0) break; basicSanity(p, i); PublicKey pubKey = null; try { pubKey = p[i].getPublicKey(); if (pubKey instanceof DSAPublicKey) { DSAParams dsa = ((DSAPublicKey) pubKey).getParams(); // If the DSA public key is missing its parameters, use those // from the previous cert's key. if (dsa == null || dsa.getP() == null || dsa.getG() == null || dsa.getQ() == null) { if (prevKey == null) throw new InvalidKeyException("DSA keys not chainable"); if (!(prevKey instanceof DSAPublicKey)) throw new InvalidKeyException("DSA keys not chainable"); dsa = ((DSAPublicKey) prevKey).getParams(); pubKey = new GnuDSAPublicKey(((DSAPublicKey) pubKey).getY(), dsa.getP(), dsa.getQ(), dsa.getG()); } } if (sigProvider == null) p[i-1].verify(pubKey); else p[i-1].verify(pubKey, sigProvider); prevKey = pubKey; } catch (Exception e) { throw new CertPathValidatorException(e.toString()); } if (!p[i].getSubjectDN().equals(p[i-1].getIssuerDN())) throw new CertPathValidatorException("issuer DN mismatch"); boolean[] issuerUid = p[i-1].getIssuerUniqueID(); boolean[] subjectUid = p[i].getSubjectUniqueID(); if (issuerUid != null && subjectUid != null) if (!Arrays.equals(issuerUid, subjectUid)) throw new CertPathValidatorException("UID mismatch"); // Check the certificate against the revocation lists. if (((PKIXParameters) params).isRevocationEnabled()) { X509CRLSelectorImpl selector = new X509CRLSelectorImpl(); try { selector.addIssuerName(p[i].getSubjectDN()); } catch (IOException ioe) { throw new CertPathValidatorException("error selecting CRLs"); } List certStores = ((PKIXParameters) params).getCertStores(); List crls = new LinkedList(); for (Iterator it = certStores.iterator(); it.hasNext(); ) { CertStore cs = (CertStore) it.next(); try { Collection c = cs.getCRLs(selector); crls.addAll(c); } catch (CertStoreException cse) { } } if (crls.isEmpty()) throw new CertPathValidatorException("no CRLs for issuer"); boolean certOk = false; for (Iterator it = crls.iterator(); it.hasNext(); ) { CRL crl = (CRL) it.next(); if (!(crl instanceof X509CRL)) continue; X509CRL xcrl = (X509CRL) crl; if (!checkCRL(xcrl, p, now, p[i], pubKey, certStores)) continue; if (xcrl.isRevoked(p[i-1])) throw new CertPathValidatorException("certificate is revoked"); else certOk = true; } if (!certOk) throw new CertPathValidatorException("certificate's validity could not be determined"); } } rootNode.setReadOnly(); // Now ensure that the first certificate in the chain was issued // by a trust anchor. Exception cause = null; Set anchors = ((PKIXParameters) params).getTrustAnchors(); for (Iterator i = anchors.iterator(); i.hasNext(); ) { TrustAnchor anchor = (TrustAnchor) i.next(); X509Certificate anchorCert = null; PublicKey anchorKey = null; if (anchor.getTrustedCert() != null) { anchorCert = anchor.getTrustedCert(); anchorKey = anchorCert.getPublicKey(); } else anchorKey = anchor.getCAPublicKey(); if (anchorKey == null) continue; try { if (anchorCert != null) anchorCert.checkValidity(now); p[p.length-1].verify(anchorKey); if (anchorCert != null && anchorCert.getBasicConstraints() >= 0 && anchorCert.getBasicConstraints() < p.length) continue; if (((PKIXParameters) params).isRevocationEnabled()) { X509CRLSelectorImpl selector = new X509CRLSelectorImpl(); if (anchorCert != null) try { selector.addIssuerName(anchorCert.getSubjectDN()); } catch (IOException ioe) { } else selector.addIssuerName(anchor.getCAName()); List certStores = ((PKIXParameters) params).getCertStores(); List crls = new LinkedList(); for (Iterator it = certStores.iterator(); it.hasNext(); ) { CertStore cs = (CertStore) it.next(); try { Collection c = cs.getCRLs(selector); crls.addAll(c); } catch (CertStoreException cse) { } } if (crls.isEmpty()) continue; for (Iterator it = crls.iterator(); it.hasNext(); ) { CRL crl = (CRL) it.next(); if (!(crl instanceof X509CRL)) continue; X509CRL xcrl = (X509CRL) crl; try { xcrl.verify(anchorKey); } catch (Exception x) { continue; } Date nextUpdate = xcrl.getNextUpdate(); if (nextUpdate != null && nextUpdate.compareTo(now) < 0) continue; if (xcrl.isRevoked(p[p.length-1])) throw new CertPathValidatorException("certificate is revoked"); } } // The chain is valid; return the result. return new PKIXCertPathValidatorResult(anchor, rootNode, p[0].getPublicKey()); } catch (Exception ignored) { cause = ignored; continue; } } // The path is not valid. CertPathValidatorException cpve = new CertPathValidatorException("path validation failed"); if (cause != null) cpve.initCause (cause); throw cpve; }
| 16,108
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (DEBUG) debug("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (DEBUG) debug("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (DEBUG) debug("read value == " + value); }
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (Configuration.DEBUG) log.fine("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (DEBUG) debug("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (DEBUG) debug("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (DEBUG) debug("read value == " + value); }
| 16,109
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (DEBUG) debug("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (DEBUG) debug("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (DEBUG) debug("read value == " + value); }
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (Configuration.DEBUG) log.fine("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (DEBUG) debug("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (DEBUG) debug("read value == " + value); }
| 16,110
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (DEBUG) debug("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (DEBUG) debug("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (DEBUG) debug("read value == " + value); }
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (DEBUG) debug("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (Configuration.DEBUG) log.fine("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (DEBUG) debug("read value == " + value); }
| 16,111
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (DEBUG) debug("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (DEBUG) debug("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (DEBUG) debug("read value == " + value); }
|
public Extension(byte[] encoded) throws IOException { this.encoded = (byte[]) encoded.clone(); DERReader der = new DERReader(encoded); // Extension ::= SEQUENCE { DERValue val = der.read(); if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength()); if (!val.isConstructed()) throw new IOException("malformed Extension"); // extnID OBJECT IDENTIFIER, val = der.read(); if (val.getTag() != DER.OBJECT_IDENTIFIER) throw new IOException("expecting OBJECT IDENTIFIER"); oid = (OID) val.getValue(); if (DEBUG) debug("read oid == " + oid); // critical BOOLEAN DEFAULT FALSE, val = der.read(); if (val.getTag() == DER.BOOLEAN) { critical = ((Boolean) val.getValue()).booleanValue(); val = der.read(); } else critical = false; if (DEBUG) debug("is critical == " + critical); // extnValue OCTET STRING } if (val.getTag() != DER.OCTET_STRING) throw new IOException("expecting OCTET STRING"); byte[] encval = (byte[]) val.getValue(); isSupported = true; if (oid.equals(AuthorityKeyIdentifier.ID)) { value = new AuthorityKeyIdentifier(encval); } else if (oid.equals(SubjectKeyIdentifier.ID)) { value = new SubjectKeyIdentifier(encval); } else if (oid.equals(KeyUsage.ID)) { value = new KeyUsage(encval); } else if (oid.equals(PrivateKeyUsagePeriod.ID)) { value = new PrivateKeyUsagePeriod(encval); } else if (oid.equals(CertificatePolicies.ID)) { value = new CertificatePolicies(encval); } else if (oid.equals (PolicyConstraint.ID)) { value = new PolicyConstraint (encval); } else if (oid.equals(PolicyMappings.ID)) { value = new PolicyMappings(encval); } else if (oid.equals(SubjectAlternativeNames.ID)) { value = new SubjectAlternativeNames(encval); } else if (oid.equals(IssuerAlternativeNames.ID)) { value = new IssuerAlternativeNames(encval); } else if (oid.equals(BasicConstraints.ID)) { value = new BasicConstraints(encval); } else if (oid.equals(ExtendedKeyUsage.ID)) { value = new ExtendedKeyUsage(encval); } else if (oid.equals(CRLNumber.ID)) { value = new CRLNumber(encval); } else if (oid.equals(ReasonCode.ID)) { value = new ReasonCode(encval); } else { value = new Value(encval); isSupported = false; } if (Configuration.DEBUG) log.fine("read value == " + value); }
| 16,112
|
public int compareTo(Date when) { return (getTime() < when.getTime()) ? -1 : (getTime() == when.getTime()) ? 0 : 1; }
|
public int compareTo(Date when) { return (getTime() < when.getTime()) ? -1 : (getTime() == when.getTime()) ? 0 : 1; }
| 16,113
|
engineValidate(CertPath certPath, CertPathParameters params) throws CertPathValidatorException, java.security.InvalidAlgorithmParameterException;
|
engineValidate(CertPath certPath, CertPathParameters params) throws CertPathValidatorException, InvalidAlgorithmParameterException;
| 16,114
|
public Date() { this(System.currentTimeMillis()); }
|
public Date() { this(System.currentTimeMillis()); }
| 16,115
|
public abstract void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException;
|
public abstract void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException;
| 16,116
|
public static boolean equals(Object[] a1, Object[] a2) { // Quick test which saves comparing elements of the same array, and also // catches the case that both are null. if (a1 == a2) return true; if (null == a1 || null == a2) return false; // If they're the same length, test each element if (a1.length == a2.length) { int i = a1.length; while (--i >= 0) if (! AbstractCollection.equals(a1[i], a2[i])) return false; return true; } return false; }
|
public static boolean equals(boolean[] a1, boolean[] a2) { // Quick test which saves comparing elements of the same array, and also // catches the case that both are null. if (a1 == a2) return true; if (null == a1 || null == a2) return false; // If they're the same length, test each element if (a1.length == a2.length) { int i = a1.length; while (--i >= 0) if (! AbstractCollection.equals(a1[i], a2[i])) return false; return true; } return false; }
| 16,117
|
public static boolean equals(Object[] a1, Object[] a2) { // Quick test which saves comparing elements of the same array, and also // catches the case that both are null. if (a1 == a2) return true; if (null == a1 || null == a2) return false; // If they're the same length, test each element if (a1.length == a2.length) { int i = a1.length; while (--i >= 0) if (! AbstractCollection.equals(a1[i], a2[i])) return false; return true; } return false; }
|
public static boolean equals(Object[] a1, Object[] a2) { // Quick test which saves comparing elements of the same array, and also // catches the case that both are null. if (a1 == a2) return true; if (null == a1 || null == a2) return false; // If they're the same length, test each element if (a1.length == a2.length) { int i = a1.length; while (--i >= 0) if (a1[i] != a2[i]) return false; return true; } return false; }
| 16,118
|
public void addIssuerName(Principal issuerName) throws IOException { if (issuerName instanceof X500DistinguishedName) issuerNames.add(issuerName); else if (issuerName instanceof X500Principal) issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded())); else issuerNames.add(new X500DistinguishedName(issuerName.getName())); }
|
public void addIssuerName(byte[] issuerName) throws IOException { if (issuerName instanceof X500DistinguishedName) issuerNames.add(issuerName); else if (issuerName instanceof X500Principal) issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded())); else issuerNames.add(new X500DistinguishedName(issuerName.getName())); }
| 16,119
|
public void addIssuerName(Principal issuerName) throws IOException { if (issuerName instanceof X500DistinguishedName) issuerNames.add(issuerName); else if (issuerName instanceof X500Principal) issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded())); else issuerNames.add(new X500DistinguishedName(issuerName.getName())); }
|
public void addIssuerName(Principal issuerName) throws IOException { if (issuerName instanceof X500DistinguishedName) issuerNames.add(issuerName); else if (issuerName instanceof X500Principal) issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded())); else issuerNames.add(new X500DistinguishedName(issuerName.getName())); }
| 16,120
|
public final Class getCategory() { return JobImpressionsSupported.class; }
|
public Class getCategory() { return JobImpressionsSupported.class; }
| 16,121
|
public final String getName() { return "job-impressions-supported"; }
|
public String getName() { return "job-impressions-supported"; }
| 16,122
|
public boolean equals(Object obj) { if (obj instanceof ActivationDesc) { ActivationDesc that = (ActivationDesc) obj; return groupid.equals(that.groupid) && classname.equals(that.classname) && location.equals(that.location) && data.equals(that.data) && restart == that.restart; } else return false; }
|
public boolean equals(Object obj) { if (obj instanceof ActivationDesc) { ActivationDesc that = (ActivationDesc) obj; return groupid.equals(that.groupid) && classname.equals(that.classname) && location.equals(that.location) && data.equals(that.data) && restart == that.restart; } else return false; }
| 16,123
|
public int hashCode() { return groupid.hashCode() ^ classname.hashCode() ^ location.hashCode() ^ data.hashCode(); }
|
public int hashCode() { return groupid.hashCode() ^ classname.hashCode() ^ location.hashCode() ^ data.hashCode(); }
| 16,124
|
public static ActivationGroupID currentGroupID() { throw new Error("Not implemented");}
|
public static ActivationGroupID currentGroupID() { throw new Error("Not implemented");}
| 16,125
|
public boolean equals(Object obj) { if (obj instanceof ActivationGroupID) { ActivationGroupID that = (ActivationGroupID) obj; return system.equals(that.system); } else return false; }
|
public boolean equals(Object obj) { if (obj instanceof ActivationGroupID) { ActivationGroupID that = (ActivationGroupID) obj; return uid.equals(that.uid); } else return false; }
| 16,126
|
public int hashCode() { return system.hashCode(); }
|
public int hashCode() { return uid.hashCode(); }
| 16,127
|
long write(ByteBuffer[] srcs) throws IOException;
|
long write(ByteBuffer[] srcs, int offset, int length) throws IOException;
| 16,128
|
clone(){ try { return(super.clone()); } catch(Exception e) { return(null); }}
|
public Object clone () throws CloneNotSupportedException{ try { return(super.public Object clone () throws CloneNotSupportedException); } catch(Exception e) { return(null); }}
| 16,129
|
getParameter(String paramName, String mimeString){ int idx = mimeString.indexOf(paramName + "="); if (idx == -1) return(null); String value = mimeString.substring(idx + paramName.length() + 2); idx = value.indexOf(" "); if (idx == -1) return(value); else return(value.substring(0, idx));}
|
getParameter(String paramName, String mimeString){ int idx = mimeString.indexOf(paramName + "="); if (idx == -1) return(null); String value = mimeString.substring(idx + paramName.length() + 1); idx = value.indexOf(" "); if (idx == -1) return(value); else return(value.substring(0, idx));}
| 16,130
|
getReaderForText(Transferable transferable) throws UnsupportedFlavorException, IOException, UnsupportedEncodingException{ if (!transferable.isDataFlavorSupported(this)) throw new UnsupportedFlavorException(this); if (Reader.class.isAssignableFrom(representationClass)) return((Reader)transferable.getTransferData(this)); if (String.class.isAssignableFrom(representationClass)) return(new StringReader((String)transferable.getTransferData(this))); if (InputStream.class.isAssignableFrom(representationClass) && "text".equals(getPrimaryType())) { InputStream in = (InputStream)transferable.getTransferData(this); String encoding = getParameter("charset"); if (encoding == null) encoding = "us-ascii"; return(new InputStreamReader(in, encoding)); } throw new UnsupportedFlavorException(this);}
|
getReaderForText(Transferable transferable) throws UnsupportedFlavorException, IOException, UnsupportedEncodingException{ if (!transferable.isDataFlavorSupported(this)) throw new UnsupportedFlavorException(this); if (Reader.class.isAssignableFrom(representationClass)) return((Reader)transferable.getTransferData(this)); if (String.class.isAssignableFrom(representationClass)) return(new StringReader((String)transferable.getTransferData(this))); if (InputStream.class.isAssignableFrom(representationClass) && "text".equals(getPrimaryType())) { InputStream in = (InputStream)transferable.getTransferData(this); String encoding = getParameter("charset"); if (encoding == null) encoding = "us-ascii"; return(new InputStreamReader(in, encoding)); } throw new UnsupportedFlavorException(this);}
| 16,131
|
tryToLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException{ try { return(Class.forName(className)); } catch(Exception e) { } // Commented out for Java 1.1 /* try { return(className.getClass().getClassLoader().findClass(className)); } catch(Exception e) { ; } try { return(ClassLoader.getSystemClassLoader().findClass(className)); } catch(Exception e) { ; } */ // FIXME: What is the context class loader? /* try { } catch(Exception e) { ; } */ if (classLoader != null) return(classLoader.loadClass(className)); else throw new ClassNotFoundException(className);}
|
tryToLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException{ try { return(Class.forName(className)); } catch(Exception e) { ; } // Commented out for Java 1.1 /* try { return(className.getClass().getClassLoader().findClass(className)); } catch(Exception e) { ; } try { return(ClassLoader.getSystemClassLoader().findClass(className)); } catch(Exception e) { ; } */ // FIXME: What is the context class loader? /* try { } catch(Exception e) { ; } */ if (classLoader != null) return(classLoader.loadClass(className)); else throw new ClassNotFoundException(className);}
| 16,132
|
public abstract boolean isDataFlavorSupported(DataFlavor flavor);
|
boolean isDataFlavorSupported(DataFlavor flavor);
| 16,133
|
public abstract Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException;
|
Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException;
| 16,134
|
getParameter(String paramName){ return getParameter(paramName, mimeType);}
|
getParameter(String paramName, String mimeString){ return getParameter(paramName, mimeType);}
| 16,135
|
getParameter(String paramName){ return getParameter(paramName, mimeType);}
|
getParameter(String paramName){ int idx = mimeString.indexOf(paramName + "="); if (idx == -1) return(null); String value = mimeString.substring(idx + paramName.length() + 1); idx = value.indexOf(" "); if (idx == -1) return(value); else return(value.substring(0, idx));}
| 16,136
|
public ClassNotFoundException(String s) { this(s, null); }
|
public ClassNotFoundException(String s) { this(null, null); }
| 16,137
|
void setLocale (Locale loc) { if (type == null) ; else if (type.equals("number")) { formatClass = java.lang.Number.class; if (style == null) format = NumberFormat.getInstance(loc); else if (style.equals("currency")) format = NumberFormat.getCurrencyInstance(loc); else if (style.equals("percent")) format = NumberFormat.getPercentInstance(loc); else if (style.equals("integer")) { NumberFormat nf = NumberFormat.getNumberInstance(loc); nf.setMaximumFractionDigits(0); nf.setGroupingUsed(false); format = nf; } else { format = NumberFormat.getNumberInstance(loc); DecimalFormat df = (DecimalFormat) format; df.applyPattern(style); } } else if (type.equals("time") || type.equals("date")) { formatClass = java.util.Date.class; int val = DateFormat.DEFAULT; if (style == null) ; else if (style.equals("short")) val = DateFormat.SHORT; else if (style.equals("medium")) val = DateFormat.MEDIUM; else if (style.equals("long")) val = DateFormat.LONG; else if (style.equals("full")) val = DateFormat.FULL; if (type.equals("time")) format = DateFormat.getTimeInstance(val, loc); else format = DateFormat.getDateInstance(val, loc); if (style != null && val == DateFormat.DEFAULT) { SimpleDateFormat sdf = (SimpleDateFormat) format; sdf.applyPattern(style); } } else if (type.equals("choice")) { formatClass = java.lang.Number.class; if (style == null) throw new IllegalArgumentException ("style required for choice format"); format = new ChoiceFormat (style); } }
|
void setLocale (Locale loc) { if (type == null) ; else if (type.equals("number")) { formatClass = java.lang.Number.class; if (style == null) format = NumberFormat.getInstance(loc); else if (style.equals("currency")) format = NumberFormat.getCurrencyInstance(loc); else if (style.equals("percent")) format = NumberFormat.getPercentInstance(loc); else if (style.equals("integer")) { NumberFormat nf = NumberFormat.getNumberInstance(loc); nf.setMaximumFractionDigits(0); nf.setGroupingUsed(false); format = nf; } else { format = NumberFormat.getNumberInstance(loc); DecimalFormat df = (DecimalFormat) format; df.applyPattern(style); } } else if (type.equals("time") || type.equals("date")) { formatClass = java.util.Date.class; int val = DateFormat.DEFAULT; if (style == null) ; else if (style.equals("short")) val = DateFormat.SHORT; else if (style.equals("medium")) val = DateFormat.MEDIUM; else if (style.equals("long")) val = DateFormat.LONG; else if (style.equals("full")) val = DateFormat.FULL; if (type.equals("time")) format = DateFormat.getTimeInstance(val, loc); else format = DateFormat.getDateInstance(val, loc); if (styleIsPattern) { SimpleDateFormat sdf = (SimpleDateFormat) format; sdf.applyPattern(style); } } else if (type.equals("choice")) { formatClass = java.lang.Number.class; if (style == null) throw new IllegalArgumentException ("style required for choice format"); format = new ChoiceFormat (style); } }
| 16,138
|
public Field(String name) { super(name); }
|
protected Field(String name) { super(name); }
| 16,139
|
public static NumberFormat getCurrencyInstance (Locale loc) { NumberFormat format; format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)"); format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits()); return format; }
|
public static final NumberFormat getCurrencyInstance () { NumberFormat format; format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)"); format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits()); return format; }
| 16,140
|
public static NumberFormat getCurrencyInstance (Locale loc) { NumberFormat format; format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)"); format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits()); return format; }
|
public static NumberFormat getCurrencyInstance (Locale loc) { NumberFormat format; format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)"); format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits()); return format; }
| 16,141
|
public int hashCode() { return hashcode; }
|
public int hashCode() { return hashcodeCache; }
| 16,142
|
public static int parseInt(String s) { return parseInt(s, 10, false); }
|
public static int parseInt(String str, int radix) { return parseInt(s, 10, false); }
| 16,143
|
public static int parseInt(String s) { return parseInt(s, 10, false); }
|
public static int parseInt(String s) { return parseInt(str, radix, false); }
| 16,144
|
JRootPane() { setLayout(createRootLayout()); getGlassPane(); getLayeredPane(); getContentPane(); setDoubleBuffered(true); updateUI(); }
|
public JRootPane() { setLayout(createRootLayout()); getGlassPane(); getLayeredPane(); getContentPane(); setDoubleBuffered(true); updateUI(); }
| 16,145
|
JComponent createContentPane() { JPanel p = new JPanel(); p.setName(this.getName()+".contentPane"); p.setLayout(new BorderLayout()); return p; }
|
protected JComponent createContentPane() { JPanel p = new JPanel(); p.setName(this.getName()+".contentPane"); p.setLayout(new BorderLayout()); return p; }
| 16,146
|
Component createGlassPane() { JPanel p = new JPanel(); p.setName(this.getName()+".glassPane"); p.setLayout(new BorderLayout()); p.setVisible(false); return p; }
|
protected Component createGlassPane() { JPanel p = new JPanel(); p.setName(this.getName()+".glassPane"); p.setLayout(new BorderLayout()); p.setVisible(false); return p; }
| 16,147
|
JLayeredPane createLayeredPane() { JLayeredPane l = new JLayeredPane(); l.setLayout(null); return l; }
|
protected JLayeredPane createLayeredPane() { JLayeredPane l = new JLayeredPane(); l.setLayout(null); return l; }
| 16,148
|
public Container getContentPane() { if (contentPane == null) { setContentPane(createContentPane()); } return contentPane; }
|
public Container getContentPane() if (contentPane == null) setContentPane(createContentPane()); } return contentPane; }
| 16,149
|
public Container getContentPane() { if (contentPane == null) { setContentPane(createContentPane()); } return contentPane; }
|
public Container getContentPane() { if (contentPane == null) { setContentPane(createContentPane()); return contentPane;
| 16,150
|
JMenuBar getJMenuBar() { return menuBar; }
|
JMenuBar getJMenuBar() { return menuBar; }
| 16,151
|
void setJMenuBar(JMenuBar m) { menuBar = m; getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER); }
|
public void setJMenuBar(JMenuBar m) { menuBar = m; getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER); }
| 16,152
|
void addLayoutComponent(Component component, Object contraint);
|
void addLayoutComponent(Component component, Object contraints);
| 16,153
|
public Dimension getSize(Dimension d) { if (d == null) d = new Dimension(); d.width = width; d.height = height; return d; }
|
public Dimension getSize() { if (d == null) d = new Dimension(); d.width = width; d.height = height; return d; }
| 16,154
|
public Dimension getSize(Dimension d) { if (d == null) d = new Dimension(); d.width = width; d.height = height; return d; }
|
public Dimension getSize(Dimension d) { if (d == null) d = new Dimension(); d.width = width; d.height = height; return d; }
| 16,155
|
JLayeredPane() { layers = new TreeMap (); componentToLayer = new Hashtable (); }
|
public JLayeredPane() { layers = new TreeMap (); componentToLayer = new Hashtable (); }
| 16,156
|
protected abstract void shutdownInput () throws IOException;
|
protected void shutdownInput() throws IOException { throw new IOException("Not implemented in this socket class"); }
| 16,157
|
protected abstract void shutdownOutput () throws IOException;
|
protected void shutdownOutput() throws IOException { throw new IOException("Not implemented in this socket class"); }
| 16,158
|
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; /* Menu item is considered to be highlighted when it is selected. It is considered to be selected if menu item is inside some menu and is armed or if it is both armed and pressed */ if (m.getModel().isArmed() && (m.getParent() instanceof MenuElement || m.getModel().isPressed())) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (! ((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint icon // FIXME: should paint different icon at different button state's. // i.e disabled icon when button is disabled.. etc. Icon i = m.getIcon(); if (i != null) { i.paintIcon(c, g, vr.x, vr.y); // Adjust view rectangle, s.t text would be drawn after menu item's icon. vr.x += i.getIconWidth() + defaultTextIconGap; } // paint text and user menu icon if it exists SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(), vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
|
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; /* Menu item is considered to be highlighted when it is selected. It is considered to be selected if menu item is inside some menu and is armed or if it is both armed and pressed */ if (m.getModel().isArmed() && (m.getParent() instanceof MenuElement || m.getModel().isPressed())) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (! ((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint icon // FIXME: should paint different icon at different button state's. // i.e disabled icon when button is disabled.. etc. Icon i = m.getIcon(); if (i != null) { i.paintIcon(c, g, vr.x, vr.y); // Adjust view rectangle, s.t text would be drawn after menu item's icon. vr.x += i.getIconWidth() + defaultTextIconGap; } // paint text and user menu icon if it exists SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(), vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
| 16,160
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,162
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selectedPath.size(); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,163
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,164
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selectedPath.size(); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,165
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,166
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,167
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,168
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedPath; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,169
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelectedPath = (MenuElement) selectedPath.get(i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,170
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals(oldSelectedPath)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,171
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
|
public void setSelectedPath (MenuElement[] path) { if (path == null) { clearSelectedPath (); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selection.size ()) { // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selection.size for (i = selection.size (); i < path.length; i++) { selection.add (path[i]); path[i].menuSelectionChanged (true); } minSize = selection.size (); } else if (path.length < selection.size ()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selection.size () - 1; i >= path.length; i--) { ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.remove (i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelection; for (i = minSize - 1; i >= 0; i--) { oldSelection = (MenuElement) selection.get (i); if (path[i].equals (oldSelection)) break; oldSelection.menuSelectionChanged (false); path[i].menuSelectionChanged (true); selection.setElementAt (path[i], i); } }
| 16,172
|
public void clearSelectedPath () { for (int i = 0; i < selection.size (); i++) ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.clear (); }
|
public void clearSelectedPath () { for (int i = 0; i < selection.size (); i++) ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.clear (); }
| 16,173
|
public void clearSelectedPath () { for (int i = 0; i < selection.size (); i++) ((MenuElement) selection.get (i)).menuSelectionChanged (false); selection.clear (); }
|
public void clearSelectedPath () { for (int i = 0; i < selection.size (); i++) ((MenuElement) selection.get (i)).menuSelectionChanged (false); fireStateChanged(); selectedPath.clear(); }
| 16,174
|
public void processMouseEvent (MouseEvent event) { Component c = ((MenuElement) event.getSource ()).getComponent (); if (selection.size () == 0) { ((MenuElement) event.getSource ()).processMouseEvent (event, getPath (c), manager); return; } // find the index of the source component in the current menu hierarchy int i = 0; for (i = 0; i < selection.size (); i++) { MenuElement me = (MenuElement) selection.get (i); if (me.getComponent ().equals (c)) break; } // Forward event to all subcomponents of the source Component subComp; for (int j = i; j < selection.size (); j++) { subComp = ((MenuElement)selection.get (j)).getComponent (); ((MenuElement) selection.get (j)).processMouseEvent (event, getPath (subComp), manager); } }
|
public void processMouseEvent (MouseEvent event) { Component c = ((MenuElement) event.getSource ()).getComponent (); if (selection.size () == 0) { ((MenuElement) event.getSource ()).processMouseEvent (event, getPath (c), manager); return; } // find the index of the source component in the current menu hierarchy int i = 0; for (i = 0; i < selection.size (); i++) { MenuElement me = (MenuElement) selection.get (i); if (me.getComponent ().equals (c)) break; } // Forward event to all subcomponents of the source Component subComp; for (int j = i; j < selection.size (); j++) { subComp = ((MenuElement)selection.get (j)).getComponent (); ((MenuElement) selection.get (j)).processMouseEvent (event, getPath (subComp), manager); } }
| 16,175
|
public void processMouseEvent (MouseEvent event) { Component c = ((MenuElement) event.getSource ()).getComponent (); if (selection.size () == 0) { ((MenuElement) event.getSource ()).processMouseEvent (event, getPath (c), manager); return; } // find the index of the source component in the current menu hierarchy int i = 0; for (i = 0; i < selection.size (); i++) { MenuElement me = (MenuElement) selection.get (i); if (me.getComponent ().equals (c)) break; } // Forward event to all subcomponents of the source Component subComp; for (int j = i; j < selection.size (); j++) { subComp = ((MenuElement)selection.get (j)).getComponent (); ((MenuElement) selection.get (j)).processMouseEvent (event, getPath (subComp), manager); } }
|
public void processMouseEvent (MouseEvent event) { Component c = ((MenuElement) event.getSource ()).getComponent (); if (selection.size () == 0) { ((MenuElement) event.getSource ()).processMouseEvent (event, getPath (c), manager); return; } // find the index of the source component in the current menu hierarchy int i = 0; for (i = 0; i < selection.size (); i++) { MenuElement me = (MenuElement) selection.get (i); if (me.getComponent ().equals (c)) break; } // Forward event to all subcomponents of the source Component subComp; for (int j = i; j < selection.size (); j++) { subComp = ((MenuElement)selection.get (j)).getComponent (); ((MenuElement) selection.get (j)).processMouseEvent (event, getPath (subComp), manager); } }
| 16,176
|
stringWidth(String str){ char[] buf = new char[str.length()]; str.getChars(0, str.length(), buf, 0); return(charsWidth(buf, 0, buf.length));}
|
stringWidth(String str){ char[] buf = new char[str.length()]; str.getChars(0, str.length(), buf, 0); return(charsWidth(buf, 0, buf.length));}
| 16,177
|
stringWidth(String str){ char[] buf = new char[str.length()]; str.getChars(0, str.length(), buf, 0); return(charsWidth(buf, 0, buf.length));}
|
stringWidth(String str){ char[] buf = new char[str.length()]; str.getChars(0, str.length(), buf, 0); return(charsWidth(buf, 0, buf.length));}
| 16,178
|
getHeight(){ return(getAscent() + getDescent() + getLeading());}
|
getHeight(){ return(getAscent() + getDescent() + getLeading());}
| 16,179
|
public static String getKeyText(int keyCode) { switch (keyCode) { case VK_CANCEL: return "Cancel"; case VK_BACK_SPACE: return "Backspace"; case VK_TAB: return "Tab"; case VK_ENTER: return "Enter"; case VK_CLEAR: return "Clear"; case VK_SHIFT: return "Shift"; case VK_CONTROL: return "Ctrl"; case VK_ALT: return "Alt"; case VK_PAUSE: return "Pause"; case VK_CAPS_LOCK: return "Caps Lock"; case VK_KANA: return "Kana"; case VK_FINAL: return "Final"; case VK_KANJI: return "Kanji"; case VK_ESCAPE: return "Escape"; case VK_CONVERT: return "Convert"; case VK_NONCONVERT: return "No Convert"; case VK_ACCEPT: return "Accept"; case VK_MODECHANGE: return "Mode Change"; case VK_SPACE: return "Space"; case VK_PAGE_UP: return "Page Up"; case VK_PAGE_DOWN: return "Page Down"; case VK_END: return "End"; case VK_HOME: return "Home"; case VK_LEFT: case VK_KP_LEFT: return "Left"; case VK_UP: case VK_KP_UP: return "Up"; case VK_RIGHT: case VK_KP_RIGHT: return "Right"; case VK_DOWN: case VK_KP_DOWN: return "Down"; case VK_MINUS: return "Minus"; case VK_MULTIPLY: return "NumPad *"; case VK_ADD: return "NumPad +"; case VK_SEPARATOR: return "NumPad ,"; case VK_SUBTRACT: return "NumPad -"; case VK_DECIMAL: return "NumPad ."; case VK_DIVIDE: return "NumPad /"; case VK_DELETE: return "Delete"; case VK_DEAD_GRAVE: return "Dead Grave"; case VK_DEAD_ACUTE: return "Dead Acute"; case VK_DEAD_CIRCUMFLEX: return "Dead Circumflex"; case VK_DEAD_TILDE: return "Dead Tilde"; case VK_DEAD_MACRON: return "Dead Macron"; case VK_DEAD_BREVE: return "Dead Breve"; case VK_DEAD_ABOVEDOT: return "Dead Above Dot"; case VK_DEAD_DIAERESIS: return "Dead Diaeresis"; case VK_DEAD_ABOVERING: return "Dead Above Ring"; case VK_DEAD_DOUBLEACUTE: return "Dead Double Acute"; case VK_DEAD_CARON: return "Dead Caron"; case VK_DEAD_CEDILLA: return "Dead Cedilla"; case VK_DEAD_OGONEK: return "Dead Ogonek"; case VK_DEAD_IOTA: return "Dead Iota"; case VK_DEAD_VOICED_SOUND: return "Dead Voiced Sound"; case VK_DEAD_SEMIVOICED_SOUND: return "Dead Semivoiced Sound"; case VK_NUM_LOCK: return "Num Lock"; case VK_SCROLL_LOCK: return "Scroll Lock"; case VK_AMPERSAND: return "Ampersand"; case VK_ASTERISK: return "Asterisk"; case VK_QUOTEDBL: return "Double Quote"; case VK_LESS: return "Less"; case VK_PRINTSCREEN: return "Print Screen"; case VK_INSERT: return "Insert"; case VK_HELP: return "Help"; case VK_META: return "Meta"; case VK_GREATER: return "Greater"; case VK_BRACELEFT: return "Left Brace"; case VK_BRACERIGHT: return "Right Brace"; case VK_BACK_QUOTE: return "Back Quote"; case VK_QUOTE: return "Quote"; case VK_ALPHANUMERIC: return "Alphanumeric"; case VK_KATAKANA: return "Katakana"; case VK_HIRAGANA: return "Hiragana"; case VK_FULL_WIDTH: return "Full-Width"; case VK_HALF_WIDTH: return "Half-Width"; case VK_ROMAN_CHARACTERS: return "Roman Characters"; case VK_ALL_CANDIDATES: return "All Candidates"; case VK_PREVIOUS_CANDIDATE: return "Previous Candidate"; case VK_CODE_INPUT: return "Code Input"; case VK_JAPANESE_KATAKANA: return "Japanese Katakana"; case VK_JAPANESE_HIRAGANA: return "Japanese Hiragana"; case VK_JAPANESE_ROMAN: return "Japanese Roman"; case VK_KANA_LOCK: return "Kana Lock"; case VK_INPUT_METHOD_ON_OFF: return "Input Method On/Off"; case VK_AT: return "At"; case VK_COLON: return "Colon"; case VK_CIRCUMFLEX: return "Circumflex"; case VK_DOLLAR: return "Dollar"; case VK_EURO_SIGN: return "Euro"; case VK_EXCLAMATION_MARK: return "Exclamation Mark"; case VK_INVERTED_EXCLAMATION_MARK: return "Inverted Exclamation Mark"; case VK_LEFT_PARENTHESIS: return "Left Parenthesis"; case VK_NUMBER_SIGN: return "Number Sign"; case VK_PLUS: return "Plus"; case VK_RIGHT_PARENTHESIS: return "Right Parenthesis"; case VK_UNDERSCORE: return "Underscore"; case VK_COMPOSE: return "Compose"; case VK_ALT_GRAPH: return "Alt Graph"; case VK_STOP: return "Stop"; case VK_AGAIN: return "Again"; case VK_PROPS: return "Props"; case VK_UNDO: return "Undo"; case VK_COPY: return "Copy"; case VK_PASTE: return "Paste"; case VK_FIND: return "Find"; case VK_CUT: return "Cut"; case VK_COMMA: case VK_PERIOD: case VK_SLASH: case VK_0: case VK_1: case VK_2: case VK_3: case VK_4: case VK_5: case VK_6: case VK_7: case VK_8: case VK_9: case VK_SEMICOLON: case VK_EQUALS: case VK_A: case VK_B: case VK_C: case VK_D: case VK_E: case VK_F: case VK_G: case VK_H: case VK_I: case VK_J: case VK_K: case VK_L: case VK_M: case VK_N: case VK_O: case VK_P: case VK_Q: case VK_R: case VK_S: case VK_T: case VK_U: case VK_V: case VK_W: case VK_X: case VK_Y: case VK_Z: case VK_OPEN_BRACKET: case VK_BACK_SLASH: case VK_CLOSE_BRACKET: return "" + (char) keyCode; case VK_NUMPAD0: case VK_NUMPAD1: case VK_NUMPAD2: case VK_NUMPAD3: case VK_NUMPAD4: case VK_NUMPAD5: case VK_NUMPAD6: case VK_NUMPAD7: case VK_NUMPAD8: case VK_NUMPAD9: return "NumPad-" + (char) (keyCode - VK_NUMPAD0); case VK_F1: case VK_F2: case VK_F3: case VK_F4: case VK_F5: case VK_F6: case VK_F7: case VK_F8: case VK_F9: case VK_F10: case VK_F11: case VK_F12: return "F" + (keyCode - (VK_F1 - 1)); case VK_F13: case VK_F14: case VK_F15: case VK_F16: case VK_F17: case VK_F18: case VK_F19: case VK_F20: case VK_F21: case VK_F22: case VK_F23: case VK_F24: return "F" + (keyCode - (VK_F13 - 13)); default: // This is funky on negative numbers, but that's Sun's fault. return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "") + Integer.toHexString(Math.abs(keyCode)); } }
|
public static String getKeyText(int keyCode) { switch (keyCode) { case VK_CANCEL: return "Cancel"; case VK_BACK_SPACE: return "Backspace"; case VK_TAB: return "Tab"; case VK_ENTER: return "Enter"; case VK_CLEAR: return "Clear"; case VK_SHIFT: return "Shift"; case VK_CONTROL: return "Ctrl"; case VK_ALT: return "Alt"; case VK_PAUSE: return "Pause"; case VK_CAPS_LOCK: return "Caps Lock"; case VK_KANA: return "Kana"; case VK_FINAL: return "Final"; case VK_KANJI: return "Kanji"; case VK_ESCAPE: return "Escape"; case VK_CONVERT: return "Convert"; case VK_NONCONVERT: return "No Convert"; case VK_ACCEPT: return "Accept"; case VK_MODECHANGE: return "Mode Change"; case VK_SPACE: return "Space"; case VK_PAGE_UP: return "Page Up"; case VK_PAGE_DOWN: return "Page Down"; case VK_END: return "End"; case VK_HOME: return "Home"; case VK_LEFT: case VK_KP_LEFT: return "Left"; case VK_UP: case VK_KP_UP: return "Up"; case VK_RIGHT: case VK_KP_RIGHT: return "Right"; case VK_DOWN: case VK_KP_DOWN: return "Down"; case VK_MINUS: return "Minus"; case VK_MULTIPLY: return "NumPad *"; case VK_ADD: return "NumPad +"; case VK_SEPARATOR: return "NumPad ,"; case VK_SUBTRACT: return "NumPad -"; case VK_DECIMAL: return "NumPad ."; case VK_DIVIDE: return "NumPad /"; case VK_DELETE: return "Delete"; case VK_DEAD_GRAVE: return "Dead Grave"; case VK_DEAD_ACUTE: return "Dead Acute"; case VK_DEAD_CIRCUMFLEX: return "Dead Circumflex"; case VK_DEAD_TILDE: return "Dead Tilde"; case VK_DEAD_MACRON: return "Dead Macron"; case VK_DEAD_BREVE: return "Dead Breve"; case VK_DEAD_ABOVEDOT: return "Dead Above Dot"; case VK_DEAD_DIAERESIS: return "Dead Diaeresis"; case VK_DEAD_ABOVERING: return "Dead Above Ring"; case VK_DEAD_DOUBLEACUTE: return "Dead Double Acute"; case VK_DEAD_CARON: return "Dead Caron"; case VK_DEAD_CEDILLA: return "Dead Cedilla"; case VK_DEAD_OGONEK: return "Dead Ogonek"; case VK_DEAD_IOTA: return "Dead Iota"; case VK_DEAD_VOICED_SOUND: return "Dead Voiced Sound"; case VK_DEAD_SEMIVOICED_SOUND: return "Dead Semivoiced Sound"; case VK_NUM_LOCK: return "Num Lock"; case VK_SCROLL_LOCK: return "Scroll Lock"; case VK_AMPERSAND: return "Ampersand"; case VK_ASTERISK: return "Asterisk"; case VK_QUOTEDBL: return "Double Quote"; case VK_LESS: return "Less"; case VK_PRINTSCREEN: return "Print Screen"; case VK_INSERT: return "Insert"; case VK_HELP: return "Help"; case VK_META: return "Meta"; case VK_GREATER: return "Greater"; case VK_BRACELEFT: return "Left Brace"; case VK_BRACERIGHT: return "Right Brace"; case VK_BACK_QUOTE: return "Back Quote"; case VK_QUOTE: return "Quote"; case VK_ALPHANUMERIC: return "Alphanumeric"; case VK_KATAKANA: return "Katakana"; case VK_HIRAGANA: return "Hiragana"; case VK_FULL_WIDTH: return "Full-Width"; case VK_HALF_WIDTH: return "Half-Width"; case VK_ROMAN_CHARACTERS: return "Roman Characters"; case VK_ALL_CANDIDATES: return "All Candidates"; case VK_PREVIOUS_CANDIDATE: return "Previous Candidate"; case VK_CODE_INPUT: return "Code Input"; case VK_JAPANESE_KATAKANA: return "Japanese Katakana"; case VK_JAPANESE_HIRAGANA: return "Japanese Hiragana"; case VK_JAPANESE_ROMAN: return "Japanese Roman"; case VK_KANA_LOCK: return "Kana Lock"; case VK_INPUT_METHOD_ON_OFF: return "Input Method On/Off"; case VK_AT: return "At"; case VK_COLON: return "Colon"; case VK_CIRCUMFLEX: return "Circumflex"; case VK_DOLLAR: return "Dollar"; case VK_EURO_SIGN: return "Euro"; case VK_EXCLAMATION_MARK: return "Exclamation Mark"; case VK_INVERTED_EXCLAMATION_MARK: return "Inverted Exclamation Mark"; case VK_LEFT_PARENTHESIS: return "Left Parenthesis"; case VK_NUMBER_SIGN: return "Number Sign"; case VK_PLUS: return "Plus"; case VK_RIGHT_PARENTHESIS: return "Right Parenthesis"; case VK_UNDERSCORE: return "Underscore"; case VK_COMPOSE: return "Compose"; case VK_ALT_GRAPH: return "Alt Graph"; case VK_STOP: return "Stop"; case VK_AGAIN: return "Again"; case VK_PROPS: return "Props"; case VK_UNDO: return "Undo"; case VK_COPY: return "Copy"; case VK_PASTE: return "Paste"; case VK_FIND: return "Find"; case VK_CUT: return "Cut"; case VK_COMMA: case VK_PERIOD: case VK_SLASH: case VK_0: case VK_1: case VK_2: case VK_3: case VK_4: case VK_5: case VK_6: case VK_7: case VK_8: case VK_9: case VK_SEMICOLON: case VK_EQUALS: case VK_A: case VK_B: case VK_C: case VK_D: case VK_E: case VK_F: case VK_G: case VK_H: case VK_I: case VK_J: case VK_K: case VK_L: case VK_M: case VK_N: case VK_O: case VK_P: case VK_Q: case VK_R: case VK_S: case VK_T: case VK_U: case VK_V: case VK_W: case VK_X: case VK_Y: case VK_Z: case VK_OPEN_BRACKET: case VK_BACK_SLASH: case VK_CLOSE_BRACKET: return "" + (char) keyCode; case VK_NUMPAD0: case VK_NUMPAD1: case VK_NUMPAD2: case VK_NUMPAD3: case VK_NUMPAD4: case VK_NUMPAD5: case VK_NUMPAD6: case VK_NUMPAD7: case VK_NUMPAD8: case VK_NUMPAD9: return "NumPad-" + (keyCode - VK_NUMPAD0); case VK_F1: case VK_F2: case VK_F3: case VK_F4: case VK_F5: case VK_F6: case VK_F7: case VK_F8: case VK_F9: case VK_F10: case VK_F11: case VK_F12: return "F" + (keyCode - (VK_F1 - 1)); case VK_F13: case VK_F14: case VK_F15: case VK_F16: case VK_F17: case VK_F18: case VK_F19: case VK_F20: case VK_F21: case VK_F22: case VK_F23: case VK_F24: return "F" + (keyCode - (VK_F13 - 13)); default: // This is funky on negative numbers, but that's Sun's fault. return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "") + Integer.toHexString(Math.abs(keyCode)); } }
| 16,180
|
getFontMetrics(Font font);
|
getFontMetrics() { return(getFontMetrics(getFont())); }
| 16,181
|
getAscent(){ return(1);}
|
getAscent(){ return(1);}
| 16,182
|
public static void drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y) { Graphics2D g2; Rectangle2D.Double underline; FontRenderContext frc; FontMetrics fmet; LineMetrics lineMetrics; Font font; TextLayout layout; double underlineX1, underlineX2; boolean drawUnderline; int textLength; textLength = text.length(); if (textLength == 0) return; drawUnderline = (underlinedIndex >= 0) && (underlinedIndex < textLength); if (!(g instanceof Graphics2D)) { /* Fall-back. This is likely to produce garbage for any text * containing right-to-left (Hebrew or Arabic) characters, even * if the underlined character is left-to-right. */ g.drawString(text, x, y); if (drawUnderline) { fmet = g.getFontMetrics(); g.fillRect( /* x */ x + fmet.stringWidth(text.substring(0, underlinedIndex)), /* y */ y + fmet.getDescent() - 1, /* width */ fmet.charWidth(text.charAt(underlinedIndex)), /* height */ 1); } return; } g2 = (Graphics2D) g; font = g2.getFont(); frc = g2.getFontRenderContext(); lineMetrics = font.getLineMetrics(text, frc); layout = new TextLayout(text, font, frc); /* Draw the text. */ layout.draw(g2, x, y); if (!drawUnderline) return; underlineX1 = x + layout.getLogicalHighlightShape( underlinedIndex, underlinedIndex).getBounds2D().getX(); underlineX2 = x + layout.getLogicalHighlightShape( underlinedIndex + 1, underlinedIndex + 1).getBounds2D().getX(); underline = new Rectangle2D.Double(); if (underlineX1 < underlineX2) { underline.x = underlineX1; underline.width = underlineX2 - underlineX1; } else { underline.x = underlineX2; underline.width = underlineX1 - underlineX2; } underline.height = lineMetrics.getUnderlineThickness(); underline.y = lineMetrics.getUnderlineOffset(); if (underline.y == 0) { /* Some fonts do not specify an underline offset, although they * actually should do so. In that case, the result of calling * lineMetrics.getUnderlineOffset() will be zero. Since it would * look very ugly if the underline was be positioned immediately * below the baseline, we check for this and move the underline * below the descent, as shown in the following ASCII picture: * * ##### ##### # * # # # # * # # # # * # # # # * ##### ###### ---- baseline (0) * # * # * ------------------###----------- lineMetrics.getDescent() */ underline.y = lineMetrics.getDescent(); } underline.y += y; g2.fill(underline); }
|
public static void drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y) { Graphics2D g2; Rectangle2D.Double underline; FontRenderContext frc; FontMetrics fmet; LineMetrics lineMetrics; Font font; TextLayout layout; double underlineX1, underlineX2; boolean drawUnderline; int textLength; textLength = text.length(); if (textLength == 0) return; drawUnderline = (underlinedIndex >= 0) && (underlinedIndex < textLength); if (!(g instanceof Graphics2D) || true) { /* Fall-back. This is likely to produce garbage for any text * containing right-to-left (Hebrew or Arabic) characters, even * if the underlined character is left-to-right. */ g.drawString(text, x, y); if (drawUnderline) { fmet = g.getFontMetrics(); g.fillRect( /* x */ x + fmet.stringWidth(text.substring(0, underlinedIndex)), /* y */ y + fmet.getDescent() - 1, /* width */ fmet.charWidth(text.charAt(underlinedIndex)), /* height */ 1); } return; } g2 = (Graphics2D) g; font = g2.getFont(); frc = g2.getFontRenderContext(); lineMetrics = font.getLineMetrics(text, frc); layout = new TextLayout(text, font, frc); /* Draw the text. */ layout.draw(g2, x, y); if (!drawUnderline) return; underlineX1 = x + layout.getLogicalHighlightShape( underlinedIndex, underlinedIndex).getBounds2D().getX(); underlineX2 = x + layout.getLogicalHighlightShape( underlinedIndex + 1, underlinedIndex + 1).getBounds2D().getX(); underline = new Rectangle2D.Double(); if (underlineX1 < underlineX2) { underline.x = underlineX1; underline.width = underlineX2 - underlineX1; } else { underline.x = underlineX2; underline.width = underlineX1 - underlineX2; } underline.height = lineMetrics.getUnderlineThickness(); underline.y = lineMetrics.getUnderlineOffset(); if (underline.y == 0) { /* Some fonts do not specify an underline offset, although they * actually should do so. In that case, the result of calling * lineMetrics.getUnderlineOffset() will be zero. Since it would * look very ugly if the underline was be positioned immediately * below the baseline, we check for this and move the underline * below the descent, as shown in the following ASCII picture: * * ##### ##### # * # # # # * # # # # * # # # # * ##### ###### ---- baseline (0) * # * # * ------------------###----------- lineMetrics.getDescent() */ underline.y = lineMetrics.getDescent(); } underline.y += y; g2.fill(underline); }
| 16,183
|
public static String toString(int i) { // This is tricky: in libgcj, String.valueOf(int) is a fast native // implementation. In Classpath it just calls back to // Integer.toString(int, int). return String.valueOf(i); }
|
public static String toString(int num, int radix) { // This is tricky: in libgcj, String.valueOf(int) is a fast native // implementation. In Classpath it just calls back to // Integer.toString(int, int). return String.valueOf(i); }
| 16,184
|
public static String toString(int i) { // This is tricky: in libgcj, String.valueOf(int) is a fast native // implementation. In Classpath it just calls back to // Integer.toString(int, int). return String.valueOf(i); }
|
public static String toString(int i) { // This is tricky: in libgcj, String.valueOf(int) is a fast native // implementation. In Classpath it just calls back to // Integer.toString(int, int). if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) radix = 10; char[] buffer = new char[33]; int i = 33; boolean isNeg = false; if (num < 0) { isNeg = true; num = -num; if (num < 0) { buffer[--i] = digits[(int) (-(num + radix) % radix)]; num = -(num / radix); } } do { buffer[--i] = digits[num % radix]; num /= radix; } while (num > 0); if (isNeg) buffer[--i] = '-'; return new String(buffer, i, 33 - i, true); }
| 16,185
|
public static void insertSystemProperties(Properties res) { final String arch; final Vm vm = Vm.getVm(); arch = vm.getArch().getName(); // Java properties res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); // Log4j properties res.put("log4j.defaultInitOverride", "true"); // GNU properties res.put("gnu.java.io.encoding_scheme_alias.US-ASCII", "ISO8859-1"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16LE", "UTF16LE"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16BE", "UTF16BE"); }
|
public static void insertSystemProperties(Properties res) { final Vm vm = Vm.getVm(); arch = vm.getArch().getName(); // Java properties res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); // Log4j properties res.put("log4j.defaultInitOverride", "true"); // GNU properties res.put("gnu.java.io.encoding_scheme_alias.US-ASCII", "ISO8859-1"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16LE", "UTF16LE"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16BE", "UTF16BE"); }
| 16,186
|
public static void insertSystemProperties(Properties res) { final String arch; final Vm vm = Vm.getVm(); arch = vm.getArch().getName(); // Java properties res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); // Log4j properties res.put("log4j.defaultInitOverride", "true"); // GNU properties res.put("gnu.java.io.encoding_scheme_alias.US-ASCII", "ISO8859-1"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16LE", "UTF16LE"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16BE", "UTF16BE"); }
|
public static void insertSystemProperties(Properties res) { final String arch; final Vm vm = Vm.getVm(); final VmArchitecture arch = vm.getArch(); // Java properties res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); // Log4j properties res.put("log4j.defaultInitOverride", "true"); // GNU properties res.put("gnu.java.io.encoding_scheme_alias.US-ASCII", "ISO8859-1"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16LE", "UTF16LE"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16BE", "UTF16BE"); }
| 16,187
|
public static void insertSystemProperties(Properties res) { final String arch; final Vm vm = Vm.getVm(); arch = vm.getArch().getName(); // Java properties res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); // Log4j properties res.put("log4j.defaultInitOverride", "true"); // GNU properties res.put("gnu.java.io.encoding_scheme_alias.US-ASCII", "ISO8859-1"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16LE", "UTF16LE"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16BE", "UTF16BE"); }
|
public static void insertSystemProperties(Properties res) { final String arch; final Vm vm = Vm.getVm(); arch = vm.getArch().getName(); // Java properties res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch.getName()); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); // Log4j properties res.put("log4j.defaultInitOverride", "true"); // GNU properties res.put("gnu.java.io.encoding_scheme_alias.US-ASCII", "ISO8859-1"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16LE", "UTF16LE"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16BE", "UTF16BE"); }
| 16,188
|
public VmType loadClass(String name, boolean resolve) throws ClassNotFoundException, PrivilegedActionPragma { // Also implement the java.lang.ClassLoader principals here // otherwise they cannot work in java.lang.ClassLoader. if ((parent != null) && !parent.skipParentLoader(name)) { try { final Class cls = parent.loadClass(name); return cls.getVmClass(); } catch (ClassNotFoundException ex) { // Don't care, try it ourselves. } } VmType cls = findLoadedClass(name); if (cls != null) { return cls; } if (classInfos == null) { //Unsafe.debug("classInfos==null"); throw new ClassNotFoundException(name); } //BootLog.debug("load class" + name); if (name.indexOf('/') >= 0) { throw new IllegalArgumentException( "name contains '/'"); } final ClassInfo ci = getClassInfo(name, true); if (!ci.isLoaded()) { try { if (failOnNewLoad) { throw new RuntimeException( "Cannot load a new class when failOnNewLoad is set (" + name + ")"); } if (name.charAt(0) == '[') { ci.setVmClass(loadArrayClass(name, resolve)); } else { ci.setVmClass(loadNormalClass(name)); } } catch (ClassNotFoundException ex) { ci.setLoadError(ex.toString()); classInfos.remove(ci.getName()); throw new ClassNotFoundException(name, ex); } catch (IOException ex) { ci.setLoadError(ex.toString()); classInfos.remove(ci.getName()); throw new ClassNotFoundException(name, ex); } if (resolve) { ci.getVmClass().link(); } } return ci.getVmClass(); }
|
public VmType loadClass(String name, boolean resolve) throws ClassNotFoundException, PrivilegedActionPragma { // Also implement the java.lang.ClassLoader principals here // otherwise they cannot work in java.lang.ClassLoader. if ((parent != null) && !parent.skipParentLoader(name)) { try { final Class cls = parent.loadClass(name); return cls.getVmClass(); } catch (ClassNotFoundException ex) { // Don't care, try it ourselves. } } VmType cls = findLoadedClass(name); if (cls != null) { return cls; } if (classInfos == null) { //Unsafe.debug("classInfos==null"); throw new ClassNotFoundException(name); } //BootLog.debug("load class" + name); if (name.indexOf('/') >= 0) { throw new IllegalArgumentException( "name contains '/'"); } final ClassInfo ci = getClassInfo(name, true); if (!ci.isLoaded()) { try { if (failOnNewLoad) { throw new RuntimeException( "Cannot load a new class when failOnNewLoad is set (" + name + ")"); } if (name.charAt(0) == '[') { ci.setVmClass(loadArrayClass(name, resolve)); } else { ci.setVmClass(loadNormalClass(name)); } } catch (ClassNotFoundException ex) { ci.setLoadError(ex.toString()); classInfos.remove(ci.getName()); throw new ClassNotFoundException(name, ex); } catch (IOException ex) { ci.setLoadError(ex.toString()); classInfos.remove(ci.getName()); throw new ClassNotFoundException(name, ex); } if (resolve) { ci.getVmClass().link(); } } return ci.getVmClass(); }
| 16,190
|
public final Object newInstance(VmType cls, int size) { testInited(); if (cls.isArray()) { throw new IllegalArgumentException("Cannot instantiate an array like this"); } if (cls.isInterface()) { throw new IllegalArgumentException("Cannot instantiate an interface"); } final Object obj = allocObject((VmNormalClass) cls, size); if (obj == null) { Unsafe.debug("Out of memory"); throw OOME; } return obj; }
|
public final Object newInstance(VmType cls, int size) { testInited(); if (cls.isArray()) { throw new IllegalArgumentException("Cannot instantiate an array like this"); } if (cls.isInterface()) { throw new IllegalArgumentException("Cannot instantiate an interface"); } final Object obj = allocObject((VmNormalClass) cls, size); if (obj == null) { Unsafe.debug("Out of memory"); throw OOME; } return obj; }
| 16,192
|
public final Object clone(Object object) { testInited(); final VmClassType objectClass = helper.getVmClass(object); final Address objectAddr = helper.addressOf(object); final int size; if (objectClass.isArray()) { final int slotSize = Unsafe.getCurrentProcessor().getArchitecture().getReferenceSize(); final VmArrayClass arrayClass = (VmArrayClass) objectClass; final int length = helper.getInt(object, VmArray.LENGTH_OFFSET * slotSize); final int elemSize = arrayClass.getComponentType().getTypeSize(); size = (VmArray.DATA_OFFSET * slotSize) * (length * elemSize); } else { final VmNormalClass normalClass = (VmNormalClass) objectClass; size = normalClass.getObjSize(); } final Object newObj = allocObject(objectClass, size); helper.copy(objectAddr, helper.addressOf(newObj), size); return newObj; }
|
public final Object clone(Object object) { testInited(); final VmClassType objectClass = helper.getVmClass(object); final Address objectAddr = helper.addressOf(object); final int size; if (objectClass.isArray()) { final int slotSize = Unsafe.getCurrentProcessor().getArchitecture().getReferenceSize(); final VmArrayClass arrayClass = (VmArrayClass) objectClass; final int length = helper.getInt(object, VmArray.LENGTH_OFFSET * slotSize); final int elemSize = arrayClass.getComponentType().getTypeSize(); size = (VmArray.DATA_OFFSET * slotSize) * (length * elemSize); } else { final VmNormalClass normalClass = (VmNormalClass) objectClass; size = normalClass.getObjectSize(); } final Object newObj = allocObject(objectClass, size); helper.copy(objectAddr, helper.addressOf(newObj), size); return newObj; }
| 16,193
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.